M7 launcher 整体 MD3 重写的 SDK 基座补全(只动 patch_v2/sdk/): - 缺口#7 meow_view 事件接线:meow_view_dispatch_event 接入 meow_ui_run 主循环 (§6.4 分流之上,TAP/KEY/SWIPE/LONG_PRESS 先经 view 路由、命中即消费、未命中回落 on_* —— 无 view 树/未命中完全向后兼容);meow_view_add_child 在父已进入时挂子视图 立即进入(递归 children 修正);meow_view_sub_push/pop 标注废弃(设计定案 b 不做页内 子导航栈)。 - 缺口#2 IconButton:meow_iconbtn_create —— sb_icons 位图 + 圆形命中 + 按压/按住态 (实时,同 meow_btn)+ owner/enabled 闸门;电源菜单/播放控制/锁屏通用件。 - 缺口#6 SDK 半主题收口:meow_theme_export/meow_theme_inject(§8.1.5 色板导出/注入), launcher s_ui_theme() 将据此变读 SDK 的薄壳(launcher 侧改动不在此批)。 - 文档:MEOW_APP_SDK.md 补 meow_iconbtn_create + meow_theme_export/inject 说明。 - 验证:新增 test_meow_ui_iconbtn / test_meow_ui_theme_export / test_meow_ui_view_event 全 PASS;全量 SDK 宿主回归(widgets/dispatch/box/anim/scroll/listvirt/str/ime/pinyin/ overlay/notif/input_keys/p1p2p3/umbrella/ft)全 PASS;交叉 -Wall -Wextra 0 warning。 meow_ui.a md5: be24214e24faadba63577f3a98c2c9d1 -> 7fc83f7731cadb2f91df1c3ed7d3814f
102 lines
5.7 KiB
C
102 lines
5.7 KiB
C
/*
|
||
* 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 */
|