From fc94455e270af8487e001efa1fb3d4402d36dee1 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Thu, 29 Jan 2026 00:40:27 +0300 Subject: [PATCH] Return progress bar height depending on orientation --- src/ScreenComponents.cpp | 17 +++++++++++++++-- src/ScreenComponents.h | 2 +- src/activities/reader/EpubReaderActivity.cpp | 5 +++-- src/activities/reader/TxtReaderActivity.cpp | 5 +++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/ScreenComponents.cpp b/src/ScreenComponents.cpp index ef47dfc5..7b2d48f3 100644 --- a/src/ScreenComponents.cpp +++ b/src/ScreenComponents.cpp @@ -6,6 +6,7 @@ #include #include "Battery.h" +#include "CrossPointSettings.h" #include "fontIds.h" void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left, const int top, @@ -48,9 +49,21 @@ void ScreenComponents::drawBookProgressBar(const GfxRenderer& renderer, const si &vieweableMarginLeft); const int progressBarMaxWidth = renderer.getScreenWidth() - vieweableMarginLeft - vieweableMarginRight; - const int progressBarY = renderer.getScreenHeight() - vieweableMarginBottom - BOOK_PROGRESS_BAR_HEIGHT; + const int progressBarY = renderer.getScreenHeight() - vieweableMarginBottom - BOOK_PROGRESS_BAR_HEIGHT(); const int barWidth = progressBarMaxWidth * bookProgress / 100; - renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, BOOK_PROGRESS_BAR_HEIGHT, true); + renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, BOOK_PROGRESS_BAR_HEIGHT(), true); +} + +int ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT() { + const auto orientation = SETTINGS.orientation; + const bool isVertical = (orientation == CrossPointSettings::ORIENTATION::PORTRAIT || + orientation == CrossPointSettings::ORIENTATION::INVERTED); + + if (isVertical) { + return 4; + } else { + return 2; + } } int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector& tabs) { diff --git a/src/ScreenComponents.h b/src/ScreenComponents.h index 15403f60..3132c92e 100644 --- a/src/ScreenComponents.h +++ b/src/ScreenComponents.h @@ -13,7 +13,7 @@ struct TabInfo { class ScreenComponents { public: - static const int BOOK_PROGRESS_BAR_HEIGHT = 4; + static int BOOK_PROGRESS_BAR_HEIGHT(); static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true); static void drawBookProgressBar(const GfxRenderer& renderer, size_t bookProgress); diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 58668c68..eb423c3c 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -291,8 +291,9 @@ void EpubReaderActivity::renderScreen() { // Add additional margin for status bar if progress bar is shown const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR || SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::ONLY_PROGRESS_BAR; - orientedMarginBottom += statusBarMargin - SETTINGS.screenMargin + - (showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT + progressBarMarginTop) : 0); + orientedMarginBottom += + statusBarMargin - SETTINGS.screenMargin + + (showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT() + progressBarMarginTop) : 0); } if (!section) { diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index e9303de3..289f9042 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -173,8 +173,9 @@ void TxtReaderActivity::initializeReader() { // Add additional margin for status bar if progress bar is shown const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR || SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::ONLY_PROGRESS_BAR; - orientedMarginBottom += statusBarMargin - cachedScreenMargin + - (showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT + progressBarMarginTop) : 0); + orientedMarginBottom += + statusBarMargin - cachedScreenMargin + + (showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT() + progressBarMarginTop) : 0); } viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;