M2.90: MIUIx 风格包落地 + ui.style 一键切换闭环

- meow_ui_theme.c: 为 MEOW_STYLE_MIUIX 实现整套 light/dark 配色(暖基面+小米橙 primary
  0xF57200/0xFF8C4A+蓝 tertiary;圆角 20/卡片 28、间距 12、细描边 1),与 MD3 可感知差异
- display.background 随 style×mode 派生 MIUIx 色板(bg_surfaces 增 style 参;图片背景保持各 style 默认面)
- meow_settings.c g_defs: ui.style 值域 'md3,miui'→'md3,miuix'(label Material You,MIUIx);
  apply_value SET_ENUM 对存量 'miui' 兼容映射为 miuix
- settings_page s_commit: ui.style 分支 → meow_ui_set_style + paint_sb_right + meow_dirty_full 即时换肤
- font_theme s_ui_theme() 接 ui.style + MIUIx dark/light 表;main_menu 背景签名含 ui.style + 纯色底随 style 换族
- 宿主编译 -Wall -Wextra 0 warning;test_meow_ui_theme 四套 s×m 渲染全 PASS;
  test_meow_ui_widgets/test_sdk_fixes 全 PASS(MD3 行为一致)
- 产物 md5: meow_ui.a a4231296 / launcher 9f97af1b(未部署走固件)/ hello e5527578 /
  files 993e41ca / ncm 6b9eeb0f(三 App 已 .new+mv 热更到卡, 设备 md5 已核一致)
- 待后续: 状态栏图标集仍 MD3 一套(sb_icons.h 无 per-style 换集接口, MIUIx 仅换配色);
  App 进程 SDK 主题缓存 g_loaded 不随 settings 外部改写重读, 运行中 App 下次启动才换肤
This commit is contained in:
MeowOS committed 2026-08-31 20:17:51 +08:00
1 parent f23720f934
commit 4e3f41a5a3
13 files changed
+250 -42

No files matched your search

+23 -6
View File
@@ -746,6 +746,18 @@ static const meow_ui_theme_t meow_ui_theme_light = {
0x4A4F5A, 0x9AA4C8, 0xB3261E, 0x2A5A8A
};
/* MIUIx 族(§8.1.3 定案):暖色基面 + 小米橙 primary,供 launcher 主界面/设置页/通知中心/
* 电源菜单(s_ui_theme())在 ui.style=miuix 时使用(与 SDK meow_theme MIUIx 同色系)。 */
static const meow_ui_theme_t meow_ui_theme_miui_dark = {
0x181310, 0x2A231C, 0x2E2620, 0xFF8C4A, 0xEDE5DC,
0xAB9884, 0x4A3F35, 0xFFB4AB, 0xFF8C4A
};
static const meow_ui_theme_t meow_ui_theme_miui_light = {
0xF7F3EE, 0xE9DFD0, 0xF4EDE3, 0xF57200, 0x251A10,
0x7D6A5A, 0xCBBFB2, 0xB3261E, 0xF57200
};
/* 获取当前本地时刻的「当天第几分钟」(tm_hour*60+tm_min);供时段判定用 */
static int s_now_min_of_day(void)
{
@@ -768,13 +780,18 @@ static int theme_should_dark(int now_min, int start, int end)
return (now_min >= start || now_min < end) ? 1 : 0; /* 跨午夜 */
}
/* 当前主题(dark/light 两套;接 display.theme_mode + display.theme)。
/* 当前主题(style×明暗 两套;接 ui.style + display.theme_mode + display.theme)。
* style(§8.1.1):ui.style 的 md3/miuix → 返回对应体系(MD3 tonal / MIUIx 暖色+橙)。
* manual(mode==THEME_MODE_MANUAL):直读 display.theme(dark/light),保持原有行为。
* auto(mode==THEME_MODE_AUTO):读深色时段两键 + 当前本地分钟;start==end 未配置 →
* 回退 manual(读 display.theme,避免误判全天深色)。
* 读取失败一律回退 dark。 */
const meow_ui_theme_t *s_ui_theme(void)
{
int style = 0; /* ui.style:0=md3 / 1=miuix */
if (meow_settings_get_enum("ui.style", &style) != 0) style = 0;
const meow_ui_theme_t *light = (style == 1) ? &meow_ui_theme_miui_light : &meow_ui_theme_light;
const meow_ui_theme_t *dark = (style == 1) ? &meow_ui_theme_miui_dark : &meow_ui_theme_dark;
int mode = THEME_MODE_MANUAL;
if (meow_settings_get_enum("display.theme_mode", &mode) != 0) mode = THEME_MODE_MANUAL;
int v = 0; /* display.theme(manual)当前索引 */
@@ -785,13 +802,13 @@ const meow_ui_theme_t *s_ui_theme(void)
meow_settings_get_int("display.theme_dark_end", &end);
int d = theme_should_dark(s_now_min_of_day(), start, end);
if (d < 0) { /* 未配置:回退 manual(display.theme) */
if (have_manual && v == 1) return &meow_ui_theme_light;
return &meow_ui_theme_dark;
if (have_manual && v == 1) return light;
return dark;
}
return d ? &meow_ui_theme_dark : &meow_ui_theme_light;
return d ? dark : light;
}
/* manual:照旧读 display.theme */
if (have_manual && v == 1) return &meow_ui_theme_light;
return &meow_ui_theme_dark;
if (have_manual && v == 1) return light;
return dark;
}
+15 -5
View File
@@ -214,15 +214,18 @@ static int menu_is_dark(const meow_ui_theme_t *th)
return th ? (th->on_surface > 0x808080) : 1;
}
/* 背景设置签名:display.background 串 + 叠加层强度 + 明暗。变化才重建缓存。 */
/* 背景设置签名:display.background 串 + 叠加层强度 + 明暗 + ui.style(§8.1.1:背景底随
* style×mode 换族)。变化才重建缓存——ui.style 切换必须入签名,否则切风格后主界面背景滞留旧族。 */
static unsigned menu_bg_sig(const meow_ui_theme_t *th, int ov)
{
char bg[MEOW_SET_MAX_LEN];
if (meow_settings_get_str("display.background", bg, sizeof bg) != 0) bg[0] = 0;
int style = 0; if (meow_settings_get_enum("ui.style", &style) != 0) style = 0;
unsigned h = 2166136261u;
for (const char *p = bg; *p; p++) { h ^= (unsigned char)*p; h *= 16777619u; }
h = h * 31u + (unsigned)ov;
h = h * 31u + (unsigned)menu_is_dark(th);
h = h * 31u + (unsigned)style;
return h;
}
@@ -291,10 +294,17 @@ static void menu_bg_prepare(const meow_ui_theme_t *th)
menu_bg = th->surface;
s_bg_img = menu_bg_load_img(bg);
if (s_bg_img) s_bg_is_img = 1;
} else { /* 纯色名(沿用既有 black/blue/green 语义) */
if (!strcmp(bg, "blue")) menu_bg = 0x0A1428; /* 深蓝 */
else if (!strcmp(bg, "green")) menu_bg = 0x0A2814; /* 深绿 */
else menu_bg = 0x000000; /* black(默认) */
} else { /* 纯色名(沿用既有 black/blue/green 语义;随 ui.style 换族) */
int mstyle = 0; if (meow_settings_get_enum("ui.style", &mstyle) != 0) mstyle = 0;
if (mstyle == MEOW_STYLE_MIUIX) { /* MIUIx 暖色族(与 SDK bg_surfaces 同色) */
if (!strcmp(bg, "blue")) menu_bg = 0x101A2E;
else if (!strcmp(bg, "green")) menu_bg = 0x14251A;
else menu_bg = 0x181310; /* black(默认)=MIUIx 深色面 */
} else { /* MD3(既有) */
if (!strcmp(bg, "blue")) menu_bg = 0x0A1428; /* 深蓝 */
else if (!strcmp(bg, "green")) menu_bg = 0x0A2814; /* 深绿 */
else menu_bg = 0x000000; /* black(默认) */
}
}
menu_bg_cache_build(th);
}
Binary file not shown.
+8 -2
View File
@@ -118,7 +118,7 @@ static const meow_setting_def g_defs[] = {
{ "font.load_full", SET_INT, "0", 0, 1, NULL, NULL },
{ "font.size.title", SET_INT, "28", 0, 0, NULL, NULL },
{ "font.size.body", SET_INT, "20", 0, 0, NULL, NULL },
{ "ui.style", SET_ENUM, "md3", 0, 0, "md3,miui", "Material You,MIUI" },
{ "ui.style", SET_ENUM, "md3", 0, 0, "md3,miuix", "Material You,MIUIx" },
/* 通知 */
{ "notify.center_enabled", SET_BOOL, "1", 0, 0, NULL, NULL },
{ "notify.app_quota", SET_INT, "16", 0, 0, NULL, NULL },
@@ -280,7 +280,13 @@ static void apply_value(meow_setting *s, const char *v)
}
case SET_ENUM: {
int idx = enum_index_of_name_str(s->enum_names, v);
if (idx < 0) idx = atoi(v); /* 向后兼容:数值索引 */
if (idx < 0) {
/* §8.1.1 注:旧版 ui.style 值域为 "md3,miui",本版对齐为 "md3,miuix"——存量
* settings.conf / 备份里的 "miui" 应兼容映射为 "miuix"(而非 atoi 落到 md3=0)。 */
if (!strcmp(s->key, "ui.style") && strcasecmp(v, "miui") == 0)
idx = enum_index_of_name_str(s->enum_names, "miuix");
if (idx < 0) idx = atoi(v); /* 向后兼容:数值索引 */
}
if (idx >= 0 && idx < enum_count_str(s->enum_names)) {
const char *name = enum_at_str(s->enum_names, idx);
if (name) strncpy(s->cur, name, sizeof s->cur - 1);
+23 -4
View File
@@ -396,16 +396,35 @@ static void s_commit(const srow_t *r, int save_now)
* 此前 SC_PRESET 只写 meow_settings,未应用 menu_bg → 黑/绿点了没用。 */
else if (!strcmp(r->key, "display.background")) {
char bg[16]; meow_settings_get_str(r->key, bg, sizeof bg);
if (!strcmp(bg, "blue")) menu_bg = 0x0A1428; /* 深蓝 */
else if (!strcmp(bg, "green")) menu_bg = 0x0A2814; /* 深绿 */
else menu_bg = 0x000000; /* black(默认) */
/* 状态栏(menu_bg)与主界面背景都会用到 menu_bg;退出设置页回主界面时重绘即可。 */
int mstyle = 0; if (meow_settings_get_enum("ui.style", &mstyle) != 0) mstyle = 0;
if (mstyle == MEOW_STYLE_MIUIX) { /* MIUIx 暖色族(与 main_menu menu_bg_prepare 同色) */
if (!strcmp(bg, "blue")) menu_bg = 0x101A2E;
else if (!strcmp(bg, "green")) menu_bg = 0x14251A;
else menu_bg = 0x181310;
} else { /* MD3(既有) */
if (!strcmp(bg, "blue")) menu_bg = 0x0A1428; /* 深蓝 */
else if (!strcmp(bg, "green")) menu_bg = 0x0A2814; /* 深绿 */
else menu_bg = 0x000000; /* black(默认) */
}
/* menu_bg 仅主界面背景用(状态栏走 SDK meow_theme bg);退出设置页回主界面时经
* menu_bg_sig(含 ui.style)重build 缓存。 */
}
/* M2.44 主题/mode 变更:状态栏文字/底色已接 s_ui_theme(),此处仅确保回主界面重绘。 */
else if (!strcmp(r->key, "display.theme") || !strcmp(r->key, "display.theme_mode") ||
!strcmp(r->key, "display.theme_dark_start") || !strcmp(r->key, "display.theme_dark_end")) {
paint_sb_right(); /* 状态栏文字/底色随主题刷新(整条标脏) */
}
/* §8.1.2 一键切换闭环:ui.style(md3/miuix)顶级风格族切换 → 全系统即时换肤,无需重启。
* meow_ui_set_style() 设 SDK g_style(launcher 同一进程内立即生效)+ 广播(App/状态栏下一帧换肤);
* paint_sb_right() → sb_sdk_refresh() 逼 SDK 状态栏重读 settings(含 display.background 派生)跟手换肤;
* meow_dirty_full() 让 launcher 主界面/设置页整帧重绘(s_ui_theme() 已接 ui.style → 换族配色)。
* 主界面背景缓存经 menu_bg_sig(含 ui.style,见 main_menu.c)在回主界面时自动重建。 */
else if (!strcmp(r->key, "ui.style")) {
int st = 0; meow_settings_get_enum("ui.style", &st);
meow_ui_set_style(st);
paint_sb_right();
meow_dirty_full();
}
/* M2.5x:字体文件(font.file)变更 → 立即 unload + reload(若已加载)。
* 置 mfont_forced 跳过 meow_font_ensure 的 SDK 复用捷径,强制走
* font.file → 卡默认 → 固件 链;全失败则回退 5x7 点阵(系统不死)。 */