mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] define table view cell switch and switch view
Change-Id: I7bf72c7f0e938513d5baeb44a07b6906bc5adebf
This commit is contained in:
@@ -13,6 +13,8 @@ objs += $(addprefix escher/src/,\
|
||||
solid_color_view.o\
|
||||
stack_view.o\
|
||||
stack_view_controller.o\
|
||||
switch_table_view_cell.o\
|
||||
switch_view.o\
|
||||
tab_view.o\
|
||||
tab_view_cell.o\
|
||||
tab_view_controller.o\
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <escher/scroll_view_indicator.h>
|
||||
#include <escher/solid_color_view.h>
|
||||
#include <escher/stack_view_controller.h>
|
||||
#include <escher/switch_view.h>
|
||||
#include <escher/switch_table_view_cell.h>
|
||||
#include <escher/text_field.h>
|
||||
#include <escher/text_view.h>
|
||||
#include <escher/tab_view_controller.h>
|
||||
|
||||
15
escher/include/escher/switch_table_view_cell.h
Normal file
15
escher/include/escher/switch_table_view_cell.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef ESCHER_SWITCH_TABLE_VIEW_CELL_H
|
||||
#define ESCHER_SWITCH_TABLE_VIEW_CELL_H
|
||||
|
||||
#include <escher/table_view_cell.h>
|
||||
#include <escher/switch_view.h>
|
||||
|
||||
class SwitchTableViewCell : public TableViewCell {
|
||||
public:
|
||||
SwitchTableViewCell(char * label);
|
||||
View * contentView() const override;
|
||||
private:
|
||||
SwitchView m_contentView;
|
||||
};
|
||||
|
||||
#endif
|
||||
14
escher/include/escher/switch_view.h
Normal file
14
escher/include/escher/switch_view.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ESCHER_SWITCH_VIEW_H
|
||||
#define ESCHER_SWITCH_VIEW_H
|
||||
|
||||
#include <escher/childless_view.h>
|
||||
#include <escher/label_view.h>
|
||||
#include <escher/palette.h>
|
||||
|
||||
class SwitchView : public ChildlessView {
|
||||
public:
|
||||
SwitchView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
11
escher/src/switch_table_view_cell.cpp
Normal file
11
escher/src/switch_table_view_cell.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <escher/switch_table_view_cell.h>
|
||||
|
||||
SwitchTableViewCell::SwitchTableViewCell(char * label) :
|
||||
TableViewCell(label),
|
||||
m_contentView(SwitchView())
|
||||
{
|
||||
}
|
||||
|
||||
View * SwitchTableViewCell::contentView() const {
|
||||
return (View *)&m_contentView;
|
||||
}
|
||||
18
escher/src/switch_view.cpp
Normal file
18
escher/src/switch_view.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <escher/switch_view.h>
|
||||
|
||||
SwitchView::SwitchView() :
|
||||
ChildlessView()
|
||||
{
|
||||
}
|
||||
|
||||
void SwitchView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
|
||||
ctx->fillRect(KDRect(0, 0, width, 1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(0, 1, 1, height-1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(1, height-1, width-1, 1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(width-1, 1, 1, height-1), Palette::LineColor);
|
||||
ctx->fillRect(KDRect(1, 1, width/3, height-2), KDColorBlack);
|
||||
ctx->fillRect(KDRect(width/3+1, 1, width-2-width/3, height-2), KDColorGreen);
|
||||
}
|
||||
Reference in New Issue
Block a user