diff --git a/apps/Makefile b/apps/Makefile index 3d89682ab..d29a5b724 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -30,6 +30,7 @@ app_objs += $(addprefix apps/,\ store_controller.o\ store_parameter_controller.o\ text_field_delegate_app.o\ + title_bar_view.o\ toolbox_controller.o\ toolbox_leaf_cell.o\ toolbox_node.o\ diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 77edabc70..517421c7a 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -56,8 +56,8 @@ bool AppsContainer::handleEvent(Ion::Events::Event event) { } void AppsContainer::switchTo(App * app) { + m_window.setTitle(app->name()); Container::switchTo(app); - /*do something with title bar*/ } Window * AppsContainer::window() { diff --git a/apps/apps_window.cpp b/apps/apps_window.cpp index 48a03000b..edc63bc2d 100644 --- a/apps/apps_window.cpp +++ b/apps/apps_window.cpp @@ -3,20 +3,16 @@ extern "C" { #include } -/* Title Bar View */ - -void AppsWindow::TitleBarView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(bounds(), KDColorBlack); -} - -/* Window */ - AppsWindow::AppsWindow() : Window(), m_titleBarView(TitleBarView()) { } +void AppsWindow::setTitle(const char * title) { + m_titleBarView.setTitle(title); +} + int AppsWindow::numberOfSubviews() const { return (m_contentView == nullptr ? 1 : 2); } diff --git a/apps/apps_window.h b/apps/apps_window.h index 637340ce1..5428336a8 100644 --- a/apps/apps_window.h +++ b/apps/apps_window.h @@ -2,14 +2,13 @@ #define APPS_WINDOW_H #include +#include "title_bar_view.h" class AppsWindow : public Window { public: AppsWindow(); + void setTitle(const char * title); private: - class TitleBarView : public View { - void drawRect(KDContext * ctx, KDRect rect) const override; - }; constexpr static KDCoordinate k_titleBarHeight = 18; int numberOfSubviews() const override; void layoutSubviews() override; diff --git a/apps/home/app.cpp b/apps/home/app.cpp index 4b0c267f6..27964c2c0 100644 --- a/apps/home/app.cpp +++ b/apps/home/app.cpp @@ -7,7 +7,7 @@ extern "C" { namespace Home { App::App(AppsContainer * container) : - ::App(container, &m_controller), + ::App(container, &m_controller, "Applications"), m_controller(Controller(&m_modalViewController, container)) { assert(container->appAtIndex(0) == this); diff --git a/apps/title_bar_view.cpp b/apps/title_bar_view.cpp new file mode 100644 index 000000000..10a60447b --- /dev/null +++ b/apps/title_bar_view.cpp @@ -0,0 +1,30 @@ +#include "title_bar_view.h" +extern "C" { +#include +} + +TitleBarView::TitleBarView() : + View(), + m_titleView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorWhite, KDColorRed) +{ +} + +void TitleBarView::drawRect(KDContext * ctx, KDRect rect) const { + ctx->fillRect(bounds(), KDColorRed); +} + +void TitleBarView::setTitle(const char * title) { + m_titleView.setText(title); +} + +int TitleBarView::numberOfSubviews() const { + return 1; +} + +View * TitleBarView::subviewAtIndex(int index) { + return &m_titleView; +} + +void TitleBarView::layoutSubviews() { + m_titleView.setFrame(bounds()); +} diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h new file mode 100644 index 000000000..120115fba --- /dev/null +++ b/apps/title_bar_view.h @@ -0,0 +1,18 @@ +#ifndef APPS_TITLE_BAR_VIEW_H +#define APPS_TITLE_BAR_VIEW_H + +#include + +class TitleBarView : public View { +public: + TitleBarView(); + void drawRect(KDContext * ctx, KDRect rect) const override; + void setTitle(const char * title); +private: + int numberOfSubviews() const override; + void layoutSubviews() override; + View * subviewAtIndex(int index) override; + PointerTextView m_titleView; +}; + +#endif