写的页面架构

This commit is contained in:
2026-09-09 17:15:04 +08:00
parent 146d160790
commit 020278d4e3
19 changed files with 1088 additions and 189 deletions
+11 -30
View File
@@ -19,6 +19,7 @@
* 2026-09-08 王建锋 4 层容器→1 个持久容器(焦点/键唯一入口;帧深度由逻辑层
* s_depth 决定,键回调 user_data=depth 冗余);根框装饰
* (浅 V)+状态行改容器自绘(删 3 lv_line + 1 label 对象)
* 2026-09-09 王建锋 "浅 V"装饰几何提取至共享 ui_deco 模块(不再本地重复定义)
*/
/* 头文件包含区 */
@@ -28,6 +29,8 @@
#include "ui_menu_tab.h"
#include "ui_deco.h"
#include "lvgl.h"
#define DBG_TAG "[UI_MENU_VIEW]"
@@ -52,8 +55,6 @@
#define MENU_ROOT_BOX_Y 44 /* 根框顶 */
#define MENU_ROOT_STATUS_X 17 /* 状态行左 */
#define MENU_ROOT_STATUS_Y 20 /* 状态行顶 */
#define MENU_DECO_LEG_W 3 /* 顶部"浅 V"两腿线宽(1bpp 下斜线边缘易被阈值吃掉,需加粗) */
#define MENU_DECO_HORIZ_W 2 /* 顶部"浅 V"水平线宽 */
/* 私有类型定义区 */
@@ -542,45 +543,25 @@ lv_obj_t *ui_menu_view_container(void) {
}
/*
* 根框装饰(浅 V)点集与自绘区域:容器 DRAW_MAIN 自绘(无对象);
* culling 区域覆盖原 lv_line 对象范围((0,0) 处 160×20)与状态行文本区
* 根框装饰(浅 V):几何/绘制/culling 由共享 ui_deco 模块承载(无对象,容器自绘);
* 状态行 culling 区为本模块私有(文本约 104px 宽 + 余量)
*/
static const lv_point_precise_t s_deco_leg_l[2] = { {7, 7}, {16, 17} }; /* 左腿:自顶端斜下 */
static const lv_point_precise_t s_deco_hoz[2] = { {16, 17}, {145, 17} }; /* 水平线:接两腿底端 */
static const lv_point_precise_t s_deco_leg_r[2] = { {158, 7}, {145, 17} }; /* 右腿 */
static const lv_point_precise_t *const s_deco_segs[3] = {s_deco_leg_l, s_deco_leg_r, s_deco_hoz};
static const int32_t s_deco_seg_w[3] = {MENU_DECO_LEG_W, MENU_DECO_LEG_W, MENU_DECO_HORIZ_W};
static const lv_area_t s_deco_band = {0, 0, MENU_SCREEN_W - 1, 19}; /* 浅 V culling 区(与原线段对象范围一致) */
static const lv_area_t s_status_area = {MENU_ROOT_STATUS_X, MENU_ROOT_STATUS_Y, 130, 33}; /* 状态行 culling 区(文本约 104px 宽 + 余量) */
static const lv_area_t s_status_area = {MENU_ROOT_STATUS_X, MENU_ROOT_STATUS_Y, 130, 33}; /* 状态行 culling 区 */
/*
* 函数功能:自绘根框装饰 + 状态行(容器 DRAW_MAIN;替代旧 4 个 LVGL 对象)
* 入口参数:e - 事件指针 lv_event_t *
* 返回值:无
* 限定条件:事件为 LV_EVENT_DRAW_MAIN,容器已建
* 函数说明: 1. 浅 V:两腿 3px 粗、水平线 2px 细(1bpp 斜线边缘易被阈值吃掉,腿须比水平线粗)
* 2. 绘制次序 = 旧对象创建序(左腿、右腿、水平线),重叠像素与旧渲染一致
* 3. 状态行:静态字符串、白色,与旧 label 同字体同位置
* 4. 重绘区不覆盖对应 culling 区则跳过(culling)
* 函数说明: 1. 浅 V:共享 ui_deco 模块(两腿 3px / 水平线 2px,绘制次序左腿、右腿、水平线)
* 2. 状态行:静态字符串、白色,与旧 label 同字体同位置
* 3. 重绘区不覆盖对应 culling 区则跳过(culling)
*/
static void view_deco_draw_cb(lv_event_t *e) {
lv_layer_t *layer = lv_event_get_layer(e);
/* "浅 V"装饰:3 段线(线宽各异,逐段画) */
if (areas_intersect(&s_deco_band, &layer->_clip_area)) {
for (uint8_t i = 0; i < 3; i++) {
lv_draw_line_dsc_t ld;
lv_draw_line_dsc_init(&ld);
ld.base.layer = layer;
ld.color = lv_color_white();
ld.width = s_deco_seg_w[i];
ld.p1 = s_deco_segs[i][0];
ld.p2 = s_deco_segs[i][1];
lv_draw_line(layer, &ld);
}
}
/* "浅 V"装饰:共享 ui_deco 模块(几何/绘制次序/culling 均在其内) */
ui_deco_draw(layer, &layer->_clip_area);
/* 状态行:当前模式(静态文本) */
if (areas_intersect(&s_status_area, &layer->_clip_area)) {