fix(sdk/hello): M2.71控件真机bug批次 — 圆形进度脏区+整环修复/Slider拖动/Dialog·Sheet背景快照scrim不叠黑/Disabled圆角α/点击重置息屏/滑动跟手/IME残影·键位·主题配色/List选中点击 (agent-162)
This commit is contained in:
1 parent
b12404a986
commit
b8c36bd33c
14 files changed
+554
-79
No files matched your search
@@ -26,6 +26,11 @@ enum { W_BTN = 0, W_SLIDER = 1, W_SWITCH = 2, W_LIST = 3,
|
||||
* 视觉区分「短按按下」与「按住」;触发语义不变(on_tap 仍按抬手判定)。 */
|
||||
#define MEOW_BTN_HOLD_MS 500u
|
||||
|
||||
/* 圆形 ProgressBar 环带厚 / 外扩边距(bgg 修复 M2.71-bug1:控件几何必须覆盖真实像素)。
|
||||
* 实际像素范围 = 中心 ± (r + thk/2);margin = thk/2 + 1 保证外接框覆盖环带外缘与圆帽。 */
|
||||
#define MEOW_PROGRESS_ARC_THK 4
|
||||
#define MEOW_PROGRESS_ARC_MARGIN (MEOW_PROGRESS_ARC_THK / 2 + 1)
|
||||
|
||||
/* MD3 状态层混色:c 为基色、o 为状态色、t 为 o 的占比(0-100)。
|
||||
* 用于把主题 accent 向黑/白调出「按下/按住」状态层(日/夜主题各配色)。 */
|
||||
static uint32_t blend_color(uint32_t c, uint32_t o, int t)
|
||||
@@ -73,6 +78,9 @@ struct meow_widget {
|
||||
char items[MEOW_CONTAINER_MAX][24]; /* W_TOPAPPBAR 动作 / W_NAVBAR 项 / W_TABBAR 页签 */
|
||||
int nitems; /* 上述项数 */
|
||||
int selected; /* W_NAVBAR / W_TABBAR 选中下标 */
|
||||
/* M2.71-bug8:W_LIST 行点击回调(可选)。 */
|
||||
meow_list_tap_fn tap_cb; /* 命中行回调(可 NULL) */
|
||||
void *tap_ctx; /* 回调 ctx */
|
||||
};
|
||||
|
||||
/* ---- §5.8 batch1 内部辅助:opts 取值(opts_used==0 时按控件内建默认)----
|
||||
@@ -584,7 +592,13 @@ meow_widget *meow_progress_circular_create(int cx, int cy, int r, int value)
|
||||
{
|
||||
meow_widget *t = (meow_widget *)calloc(1, sizeof *t);
|
||||
if (!t) return NULL;
|
||||
t->type = W_PROGRESS; t->x = cx; t->y = cy; t->w = r; t->h = r;
|
||||
/* bbox = 整圆像素外接框(中心 ± (r + margin)):使 w->x/y/w/h 即真实绘制范围,
|
||||
* 于是 meow_progress_set 的 mark_dirty 与 App 的 flush_region(w->x,w->y,w->w,w->h)
|
||||
* 都天然对齐,不漏刷/不多刷(修复 bgg M2.71 圆形进度脏区)。 */
|
||||
int m = MEOW_PROGRESS_ARC_MARGIN;
|
||||
t->type = W_PROGRESS;
|
||||
t->x = cx - r - m; t->y = cy - r - m;
|
||||
t->w = 2 * (r + m); t->h = 2 * (r + m);
|
||||
t->owner = meow_ui_activity_active();
|
||||
t->state = MEOW_WS_ENABLED;
|
||||
t->variant = 1; /* 圆形 */
|
||||
@@ -791,6 +805,34 @@ int meow_list_hit_index(meow_widget *w, int x, int y)
|
||||
return (idx >= 0 && idx < w->count) ? idx : -1;
|
||||
}
|
||||
|
||||
/* M2.71-bug8:选中行(越界 clamp)+ 标脏(高亮刷新)。 */
|
||||
void meow_list_set_selected(meow_widget *w, int idx)
|
||||
{
|
||||
if (!w || w->type != W_LIST) return;
|
||||
if (idx < 0) idx = 0;
|
||||
if (w->count > 0 && idx >= w->count) idx = w->count - 1;
|
||||
if (idx == w->sel) return;
|
||||
w->sel = idx;
|
||||
meow_gfx_mark_dirty(w->x, w->y, w->w, w->h);
|
||||
}
|
||||
int meow_list_selected(meow_widget *w) { return (w && w->type == W_LIST) ? w->sel : -1; }
|
||||
|
||||
void meow_list_set_on_tap(meow_widget *w, meow_list_tap_fn cb, void *ctx)
|
||||
{
|
||||
if (!w || w->type != W_LIST) return;
|
||||
w->tap_cb = cb; w->tap_ctx = ctx;
|
||||
}
|
||||
|
||||
/* 命中行:置选中 + 回调(若设)+ 返回 idx;未命中返回 -1(不置选中)。 */
|
||||
int meow_list_tap_at(meow_widget *w, int x, int y)
|
||||
{
|
||||
int idx = meow_list_hit_index(w, x, y);
|
||||
if (idx < 0) return -1;
|
||||
meow_list_set_selected(w, idx);
|
||||
if (w->tap_cb) w->tap_cb(idx, w->tap_ctx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int hit(meow_widget *w, int x, int y)
|
||||
{
|
||||
if (!w) return 0;
|
||||
@@ -816,7 +858,9 @@ void meow_slider_set(meow_widget *w, int val)
|
||||
{
|
||||
if (!w || w->type != W_SLIDER) return;
|
||||
if (val < w->min) val = w->min; if (val > w->max) val = w->max;
|
||||
if (val == w->val) return;
|
||||
w->val = val;
|
||||
meow_gfx_mark_dirty(w->x, w->y, w->w, w->h); /* 滑块/轨道随值变化:标脏 */
|
||||
}
|
||||
int meow_slider_get(meow_widget *w) { return w && w->type == W_SLIDER ? w->val : 0; }
|
||||
void meow_switch_set(meow_widget *w, int on)
|
||||
@@ -899,8 +943,8 @@ void meow_widget_draw(meow_widget *w)
|
||||
if (sw > 0 && sc) meow_ui_draw_rect_round(w->x, w->y, w->w, w->h, r, sc);
|
||||
if (w->state & MEOW_WS_FOCUSED)
|
||||
meow_ui_draw_rect_round(w->x, w->y, w->w, w->h, r, th->primary);
|
||||
/* 禁用:整体变暗(状态层向 onSurface 叠 α) */
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
/* 禁用:整体变暗(圆角 α,防在圆角外叠出灰方块——M2.71-bug4) */
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, r, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_SLIDER: {
|
||||
@@ -922,7 +966,7 @@ void meow_widget_draw(meow_widget *w)
|
||||
int knob_r = w->h / 2 - 3;
|
||||
int kx = w->on ? w->x + w->w - knob_r * 2 - 3 : w->x + 3;
|
||||
meow_gfx_fill_round(kx, w->y + 3, knob_r * 2, knob_r * 2, knob_r, 0xFFFFFF);
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, w->h / 2, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_LIST: {
|
||||
@@ -995,7 +1039,7 @@ void meow_widget_draw(meow_widget *w)
|
||||
int tw = meow_ui_text_width(w->buf, th->font_body);
|
||||
meow_ui_fill_rect(tx + tw, ty, 2, meow_ui_text_height(th->font_body), th->primary);
|
||||
}
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, r, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_CARD: {
|
||||
@@ -1008,7 +1052,7 @@ void meow_widget_draw(meow_widget *w)
|
||||
meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->primary, 24);
|
||||
if (w->nchildren > 0 && w->children[0]) meow_widget_draw(w->children[0]);
|
||||
if (w->state & MEOW_WS_FOCUSED) meow_ui_draw_rect_round(w->x, w->y, w->w, w->h, r, th->primary);
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, r, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_DIVIDER: {
|
||||
@@ -1046,7 +1090,7 @@ void meow_widget_draw(meow_widget *w)
|
||||
meow_ui_draw_rect_round(w->x, w->y, sz, sz, r, th->outline);
|
||||
}
|
||||
if (w->state & MEOW_WS_FOCUSED) meow_ui_draw_rect_round(w->x, w->y, sz, sz, r, th->primary);
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, sz, sz, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, sz, sz, r, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_RADIO: {
|
||||
@@ -1054,13 +1098,16 @@ void meow_widget_draw(meow_widget *w)
|
||||
int ccx = w->x + w->w / 2, ccy = w->y + w->h / 2;
|
||||
meow_gfx_ring_arc(ccx, ccy, 12, 2, 0, 360, sel ? th->primary : th->outline);
|
||||
if (sel) meow_gfx_fill_circle(ccx, ccy, 6, th->primary);
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, w->w / 2, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_PROGRESS: {
|
||||
if (w->variant == 1) { /* 圆形 */
|
||||
int ccx = w->x, ccy = w->y, rr = w->w;
|
||||
int thk = 4;
|
||||
if (w->variant == 1) { /* 圆形(几何 = 整圆像素外接框;由此解回圆心/半径) */
|
||||
int thk = MEOW_PROGRESS_ARC_THK;
|
||||
int m = MEOW_PROGRESS_ARC_MARGIN;
|
||||
int ccx = w->x + w->w / 2, ccy = w->y + w->h / 2;
|
||||
int rr = w->w / 2 - m; /* 与 create 一致:回到调用方传入的半径 r */
|
||||
if (rr <= 0) break;
|
||||
meow_gfx_ring_arc(ccx, ccy, rr, thk, 0, 360, th->surfaceVariant);
|
||||
if (w->value < 0) { /* 不定:按时间推进一段弧(App 在 on_tick 里重绘驱动) */
|
||||
int start = (int)((meow_ui_time_ms() / 30) % 360);
|
||||
@@ -1094,7 +1141,7 @@ void meow_widget_draw(meow_widget *w)
|
||||
meow_ui_text_center(w->x + w->w / 2, w->y + (w->h - meow_ui_text_height(th->font_body)) / 2,
|
||||
w->label, th->font_body, tc);
|
||||
if (w->state & MEOW_WS_FOCUSED) meow_ui_draw_rect_round(w->x, w->y, w->w, w->h, r, th->primary);
|
||||
if (disabled) meow_ui_fill_rect_alpha(w->x, w->y, w->w, w->h, th->onSurface, 90);
|
||||
if (disabled) meow_gfx_fill_round_alpha(w->x, w->y, w->w, w->h, r, th->onSurface, 90);
|
||||
break;
|
||||
}
|
||||
case W_TOPAPPBAR: {
|
||||
|
||||
Reference in new issue
Block a user