## Summary This pull request introduces a new "Chapter Progress Bar" mode to the status bar, allowing users to track their progress within the current chapter in addition to the existing book-level progress options. It also unifies and increases the progress bar height for better visibility, and updates the settings UI to support the new mode. Closes #636 **Status Bar/Progress Bar Enhancements:** * Added a new `CHAPTER_PROGRESS_BAR` mode to `CrossPointSettings::STATUS_BAR_MODE`, and updated the settings UI to allow users to select this mode. [[1]](diffhunk://#diff-3af36372bb6233a83387a68091b5e0651c23585c7c0a95669ed893268ca709a8R34) [[2]](diffhunk://#diff-c55df9ec3ade843be000ba463cb75aa3df27dc34620a56c248fc4cc4e917b34bL22-R23) * Implemented `drawChapterProgressBar` in `ScreenComponents` and integrated it into both EPUB and TXT reader activities, so the chapter progress bar is displayed when the new mode is selected. [[1]](diffhunk://#diff-be271778a942f7fab0d920acd73442512346ff811a4625c011275a7ca6be3a3eL51-R64) [[2]](diffhunk://#diff-dd410cab3a363d78172706d2ad6591f327e9b5b05f314db405db31a667af03faL16-R20) [[3]](diffhunk://#diff-82798dedbe135495e619d4aa27a4bef560c70c7663cf43148b67a26ddde45682R518-R525) [[4]](diffhunk://#diff-471ba9d9eb65b1a8451d41246db2aa695a42ea4ae4762163adfda4c20fec0950R563-R567) * Updated logic in EPUB and TXT reader activities to show the correct progress bar, progress text, and battery indicator based on the selected status bar mode, including the new chapter progress bar mode. [[1]](diffhunk://#diff-82798dedbe135495e619d4aa27a4bef560c70c7663cf43148b67a26ddde45682R470-R481) [[2]](diffhunk://#diff-82798dedbe135495e619d4aa27a4bef560c70c7663cf43148b67a26ddde45682L490-R503) [[3]](diffhunk://#diff-471ba9d9eb65b1a8451d41246db2aa695a42ea4ae4762163adfda4c20fec0950R522-R533) [[4]](diffhunk://#diff-471ba9d9eb65b1a8451d41246db2aa695a42ea4ae4762163adfda4c20fec0950L539-R548) **UI/Visual Tweaks:** * Increased the progress bar height from 4 to 6 pixels for improved visibility, and refactored code to use the new constant. [[1]](diffhunk://#diff-dd410cab3a363d78172706d2ad6591f327e9b5b05f314db405db31a667af03faL16-R20) [[2]](diffhunk://#diff-82798dedbe135495e619d4aa27a4bef560c70c7663cf43148b67a26ddde45682L295-R295) [[3]](diffhunk://#diff-471ba9d9eb65b1a8451d41246db2aa695a42ea4ae4762163adfda4c20fec0950L177-R177) These changes collectively provide users with more granular progress tracking options and a clearer visual indicator for reading progress. ## Additional Context --- ### AI Usage Did you use AI tools to help write this code? _**YES**_ --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
118 lines
4.5 KiB
C++
118 lines
4.5 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
class GfxRenderer;
|
|
struct RecentBook;
|
|
|
|
struct Rect {
|
|
int x;
|
|
int y;
|
|
int width;
|
|
int height;
|
|
|
|
explicit Rect(int x = 0, int y = 0, int width = 0, int height = 0) : x(x), y(y), width(width), height(height) {}
|
|
};
|
|
|
|
struct TabInfo {
|
|
const char* label;
|
|
bool selected;
|
|
};
|
|
|
|
struct ThemeMetrics {
|
|
int batteryWidth;
|
|
int batteryHeight;
|
|
|
|
int topPadding;
|
|
int batteryBarHeight;
|
|
int headerHeight;
|
|
int verticalSpacing;
|
|
|
|
int contentSidePadding;
|
|
int listRowHeight;
|
|
int listWithSubtitleRowHeight;
|
|
int menuRowHeight;
|
|
int menuSpacing;
|
|
|
|
int tabSpacing;
|
|
int tabBarHeight;
|
|
|
|
int scrollBarWidth;
|
|
int scrollBarRightOffset;
|
|
|
|
int homeTopPadding;
|
|
int homeCoverHeight;
|
|
int homeCoverTileHeight;
|
|
int homeRecentBooksCount;
|
|
|
|
int buttonHintsHeight;
|
|
int sideButtonHintsWidth;
|
|
|
|
int versionTextRightX;
|
|
int versionTextY;
|
|
|
|
int bookProgressBarHeight;
|
|
};
|
|
|
|
// Default theme implementation (Classic Theme)
|
|
// Additional themes can inherit from this and override methods as needed
|
|
|
|
namespace BaseMetrics {
|
|
constexpr ThemeMetrics values = {.batteryWidth = 15,
|
|
.batteryHeight = 12,
|
|
.topPadding = 5,
|
|
.batteryBarHeight = 20,
|
|
.headerHeight = 45,
|
|
.verticalSpacing = 10,
|
|
.contentSidePadding = 20,
|
|
.listRowHeight = 30,
|
|
.listWithSubtitleRowHeight = 65,
|
|
.menuRowHeight = 45,
|
|
.menuSpacing = 8,
|
|
.tabSpacing = 10,
|
|
.tabBarHeight = 50,
|
|
.scrollBarWidth = 4,
|
|
.scrollBarRightOffset = 5,
|
|
.homeTopPadding = 20,
|
|
.homeCoverHeight = 400,
|
|
.homeCoverTileHeight = 400,
|
|
.homeRecentBooksCount = 1,
|
|
.buttonHintsHeight = 40,
|
|
.sideButtonHintsWidth = 30,
|
|
.versionTextRightX = 20,
|
|
.versionTextY = 738,
|
|
.bookProgressBarHeight = 4};
|
|
}
|
|
|
|
class BaseTheme {
|
|
public:
|
|
virtual ~BaseTheme() = default;
|
|
|
|
// Component drawing methods
|
|
virtual void drawProgressBar(const GfxRenderer& renderer, Rect rect, size_t current, size_t total) const;
|
|
virtual void drawBattery(const GfxRenderer& renderer, Rect rect, bool showPercentage = true) const;
|
|
virtual void drawButtonHints(GfxRenderer& renderer, const char* btn1, const char* btn2, const char* btn3,
|
|
const char* btn4) const;
|
|
virtual void drawSideButtonHints(const GfxRenderer& renderer, const char* topBtn, const char* bottomBtn) const;
|
|
virtual void drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex,
|
|
const std::function<std::string(int index)>& rowTitle,
|
|
const std::function<std::string(int index)>& rowSubtitle,
|
|
const std::function<std::string(int index)>& rowIcon,
|
|
const std::function<std::string(int index)>& rowValue) const;
|
|
|
|
virtual void drawHeader(const GfxRenderer& renderer, Rect rect, const char* title) const;
|
|
virtual void drawTabBar(const GfxRenderer& renderer, Rect rect, const std::vector<TabInfo>& tabs,
|
|
bool selected) const;
|
|
virtual void drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std::vector<RecentBook>& recentBooks,
|
|
const int selectorIndex, bool& coverRendered, bool& coverBufferStored,
|
|
bool& bufferRestored, std::function<bool()> storeCoverBuffer) const;
|
|
virtual void drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount, int selectedIndex,
|
|
const std::function<std::string(int index)>& buttonLabel,
|
|
const std::function<std::string(int index)>& rowIcon) const;
|
|
virtual Rect drawPopup(const GfxRenderer& renderer, const char* message) const;
|
|
virtual void fillPopupProgress(const GfxRenderer& renderer, const Rect& layout, const int progress) const;
|
|
virtual void drawReadingProgressBar(const GfxRenderer& renderer, const size_t bookProgress) const;
|
|
}; |