187 lines
5.3 KiB
C
187 lines
5.3 KiB
C
#ifndef THEME_H
|
|
#define THEME_H
|
|
|
|
#include "kryon.h"
|
|
#include "theme_style.h"
|
|
#include <stdbool.h>
|
|
|
|
#define THEME_MAX_SCOPES 24
|
|
#define THEME_MAX_VALUES 64
|
|
#define THEME_NAME_SIZE 64
|
|
#define THEME_PATH_SIZE 256
|
|
#define THEME_MAX_VARS 64
|
|
|
|
typedef struct ThemeValue {
|
|
char key[THEME_NAME_SIZE];
|
|
Color value;
|
|
} ThemeValue;
|
|
|
|
typedef struct ThemeScope {
|
|
char name[THEME_NAME_SIZE];
|
|
char path[THEME_PATH_SIZE];
|
|
char dark_path[THEME_PATH_SIZE];
|
|
ThemeValue values[THEME_MAX_VALUES];
|
|
int count;
|
|
} ThemeScope;
|
|
|
|
typedef struct {
|
|
char key[THEME_NAME_SIZE];
|
|
Color value;
|
|
bool scopes[THEME_MAX_SCOPES];
|
|
int scope_count;
|
|
} ThemeAggregateVariable;
|
|
|
|
typedef enum {
|
|
THEME_SOURCE_APP = 0,
|
|
THEME_SOURCE_SYSTEM = 1
|
|
} ThemeSource;
|
|
|
|
typedef enum {
|
|
THEME_MODE_SYSTEM = 0,
|
|
THEME_MODE_LIGHT = 1,
|
|
THEME_MODE_DARK = 2
|
|
} ThemeMode;
|
|
|
|
typedef struct ThemeColors {
|
|
Color background;
|
|
Color surface;
|
|
Color surface_raised;
|
|
Color surface_sunken;
|
|
Color overlay;
|
|
Color text;
|
|
Color text_muted;
|
|
Color text_disabled;
|
|
Color icon;
|
|
Color icon_muted;
|
|
Color border;
|
|
Color border_strong;
|
|
Color divider;
|
|
Color focus;
|
|
Color selection;
|
|
Color accent;
|
|
Color on_accent;
|
|
Color accent_hover;
|
|
Color accent_pressed;
|
|
Color success;
|
|
Color on_success;
|
|
Color warning;
|
|
Color on_warning;
|
|
Color danger;
|
|
Color on_danger;
|
|
Color info;
|
|
Color on_info;
|
|
Color link;
|
|
Color link_hover;
|
|
Color shadow;
|
|
} ThemeColors;
|
|
|
|
typedef struct Theme {
|
|
const char *name;
|
|
ThemeMode mode;
|
|
ThemeColors colors;
|
|
ThemeMetrics metrics;
|
|
} Theme;
|
|
|
|
typedef struct ThemeFamily {
|
|
const char *name;
|
|
Theme light;
|
|
Theme dark;
|
|
} ThemeFamily;
|
|
|
|
Theme ThemeDefaultLight(void);
|
|
Theme ThemeDefaultDark(void);
|
|
void SetTheme(Theme theme);
|
|
void SetThemeFamily(ThemeFamily family);
|
|
ThemeFamily GetThemeFamily(void);
|
|
Theme GetTheme(void);
|
|
const Theme *GetThemeRef(void);
|
|
|
|
void ResetTheme(void);
|
|
ThemeScope *RegisterThemeScope(const char *name, const char *path);
|
|
ThemeScope *RegisterDarkThemeScope(const char *name, const char *path, const char *dark_path);
|
|
ThemeScope *GetThemeScope(const char *name);
|
|
const ThemeScope *GetThemeScopeAt(int index);
|
|
int GetThemeScopeCount(void);
|
|
Color GetThemeColor(const char *scope, const char *key);
|
|
bool SetThemeColor(const char *scope, const char *key, Color color);
|
|
bool SaveThemeScope(const char *scope);
|
|
bool SaveAllThemes(void);
|
|
const char *GetThemeColorText(Color color, char *buffer, int size);
|
|
bool ParseThemeColor(const char *text, Color *color);
|
|
void DrawThemeTKBorder(Rectangle rec, int borderWidth, bool raised);
|
|
|
|
void AggregateAllThemes(void);
|
|
ThemeAggregateVariable* GetThemeAggregateVars(void);
|
|
int GetThemeAggregateCount(void);
|
|
void ApplyThemeAggregate(const char *key, Color color);
|
|
bool SyncThemeFromScope(const char *src_scope);
|
|
bool SyncThemeToApps(const char *src_scope);
|
|
bool ExportTheme(const char *path);
|
|
bool ImportTheme(const char *path);
|
|
|
|
void SetThemeDarkMode(bool dark);
|
|
bool GetThemeDarkMode(void);
|
|
void ReloadThemes(void);
|
|
|
|
void SetThemeSource(ThemeSource source);
|
|
ThemeSource GetThemeSource(void);
|
|
void SetThemeMode(ThemeMode mode);
|
|
ThemeMode GetThemeMode(void);
|
|
void SetThemeStyle(ThemeStyle style);
|
|
ThemeStyle GetThemeStyle(void);
|
|
ThemeStyle GetEffectiveThemeStyle(void);
|
|
ThemeStyle GetDefaultPlatformThemeStyle(void);
|
|
ThemeSource GetDefaultPlatformThemeSource(void);
|
|
ThemeMode GetDefaultPlatformThemeMode(void);
|
|
int GetDefaultThemeForThemeStyle(ThemeStyle style);
|
|
const char *GetThemeStyleLabel(ThemeStyle style);
|
|
bool IsSystemThemeAvailable(void);
|
|
const char *GetSystemThemeName(void);
|
|
const char *GetSystemThemeNameCached(void);
|
|
ThemeStyle GetSystemThemeStyle(void);
|
|
ThemeStyle GetSystemThemeStyleCached(void);
|
|
bool GetSystemTextFontName(char *out, int out_size);
|
|
bool GetSystemTextFontFile(char *out, int out_size);
|
|
bool RefreshSystemTheme(void);
|
|
/* Number of full detection attempts so far — lets tests and diagnostics
|
|
assert that per-frame theme queries never re-run file I/O. */
|
|
long SystemThemeRefreshCount(void);
|
|
bool GetSystemDesktopBackground(char *out, int out_size);
|
|
bool SystemThemePrefersDark(void);
|
|
bool SystemThemeSupportsMode(void);
|
|
void SetSystemThemeDarkMode(bool dark);
|
|
void SetSystemThemePalette(const char *name,
|
|
Color background,
|
|
Color surface,
|
|
Color text,
|
|
Color circle,
|
|
Color button,
|
|
Color button_hover,
|
|
Color icon,
|
|
Color link,
|
|
bool prefers_dark,
|
|
bool supports_mode);
|
|
bool GetEffectiveThemeDarkMode(void);
|
|
|
|
void SetCurrentTheme(int theme_id, int dark_mode);
|
|
Color GetCurrentThemeColor(const char *key);
|
|
Color GetThemeText(void);
|
|
Color GetThemeBackground(void);
|
|
Color GetThemeSurface(void);
|
|
Color GetThemeCircle(void);
|
|
Color GetThemeButton(void);
|
|
Color GetThemeButtonHover(void);
|
|
Color GetThemeIcon(void);
|
|
Color GetThemeLink(void);
|
|
Color MixThemeColor(Color from, Color to, float amount);
|
|
int GetThemeColorLuminance(Color color);
|
|
bool IsThemeColorDark(Color color);
|
|
Color GetThemeReadableText(Color background);
|
|
Color GetThemeSurfaceAlt(void);
|
|
Color GetThemeBorder(void);
|
|
Color GetThemeMutedText(void);
|
|
Color GetThemeSelection(void);
|
|
Color GetThemeButtonText(void);
|
|
|
|
#endif
|