Files
MeowOS-For-R3P2/patch_v2/sdk/meow_ui_activity.c
T

39 lines
1.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_activity.c — Activity 栈(§6.1 ①)。
*
* 控件严格归属创建它的 Activity;命中/实时按压只在「当前 active Activity」的控件集里
* 生效(见 meow_ui_widget.c 的 owner 绑定 + live_btn_hit/meow_widget_hit 过滤)。
* 栈空时 active() 返回 0(根/default Activity)。
*
* 依赖:无(纯静态数组 + 无外部符号),宿主/真机均可链入,便于单测。
* 语义:push = 压栈(新 Activity 成为 active); pop = 弹栈(回上级,栈空则停在根 0)。
*/
#include "meow_ui.h"
#define MEOW_ACT_MAX 32
static int g_act[MEOW_ACT_MAX];
static int g_act_n = 0;
void meow_ui_activity_push(int id)
{
if (g_act_n >= MEOW_ACT_MAX)
return; /* 栈满:静默钳制(骨架级,不崩) */
g_act[g_act_n++] = id;
}
void meow_ui_activity_pop(void)
{
if (g_act_n > 0) g_act_n--;
}
int meow_ui_activity_active(void)
{
return g_act_n > 0 ? g_act[g_act_n - 1] : 0;
}
int meow_ui_activity_depth(void)
{
return g_act_n;
}