Linux项目实战——UI系统、页面系统(后附百问网课程视频链接)

UI系统

一、数据结构抽象

  1. 按钮的名字

  2. 按钮的区域

3.按钮的绘制

4.按钮的事件

cpp 复制代码
typedef struct Button {
	char *name;
    int status;
	Region tRegion;
	int (*OnDraw)(struct Button *ptButton);
	int (*OnPressed)(struct Button *ptButton,PDispBuff ptDispBuff,PInputEvent ptInputEvent);
}Button, *PButton;

二、按键编程

对按键进行初始化,实现抽象出来的结构体。

2.1 实现OnDraw()

需要先实现:

1. 绘制底色

cpp 复制代码
void DrawRegion(PRegion ptRegion, unsigned int dwcolor)

2. 居中绘制文字

cpp 复制代码
void DrawTextInButtonCenter(char *name, PRegion ptRegion, unsigned int dwColor)

①确定每一个字符的大小

② 确定第一个字符的起点

然后就可以将绘制出来的按钮刷到LCD上。

cpp 复制代码
int FlushDisplayRegion(PRegion ptRegion, PDispBuff ptDispBuff)

2.2 实现OnPressed()

通过标志位status判断按键当前的状态,从而选颜色的显示。


页面系统

一、数据结构抽象

cpp 复制代码
typedef struct PageAction {
    char *name;
    void (*Run)(void *pParams);
    struct PageAction *ptNext;
}PageAction,*PPageAction;

二、页面管理器

页面管理器用来管理页面,只需要实现2个函数:

1.PageRegister:把多个页面注册进链表

2.Page(name):取出某个页面

相关推荐
Sheffield7 小时前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
Johny_Zhao1 天前
centos7安装部署openclaw
linux·人工智能·信息安全·云计算·yum源·系统运维·openclaw
haibindev1 天前
在 Windows+WSL2 上部署 OpenClaw AI员工的实践与踩坑
linux·wsl2·openclaw
0xDevNull2 天前
Linux切换JDK版本详细教程
linux
进击的丸子2 天前
虹软人脸服务器版SDK(Linux/ARM Pro)多线程调用及性能优化
linux·数据库·后端
Johny_Zhao4 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
RuoZoe4 天前
重塑WPF辉煌?基于DirectX 12的现代.NET UI框架Jalium
c语言
chlk1235 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑5 天前
Ubuntu系统安装CodeX出现问题
linux·后端