Files
crosspoint-reader-mod/src/components/UITheme.h
cottongin 905f694576 prerender book covers and thumbnails when opening a book for the first time
Moves cover/thumbnail generation from lazy (Home screen, Sleep screen) into
each reader activity's onEnter(). On first open, generates all needed BMPs
(cover, cover_crop, thumbnails for all theme heights) with a "Preparing
book..." progress popup. Subsequent opens skip instantly when files exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:13:55 -05:00

37 lines
1.2 KiB
C++

#pragma once
#include <functional>
#include <vector>
#include "CrossPointSettings.h"
#include "components/themes/BaseTheme.h"
class UITheme {
// Static instance
static UITheme instance;
public:
UITheme();
static UITheme& getInstance() { return instance; }
const ThemeMetrics& getMetrics() { return *currentMetrics; }
const BaseTheme& getTheme() { return *currentTheme; }
void reload();
void setTheme(CrossPointSettings::UI_THEME type);
static int getNumberOfItemsPerPage(const GfxRenderer& renderer, bool hasHeader, bool hasTabBar, bool hasButtonHints,
bool hasSubtitle);
static std::string getCoverThumbPath(std::string coverBmpPath, int coverHeight);
private:
const ThemeMetrics* currentMetrics;
const BaseTheme* currentTheme;
};
// Known theme thumbnail heights to prerender when opening a book for the first time.
// These correspond to homeCoverHeight values across all themes (Lyra=226, Base=400).
static constexpr int PRERENDER_THUMB_HEIGHTS[] = {226, 400};
static constexpr int PRERENDER_THUMB_HEIGHTS_COUNT = 2;
// Helper macro to access current theme
#define GUI UITheme::getInstance().getTheme()