[escher] Correct layout metrics

Change-Id: I829d387885af23be3782b99926c09547219ba6cc
This commit is contained in:
Émilie Feral
2017-01-26 10:42:45 +01:00
parent 7fe4d497f3
commit 6ef76341aa
11 changed files with 16 additions and 18 deletions

View File

@@ -7,9 +7,8 @@ class Metric {
public:
constexpr static KDCoordinate LeftMargin = 20;
constexpr static KDCoordinate RightMargin = 20;
constexpr static KDCoordinate TopMargin = 10;
constexpr static KDCoordinate BottomMargin = 10;
constexpr static KDCoordinate LabelMargin = 5;
constexpr static KDCoordinate TopMargin = 15;
constexpr static KDCoordinate BottomMargin = 15;
constexpr static KDCoordinate ParameterCellHeight = 35;
};

View File

@@ -9,7 +9,7 @@ class ScrollView : public View {
public:
ScrollView(View * contentView, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0,
KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0, bool showIndicators = true,
bool colorBackground = true, KDColor backgroundColor = Palette::WallScreen, KDCoordinate indicatorThickness = 10,
bool colorBackground = true, KDColor backgroundColor = Palette::WallScreen, KDCoordinate indicatorThickness = 20,
KDColor indicatorColor = Palette::GreyDark, KDColor backgroundIndicatorColor = Palette::GreyMiddle,
KDCoordinate indicatorMargin = 14);

View File

@@ -20,7 +20,7 @@ public:
KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0,
KDCoordinate leftMargin = 0, SelectableTableViewDelegate * delegate = nullptr,
bool showIndicators = true, bool colorBackground = true, KDColor backgroundColor = Palette::WallScreen,
KDCoordinate indicatorThickness = 10, KDColor indicatorColor = Palette::GreyDark,
KDCoordinate indicatorThickness = 20, KDColor indicatorColor = Palette::GreyDark,
KDColor backgroundIndicatorColor = Palette::GreyMiddle, KDCoordinate indicatorMargin = 14);
int selectedRow();

View File

@@ -34,6 +34,7 @@ private:
const char * className() const override;
#endif
private:
static constexpr KDCoordinate k_stackHeight = 20;
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;

View File

@@ -22,6 +22,7 @@ protected:
void logAttributes(std::ostream &os) const override;
#endif
private:
constexpr static KDCoordinate k_activeTabWidth = 5;
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;

View File

@@ -29,6 +29,7 @@ private:
const char * className() const override;
#endif
private:
static constexpr KDCoordinate k_tabHeight = 27;
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;

View File

@@ -11,7 +11,7 @@ public:
TableView(TableViewDataSource * dataSource, KDCoordinate topMargin = 0,
KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0,
bool showIndicators = true, bool colorBackground = true, KDColor backgroundColor = Palette::WallScreen,
KDCoordinate indicatorThickness = 10, KDColor indicatorColor = Palette::GreyDark,
KDCoordinate indicatorThickness = 20, KDColor indicatorColor = Palette::GreyDark,
KDColor backgroundIndicatorColor = Palette::GreyMiddle, KDCoordinate indicatorMargin = 14);
virtual void scrollToCell(int i, int j);

View File

@@ -4,5 +4,4 @@ constexpr KDCoordinate Metric::LeftMargin;
constexpr KDCoordinate Metric::RightMargin;
constexpr KDCoordinate Metric::TopMargin;
constexpr KDCoordinate Metric::BottomMargin;
constexpr KDCoordinate Metric::LabelMargin;
constexpr KDCoordinate Metric::ParameterCellHeight;

View File

@@ -35,16 +35,15 @@ void StackViewController::ControllerView::popStack() {
}
void StackViewController::ControllerView::layoutSubviews() {
KDCoordinate stackHeight = 20;
KDCoordinate width = m_frame.width();
int indexFirstHeader = m_displayFirstStackHeader ? 0 : 1;
for (int i=indexFirstHeader; i<m_numberOfStacks; i++) {
m_stackViews[i].setFrame(KDRect(0, stackHeight*(i-indexFirstHeader), width, stackHeight + 1));
m_stackViews[i].setFrame(KDRect(0, k_stackHeight*(i-indexFirstHeader), width, k_stackHeight + 1));
}
if (m_contentView) {
bool separatorHeight = m_displayFirstStackHeader + (m_numberOfStacks > 1);
KDRect contentViewFrame = KDRect( 0, (m_numberOfStacks-indexFirstHeader)*stackHeight + separatorHeight,
width, m_frame.height() - (m_numberOfStacks-indexFirstHeader)*stackHeight);
KDRect contentViewFrame = KDRect( 0, (m_numberOfStacks-indexFirstHeader)*k_stackHeight + separatorHeight,
width, m_frame.height() - (m_numberOfStacks-indexFirstHeader)*k_stackHeight);
m_contentView->setFrame(contentViewFrame);
}
}

View File

@@ -20,7 +20,7 @@ void TabView::drawRect(KDContext * ctx, KDRect rect) const {
KDCoordinate height = bounds().height();
KDCoordinate width = bounds().width();
// Draw a separator with the content
ctx->fillRect(KDRect(0, height-5, width, 5), KDColorWhite);
ctx->fillRect(KDRect(0, height-k_activeTabWidth, width, k_activeTabWidth), KDColorWhite);
}
void TabView::addTabNamed(const char * name) {
@@ -81,7 +81,7 @@ void TabView::layoutSubviews() {
}
KDRect cellFrame = KDRect(
widthUsed, 0,
tabWidth, m_frame.height() - 5
tabWidth, m_frame.height() - k_activeTabWidth
);
m_cells[i].setFrame(cellFrame);
widthUsed += tabWidth;

View File

@@ -17,18 +17,16 @@ void TabViewController::ContentView::setActiveView(View * view) {
}
void TabViewController::ContentView::layoutSubviews() {
KDCoordinate tabHeight = 20;
KDRect tabViewFrame = KDRect(
0, 0,
m_frame.width(), tabHeight
m_frame.width(), k_tabHeight
);
m_tabView.setFrame(tabViewFrame);
if (m_activeView) {
KDRect activeViewFrame = KDRect(
0, tabHeight,
0, k_tabHeight,
m_frame.width(),
m_frame.height() - tabHeight
m_frame.height() - k_tabHeight
);
m_activeView->setFrame(activeViewFrame);
}