mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] add a boolean in table constructor to choose whether to paint
the backgroung Change-Id: Idee8aff20ab86011775e9a995a2d2f425b60df67
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
|
||||
#include <escher/view.h>
|
||||
#include <escher/scroll_view_indicator.h>
|
||||
#include <escher/palette.h>
|
||||
|
||||
class ScrollView : public View {
|
||||
public:
|
||||
ScrollView(View * contentView, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0,
|
||||
KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0, bool showIndicators = true);
|
||||
KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0, bool showIndicators = true,
|
||||
bool colorBackground = true, KDColor backgroundColor = Palette::BackgroundColor);
|
||||
|
||||
void setContentOffset(KDPoint offset);
|
||||
KDPoint contentOffset();
|
||||
@@ -39,6 +41,8 @@ private:
|
||||
KDCoordinate m_bottomMargin;
|
||||
KDCoordinate m_leftMargin;
|
||||
bool m_showIndicators;
|
||||
bool m_colorBackground;
|
||||
KDColor m_backgroundColor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <escher/app.h>
|
||||
#include <escher/selectable_table_view_delegate.h>
|
||||
#include <escher/table_view_data_source.h>
|
||||
#include <escher/palette.h>
|
||||
#include <escher/responder.h>
|
||||
|
||||
/* SelectableTableView is a Table View that handles selection. To implement it,
|
||||
@@ -17,7 +18,8 @@ class SelectableTableView : public TableView, public Responder {
|
||||
public:
|
||||
SelectableTableView(Responder * parentResponder, TableViewDataSource * dataSource,
|
||||
KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0,
|
||||
KDCoordinate leftMargin = 0, SelectableTableViewDelegate * delegate = nullptr);
|
||||
KDCoordinate leftMargin = 0, SelectableTableViewDelegate * delegate = nullptr,
|
||||
bool showIndicators = true, bool colorBackground = true, KDColor backgroundColor = Palette::BackgroundColor);
|
||||
int selectedRow();
|
||||
int selectedColumn();
|
||||
virtual bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef ESCHER_TABLE_VIEW_H
|
||||
#define ESCHER_TABLE_VIEW_H
|
||||
|
||||
#include <escher/palette.h>
|
||||
#include <escher/scroll_view.h>
|
||||
#include <escher/table_view_cell.h>
|
||||
#include <escher/table_view_data_source.h>
|
||||
@@ -8,7 +9,8 @@
|
||||
class TableView : public ScrollView {
|
||||
public:
|
||||
TableView(TableViewDataSource * dataSource, KDCoordinate topMargin = 0,
|
||||
KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0);
|
||||
KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0,
|
||||
bool showIndicators = true, bool colorBackground = true, KDColor backgroundColor = Palette::BackgroundColor);
|
||||
|
||||
virtual void scrollToCell(int i, int j);
|
||||
TableViewCell * cellAtLocation(int i, int j);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <escher/scroll_view.h>
|
||||
#include <escher/palette.h>
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -8,7 +7,8 @@ extern "C" {
|
||||
constexpr KDCoordinate ScrollView::k_indicatorThickness;
|
||||
|
||||
ScrollView::ScrollView(View * contentView, KDCoordinate topMargin, KDCoordinate rightMargin,
|
||||
KDCoordinate bottomMargin, KDCoordinate leftMargin, bool showIndicators) :
|
||||
KDCoordinate bottomMargin, KDCoordinate leftMargin, bool showIndicators, bool colorBackground,
|
||||
KDColor backgroundColor) :
|
||||
View(),
|
||||
m_topMargin(topMargin),
|
||||
m_offset(KDPointZero),
|
||||
@@ -18,9 +18,12 @@ ScrollView::ScrollView(View * contentView, KDCoordinate topMargin, KDCoordinate
|
||||
m_rightMargin(rightMargin),
|
||||
m_bottomMargin(bottomMargin),
|
||||
m_leftMargin(leftMargin),
|
||||
m_showIndicators(showIndicators)
|
||||
m_showIndicators(showIndicators),
|
||||
m_colorBackground(colorBackground),
|
||||
m_backgroundColor(backgroundColor)
|
||||
{
|
||||
}
|
||||
|
||||
bool ScrollView::hasVerticalIndicator() const {
|
||||
if (m_showIndicators) {
|
||||
return m_verticalScrollIndicator.end() < 1 || m_verticalScrollIndicator.start() > 0;
|
||||
@@ -52,9 +55,12 @@ View * ScrollView::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void ScrollView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (!m_colorBackground) {
|
||||
return;
|
||||
}
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
ctx->fillRect(KDRect(0, 0, width, height), Palette::BackgroundColor);
|
||||
ctx->fillRect(KDRect(0, 0, width, height), m_backgroundColor);
|
||||
// Future optimization: avoid drawing behind the content view/
|
||||
//ctx->fillRect(KDRect(m_leftMargin, m_contentView->bounds().height()+m_topMargin, width-m_leftMargin-m_rightMargin, height- m_contentView->bounds().height())-m_topMargin, Palette::BackgroundColor);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <escher/selectable_table_view.h>
|
||||
|
||||
SelectableTableView::SelectableTableView(Responder * parentResponder, TableViewDataSource * dataSource,
|
||||
KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin,
|
||||
SelectableTableViewDelegate * delegate) :
|
||||
TableView(dataSource, topMargin, rightMargin, bottomMargin, leftMargin),
|
||||
KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin,
|
||||
SelectableTableViewDelegate * delegate, bool showIndicators, bool colorBackground,
|
||||
KDColor backgroundColor) :
|
||||
TableView(dataSource, topMargin, rightMargin, bottomMargin, leftMargin, showIndicators, colorBackground, backgroundColor),
|
||||
Responder(parentResponder),
|
||||
m_delegate(delegate),
|
||||
m_selectedCellX(0),
|
||||
|
||||
@@ -8,8 +8,10 @@ extern "C" {
|
||||
#define MIN(x,y) ((x)<(y) ? (x) : (y))
|
||||
|
||||
TableView::TableView(TableViewDataSource * dataSource, KDCoordinate topMargin, KDCoordinate rightMargin,
|
||||
KDCoordinate bottomMargin, KDCoordinate leftMargin) :
|
||||
ScrollView(&m_contentView, topMargin, rightMargin, bottomMargin, leftMargin),
|
||||
KDCoordinate bottomMargin, KDCoordinate leftMargin, bool showIndicators, bool colorBackground,
|
||||
KDColor backgroundColor) :
|
||||
ScrollView(&m_contentView, topMargin, rightMargin, bottomMargin, leftMargin, showIndicators, colorBackground,
|
||||
backgroundColor),
|
||||
m_contentView(TableView::ContentView(this, dataSource))
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user