mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] Add margins in all table cells
Change-Id: I7fe47c87d8129b28b8b5250141ff505af6b6d5d7
This commit is contained in:
@@ -11,8 +11,6 @@ public:
|
||||
/* k_chevronHeight and k_chevronWidth are the dimensions of the chevron. */
|
||||
constexpr static KDCoordinate k_chevronHeight = 10;
|
||||
constexpr static KDCoordinate k_chevronWidth = 8;
|
||||
private:
|
||||
constexpr static KDCoordinate k_chevronRightMargin = 10;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,6 @@ private:
|
||||
constexpr static KDCoordinate k_switchHeight = 16;
|
||||
constexpr static KDCoordinate k_switchWidth = 20;
|
||||
constexpr static KDCoordinate k_separatorThickness = 1;
|
||||
constexpr static KDCoordinate k_switchMargin = 10;
|
||||
bool m_state;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ protected:
|
||||
void layoutSubviews() override;
|
||||
constexpr static KDCoordinate k_separatorThickness = 1;
|
||||
private:
|
||||
constexpr static KDCoordinate k_labelMargin = 10;
|
||||
constexpr static KDCoordinate k_accessoryMargin = 10;
|
||||
constexpr static KDCoordinate k_labelTopMargin = 3;
|
||||
constexpr static KDCoordinate k_accessoryBottomMargin = 3;
|
||||
Layout m_layout;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ void ChevronView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate heightCenter = bounds().height()/2;
|
||||
KDCoordinate chevronHalfHeight = k_chevronHeight/2;
|
||||
KDRect frame(width - k_chevronRightMargin - k_chevronWidth, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight);
|
||||
KDRect frame(width - k_chevronWidth, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight);
|
||||
ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)chevronMask, s_workingBuffer);
|
||||
}
|
||||
|
||||
KDSize ChevronView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(k_chevronRightMargin+k_chevronWidth, k_chevronHeight);
|
||||
return KDSize(k_chevronWidth, k_chevronHeight);
|
||||
}
|
||||
|
||||
@@ -27,20 +27,20 @@ void SwitchView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
KDColor mainColor = m_state ? Palette::YellowDark : Palette::GreyDark;
|
||||
// These 4 lines draw the outline of the switch.
|
||||
ctx->fillRect(KDRect(width - 2*k_separatorThickness - k_switchMargin - k_switchWidth, heightCenter-switchHalfHeight - k_separatorThickness, k_switchWidth + 2*k_separatorThickness, k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - 2*k_separatorThickness - k_switchMargin - k_switchWidth, heightCenter-switchHalfHeight, k_separatorThickness, k_switchHeight+k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_separatorThickness - k_switchMargin - k_switchWidth, heightCenter+switchHalfHeight, k_switchWidth+k_separatorThickness, k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_separatorThickness - k_switchMargin, heightCenter-switchHalfHeight, k_separatorThickness, k_switchHeight), mainColor);
|
||||
ctx->fillRect(KDRect(width - 2*k_separatorThickness - k_switchWidth, heightCenter-switchHalfHeight - k_separatorThickness, k_switchWidth + 2*k_separatorThickness, k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - 2*k_separatorThickness - k_switchWidth, heightCenter-switchHalfHeight, k_separatorThickness, k_switchHeight+k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_separatorThickness - k_switchWidth, heightCenter+switchHalfHeight, k_switchWidth+k_separatorThickness, k_separatorThickness), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_separatorThickness, heightCenter-switchHalfHeight, k_separatorThickness, k_switchHeight), mainColor);
|
||||
// These next lines fill the switch with black and green/red.
|
||||
if (m_state) {
|
||||
ctx->fillRect(KDRect(width - k_switchMargin - k_switchWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), KDColorWhite);
|
||||
ctx->fillRect(KDRect(width - k_switchMargin - switchHalfWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_switchWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), KDColorWhite);
|
||||
ctx->fillRect(KDRect(width - switchHalfWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), mainColor);
|
||||
} else {
|
||||
ctx->fillRect(KDRect(width - k_switchMargin - k_switchWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), mainColor);
|
||||
ctx->fillRect(KDRect(width - k_switchMargin - switchHalfWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), KDColorWhite);
|
||||
ctx->fillRect(KDRect(width - k_switchWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), mainColor);
|
||||
ctx->fillRect(KDRect(width - switchHalfWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), KDColorWhite);
|
||||
}
|
||||
}
|
||||
|
||||
KDSize SwitchView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(2*k_separatorThickness + k_switchMargin + k_switchWidth, k_switchHeight);
|
||||
return KDSize(2*k_separatorThickness + k_switchWidth, k_switchHeight);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ void TableCell::layoutSubviews() {
|
||||
KDSize labelSize = label->minimalSizeForOptimalDisplay();
|
||||
switch (m_layout) {
|
||||
case Layout::Vertical:
|
||||
label->setFrame(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, labelSize.height()));
|
||||
label->setFrame(KDRect(k_separatorThickness+k_labelMargin, k_separatorThickness+k_labelTopMargin, width-2*k_separatorThickness-k_labelMargin, labelSize.height()));
|
||||
break;
|
||||
default:
|
||||
label->setFrame(KDRect(k_separatorThickness, k_separatorThickness, labelSize.width(), height - 2*k_separatorThickness));
|
||||
label->setFrame(KDRect(k_separatorThickness+k_labelMargin, k_separatorThickness, labelSize.width(), height - 2*k_separatorThickness));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -57,16 +57,16 @@ void TableCell::layoutSubviews() {
|
||||
accessorySize = KDSize(width - 2*k_separatorThickness, accessorySize.height());
|
||||
if (label) {
|
||||
KDSize labelSize = label->minimalSizeForOptimalDisplay();
|
||||
accessorySize = KDSize(width - 2*k_separatorThickness - labelSize.width(), accessorySize.height());
|
||||
accessorySize = KDSize(width - 2*k_separatorThickness - labelSize.width()-k_labelMargin-k_accessoryMargin, accessorySize.height());
|
||||
}
|
||||
}
|
||||
switch (m_layout) {
|
||||
case Layout::Vertical:
|
||||
accessory->setFrame(KDRect(k_separatorThickness, height-k_separatorThickness-accessorySize.height(),
|
||||
width-2*k_separatorThickness, accessorySize.height()));
|
||||
accessory->setFrame(KDRect(k_separatorThickness+k_accessoryMargin, height-k_separatorThickness-accessorySize.height()-k_accessoryBottomMargin,
|
||||
width-2*k_separatorThickness - k_accessoryMargin, accessorySize.height()));
|
||||
break;
|
||||
default:
|
||||
accessory->setFrame(KDRect(width - accessorySize.width() - k_separatorThickness, k_separatorThickness,
|
||||
accessory->setFrame(KDRect(width - accessorySize.width() - k_separatorThickness-k_accessoryMargin, k_separatorThickness,
|
||||
accessorySize.width(), height-2*k_separatorThickness));
|
||||
break;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void TableCell::layoutSubviews() {
|
||||
if (subAccessory && accessory) {
|
||||
KDSize accessorySize = accessory->minimalSizeForOptimalDisplay();
|
||||
KDSize subAccessorySize = subAccessory->minimalSizeForOptimalDisplay();
|
||||
subAccessory->setFrame(KDRect(width-k_separatorThickness-accessorySize.width()-subAccessorySize.width(), k_separatorThickness,
|
||||
subAccessory->setFrame(KDRect(width-k_separatorThickness-k_accessoryMargin-accessorySize.width()-subAccessorySize.width(), k_separatorThickness,
|
||||
subAccessorySize.width(), height-2*k_separatorThickness));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user