[escher] define table view cell switch and switch view

Change-Id: I7bf72c7f0e938513d5baeb44a07b6906bc5adebf
This commit is contained in:
Émilie Feral
2016-09-20 16:09:08 +02:00
parent 219d6e6731
commit a28731c459
6 changed files with 62 additions and 0 deletions

View File

@@ -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\

View File

@@ -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>

View 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

View 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

View 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;
}

View 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);
}