Files
MeowOS-For-R3P2/patch_v2/sdk/meow_ui_global.c
T
MeowOS 6824defdf9 M2.60→M2.61 骨架: SDK Activity 栈 + 控件归属(agent-122) + 按钮去圈/即时重绘(agent-119) + SDK 模板文档(agent-121)
- SDK §6.1 三层控件模型: Activity栈(push/pop/active) + 页面控件归属 owner + meow_ui_global_* 骨架(②) + 系统级仅内部接口(③)
- meow_widget 加 owner; live_btn_hit/meow_widget_hit 仅 active activity 命中; touch_refresh stale 保护
- 根治"全屏页触摸主页按钮闪现"(跨页面控件残留); 控件对象复用弹栈不重建
- hello 迁移双 Activity(home/full): 全屏左滑=弹栈回主页, 根左滑=退出
- agent-119 按钮去圈(纯色accent+黑12/24%)+即时局部重绘保留; agent-121 SDK模板§5.3-5.7
2026-08-30 15:27:10 +08:00

62 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* meow_ui_global.c — App 跨 Activity 控件(§6.1 ②,SDK 托管骨架)。
*
* SDK 维护一个全局控件列表(钉在 App 的 Activity 栈之上、跨 Activity 常驻):
* - 渲染:meow_ui_gfx present() 每帧在 active activity 内容之上、全局状态栏之下调
* meow_ui_global_render()(遍历列表调 render_cb);
* - 触摸:meow_ui_input TAP 分发先给 meow_ui_global_hit(x,y)——命中返回 1=消费,
* 否则落到 active activity 页面控件(①)。
*
* 骨架(待 B2 细化):无 z 序细分/无按压态管理/无命中区排布——App 的 render/hit 回调
* 自行决定绘制与命中。跨 Activity 常驻由「列表不随 Activity 栈变化」天然保证。
*/
#include "meow_ui.h"
#define MEOW_GLOBAL_MAX 16
typedef struct {
int id;
meow_global_render_fn render;
meow_global_hit_fn hit;
void *ctx;
} gentry;
static gentry g_globals[MEOW_GLOBAL_MAX];
static int g_global_n = 0;
void meow_ui_global_add(int id, meow_global_render_fn r, meow_global_hit_fn h, void *ctx)
{
for (int i = 0; i < g_global_n; i++)
if (g_globals[i].id == id) return; /* 同 id 幂等(重复 add 不新增,骨架) */
if (g_global_n >= MEOW_GLOBAL_MAX) return;
g_globals[g_global_n].id = id;
g_globals[g_global_n].render = r;
g_globals[g_global_n].hit = h;
g_globals[g_global_n].ctx = ctx;
g_global_n++;
}
void meow_ui_global_remove(int id)
{
for (int i = 0; i < g_global_n; i++) {
if (g_globals[i].id == id) {
g_globals[i] = g_globals[--g_global_n];
return;
}
}
}
void meow_ui_global_render(void)
{
for (int i = 0; i < g_global_n; i++)
if (g_globals[i].render) g_globals[i].render(g_globals[i].ctx);
}
int meow_ui_global_hit(int x, int y)
{
for (int i = 0; i < g_global_n; i++)
if (g_globals[i].hit && g_globals[i].hit(g_globals[i].ctx, x, y))
return 1;
return 0;
}