mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps] Display app title in the title bar
Change-Id: I8cd8d09359e627a0915c99c13dc445027ec361e3
This commit is contained in:
@@ -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\
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -3,20 +3,16 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
#define APPS_WINDOW_H
|
||||
|
||||
#include <escher.h>
|
||||
#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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
30
apps/title_bar_view.cpp
Normal file
30
apps/title_bar_view.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "title_bar_view.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
18
apps/title_bar_view.h
Normal file
18
apps/title_bar_view.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef APPS_TITLE_BAR_VIEW_H
|
||||
#define APPS_TITLE_BAR_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user