mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
fix: status bar elements respect inverse display setting
Battery icon, percentage text, progress bar, and chapter title were always drawn black because renderStatusBar() didn't use the inverse flag. Thread it through ScreenComponents and all status bar draw calls.
This commit is contained in:
parent
aa2467de9e
commit
24b5e270c4
@ -9,11 +9,11 @@
|
|||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
|
||||||
void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left, const int top,
|
void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left, const int top,
|
||||||
const bool showPercentage) {
|
const bool showPercentage, const bool black) {
|
||||||
// Left aligned battery icon and percentage
|
// Left aligned battery icon and percentage
|
||||||
const uint16_t percentage = battery.readPercentage();
|
const uint16_t percentage = battery.readPercentage();
|
||||||
const auto percentageText = showPercentage ? std::to_string(percentage) + "%" : "";
|
const auto percentageText = showPercentage ? std::to_string(percentage) + "%" : "";
|
||||||
renderer.drawText(SMALL_FONT_ID, left + 20, top, percentageText.c_str());
|
renderer.drawText(SMALL_FONT_ID, left + 20, top, percentageText.c_str(), black);
|
||||||
|
|
||||||
// 1 column on left, 2 columns on right, 5 columns of battery body
|
// 1 column on left, 2 columns on right, 5 columns of battery body
|
||||||
constexpr int batteryWidth = 15;
|
constexpr int batteryWidth = 15;
|
||||||
@ -22,16 +22,16 @@ void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left,
|
|||||||
const int y = top + 6;
|
const int y = top + 6;
|
||||||
|
|
||||||
// Top line
|
// Top line
|
||||||
renderer.drawLine(x + 1, y, x + batteryWidth - 3, y);
|
renderer.drawLine(x + 1, y, x + batteryWidth - 3, y, black);
|
||||||
// Bottom line
|
// Bottom line
|
||||||
renderer.drawLine(x + 1, y + batteryHeight - 1, x + batteryWidth - 3, y + batteryHeight - 1);
|
renderer.drawLine(x + 1, y + batteryHeight - 1, x + batteryWidth - 3, y + batteryHeight - 1, black);
|
||||||
// Left line
|
// Left line
|
||||||
renderer.drawLine(x, y + 1, x, y + batteryHeight - 2);
|
renderer.drawLine(x, y + 1, x, y + batteryHeight - 2, black);
|
||||||
// Battery end
|
// Battery end
|
||||||
renderer.drawLine(x + batteryWidth - 2, y + 1, x + batteryWidth - 2, y + batteryHeight - 2);
|
renderer.drawLine(x + batteryWidth - 2, y + 1, x + batteryWidth - 2, y + batteryHeight - 2, black);
|
||||||
renderer.drawPixel(x + batteryWidth - 1, y + 3);
|
renderer.drawPixel(x + batteryWidth - 1, y + 3, black);
|
||||||
renderer.drawPixel(x + batteryWidth - 1, y + batteryHeight - 4);
|
renderer.drawPixel(x + batteryWidth - 1, y + batteryHeight - 4, black);
|
||||||
renderer.drawLine(x + batteryWidth - 0, y + 4, x + batteryWidth - 0, y + batteryHeight - 5);
|
renderer.drawLine(x + batteryWidth - 0, y + 4, x + batteryWidth - 0, y + batteryHeight - 5, black);
|
||||||
|
|
||||||
// The +1 is to round up, so that we always fill at least one pixel
|
// The +1 is to round up, so that we always fill at least one pixel
|
||||||
int filledWidth = percentage * (batteryWidth - 5) / 100 + 1;
|
int filledWidth = percentage * (batteryWidth - 5) / 100 + 1;
|
||||||
@ -39,7 +39,7 @@ void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left,
|
|||||||
filledWidth = batteryWidth - 5; // Ensure we don't overflow
|
filledWidth = batteryWidth - 5; // Ensure we don't overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.fillRect(x + 2, y + 2, filledWidth, batteryHeight - 4);
|
renderer.fillRect(x + 2, y + 2, filledWidth, batteryHeight - 4, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenComponents::PopupLayout ScreenComponents::drawPopup(const GfxRenderer& renderer, const char* message) {
|
ScreenComponents::PopupLayout ScreenComponents::drawPopup(const GfxRenderer& renderer, const char* message) {
|
||||||
@ -74,7 +74,7 @@ void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const Popu
|
|||||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenComponents::drawBookProgressBar(const GfxRenderer& renderer, const size_t bookProgress) {
|
void ScreenComponents::drawBookProgressBar(const GfxRenderer& renderer, const size_t bookProgress, const bool black) {
|
||||||
int vieweableMarginTop, vieweableMarginRight, vieweableMarginBottom, vieweableMarginLeft;
|
int vieweableMarginTop, vieweableMarginRight, vieweableMarginBottom, vieweableMarginLeft;
|
||||||
renderer.getOrientedViewableTRBL(&vieweableMarginTop, &vieweableMarginRight, &vieweableMarginBottom,
|
renderer.getOrientedViewableTRBL(&vieweableMarginTop, &vieweableMarginRight, &vieweableMarginBottom,
|
||||||
&vieweableMarginLeft);
|
&vieweableMarginLeft);
|
||||||
@ -82,7 +82,7 @@ void ScreenComponents::drawBookProgressBar(const GfxRenderer& renderer, const si
|
|||||||
const int progressBarMaxWidth = renderer.getScreenWidth() - vieweableMarginLeft - vieweableMarginRight;
|
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;
|
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, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector<TabInfo>& tabs) {
|
int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector<TabInfo>& tabs) {
|
||||||
|
|||||||
@ -22,8 +22,9 @@ class ScreenComponents {
|
|||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
bool black = true);
|
||||||
|
static void drawBookProgressBar(const GfxRenderer& renderer, size_t bookProgress, bool black = true);
|
||||||
|
|
||||||
static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message);
|
static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message);
|
||||||
|
|
||||||
|
|||||||
@ -493,6 +493,8 @@ void EpubReaderActivity::renderContents(std::unique_ptr<Page> page, const int or
|
|||||||
|
|
||||||
void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
||||||
const int orientedMarginLeft) const {
|
const int orientedMarginLeft) const {
|
||||||
|
const bool inverse = SETTINGS.inverseDisplay;
|
||||||
|
|
||||||
// determine visible status bar elements
|
// determine visible status bar elements
|
||||||
const bool showProgressPercentage = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
const bool showProgressPercentage = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
||||||
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR ||
|
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR ||
|
||||||
@ -531,16 +533,16 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
|
|
||||||
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
|
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
|
||||||
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
||||||
progressStr);
|
progressStr, !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(bookProgress));
|
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(bookProgress), !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showBattery) {
|
if (showBattery) {
|
||||||
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
|
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage, !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showChapterTitle) {
|
if (showChapterTitle) {
|
||||||
@ -580,6 +582,6 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
|
|
||||||
renderer.drawText(SMALL_FONT_ID,
|
renderer.drawText(SMALL_FONT_ID,
|
||||||
titleMarginLeftAdjusted + orientedMarginLeft + (availableTitleSpace - titleWidth) / 2, textY,
|
titleMarginLeftAdjusted + orientedMarginLeft + (availableTitleSpace - titleWidth) / 2, textY,
|
||||||
title.c_str());
|
title.c_str(), !inverse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -486,6 +486,8 @@ void TxtReaderActivity::renderPage() {
|
|||||||
|
|
||||||
void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int orientedMarginBottom,
|
||||||
const int orientedMarginLeft) const {
|
const int orientedMarginLeft) const {
|
||||||
|
const bool inverse = SETTINGS.inverseDisplay;
|
||||||
|
|
||||||
const bool showProgressPercentage = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
const bool showProgressPercentage = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL;
|
||||||
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR ||
|
const bool showProgressBar = SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::FULL_WITH_PROGRESS_BAR ||
|
||||||
SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::ONLY_PROGRESS_BAR;
|
SETTINGS.statusBar == CrossPointSettings::STATUS_BAR_MODE::ONLY_PROGRESS_BAR;
|
||||||
@ -516,16 +518,16 @@ void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int
|
|||||||
|
|
||||||
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
|
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
|
||||||
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
||||||
progressStr);
|
progressStr, !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(progress));
|
ScreenComponents::drawBookProgressBar(renderer, static_cast<size_t>(progress), !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showBattery) {
|
if (showBattery) {
|
||||||
ScreenComponents::drawBattery(renderer, orientedMarginLeft, textY, showBatteryPercentage);
|
ScreenComponents::drawBattery(renderer, orientedMarginLeft, textY, showBatteryPercentage, !inverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTitle) {
|
if (showTitle) {
|
||||||
@ -540,7 +542,8 @@ void TxtReaderActivity::renderStatusBar(const int orientedMarginRight, const int
|
|||||||
titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str());
|
titleWidth = renderer.getTextWidth(SMALL_FONT_ID, title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.drawText(SMALL_FONT_ID, titleMarginLeft + (availableTextWidth - titleWidth) / 2, textY, title.c_str());
|
renderer.drawText(SMALL_FONT_ID, titleMarginLeft + (availableTextWidth - titleWidth) / 2, textY, title.c_str(),
|
||||||
|
!inverse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user