Merge branch 'feat-additional-compensation' of https://github.com/jpirnay/crosspoint-reader into mybuild

This commit is contained in:
jpirnay
2026-03-29 18:35:36 +02:00
parent 4740145a88
commit 0bdfc6e816
27 changed files with 1514 additions and 85 deletions
@@ -11,13 +11,14 @@
#include "fontIds.h"
namespace {
constexpr int MENU_ITEMS = 6;
constexpr int MENU_ITEMS = 7;
const StrId menuNames[MENU_ITEMS] = {StrId::STR_CHAPTER_PAGE_COUNT,
StrId::STR_BOOK_PROGRESS_PERCENTAGE,
StrId::STR_PROGRESS_BAR,
StrId::STR_PROGRESS_BAR_THICKNESS,
StrId::STR_TITLE,
StrId::STR_BATTERY};
StrId::STR_BATTERY,
StrId::STR_CLOCK};
constexpr int PROGRESS_BAR_ITEMS = 3;
const StrId progressBarNames[PROGRESS_BAR_ITEMS] = {StrId::STR_BOOK, StrId::STR_CHAPTER, StrId::STR_HIDE};
@@ -36,7 +37,10 @@ const int verticalPreviewTextPadding = 40;
void StatusBarSettingsActivity::onEnter() {
Activity::onEnter();
selectedIndex = 0;
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
if (selectedIndex >= menuCount) {
selectedIndex = 0;
}
// Clamp statusBarProgressBar and statusBarTitle in case of corrupt/migrated data
if (SETTINGS.statusBarProgressBar >= PROGRESS_BAR_ITEMS) {
@@ -70,22 +74,26 @@ void StatusBarSettingsActivity::loop() {
// Handle navigation
buttonNavigator.onNextRelease([this] {
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, MENU_ITEMS);
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, menuCount);
requestUpdate();
});
buttonNavigator.onPreviousRelease([this] {
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, menuCount);
requestUpdate();
});
buttonNavigator.onNextContinuous([this] {
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, MENU_ITEMS);
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
selectedIndex = ButtonNavigator::nextIndex(selectedIndex, menuCount);
requestUpdate();
});
buttonNavigator.onPreviousContinuous([this] {
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, MENU_ITEMS);
const int menuCount = SETTINGS.useClock ? MENU_ITEMS : MENU_ITEMS - 1;
selectedIndex = ButtonNavigator::previousIndex(selectedIndex, menuCount);
requestUpdate();
});
}
@@ -110,6 +118,9 @@ void StatusBarSettingsActivity::handleSelection() {
} else if (selectedIndex == 5) {
// Show Battery
SETTINGS.statusBarBattery = (SETTINGS.statusBarBattery + 1) % 2;
} else if (selectedIndex == 6 && SETTINGS.useClock) {
// Show Clock
SETTINGS.statusBarClock = (SETTINGS.statusBarClock + 1) % 2;
}
SETTINGS.saveToFile();
}
@@ -124,9 +135,9 @@ void StatusBarSettingsActivity::render(RenderLock&&) {
tr(STR_CUSTOMISE_STATUS_BAR));
const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing;
const int contentHeight = contentRect.height - contentTop - metrics.verticalSpacing * 2;
const int contentHeight = pageHeight - contentTop - metrics.buttonHintsHeight - metrics.verticalSpacing * 2;
GUI.drawList(
renderer, Rect{contentRect.x, contentTop, contentRect.width, contentHeight}, static_cast<int>(MENU_ITEMS),
renderer, Rect{0, contentTop, pageWidth, contentHeight}, static_cast<int>(MENU_ITEMS),
static_cast<int>(selectedIndex), [](int index) { return std::string(I18N.get(menuNames[index])); }, nullptr,
nullptr,
[this](int index) {
@@ -143,6 +154,8 @@ void StatusBarSettingsActivity::render(RenderLock&&) {
return I18N.get(titleNames[SETTINGS.statusBarTitle]);
} else if (index == 5) {
return SETTINGS.statusBarBattery ? tr(STR_SHOW) : tr(STR_HIDE);
} else if (index == 6) {
return SETTINGS.statusBarClock ? tr(STR_SHOW) : tr(STR_HIDE);
} else {
return tr(STR_HIDE);
}