mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 23:27:38 +03:00
fix: Remove status bar margin from reader screen if status bar is disabled
This commit is contained in:
parent
20b6d4d055
commit
fd6ea01f64
@ -42,6 +42,17 @@ void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left,
|
|||||||
renderer.fillRect(x + 2, y + 2, filledWidth, batteryHeight - 4);
|
renderer.fillRect(x + 2, y + 2, filledWidth, batteryHeight - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenComponents::drawBookProgressBar(const GfxRenderer& renderer, const size_t bookProgress) {
|
||||||
|
int vieweableMarginTop, vieweableMarginRight, vieweableMarginBottom, vieweableMarginLeft;
|
||||||
|
renderer.getOrientedViewableTRBL(&vieweableMarginTop, &vieweableMarginRight, &vieweableMarginBottom,
|
||||||
|
&vieweableMarginLeft);
|
||||||
|
|
||||||
|
const int progressBarMaxWidth = renderer.getScreenWidth() - vieweableMarginLeft - vieweableMarginRight;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenComponents::drawProgressBar(const GfxRenderer& renderer, const int x, const int y, const int width,
|
void ScreenComponents::drawProgressBar(const GfxRenderer& renderer, const int x, const int y, const int width,
|
||||||
const int height, const size_t current, const size_t total) {
|
const int height, const size_t current, const size_t total) {
|
||||||
if (total == 0) {
|
if (total == 0) {
|
||||||
|
|||||||
@ -7,7 +7,10 @@ class GfxRenderer;
|
|||||||
|
|
||||||
class ScreenComponents {
|
class ScreenComponents {
|
||||||
public:
|
public:
|
||||||
|
static const int BOOK_PROGRESS_BAR_HEIGHT = 4;
|
||||||
|
|
||||||
static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true);
|
static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true);
|
||||||
|
static void drawBookProgressBar(const GfxRenderer& renderer, size_t bookProgress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a progress bar with percentage text.
|
* Draw a progress bar with percentage text.
|
||||||
|
|||||||
@ -17,7 +17,6 @@ namespace {
|
|||||||
constexpr unsigned long skipChapterMs = 700;
|
constexpr unsigned long skipChapterMs = 700;
|
||||||
constexpr unsigned long goHomeMs = 1000;
|
constexpr unsigned long goHomeMs = 1000;
|
||||||
constexpr int statusBarMargin = 19;
|
constexpr int statusBarMargin = 19;
|
||||||
constexpr int progressBarHeight = 4;
|
|
||||||
constexpr int progressBarMarginTop = 1;
|
constexpr int progressBarMarginTop = 1;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -264,9 +263,6 @@ void EpubReaderActivity::renderScreen() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add additional margin for status bar if progress bar is shown
|
|
||||||
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::FULL_WITH_PROGRESS_BAR;
|
|
||||||
|
|
||||||
// Apply screen viewable areas and additional padding
|
// Apply screen viewable areas and additional padding
|
||||||
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
||||||
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
||||||
@ -274,7 +270,15 @@ void EpubReaderActivity::renderScreen() {
|
|||||||
orientedMarginTop += SETTINGS.screenMargin;
|
orientedMarginTop += SETTINGS.screenMargin;
|
||||||
orientedMarginLeft += SETTINGS.screenMargin;
|
orientedMarginLeft += SETTINGS.screenMargin;
|
||||||
orientedMarginRight += SETTINGS.screenMargin;
|
orientedMarginRight += SETTINGS.screenMargin;
|
||||||
orientedMarginBottom += statusBarMargin + (showProgressBar ? (progressBarHeight + progressBarMarginTop) : 0);
|
orientedMarginBottom += SETTINGS.screenMargin;
|
||||||
|
|
||||||
|
// Add status bar margin
|
||||||
|
if (SETTINGS.statusBar != CrossPointSettings::STATUS_BAR_MODE::NONE) {
|
||||||
|
// Add additional margin for status bar if progress bar is shown
|
||||||
|
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::FULL_WITH_PROGRESS_BAR;
|
||||||
|
orientedMarginBottom += statusBarMargin - SETTINGS.screenMargin +
|
||||||
|
(showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT + progressBarMarginTop) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!section) {
|
if (!section) {
|
||||||
const auto filepath = epub->getSpineItem(currentSpineIndex).href;
|
const auto filepath = epub->getSpineItem(currentSpineIndex).href;
|
||||||
@ -470,14 +474,7 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
|
|
||||||
if (showProgressBar) {
|
if (showProgressBar) {
|
||||||
// Draw progress bar at the very bottom of the screen, from edge to edge of viewable area
|
// Draw progress bar at the very bottom of the screen, from edge to edge of viewable area
|
||||||
int vieweableMarginTop, vieweableMarginRight, vieweableMarginBottom, vieweableMarginLeft;
|
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(bookProgress));
|
||||||
renderer.getOrientedViewableTRBL(&vieweableMarginTop, &vieweableMarginRight, &vieweableMarginBottom,
|
|
||||||
&vieweableMarginLeft);
|
|
||||||
|
|
||||||
const int progressBarMaxWidth = renderer.getScreenWidth() - vieweableMarginLeft - vieweableMarginRight;
|
|
||||||
const int progressBarY = renderer.getScreenHeight() - vieweableMarginBottom - progressBarHeight;
|
|
||||||
const int barWidth = progressBarMaxWidth * bookProgress / 100;
|
|
||||||
renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, progressBarHeight, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr unsigned long goHomeMs = 1000;
|
constexpr unsigned long goHomeMs = 1000;
|
||||||
constexpr int statusBarMargin = 25;
|
constexpr int statusBarMargin = 25;
|
||||||
constexpr int progressBarHeight = 4;
|
|
||||||
constexpr int progressBarMarginTop = 1;
|
constexpr int progressBarMarginTop = 1;
|
||||||
constexpr size_t CHUNK_SIZE = 8 * 1024; // 8KB chunk for reading
|
constexpr size_t CHUNK_SIZE = 8 * 1024; // 8KB chunk for reading
|
||||||
|
|
||||||
@ -151,9 +150,6 @@ void TxtReaderActivity::initializeReader() {
|
|||||||
cachedScreenMargin = SETTINGS.screenMargin;
|
cachedScreenMargin = SETTINGS.screenMargin;
|
||||||
cachedParagraphAlignment = SETTINGS.paragraphAlignment;
|
cachedParagraphAlignment = SETTINGS.paragraphAlignment;
|
||||||
|
|
||||||
// Add additional margin for status bar if progress bar is shown
|
|
||||||
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::FULL_WITH_PROGRESS_BAR;
|
|
||||||
|
|
||||||
// Calculate viewport dimensions
|
// Calculate viewport dimensions
|
||||||
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
|
||||||
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
|
||||||
@ -161,7 +157,15 @@ void TxtReaderActivity::initializeReader() {
|
|||||||
orientedMarginTop += cachedScreenMargin;
|
orientedMarginTop += cachedScreenMargin;
|
||||||
orientedMarginLeft += cachedScreenMargin;
|
orientedMarginLeft += cachedScreenMargin;
|
||||||
orientedMarginRight += cachedScreenMargin;
|
orientedMarginRight += cachedScreenMargin;
|
||||||
orientedMarginBottom += statusBarMargin + (showProgressBar ? (progressBarHeight + progressBarMarginTop) : 0);
|
orientedMarginBottom += cachedScreenMargin;
|
||||||
|
|
||||||
|
// Add status bar margin
|
||||||
|
if (SETTINGS.statusBar != CrossPointSettings::STATUS_BAR_MODE::NONE) {
|
||||||
|
// Add additional margin for status bar if progress bar is shown
|
||||||
|
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::FULL_WITH_PROGRESS_BAR;
|
||||||
|
orientedMarginBottom += statusBarMargin - cachedScreenMargin +
|
||||||
|
(showProgressBar ? (ScreenComponents::BOOK_PROGRESS_BAR_HEIGHT + progressBarMarginTop) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
|
viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
|
||||||
const int viewportHeight = renderer.getScreenHeight() - orientedMarginTop - orientedMarginBottom;
|
const int viewportHeight = renderer.getScreenHeight() - orientedMarginTop - orientedMarginBottom;
|
||||||
@ -531,14 +535,7 @@ void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int
|
|||||||
|
|
||||||
if (showProgressBar) {
|
if (showProgressBar) {
|
||||||
// Draw progress bar at the very bottom of the screen, from edge to edge of viewable area
|
// Draw progress bar at the very bottom of the screen, from edge to edge of viewable area
|
||||||
int vieweableMarginTop, vieweableMarginRight, vieweableMarginBottom, vieweableMarginLeft;
|
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(progress));
|
||||||
renderer.getOrientedViewableTRBL(&vieweableMarginTop, &vieweableMarginRight, &vieweableMarginBottom,
|
|
||||||
&vieweableMarginLeft);
|
|
||||||
|
|
||||||
const int progressBarMaxWidth = renderer.getScreenWidth() - vieweableMarginLeft - vieweableMarginRight;
|
|
||||||
const int progressBarY = renderer.getScreenHeight() - vieweableMarginBottom - progressBarHeight;
|
|
||||||
const int barWidth = progressBarMaxWidth * progress / 100;
|
|
||||||
renderer.fillRect(vieweableMarginLeft, progressBarY, barWidth, progressBarHeight, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user