mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps] create a class toolbox leaf cell
Change-Id: Iee2efaab85646329700078ebd83079a82e5a31f6
This commit is contained in:
@@ -13,6 +13,7 @@ app_objs += $(addprefix apps/,\
|
||||
node_list_view_controller.o\
|
||||
node_navigation_controller.o\
|
||||
toolbox_controller.o\
|
||||
toolbox_leaf_cell.o\
|
||||
toolbox_node.o\
|
||||
variable_box_controller.o\
|
||||
variable_box_node.o\
|
||||
|
||||
53
apps/toolbox_leaf_cell.cpp
Normal file
53
apps/toolbox_leaf_cell.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "toolbox_leaf_cell.h"
|
||||
#include <assert.h>
|
||||
|
||||
ToolboxLeafCell::ToolboxLeafCell() :
|
||||
TableViewCell(),
|
||||
m_labelView(PointerTextView(nullptr, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)),
|
||||
m_subtitleView(PointerTextView(nullptr, 0, 0.5, Palette::DesactiveTextColor, Palette::CellBackgroundColor))
|
||||
{
|
||||
}
|
||||
|
||||
int ToolboxLeafCell::numberOfSubviews() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
View * ToolboxLeafCell::subviewAtIndex(int index) {
|
||||
assert(index == 0 || index == 1);
|
||||
if (index == 0) {
|
||||
return &m_labelView;
|
||||
}
|
||||
return &m_subtitleView;
|
||||
}
|
||||
|
||||
void ToolboxLeafCell::layoutSubviews() {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
m_labelView.setFrame(KDRect(1, 1, width-2, height/2 - 1));
|
||||
m_subtitleView.setFrame(KDRect(1, height/2, width-2, height/2 - 1));
|
||||
}
|
||||
|
||||
void ToolboxLeafCell::reloadCell() {
|
||||
TableViewCell::reloadCell();
|
||||
KDColor backgroundColor = isHighlighted()? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor;
|
||||
m_labelView.setBackgroundColor(backgroundColor);
|
||||
m_subtitleView.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
void ToolboxLeafCell::setLabel(const char * text) {
|
||||
m_labelView.setText(text);
|
||||
}
|
||||
|
||||
void ToolboxLeafCell::setSubtitle(const char * text) {
|
||||
m_subtitleView.setText(text);
|
||||
}
|
||||
|
||||
void ToolboxLeafCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
KDColor backgroundColor = isHighlighted() ? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor;
|
||||
ctx->fillRect(KDRect(1, 0, width-2, height-1), backgroundColor);
|
||||
ctx->fillRect(KDRect(0, height-1, width, 1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(0, 0, 1, height-1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(width-1, 0, 1, height-1), Palette::LineColor);
|
||||
}
|
||||
21
apps/toolbox_leaf_cell.h
Normal file
21
apps/toolbox_leaf_cell.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef APPS_TOOLBOX_LEAF_CELL_H
|
||||
#define APPS_TOOLBOX_LEAF_CELL_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
class ToolboxLeafCell : public TableViewCell {
|
||||
public:
|
||||
ToolboxLeafCell();
|
||||
void reloadCell() override;
|
||||
void setLabel(const char * text);
|
||||
void setSubtitle(const char * text);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
private:
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
PointerTextView m_labelView;
|
||||
PointerTextView m_subtitleView;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user