/* ui/common/chrome.c — files 应用共享 chrome(TopAppBar 建置 / 几何 / 空态&页脚绘制)。 * * 与 hello_app/ui/common/chrome.c 同理:把「页面 chrome 固定不随内容重建」分出去;本模块只 * 提供几何计算 + topbar 建置 + 非控件直绘辅助(空态/页脚),供 browser/viewer 两页复用。 * 绘制全部读 meow_theme_get() 语义色(§8.1),不硬编码配色;topbar 由 meow_topappbar 建, * 自动注册进绘制物注册表(§6.2),owner=创建时 active activity。 */ #include "files_internal.h" int app_statusbar(void) { int sb = meow_ui_statusbar_height(); return sb < 0 ? 0 : sb; } app_rect_t app_topbar_rect(void) { int sb = app_statusbar(); return AR(0, sb, meow_ui_width(), APP_TOPBAR_H); } app_rect_t app_content_rect(void) { int sb = app_statusbar(); int y = sb + APP_TOPBAR_H; int h = meow_ui_height() - y; if (h < 0) h = 0; return AR(0, y, meow_ui_width(), h); } meow_widget *app_topbar_create(const char *title, int back, const char *action_label) { app_rect_t r = app_topbar_rect(); meow_widget *tb = meow_topappbar_create(r.x, r.y, r.w, r.h, title); meow_topappbar_set_back(tb, back); if (action_label) meow_topappbar_add_action(tb, action_label); meow_widget_set_z(tb, 999); /* chrome 置顶(§6.2:> 一切自动 z,区域重画最后画它) */ return tb; } /* 空态/错误:居中两行(kind 大字 + what 小字)。kind=状态标题,what=说明/路径。 */ void app_draw_empty(app_rect_t r, const char *kind, const char *what) { const meow_theme *th = meow_theme_get(); int cy = r.y + r.h / 2; meow_ui_text_center(r.x + r.w / 2, cy - 34, kind ? kind : "", 28, th->primary); if (what && what[0]) meow_ui_text_center(r.x + r.w / 2, cy + 4, what, 20, th->dim); } /* 底部信息(右对齐 dim):项数/路径/截断提示。 */ void app_draw_footer(app_rect_t r, const char *text) { const meow_theme *th = meow_theme_get(); if (!text || !text[0]) return; meow_ui_text_right(r.x + r.w - APP_PAD, r.y + r.h - 26, text, 20, th->dim); }