feat(bt): 批③后台管理页UI按钮化 — 每行右'杀'按钮(bgm_btn_rect精确命中,行区不误杀)+顶栏'一键清除后台'按钮(sub_page_t增row_draw/row_tap/top_action/top_action_cb全NULL守卫,wifi/bt/lock行为不变);test_bgpage 32项ALL PASS,0warning
This commit is contained in:
1 parent
c69fb92284
commit
5c174224f7
4 files changed
+324
-43
No files matched your search
@@ -589,6 +589,42 @@ static void sp_lv_bind(int idx, meow_lv_item *out, void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- 行完全自绘(批③:页面经 sub_page_t.row_draw 定制整行;默认 renderer 被覆盖)---- */
|
||||
static void sp_lv_draw(int idx, int x, int y, int w, int h, int state, void *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
if (!g_sp || !g_sp->row_draw) return;
|
||||
if (idx < 0 || idx >= g_nrows) return;
|
||||
g_sp->row_draw(g_sp->ctx, idx, &g_rows[idx], x, y, w, h, state);
|
||||
}
|
||||
|
||||
/* ---- 顶栏标题栏右侧动作按钮矩形(批③:sub_page_t.top_action)---- */
|
||||
static void sp_top_action_rect(int *x, int *y, int *w, int *h)
|
||||
{
|
||||
if (x) *x = 0; if (y) *y = 0; if (w) *w = 0; if (h) *h = 0;
|
||||
if (!g_sp || !g_sp->top_action) return;
|
||||
int tw = ui_width(g_sp->top_action, 20);
|
||||
if (tw <= 0) return;
|
||||
int bw = tw + 24, bh = 40; /* 含内边距的圆角按钮 */
|
||||
*x = fb_xres - 12 - bw;
|
||||
*y = SUB_TB_Y + (SUB_TB_H - bh) / 2;
|
||||
*w = bw; *h = bh;
|
||||
}
|
||||
|
||||
/* 绘制顶栏动作按钮(sp_paint_page 内调用)。 */
|
||||
static void sp_paint_top_action(void)
|
||||
{
|
||||
if (!g_sp || !g_sp->top_action) return;
|
||||
int x, y, w, h; sp_top_action_rect(&x, &y, &w, &h);
|
||||
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); /* 圆角描边按钮 */
|
||||
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);
|
||||
}
|
||||
|
||||
/* ---- meow_scroll 回调(包 listview)---- */
|
||||
static void sp_sc_set(void *ctx, int off) { (void)ctx; if (g_lv) meow_listview_set_scroll(g_lv, off); }
|
||||
static int sp_sc_max(void *ctx) { (void)ctx; return g_lv ? meow_listview_max_scroll(g_lv) : 0; }
|
||||
@@ -648,6 +684,8 @@ static void sp_configure_page(const sub_page_t *p, int top_sw_en, int top_on)
|
||||
meow_switch_set(g_sw, top_on);
|
||||
}
|
||||
}
|
||||
/* 批③:行完全自绘 on/off —— 页提供 row_draw 用自绘;否则清 NULL 回默认 renderer。 */
|
||||
if (g_lv) meow_listview_set_item_draw(g_lv, p->row_draw ? sp_lv_draw : NULL, NULL);
|
||||
}
|
||||
|
||||
/* 整页绘制(进 back_buf;调用方 meow_dirty_full + flush 上屏)。 */
|
||||
@@ -659,6 +697,7 @@ static void sp_paint_page(void)
|
||||
draw_statusbar();
|
||||
if (g_tb) meow_widget_draw(g_tb); /* topappbar(含底部分隔线) */
|
||||
if (g_sw && g_top_sw_en) meow_widget_draw(g_sw); /* 顶开关(叠顶栏右缘) */
|
||||
sp_paint_top_action(); /* 批③:顶栏右侧动作按钮 */
|
||||
int lvx, lvy, lvw, lvh;
|
||||
sp_lv_rect(&lvx, &lvy, &lvw, &lvh);
|
||||
meow_ui_fill_rect(lvx, lvy, lvw, lvh, mt->surface); /* 内容底 surface */
|
||||
@@ -929,6 +968,18 @@ int meow_subpage_run(sub_page_t *p)
|
||||
if (tfd >= 0) { unsigned char e[16]; while (read(tfd, e, sizeof e) == 16) {} }
|
||||
goto subdone;
|
||||
}
|
||||
/* 批③:顶栏标题栏右侧动作按钮(一键清除;先于顶开关判定,二者页间互斥) */
|
||||
if (g_sp && g_sp->top_action) {
|
||||
int ax, ay, aw, ah; sp_top_action_rect(&ax, &ay, &aw, &ah);
|
||||
if (aw > 0 && tx >= ax && tx < ax + aw && ty >= ay && ty < ay + ah) {
|
||||
if (g_sp->top_action_cb) g_sp->top_action_cb(g_sp->ctx);
|
||||
last_act = now;
|
||||
sp_refresh_rows(); /* 清后立即重扫行 */
|
||||
need_paint = 1;
|
||||
if (tfd >= 0) { unsigned char e[16]; while (read(tfd, e, sizeof e) == 16) {} }
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (g_top_sw_en && g_sw && meow_widget_hit(g_sw, tx, ty)) {
|
||||
sp_top_sw_toggle();
|
||||
last_act = now;
|
||||
@@ -940,7 +991,13 @@ int meow_subpage_run(sub_page_t *p)
|
||||
int row_hit = g_lv ? meow_listview_hit(g_lv, tx, ty) : -1;
|
||||
if (row_hit >= 0) {
|
||||
sub_kind_t kind = g_rows[row_hit].kind;
|
||||
if (kind == SUB_SW || kind == SUB_ACT) {
|
||||
if (kind == SUB_ROW && g_sp->row_tap) {
|
||||
/* 批③:行内自定义命中(行内杀按钮 vs 行体;页自判,返回 1=重绘) */
|
||||
int rry = SUB_CONT_TOP + row_hit * SUB_ITEM_H -
|
||||
(g_lv ? meow_listview_scroll(g_lv) : 0);
|
||||
g_sp->row_tap(g_sp->ctx, row_hit, &g_rows[row_hit],
|
||||
tx, ty, 0, rry, fb_xres, SUB_ITEM_H);
|
||||
} else if (kind == SUB_SW || kind == SUB_ACT) {
|
||||
if (g_sp->act) g_sp->act(g_sp->ctx, row_hit, g_rows[row_hit].act);
|
||||
} else if (kind == SUB_ROW) {
|
||||
if (g_sp->detail) g_sp->detail(g_sp->ctx, row_hit, g_rows[row_hit].act);
|
||||
|
||||
Reference in new issue
Block a user