feat: Themed reader menus (#1072)

This commit is contained in:
CaptainFrito
2026-05-18 17:35:27 +03:00
committed by GitHub
parent 061c7688a4
commit 8a11f44571
10 changed files with 209 additions and 211 deletions
+43 -1
View File
@@ -53,6 +53,7 @@ void UITheme::setTheme(CrossPointSettings::UI_THEME type) {
int UITheme::getNumberOfItemsPerPage(const GfxRenderer& renderer, bool hasHeader, bool hasTabBar, bool hasButtonHints,
bool hasSubtitle, int extraReservedHeight) {
const ThemeMetrics& metrics = UITheme::getInstance().getMetrics();
auto orientation = renderer.getOrientation();
int reservedHeight = metrics.topPadding;
if (hasHeader) {
reservedHeight += metrics.headerHeight + metrics.verticalSpacing;
@@ -60,7 +61,8 @@ int UITheme::getNumberOfItemsPerPage(const GfxRenderer& renderer, bool hasHeader
if (hasTabBar) {
reservedHeight += metrics.tabBarHeight;
}
if (hasButtonHints) {
if (hasButtonHints && orientation != GfxRenderer::Orientation::LandscapeClockwise &&
orientation != GfxRenderer::Orientation::LandscapeCounterClockwise) {
reservedHeight += metrics.verticalSpacing + metrics.buttonHintsHeight;
}
const int availableHeight = renderer.getScreenHeight() - reservedHeight - extraReservedHeight;
@@ -68,6 +70,39 @@ int UITheme::getNumberOfItemsPerPage(const GfxRenderer& renderer, bool hasHeader
return availableHeight / rowHeight;
}
// Screen area excluding the button hints
Rect UITheme::getScreenSafeArea(const GfxRenderer& renderer, bool hasFrontButtonHints, bool hasSideButtonHints) {
auto orientation = renderer.getOrientation();
const int screenWidth = renderer.getScreenWidth();
const int screenHeight = renderer.getScreenHeight();
Rect safeArea = Rect{0, 0, screenWidth, screenHeight};
switch (orientation) {
case GfxRenderer::Orientation::Portrait:
if (hasFrontButtonHints) {
safeArea.height -= currentMetrics->buttonHintsHeight;
}
break;
case GfxRenderer::Orientation::LandscapeClockwise:
if (hasFrontButtonHints) {
safeArea.x += currentMetrics->buttonHintsHeight;
safeArea.width -= currentMetrics->buttonHintsHeight;
}
break;
case GfxRenderer::Orientation::PortraitInverted:
if (hasFrontButtonHints) {
safeArea.y += currentMetrics->buttonHintsHeight;
safeArea.height -= currentMetrics->buttonHintsHeight;
}
break;
case GfxRenderer::Orientation::LandscapeCounterClockwise:
if (hasFrontButtonHints) {
safeArea.width -= currentMetrics->buttonHintsHeight;
}
break;
}
return safeArea;
}
std::string UITheme::getCoverThumbPath(std::string coverBmpPath, int coverHeight) {
size_t pos = coverBmpPath.find("[HEIGHT]", 0);
if (pos != std::string::npos) {
@@ -111,3 +146,10 @@ int UITheme::getProgressBarHeight() {
SETTINGS.statusBarProgressBar != CrossPointSettings::STATUS_BAR_PROGRESS_BAR::HIDE_PROGRESS;
return (showProgressBar ? (((SETTINGS.statusBarProgressBarThickness + 1) * 2) + metrics.progressBarMarginTop) : 0);
}
// Centered text implementation that takes the safe area into account
void UITheme::drawCenteredText(const GfxRenderer& renderer, Rect screen, int fontId, int y, const char* text,
bool black, EpdFontFamily::Style style) {
const int x = screen.x + (screen.width - renderer.getTextWidth(fontId, text, style)) / 2;
renderer.drawText(fontId, x, y, text, black, style);
}