Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
2.1 kB · 54 lines
C
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455#pragma once
#include <EpdFontFamily.h>
#include <functional>#include <memory>
#include "CrossPointSettings.h"#include "components/themes/BaseTheme.h"
class CoverGridHomeUi;
class UITheme { // Static instance static UITheme instance;
public: enum class TextVerticalAlignment { TOP, CENTER, BOTTOM };
UITheme(); static UITheme& getInstance() { return instance; }
const ThemeMetrics& getMetrics() const; const BaseTheme& getTheme() const { return currentTheme ? *currentTheme : fallbackTheme; } Rect getScreenSafeArea(const GfxRenderer& renderer, bool hasFrontButtonHints = false, bool hasSideButtonHints = false); static void drawCenteredText(const GfxRenderer& renderer, Rect screen, int fontId, int y, const char* text, bool black = true, EpdFontFamily::Style style = EpdFontFamily::REGULAR); // Wraps only overflowing text, then aligns the complete line block within bounds. static void drawCenteredWrappedText(const GfxRenderer& renderer, Rect bounds, int fontId, const char* text, int maxLines, bool black = true, EpdFontFamily::Style style = EpdFontFamily::REGULAR, TextVerticalAlignment verticalAlignment = TextVerticalAlignment::CENTER); static bool supportsCoverGrid(); static bool hasCoverGridHome(); static void drawCoverGridHome(CoverGridHomeUi& home); void reload(); void setTheme(CrossPointSettings::UI_THEME type); static std::string getCoverThumbPath(std::string coverBmpPath, int coverHeight); static UIIcon getFileIcon(const std::string& filename); static int getStatusBarHeight(); static int getProgressBarHeight();
private: BaseTheme fallbackTheme; const ThemeMetrics* currentMetrics = &BaseMetrics::values; std::unique_ptr<BaseTheme> currentTheme; mutable ThemeMetrics adjustedMetrics; mutable bool metricsValid = false; mutable bool metricsForTouch = false;};
// Helper macro to access current theme#define GUI UITheme::getInstance().getTheme()