diff --git a/src/ScreenComponents.cpp b/src/ScreenComponents.cpp index 72f7faf0..d9725acc 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, @@ -80,9 +81,24 @@ 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 - bookProgressBarHeight(); const int barWidth = progressBarMaxWidth * bookProgress / 100; - renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, BOOK_PROGRESS_BAR_HEIGHT, true); + renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, bookProgressBarHeight(), true); +} + +int ScreenComponents::bookProgressBarHeight() { + const auto orientation = SETTINGS.orientation; + const bool isVertical = (orientation == CrossPointSettings::ORIENTATION::PORTRAIT || + orientation == CrossPointSettings::ORIENTATION::INVERTED); + + constexpr int bookProgressBarVerticalHeight = 4; + constexpr int bookProgressBarHorizontalHeight = 2; + + if (isVertical) { + return bookProgressBarVerticalHeight; + } else { + return bookProgressBarHorizontalHeight; + } } int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector& tabs) { diff --git a/src/ScreenComponents.h b/src/ScreenComponents.h index 78ed5920..9269a39b 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 bookProgressBarHeight(); struct PopupLayout { int x; diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 5ccfb4fe..868b16de 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -353,7 +353,7 @@ void EpubReaderActivity::renderScreen() { 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); + (showProgressBar ? (ScreenComponents::bookProgressBarHeight() + progressBarMarginTop) : 0); } if (!section) { diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index eb1a9eef..b3582aaf 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -174,7 +174,7 @@ void TxtReaderActivity::initializeReader() { 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); + (showProgressBar ? (ScreenComponents::bookProgressBarHeight() + progressBarMarginTop) : 0); } viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;