style(md3): 全面MD3对齐P0-P3 — P0扁平行列表容器化(meow_listview_set_container容器模式:surfaceContainer圆角卡12dp+tonal状态层+去分隔线;sub_page/settings_page/bg_page圆角容器) P1按钮胶囊化+shape令牌(extrasmall/small/medium/large/full) P2状态层补齐 P3子控件(Switch off-track/NavBar pill64×32/Checkbox24/对话框28);宿主test_meow_md3等全过,0warning;meow_ui.a变M6.36需重编+四App重链
This commit is contained in:
1 parent
3fea237306
commit
b712088daa
6 files changed
+343
-75
No files matched your search
@@ -226,9 +226,9 @@ static void bgm_row_draw(void *ctx, int idx, sub_row_t *r,
|
||||
int ry = cy + (ch - (th + tsub + 4)) / 2; /* 内容在卡内垂直居中(行中心=卡中心) */
|
||||
if (r->label) meow_ui_text(rx, ry, r->label, 20, mt->onSurface);
|
||||
if (r->sub) meow_ui_text(rx, ry + th + 4, r->sub, 16, mt->onSurfaceVariant);
|
||||
/* 行内杀按钮(圆角框 + 「杀」;error=红=杀) */
|
||||
/* 行内杀按钮(全形=胶囊(bh/2);「杀」;error=红=杀)——P1 按钮胶囊化 */
|
||||
int bx, by, bw, bh; bgm_btn_rect(x, y, w, h, &bx, &by, &bw, &bh);
|
||||
meow_ui_draw_rect_round(bx, by, bw, bh, 10, mt->error);
|
||||
meow_ui_draw_rect_round(bx, by, bw, bh, bh / 2, mt->error);
|
||||
int bth = meow_ui_text_height(16);
|
||||
if (bth > bh) bth = bh;
|
||||
meow_ui_text_center(bx + bw / 2, by + (bh - bth) / 2, "杀", 16, mt->error);
|
||||
|
||||
@@ -780,8 +780,8 @@ static void dd_modal_paint(const meow_ui_theme_t *th, int W, int H, int d_x, int
|
||||
int content_top, int content_bot, int dd_scroll)
|
||||
{
|
||||
meow_ui_fill_rect_alpha(0, 0, W, H, 0x000000, 150);
|
||||
meow_gfx_fill_round(d_x, d_y, d_w, d_h, 16, th->surface_container);
|
||||
meow_ui_draw_rect_round(d_x, d_y, d_w, d_h, 16, th->outline);
|
||||
meow_gfx_fill_round(d_x, d_y, d_w, d_h, 28, th->surface_container); /* MD3 extraLarge 28(原 16 偏小) */
|
||||
meow_ui_draw_rect_round(d_x, d_y, d_w, d_h, 28, th->outline);
|
||||
if (mfont_ready) ui_draw(d_x + 18, d_y + 8, title, th->on_surface, 20);
|
||||
else draw_text(d_x + 18, d_y + 8, title, 2, th->on_surface);
|
||||
for (int i = 0; i < n; i++) {
|
||||
@@ -1094,6 +1094,11 @@ static int s_font_dropdown(const srow_t *r, char *out_val, int vlen)
|
||||
#define SET_TRACK_CY 48 /* 滑条 track 中心相对行顶 y(=SET_SLIDER_YOFF+3,与绘制对齐) */
|
||||
#define SET_SLIDER_LY 12 /* 滑条行 label 顶相对行顶 y(上移给 track 留位) */
|
||||
#define SET_SWITCH_POOL 12
|
||||
/* MD3 容器化(P0):设置页行=surface 上 surfaceContainer 圆角卡 + 行间空隙(去分隔线);
|
||||
* 卡横向外边距=SET_CARD_X(8),卡在行高内上下对称内缩(行中心=卡中心,同主界面/ncm 歌单手法)。 */
|
||||
#define SET_ROW_CARD_X SET_CARD_X /* 8:卡左缘 = 内容区左缘 */
|
||||
#define SET_ROW_CARD_G 8 /* 卡纵向间隙(px) */
|
||||
#define SET_ROW_CARD_R 12 /* 卡圆角(12dp) */
|
||||
|
||||
static meow_widget *g_set_lv = NULL; /* meow_listview(虚拟化) */
|
||||
static meow_scroll *g_set_sc = NULL; /* 滚动物理 */
|
||||
@@ -1155,24 +1160,30 @@ static void set_lv_draw(int idx, int x, int y, int w, int h, int state, void *ct
|
||||
uint32_t textcol = sel ? mt->onPrimaryContainer : mt->onSurface;
|
||||
uint32_t subcol = sel ? mt->onPrimaryContainer : mt->onSurfaceVariant;
|
||||
|
||||
/* MD3 容器化(P0):行=surface 上 surfaceContainer 圆角卡;段头=surface 上的 primary 段标签(无卡)。 */
|
||||
int cx = x + SET_ROW_CARD_X; /* 卡左缘 */
|
||||
int cw = w - 2 * SET_ROW_CARD_X; /* 卡宽 */
|
||||
int cy = y + SET_ROW_CARD_G / 2; /* 卡顶(行内对称内缩) */
|
||||
int ch = SET_ITEM_H - SET_ROW_CARD_G; /* 卡高 */
|
||||
|
||||
if (r->ctrl == SC_HEADER) {
|
||||
meow_ui_fill_rect(x, y, w, SET_ITEM_H, mt->surfaceContainerHigh);
|
||||
int ty = y + (SET_ITEM_H - thh) / 2;
|
||||
if (ty >= 0) meow_ui_text(x + 16, ty, s_row_label(r), mt->font_body, mt->primary);
|
||||
meow_ui_fill_rect(x, y + SET_ITEM_H - 1, w, 1, mt->outlineVariant);
|
||||
if (ty >= 0) meow_ui_text(cx + 16, ty, s_row_label(r), mt->font_body, mt->primary);
|
||||
return;
|
||||
}
|
||||
if (sel) meow_ui_fill_rect(x, y, w, SET_ITEM_H, mt->primaryContainer);
|
||||
else if (press) meow_ui_fill_rect_alpha(x, y, w, SET_ITEM_H, mt->primary, 26);
|
||||
meow_gfx_fill_round(cx, cy, cw, ch, SET_ROW_CARD_R, mt->surfaceContainer);
|
||||
if (sel) meow_gfx_fill_round(cx, cy, cw, ch, SET_ROW_CARD_R, mt->primaryContainer);
|
||||
else if (press) meow_gfx_fill_round_alpha(cx, cy, cw, ch, SET_ROW_CARD_R, mt->primary, 26);
|
||||
|
||||
int ly = y + (SET_ITEM_H - thh) / 2; /* label 单行垂直居中 */
|
||||
int rgt = cx + cw - 16; /* 卡内右缘(内容右对齐锚点) */
|
||||
switch (r->ctrl) {
|
||||
case SC_SWITCH: {
|
||||
meow_ui_text(x + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
meow_ui_text(cx + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
meow_widget *sw = set_sw_take();
|
||||
if (sw) {
|
||||
int on = 0; meow_settings_get_switch(r->key, &on);
|
||||
meow_widget_set_rect(sw, x + w - 16 - 56, y + (SET_ITEM_H - 32) / 2, 56, 32);
|
||||
meow_widget_set_rect(sw, rgt - 56, y + (SET_ITEM_H - 32) / 2, 56, 32);
|
||||
meow_switch_set(sw, on);
|
||||
meow_widget_draw(sw);
|
||||
}
|
||||
@@ -1180,9 +1191,9 @@ static void set_lv_draw(int idx, int x, int y, int w, int h, int state, void *ct
|
||||
}
|
||||
case SC_SLIDER: {
|
||||
/* label 上移一行,track 放行下方(中心=SET_SLIDER_YOFF+3=48),与拖动命中带对齐 */
|
||||
meow_ui_text(x + 16, y + SET_SLIDER_LY, s_row_label(r), mt->font_body, textcol);
|
||||
meow_ui_text(cx + 16, y + SET_SLIDER_LY, s_row_label(r), mt->font_body, textcol);
|
||||
char vb[32]; s_fmt_value(r, vb, sizeof vb);
|
||||
meow_ui_text(x + w - 16 - meow_ui_text_width(vb, mt->font_body), y + SET_SLIDER_LY, vb, mt->font_body, subcol);
|
||||
meow_ui_text(rgt - meow_ui_text_width(vb, mt->font_body), y + SET_SLIDER_LY, vb, mt->font_body, subcol);
|
||||
int v = 0; meow_settings_get_int(r->key, &v);
|
||||
/* 息屏时间为档位索引型(秒→索引 等距画);其余 clamp 到 [min,max] */
|
||||
if (!strcmp(r->key, "display.screen_off_timeout")) v = s_time_tier_idx(v);
|
||||
@@ -1191,30 +1202,29 @@ static void set_lv_draw(int idx, int x, int y, int w, int h, int state, void *ct
|
||||
break;
|
||||
}
|
||||
case SC_INFO: {
|
||||
meow_ui_text(x + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
meow_ui_text(cx + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
char vb[48]; s_net_get(r, vb, sizeof vb);
|
||||
meow_ui_text(x + w - 16 - meow_ui_text_width(vb, mt->font_body), ly, vb, mt->font_body, subcol);
|
||||
meow_ui_text(rgt - meow_ui_text_width(vb, mt->font_body), ly, vb, mt->font_body, subcol);
|
||||
break;
|
||||
}
|
||||
case SC_LIST: {
|
||||
meow_ui_text(x + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
meow_ui_text(cx + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
char vb[48]; s_net_get(r, vb, sizeof vb);
|
||||
int vx = x + w - 16 - 12 - meow_ui_text_width(vb, mt->font_body);
|
||||
int vx = rgt - 12 - meow_ui_text_width(vb, mt->font_body);
|
||||
meow_ui_text(vx, ly, vb, mt->font_body, subcol);
|
||||
s_draw_chevron(x + w - 16, y + SET_ITEM_H / 2, subcol);
|
||||
s_draw_chevron(rgt, y + SET_ITEM_H / 2, subcol);
|
||||
break;
|
||||
}
|
||||
default: { /* SC_ENUM / SC_PRESET */
|
||||
meow_ui_text(x + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
meow_ui_text(cx + 16, ly, s_row_label(r), mt->font_body, textcol);
|
||||
char vb[40]; s_display_value(r, vb, sizeof vb);
|
||||
int vx = x + w - 16 - meow_ui_text_width(vb, mt->font_body);
|
||||
int vx = rgt - meow_ui_text_width(vb, mt->font_body);
|
||||
meow_ui_text(vx, ly, vb, mt->font_body, subcol);
|
||||
s_draw_chevron(vx - 8, y + SET_ITEM_H / 2, subcol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
meow_ui_fill_rect(x, y + SET_ITEM_H - 1, w, 1, mt->outlineVariant);
|
||||
if (dis) meow_ui_fill_rect_alpha(x, y, w, SET_ITEM_H, mt->onSurface, 90);
|
||||
if (dis) meow_gfx_fill_round_alpha(cx, cy, cw, ch, SET_ROW_CARD_R, mt->onSurface, 90);
|
||||
}
|
||||
|
||||
/* ---- meow_scroll 回调(包 listview)---- */
|
||||
@@ -1229,7 +1239,7 @@ static void set_redraw_region(void *ctx)
|
||||
int lvx, lvy, lvw, lvh; set_lv_rect(&lvx, &lvy, &lvw, &lvh);
|
||||
if (lvh <= 0) return;
|
||||
const meow_ui_theme_t *th = s_ui_theme();
|
||||
meow_ui_fill_rect(lvx, lvy, lvw, lvh, th->surface_variant);
|
||||
meow_ui_fill_rect(lvx, lvy, lvw, lvh, th->surface); /* P0:内容底改 surface(卡在其上抬升) */
|
||||
if (g_set_lv) { g_set_sw_use = 0; meow_widget_draw(g_set_lv); }
|
||||
meow_dirty_add(lvx, lvy, lvw, lvh);
|
||||
meow_ui_flush();
|
||||
@@ -1274,7 +1284,7 @@ static void set_paint_page(int sel)
|
||||
if (mfont_ready) ui_draw(24, 50, meow_str_zh("menu.settings", "系统设置"), th->on_surface, 28);
|
||||
else draw_text(24, 30, "SETTINGS", 3, th->on_surface);
|
||||
fill_rect(0, 50 + (mfont_ready ? meow_font_line_height(28) : 24) + 2, W, 2, th->outline);
|
||||
fill_rect(0, SET_CARD_Y, W, H - SET_CARD_Y, th->surface_variant);
|
||||
fill_rect(0, SET_CARD_Y, W, H - SET_CARD_Y, th->surface); /* P0:内容底 surface,行用圆角卡抬升 */
|
||||
if (g_set_lv) {
|
||||
g_set_sw_use = 0;
|
||||
int p = s_vis_of(sel); if (p >= 0) meow_listview_set_sel(g_set_lv, p);
|
||||
|
||||
@@ -619,7 +619,7 @@ static void sp_paint_top_action(void)
|
||||
if (w <= 0 || h <= 0) return;
|
||||
const meow_theme *mt = meow_theme_get();
|
||||
uint32_t col = mt->primary;
|
||||
meow_ui_draw_rect_round(x, y, w, h, 10, col); /* 圆角描边按钮 */
|
||||
meow_ui_draw_rect_round(x, y, w, h, h / 2, col); /* 全形=胶囊描边按钮(P1) */
|
||||
int th = meow_ui_text_height(20);
|
||||
if (th > h) th = h;
|
||||
meow_ui_text_center(x + w / 2, y + (h - th) / 2, g_sp->top_action, 20, col);
|
||||
@@ -658,6 +658,9 @@ static void sp_widgets_create(void)
|
||||
/* 双行富 item + 无左图标 + 右尾件(SWITCH/ARROW);行高 56 */
|
||||
meow_listview_set_item_renderer(g_lv, 2, 0, 1);
|
||||
meow_listview_set_item_h(g_lv, SUB_ITEM_H);
|
||||
/* MD3(P0):默认 renderer 容器模式——行=surfaceContainer 圆角卡+行间空隙,
|
||||
* 选中/按压 tonal(primaryContainer/primary α26)、去冗余分隔线;段头=surface 上的 primary 段标签。 */
|
||||
meow_listview_set_container(g_lv, 1);
|
||||
}
|
||||
/* 注:刻意不 set_snap —— SDK meow_scroll 的 snap 以「fling 起点」为吸附目标,快速滑动时会
|
||||
* 从自然停点往回拉一整行(实测 697→336),UX 不佳;默认 ease-out 惯性停(无 snap)更顺滑。
|
||||
|
||||
Reference in new issue
Block a user