style(bt): 后台管理页行改MD3圆角卡+8px外距(bgm_row_card_y/h,卡高48行距56上下对称,删除分隔线,按压限卡内,按钮相对卡定位恒等)+test_bg_row_card PASS,0warning

This commit is contained in:
AskaEth committed 2026-09-04 11:27:07 +08:00
1 parent 7a276f609e
commit 2db87b2c5c
2 files changed
+129 -9

No files matched your search

+23 -9
View File
@@ -6,6 +6,8 @@
* 列表(live=1 约 2s 重扫,实时增删):
* - 每后台 App 一行 SUB_ROW:label=名字,sub=「CPU x% · yMB · 状态」,**行最右一个「杀」按钮**
* (sub_page_t.row_draw 行自绘 + row_tap 自定义命中:命中按钮区=kill 该 App;行体不响应)。
* - 行=MD3 圆角卡(meow_gfx_fill_round r=12 surfaceContainer;卡在行高内上下对称内缩
* BGM_CARD_GAP/2,行中心=卡中心,相邻卡 8px 外距——与主界面列表/ ncm 歌单同手法)。
* - 空态「无后台 App」。
* 数据源=amsd FG/BG 注册表(后台常驻集=launcher meow_bg 表,EV BG/FG 上报进 amsd)+ 每进程
* pcpu/rss(meow_svc_perf 同源 /proc 聚合,本页在 launcher 内同口径取)。
@@ -24,6 +26,13 @@
#define BGM_BTN_W 46
#define BGM_BTN_H 34
/* 圆角卡列表项外边距(item margin/gap):相邻卡片间可见空隙 px。SDK listview 行距(=SUB_ITEM_H)
* 不变——卡片在其行高内上下对称内缩 BGM_CARD_GAP/2,故行内内容(按行高垂直居中)仍落卡中心;
* 相邻卡顶间距恒=SUB_ITEM_H=卡高+BGM_CARD_GAP。要求偶数,保证上下对称。 */
#define BGM_CARD_GAP 8
static inline int bgm_row_card_y(int row_top) { return row_top + BGM_CARD_GAP / 2; }
static inline int bgm_row_card_h(int h) { return h - BGM_CARD_GAP; }
typedef struct {
struct app *apps;
int napps;
@@ -177,13 +186,15 @@ static int bgm_rows(void *ctx, sub_row_t *rbuf, int max)
/* kill 通道(bgmgr_kill_all 的函数指针签名:void(*)(const char*)) */
static void bgm_kill_fn(const char *app_id) { meow_bg_terminate(app_id); }
/* ---- 行内杀按钮矩形(绘制与命中共用;行视口矩形 rx,ry,rw,rh → 右侧 46×34 圆角钮)---- */
/* ---- 行内杀按钮矩形(绘制与命中共用;行视口矩形 rx,ry,rw,rh → 右侧 46×34 圆角钮)----
* 卡在行高内上下对称内缩 BGM_CARD_GAP/2(行中心=卡中心);按钮垂直居中于卡内,故其中心
* =卡中心=行中心。命中矩形仍为整行距(row_tap 传整行视口),按钮几何不变 → 卡内缩后命中不破。 */
static void bgm_btn_rect(int rx, int ry, int rw, int rh, int *bx, int *by, int *bw, int *bh)
{
*bw = BGM_BTN_W;
*bh = BGM_BTN_H;
*bx = rx + rw - 12 - BGM_BTN_W;
*by = ry + (rh - BGM_BTN_H) / 2;
*by = bgm_row_card_y(ry) + (bgm_row_card_h(rh) - BGM_BTN_H) / 2;
}
/* ---- 行完全自绘(sub_page_t.row_draw;覆盖默认 renderer)----
@@ -195,18 +206,24 @@ static void bgm_row_draw(void *ctx, int idx, sub_row_t *r,
bgm_ctx_t *b = ctx;
const meow_theme *mt = meow_theme_get();
int i = r->act;
/* MD3 圆角卡:行高内上下对称内缩 BGM_CARD_GAP/2(行中心=卡中心),替代扁平行+底部分隔线。 */
int cy = bgm_row_card_y(y);
int ch = bgm_row_card_h(h);
meow_gfx_fill_round(x, cy, w, ch, 12, mt->surfaceContainer);
if (state & MEOW_LISTVIEW_ST_PRESSED)
meow_gfx_fill_round_alpha(x, cy, w, ch, 12, mt->primary, 26); /* 按压态(实时,限卡内) */
if (i < 0 || i >= b->n) { /* 空态行 */
int th = meow_ui_text_height(18);
meow_ui_text_center(x + w / 2, y + (h - th) / 2,
meow_ui_text_center(x + w / 2, cy + (ch - th) / 2,
r->label ? r->label : meow_str_zh("bgmgr.empty", "无后台 App"),
18, mt->onSurfaceVariant);
return;
}
if (state & MEOW_LISTVIEW_ST_PRESSED)
meow_ui_fill_rect_alpha(x, y, w, h, mt->primary, 26); /* 按压态(实时) */
int th = meow_ui_text_height(20), tsub = meow_ui_text_height(16);
int rx = x + 16; /* 左内边距 */
int ry = y + (h - (th + tsub + 4)) / 2;
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=红=杀) */
@@ -215,9 +232,6 @@ static void bgm_row_draw(void *ctx, int idx, sub_row_t *r,
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);
/* 底部分隔线 */
if (y + h - 1 <= fb_yres)
meow_ui_fill_rect(x, y + h - 1, w, 1, mt->outlineVariant);
}
/* ---- 行内自定义命中(sub_page_t.row_tap;仅按钮区 kill,行体不响应/不误杀)---- */