From c98ba142e8a7028e0d07ef52ba0201c60464c121 Mon Sep 17 00:00:00 2001 From: Maeve Andrews <37351465+maeveynot@users.noreply.github.com> Date: Thu, 15 Jan 2026 06:23:36 -0600 Subject: [PATCH] fix: draw button hints correctly if orientation is not portrait (#363) ~~Quick~~ fix for https://github.com/daveallie/crosspoint-reader/issues/362 (this just applies to the chapter selection menu:) ~~If the orientation is portrait, hints as we know them make sense to draw. If the orientation is inverted, we'd have to change the order of the labels (along with everything's position), and if it's one of the landscape choices, we'd have to render the text and buttons vertically. All those other cases will be more complicated.~~ ~~Punt on this for now by only rendering if portrait.~~ Update: this now draws the hints at the physical button position no matter what the orientation is, by temporarily changing orientation to portrait. --------- Co-authored-by: Maeve Andrews --- lib/GfxRenderer/GfxRenderer.cpp | 8 +++++++- lib/GfxRenderer/GfxRenderer.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index 28022e9..7072fed 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -468,7 +468,10 @@ int GfxRenderer::getLineHeight(const int fontId) const { } void GfxRenderer::drawButtonHints(const int fontId, const char* btn1, const char* btn2, const char* btn3, - const char* btn4) const { + const char* btn4) { + const Orientation orig_orientation = getOrientation(); + setOrientation(Orientation::Portrait); + const int pageHeight = getScreenHeight(); constexpr int buttonWidth = 106; constexpr int buttonHeight = 40; @@ -481,12 +484,15 @@ void GfxRenderer::drawButtonHints(const int fontId, const char* btn1, const char // Only draw if the label is non-empty if (labels[i] != nullptr && labels[i][0] != '\0') { const int x = buttonPositions[i]; + fillRect(x, pageHeight - buttonY, buttonWidth, buttonHeight, false); drawRect(x, pageHeight - buttonY, buttonWidth, buttonHeight); const int textWidth = getTextWidth(fontId, labels[i]); const int textX = x + (buttonWidth - 1 - textWidth) / 2; drawText(fontId, textX, pageHeight - buttonY + textYOffset, labels[i]); } } + + setOrientation(orig_orientation); } void GfxRenderer::drawSideButtonHints(const int fontId, const char* topBtn, const char* bottomBtn) const { diff --git a/lib/GfxRenderer/GfxRenderer.h b/lib/GfxRenderer/GfxRenderer.h index 9d341bc..b1fea69 100644 --- a/lib/GfxRenderer/GfxRenderer.h +++ b/lib/GfxRenderer/GfxRenderer.h @@ -84,7 +84,7 @@ class GfxRenderer { EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; // UI Components - void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4) const; + void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4); void drawSideButtonHints(int fontId, const char* topBtn, const char* bottomBtn) const; private: