重构显示逻辑为 MVP 架构,进行显示模块的解耦

This commit is contained in:
2026-03-24 19:52:22 +08:00
parent a4bf0962b2
commit 0690d6a00e
42 changed files with 2207 additions and 1417 deletions

View File

@@ -0,0 +1,47 @@
#include "test_common.h"
#include <string.h>
#include "../src/Drv/lcd/lcd.h"
#include "../src/Drv/menu/app/menu.h"
#include "../src/Drv/menu/view/menu_layout.h"
int main(void)
{
tagMenuItem root;
tagMenuItem child;
MenuLayoutConfig config = {
LCD_SIZE_X,
LCD_SIZE_Y,
MENU_YMIN,
MENU_YMAX_FROM_LCD(LCD_SIZE_Y),
LINE_HEIGHT,
MENU_WITDTH,
MENU_XADD,
MENU_YADD};
memset(&root, 0, sizeof(root));
memset(&child, 0, sizeof(child));
memcpy(root.byName, "Root", 5);
memcpy(child.byName, "Child", 6);
root.byClass = 0;
child.byClass = 1;
root.ptLower = &child;
root.ptBehind = &root;
root.ptBefore = &root;
child.ptHigher = &root;
child.ptBehind = &child;
child.ptBefore = &child;
ASSERT_EQ_INT(3, MenuLayout_Utf8LenCal((uint8_t *)"ABC"));
ASSERT_EQ_INT(2, MenuLayout_Utf8LenCal((uint8_t *)""));
MenuLayout_PositionCal(&root, 1, &config);
ASSERT_TRUE(root.wEPosX > root.wSPosX);
ASSERT_TRUE(root.wEPosY > root.wSPosY);
ASSERT_TRUE(root.wEPosY <= LCD_SIZE_Y);
return 0;
}