GUI lite全平台界面框架启动过程

本文基于GUI lite的'Hello widgets'实例,解析了全平台界面框架的启动过程。从创建UI、加载资源、初始化画布及滑动页面,到层级管理、窗口初始化,再到界面元素的连接,详细阐述了每个步骤的关键操作和涉及的类。最后提到了c_display、c_surface、c_wnd等重要类的作用。
摘要由CSDN通过智能技术生成

//基于 GUI lite “Hello widgets” 实例 分析

1,全平台接口

//传入:物理framebuffer指针,物理显示器宽度,物理显示器高度,颜色深度
create_ui(phy_fb, width, height, color_bytes);

2,加载主题等资源参数
load_resource();

3,传入给 GUI lite 参数,并初始化画布(c_display )和画布的滑动页面(c_surface )
// c_display构造函数,初始化显示参数。输入:物理framebuffer指针,物理显示器宽度,物理显示器高度,surface宽度,surface高度,颜色深度,surface个数(滑动页面的个数);
首先要明白,这里有个包含关系是 (c_display 画布(c_surface 滑动页面(c_frame_layer 层级)));
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
unsigned int surface_width, unsigned int surface_height,
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = NULL);
// c_display内部创建c_surface对象,并将调用c_suface构造函数; c_surface和c_display是组合关系,c_display里有c_surface对象缓存,初始化完c_display后,就初始化c_surface
c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes)
// 构造函数内将初始化保护数据 m_width,m_height, m_color_bytes, m_fb, m_frame_layers, m_phy_fb,m_display … 等等

4,层级管理,分配内存,并返回一个m_surface_group[ ]缓存指针,这个数组是c_display类内部的c_surface缓存数组
也就是说,如果c_display内的c_surface有多个,则需要初始化c_surface的一个m_fb,作为"Top frame buffer you could see"。 初始化完c_display后只是将c_display内部的c_surface给初始化了,但是需要用到哪个c_surface还需要进一步的将c_surface进行层级c_frame_layer 初始化
alloc_surface((void*)1, Z_ORDER_LEVEL_2);
其内部调用:
set_surface(s_surface); // 设置surface的层级关系,并分配堆内存给surface对象的层级c_frame_layer 用
内部调用 calloc(size_t numElements, size_t sizeOfElement) 函数,此函数分配一段连续的堆内存并清0,与malloc相似,参数sizeOfElement为申请地址的单位元素长度,numElements为元素个数,即在动态内存中申请numElements*sizeOfElement字节大小的连续地址空间.

5, 初始化c_wnd 的 m_surface
调用 wnd 类方法 s_my_ui.set_surface(c_surface* surface) { m_surface = surface; },初始化 m_surface (c_surface类对象的保护数据);将构造好的c_surface对象给c_wnd使用,为开启窗口做准备。
s_my_ui对象定义: static c_my_ui s_my_ui;
s_my_ui类定义:

class c_my_ui : public c_wnd
{
   
	virtual c_wnd* clone() {
    return new c_my_ui(); }
	virtual void on_init_children() 
	{
   
		c_list_box  *list_box = (c_list_box*)get_wnd_ptr(ID_LIST_BOX);
		list_box->clear_item();
		list_box->add_item((char*)"Item 0");
		list_box->add_item((char*)"Item 1");
		list_box->add_item((char*)"Item 2");
		list_box
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值