From 3b12c083bca972d4ee79113ced0e2cf2b5291acf Mon Sep 17 00:00:00 2001 From: Jan Ivanov Date: Fri, 17 Apr 2026 01:37:41 +0300 Subject: [PATCH] fix: make footnotes consider orientation for gutters (#1665) ## Summary * **What is the goal of this PR?** Noticed that the footnotes selection screen does not add proper margins to accommodate screen orientation * **What changes are included?** Copied some code over from `EpubReaderChapterSelectionActivity` to calculate the proper margins in `CW` and `Inverted` orientation | Before | After | |--------|--------| | image | image | | image | image | --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_ --------- Co-authored-by: Jan Ivanov --- .../reader/EpubReaderFootnotesActivity.cpp | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/activities/reader/EpubReaderFootnotesActivity.cpp b/src/activities/reader/EpubReaderFootnotesActivity.cpp index ef077a077..a50163ae9 100644 --- a/src/activities/reader/EpubReaderFootnotesActivity.cpp +++ b/src/activities/reader/EpubReaderFootnotesActivity.cpp @@ -52,27 +52,43 @@ void EpubReaderFootnotesActivity::loop() { void EpubReaderFootnotesActivity::render(RenderLock&&) { renderer.clearScreen(); - renderer.drawCenteredText(UI_12_FONT_ID, 15, tr(STR_FOOTNOTES), true, EpdFontFamily::BOLD); + const auto pageWidth = renderer.getScreenWidth(); + const auto orientation = renderer.getOrientation(); + // Landscape orientation: reserve a horizontal gutter for button hints. + const bool isLandscapeCw = orientation == GfxRenderer::Orientation::LandscapeClockwise; + const bool isLandscapeCcw = orientation == GfxRenderer::Orientation::LandscapeCounterClockwise; + // Inverted portrait: reserve vertical space for hints at the top. + const bool isPortraitInverted = orientation == GfxRenderer::Orientation::PortraitInverted; + const int hintGutterWidth = (isLandscapeCw || isLandscapeCcw) ? 30 : 0; + // Landscape CW places hints on the left edge; CCW keeps them on the right. + const int contentX = isLandscapeCw ? hintGutterWidth : 0; + const int contentWidth = pageWidth - hintGutterWidth; + const int hintGutterHeight = isPortraitInverted ? 50 : 0; + const int contentY = hintGutterHeight; + + // Manual centering to honor content gutters. + const int titleX = + contentX + (contentWidth - renderer.getTextWidth(UI_12_FONT_ID, tr(STR_FOOTNOTES), EpdFontFamily::BOLD)) / 2; + renderer.drawText(UI_12_FONT_ID, titleX, 15 + contentY, tr(STR_FOOTNOTES), true, EpdFontFamily::BOLD); if (footnotes.empty()) { - renderer.drawCenteredText(UI_10_FONT_ID, 90, tr(STR_NO_FOOTNOTES)); + renderer.drawCenteredText(UI_10_FONT_ID, 90 + contentY, tr(STR_NO_FOOTNOTES)); const auto labels = mappedInput.mapLabels(tr(STR_BACK), "", "", ""); GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4); renderer.displayBuffer(); return; } - constexpr int startY = 50; constexpr int lineHeight = 36; const int screenWidth = renderer.getScreenWidth(); - constexpr int marginLeft = 20; + const int marginLeft = contentX + 20; - const int visibleCount = std::max(1, (renderer.getScreenHeight() - startY) / lineHeight); + const int visibleCount = std::max(1, (renderer.getScreenHeight() - contentY) / lineHeight); if (selectedIndex < scrollOffset) scrollOffset = selectedIndex; if (selectedIndex >= scrollOffset + visibleCount) scrollOffset = selectedIndex - visibleCount + 1; for (int i = scrollOffset; i < static_cast(footnotes.size()) && i < scrollOffset + visibleCount; i++) { - const int y = startY + (i - scrollOffset) * lineHeight; + const int y = 60 + contentY + (i - scrollOffset) * lineHeight; const bool isSelected = (i == selectedIndex); if (isSelected) {