Files
MeowOS-SDK/sdk/include/meow_ui_theme.h
T

102 lines
5.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* meow_ui_theme.h — SDK 主题/配置(§8):主题模型 + MD3 语义色板 + 顶级主题风格族。
*
* 原 meow_ui.h 拆分的一部分(theme 模块)。权威结构体名 = meow_theme(App 侧),
* 与 launcher 内部的 meow_ui_theme_t(font_theme.c,仅供状态栏/设置页)无关。
*/
#ifndef MEOW_UI_THEME_H
#define MEOW_UI_THEME_H
#include "meow_ui_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================ */
/* §8 主题/配置 */
/* ============================================================ */
typedef enum { MEOW_THEME_LIGHT, MEOW_THEME_DARK, MEOW_THEME_AUTO } meow_theme_mode;
/* 主题(§5.8.4 + §8.1.3)。既有字段 bg/fg/accent/dim 保留(兼容映射,见下表),
* 其后追加 MD3 语义色板 + 风格参数段(扩展兼容——既有代码读旧字段不受影响)。
* 映射:bg↔surface、fg↔onSurface、accent↔primary、dim↔onSurfaceVariant。
* 「当前 style×mode」完整主题 = meow_theme_get()(MD3 默认;MIUIx 用 MD3 基础/占位)。 */
typedef struct meow_theme {
/* —— 既有字段(兼容保留;映射见上)—— */
uint32_t bg; /* 背景色 = surface */
uint32_t fg; /* 前景/正文 = onSurface */
uint32_t accent; /* 强调色(按钮/选中)= primary */
uint32_t dim; /* 次要文字 = onSurfaceVariant */
int font_title; /* 28 */
int font_body; /* 20 */
/* —— MD3 语义色板(§5.8.4;日/夜各一组,AUTO 按 meow_theme_mode 切换)—— */
uint32_t primary, onPrimary, primaryContainer, onPrimaryContainer;
uint32_t secondary, onSecondary, secondaryContainer, onSecondaryContainer;
uint32_t tertiary, onTertiary, tertiaryContainer, onTertiaryContainer;
uint32_t surface, onSurface, surfaceVariant, onSurfaceVariant;
uint32_t surfaceContainerLowest, surfaceContainerLow, surfaceContainer,
surfaceContainerHigh, surfaceContainerHighest;
uint32_t surfaceDim, surfaceBright, surfaceTint;
uint32_t outline, outlineVariant, scrim;
uint32_t error, onError, errorContainer, onErrorContainer;
uint32_t inverseSurface, inverseOnSurface, inversePrimary;
uint32_t shadow; /* 仅状态层/描边近似用;无 GPU 不做投影(§5.8.7) */
/* —— 风格参数段(§8.1.3;MD3 默认 / MIUIx 加大圆角+描边+间距)—— */
int radius; /* 控件默认圆角(按钮等,px) */
int radius_card; /* 卡片/容器默认圆角(px) */
int spacing; /* 布局/间距步进(px) */
int stroke_w; /* 默认细描边宽(0=无边框,MD3;MIUIx=1) */
} meow_theme;
const meow_theme *meow_theme_get(void);
void meow_theme_set_mode(meow_theme_mode m);
meow_theme_mode meow_theme_get_mode(void);
typedef void (*meow_theme_listener)(meow_theme_mode m);
void meow_theme_add_listener(meow_theme_listener cb);
void meow_theme_remove_listener(meow_theme_listener cb);
/* [D4] 脱机访问两套内置色板(无 settings 文件也可靠):返回当前解析生效的色板副本。 */
meow_theme meow_theme_defaults(meow_theme_mode m);
/* ---- §8.1.5 色板导出/注入(单一权威桥,M7.0a)----
* 用户在 M7 定案「SDK meow_theme 为唯一权威」:launcher 的 s_ui_theme() 将改为读 SDK 的薄壳,
* 不再自持 4 套静态色板。本接口是那个前置(launcher 侧改动不在此批)——
*
* meow_theme_export(out) 把当前「style×mode」解析生效的完整权威主题拷给调用方。
* 调用方是 stateless 的绘制原语时(如 launcher s_ui_theme),由此读
* 单一权威,再按它的角色字段(9 色)映射到自己的绘制便利结构,即:
* surface → surface
* surfaceVariant → surface_variant
* surfaceContainer → surface_container
* primary → primary
* onSurface → on_surface
* onSurfaceVariant → on_surface_variant
* outline → outline
* error → error
* surfaceTint → surface_tint
* meow_theme_inject(src) 用一份自定义板覆写当前生效主题(如 launcher 自定义背景/强调/风格),
* src==NULL 恢复内建(随 settings 解析)。覆写不随 meow_theme_reload() 丢弃
* (程序化覆写优先于 settings,与 meow_ui_set_style 语义一致)。 */
void meow_theme_export(meow_theme *out);
void meow_theme_inject(const meow_theme *src);
/* ---- §8.1 顶级主题风格族(minimal,2026-08-30)----
* 主题 = 顶级主题风格族(ui.style:MD3/MIUIx)× 明暗(display.theme)。本批只落「状态栏图标集
* 随 ui.style 换集」的最小闭环:meow_ui_set_style 记录 style(同值忽略)+ 触发 theme_reload/
* 广播(让状态栏/控件下一帧用新 style 重绘)。style 还决定状态栏右侧图标集(§3.1 同一个状态栏)。
* 完整 style×mode 配色/控件形态矩阵(§8.1.3)为后续里程碑。 */
#define MEOW_STYLE_MD3 0 /* Material You(默认) */
#define MEOW_STYLE_MIUIX 1 /* MIUI 风格族(基础占位) */
void meow_ui_set_style(int style); /* 设顶级主题风格族;越界 clamp 到合法值;同值忽略 */
int meow_ui_style(void); /* 当前 style(默认 MEOW_STYLE_MD3) */
#ifdef __cplusplus
}
#endif
#endif /* MEOW_UI_THEME_H */