diff --git a/README.md b/README.md index 2a937a2..cca6167 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ - [编译/运行在任意平台上](https://gitee.com/idea4good/GuiLiteSamples/tree/master/HostMonitor/README.md) ## 开发文档 -[代码走读](doc/CodeWalkthrough-cn.md) +[代码结构及注释](doc/CodeWalkthrough-cn.md) [如何编译?](doc/HowToBuild.md) @@ -38,10 +38,12 @@ [如何传递消息?](doc/HowMessageWork.md) -## 实例代码及运行效果: -[GuiLiteSamples 代码库](https://gitee.com/idea4good/GuiLiteSamples) +## 视频链接: +[GuiLite简介](https://v.youku.com/v_show/id_XMzA5NTMzMTYyOA) -[GuiLiteSamples 运行视频](http://v.youku.com/v_show/id_XMzA5NTMzMTYyOA) +[GuiLite办公室](https://v.youku.com/v_show/id_XMzYxNTE3MTI0MA) +## 实例代码链接 +[GuiLiteSamples](https://gitee.com/idea4good/GuiLiteSamples) -## 代码镜像 +## GitHub链接 [GitHub链接](https://github.com/idea4good/GuiLite) diff --git a/core/core_include/api.h b/core/core_include/api.h index e7e7262..cb8ba87 100644 --- a/core/core_include/api.h +++ b/core/core_include/api.h @@ -15,7 +15,7 @@ void do_assert(const char* file, int line); void log_out(const char* log); -#define GLT_RGB(r, g, b) ((r << 16) | (g << 8) | b) +#define GLT_RGB(r, g, b) ((0xFF << 24) | (r << 16) | (g << 8) | b) #define GLT_RGB_R(rgb) ((rgb >> 16) & 0xFF) #define GLT_RGB_G(rgb) ((rgb >> 8) & 0xFF) #define GLT_RGB_B(rgb) (rgb & 0xFF) diff --git a/core/src/display.cpp b/core/src/display.cpp index ab5e89c..e2b16aa 100644 --- a/core/src/display.cpp +++ b/core/src/display.cpp @@ -80,10 +80,10 @@ c_surface* c_display::create_surface(void* usr, Z_ORDER_LEVEL max_zorder) return NULL; } -int c_display::merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y1, int offset) +int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset) { - int surface_width = s1->get_width(); - int surface_height = s1->get_height(); + int surface_width = s0->get_width(); + int surface_height = s0->get_height(); if (offset < 0 || offset >= surface_width || y0 < 0 || y0 >= surface_height || y1 < 0 || y1 >= surface_height || x0 < 0 || x0 >= surface_width || x1 < 0 || x1 >= surface_width) @@ -106,11 +106,11 @@ int c_display::merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y for (int y = y0; y <= y1; y++) { //Left surface - char* addr_s = ((char*)(s1->m_fb) + (y * (s1->get_width()) + x0 + offset) * m_color_bytes); + char* addr_s = ((char*)(s0->m_fb) + (y * (s0->get_width()) + x0 + offset) * m_color_bytes); char* addr_d = ((char*)(m_phy_fb) + (y * m_width + x0) * m_color_bytes); memcpy(addr_d, addr_s, (width - offset) * m_color_bytes); //Right surface - addr_s = ((char*)(s2->m_fb) + (y * (s2->get_width()) + x0) * m_color_bytes); + addr_s = ((char*)(s1->m_fb) + (y * (s1->get_width()) + x0) * m_color_bytes); addr_d = ((char*)(m_phy_fb) + (y * m_width + x0 + (width - offset)) * m_color_bytes); memcpy(addr_d, addr_s, offset * m_color_bytes); } diff --git a/doc/CodeWalkthrough-cn.md b/doc/CodeWalkthrough-cn.md index af1b086..98db4c2 100644 --- a/doc/CodeWalkthrough-cn.md +++ b/doc/CodeWalkthrough-cn.md @@ -1,4 +1,4 @@ -# 代码简介 +# 代码结构及注释 gui: 1)实现了各种常规控件(例如:按钮,标签,键盘)及容器(例如:视窗,对话框,滑动页面),开发者可以根据自己的需要,直接在相应的代码上进行修改或重绘,开发出有自己风格,特色的界面;2)实现了用户输入(例如:手指按下/释放)的消息传递,将用户的输入信息传递到整个UI体系树中,并调用相应的响应回调函数;开发者可以根据自己的需要添加/修改响应回调函数。 core: 实现了各个平台(例如:Windows, Linux)的封装,这些封装包括了基本的操作系统接口,底层绘制,图层管理和消息传递。由于开发者面对的应用场景有所不同,所需的操作系统接口也有区别,core中只提供了最基础的接口形式,开发者可以根据自己的需要,直接在api.h/api.cpp中添加新的操作系统接口或**单片机接口**。 @@ -39,3 +39,46 @@ surface层: frame层: 该层属于surface层的一个部分;它现实叠加界面元素而存在。 + +### 文件注释 +| core 文件名称 | 代码简介 | +| --- | --- | +| bitmap.cpp | 绘制位图,支持16 bits和32 bits | +| cmd_target.cpp | 映射UI消息及用户自定义的消息 | +| display.cpp | 生成显示设备,设定surface的数目,一个surface对应一个滑动页面 | +| rect.cpp | UI元素的位置信息 | +| surface.cpp | 实现像素点的绘制,并对各个图层(layer)进行管理 | +| wave_buffer.cpp | 波形数据的缓冲管理 | +| wave_ctrl.cpp | 实现波形控件 | +| wnd.cpp | UI元素的基本类,定义所有的UI元素信息、绘制及管理办法 | +| word.cpp | 显示文字 | +| api_linux.cpp | Linux适配层 | +| api_win.cpp | Window适配层 | +| audio_linux.cpp | Linux audio适配层 | +| audio_win.cpp | Windows audio适配层 | +| msg_linux.cpp | Dispatch消息的Linux实现 | +| msg_win.cpp | Dispatch消息的Windows实现 | + + +| gui 文件名称 | 代码简介 | +| --- | --- | +| button.cpp | 按钮控件的绘制及用户点击响应函数 | +| dialog.cpp | 对话框的绘制及管理方法 | +| edit.cpp | Edit控件的绘制及用户点击响应函数 | +| gesture.cpp | 手势识别方法,包括:鼠标按下,弹起及滑动 | +| keyboard.cpp | 键盘控件的绘制及用户点击响应函数 | +| label.cpp | 标签控件的绘制 | +| list_box.cpp | List控件的绘制及用户点击响应函数 | +| shape_resource.cpp | 自定义的形状资源,主要用于:支持圆角控件的缩放 | +| slide_group.cpp | 滑动页面的显示及管理 | +| spinbox.cpp | Spinbox控件的绘制及用户点击响应函数 | +| table.cpp | Table控件的绘制 | + +### 函数接口注释 +| 函数名称 | display.cpp 函数接口注释 | +| --- | --- | +| c_display | c_display构造函数,初始化显示参数。输入:物理framebuffer指针,物理显示器宽度,物理显示器高度,surface宽度,surface高度,颜色深度,surface个数/滑动页面的个数 | +| create_surface | 创建surface/滑动页面。输入: 用户ID,图层的个数| +| merge_surface | 横向组合surface,多用于滑动surface。输入:待组合的surface源1,待组合的surface源2,surface源1的起始点x坐标,surface源2的起始点x坐标,surface源1的起始点y坐标,surface源2的起始点y坐标,横向组合的偏移距离;输出:可能改变当前显示内容 | +| get_frame_buffer | 获取该display的物理framebuffer指针 | +| snap_shot | 生成当前显示的快照,并输出到bmp文件 |