refactor: Consolidate theme rendering into ThemeMetrics (#1868)
This commit is contained in:
@@ -33,8 +33,6 @@ namespace {
|
||||
constexpr int hPaddingInSelection = 8;
|
||||
constexpr int cornerRadius = 6;
|
||||
constexpr int topHintButtonY = 345;
|
||||
constexpr int popupMarginX = 16;
|
||||
constexpr int popupMarginY = 12;
|
||||
constexpr int maxListValueWidth = 200;
|
||||
constexpr int mainMenuIconSize = 32;
|
||||
constexpr int listIconSize = 24;
|
||||
@@ -536,41 +534,3 @@ void LyraTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount
|
||||
renderer.drawText(UI_12_FONT_ID, textX, textY, label, true);
|
||||
}
|
||||
}
|
||||
|
||||
Rect LyraTheme::drawPopup(const GfxRenderer& renderer, const char* message) const {
|
||||
// Scale y position proportionally to screen height (16.5% from top)
|
||||
const int y = static_cast<int>(renderer.getScreenHeight() * 0.165f);
|
||||
constexpr int outline = 2;
|
||||
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::REGULAR);
|
||||
const int textHeight = renderer.getLineHeight(UI_12_FONT_ID);
|
||||
const int w = textWidth + popupMarginX * 2;
|
||||
const int h = textHeight + popupMarginY * 2;
|
||||
const int x = (renderer.getScreenWidth() - w) / 2;
|
||||
|
||||
renderer.fillRoundedRect(x - outline, y - outline, w + outline * 2, h + outline * 2, cornerRadius + outline,
|
||||
Color::White);
|
||||
renderer.fillRoundedRect(x, y, w, h, cornerRadius, Color::Black);
|
||||
|
||||
const int textX = x + (w - textWidth) / 2;
|
||||
const int textY = y + popupMarginY - 2;
|
||||
renderer.drawText(UI_12_FONT_ID, textX, textY, message, false, EpdFontFamily::REGULAR);
|
||||
renderer.displayBuffer();
|
||||
|
||||
return Rect{x, y, w, h};
|
||||
}
|
||||
|
||||
void LyraTheme::fillPopupProgress(const GfxRenderer& renderer, const Rect& layout, const int progress) const {
|
||||
constexpr int barHeight = 4;
|
||||
|
||||
// Twice the margin in drawPopup to match text width
|
||||
const int barWidth = layout.width - popupMarginX * 2;
|
||||
const int barX = layout.x + (layout.width - barWidth) / 2;
|
||||
// Center inside the margin of drawPopup. The - 1 is added to account for the - 2 in drawPopup.
|
||||
const int barY = layout.y + layout.height - popupMarginY / 2 - barHeight / 2 - 1;
|
||||
|
||||
int fillWidth = barWidth * progress / 100;
|
||||
|
||||
renderer.fillRect(barX, barY, fillWidth, barHeight, false);
|
||||
|
||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user