refactor display, surface; get_frame_buffer will return NULL if no UI update
This commit is contained in:
parent
78f42abe7b
commit
bb90464136
71
README.md
71
README.md
|
@ -1,16 +1,28 @@
|
||||||
# GuiLite - 简洁出奇迹
|
# GuiLite - 简洁出奇迹
|
||||||
|
- [功能介绍](#功能介绍)
|
||||||
|
- [实例程序](#实例程序)
|
||||||
|
- [开发文档](#开发文档)
|
||||||
|
- [致谢](#致谢)
|
||||||
|
***
|
||||||
|
## GuiLite是什么鬼?
|
||||||
- GuiLite(超轻量UI框架)是5千行代码的**全平台UI框架**,可以完美运行在iOS,Android,Windows(包含VR),Mac,单片机和**市面所有的 ARM Linux物联网终端设备**上。
|
- GuiLite(超轻量UI框架)是5千行代码的**全平台UI框架**,可以完美运行在iOS,Android,Windows(包含VR),Mac,单片机和**市面所有的 ARM Linux物联网终端设备**上。
|
||||||
- GuiLite可以嵌入在iOS、Android、MFC、QT等其他UI系统中,让你的界面集百家之长,又不失个性。
|
- GuiLite可以嵌入在iOS、Android、MFC、QT等其他UI系统中,让你的界面集百家之长,又不失个性。
|
||||||
- GuiLite鼓励混合编程,开发者可以用GuiLite接管UI部分,用Swift,Java,Go,C#,Python发开业务部分。
|
- GuiLite鼓励混合编程,开发者可以用GuiLite接管UI部分,用Swift,Java,Go,C#,Python开发业务部分。
|
||||||
|
|
||||||
相比QT、MFC,GuiLite不预设开发者的使用场景,不在具体功能上,大包大揽;用框架的简洁,换取开发的自由;GuiLite在图形绘制上面,力图一步到位,运行效率感人。
|
相比QT、MFC,GuiLite不预设开发者的使用场景,不在具体功能上,大包大揽;用框架的简洁,换取开发的自由;GuiLite在图形绘制上面,力图一步到位,运行效率感人。
|
||||||
|
|
||||||
## 新功能:多语言demo -- HelloFont
|
## 为什么开发GuiLite?如何使用?
|
||||||
![HelloFont](doc/HelloFont.gif)
|
- 任何UI框架都不是为你我而生的,只有掌握核心原理,对其深度定制,才能真正掌握自己的命运!因此,我们开发了GuiLite,希望用这5千行代码揭示UI的核心原理和定制方法。
|
||||||
|
- 我们不推荐开发者全盘使用GuiLite;鼓励开发者在吃透代码后,根据自身业务特点,修改出更加丰富、个性的界面;或者发展出适合自己的UI框架。
|
||||||
|
- 为了聚焦UI核心原理,GuiLite会一直保持单片机的代码体量。
|
||||||
|
|
||||||
**信不信由你,代码只有100+行!**[查阅代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloFont/UIcode/UIcode.cpp)
|
## 新功能:滑屏demo -- HelloSlide
|
||||||
|
![HelloSlide](doc/HelloSlide.gif)
|
||||||
|
|
||||||
## 卓越的跨平台能力
|
**信不信由你,代码只有100+行!**[查阅代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloSlide/UIcode/UIcode.cpp)
|
||||||
|
|
||||||
|
## 功能介绍
|
||||||
|
### 卓越的跨平台能力
|
||||||
在Mac, iOS下的运行效果:
|
在Mac, iOS下的运行效果:
|
||||||
|
|
||||||
![Mac](doc/Mac.gif) ![iOS](doc/Ios.landscape.gif)
|
![Mac](doc/Mac.gif) ![iOS](doc/Ios.landscape.gif)
|
||||||
|
@ -23,7 +35,7 @@
|
||||||
|
|
||||||
![Win MR](doc/WinMR.gif)
|
![Win MR](doc/WinMR.gif)
|
||||||
|
|
||||||
## 万国语和墙纸
|
### 万国语和墙纸
|
||||||
墙纸:
|
墙纸:
|
||||||
![unicode](doc/wallpaper.jpg)
|
![unicode](doc/wallpaper.jpg)
|
||||||
|
|
||||||
|
@ -32,12 +44,12 @@
|
||||||
|
|
||||||
[如何制作多种文字/位图资源?](https://github.com/idea4good/GuiLiteToolkit)
|
[如何制作多种文字/位图资源?](https://github.com/idea4good/GuiLiteToolkit)
|
||||||
|
|
||||||
## “换肤”功能
|
### “换肤”功能
|
||||||
![multi-theme](doc/multi-theme.png)
|
![multi-theme](doc/multi-theme.png)
|
||||||
|
|
||||||
[如何“换肤”?](https://github.com/idea4good/GuiLiteSamples/blob/master/HostMonitor/SampleCode/source/resource/resource.cpp)
|
[如何“换肤”?](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HostMonitor/SampleCode/source/resource/resource.cpp)
|
||||||
|
|
||||||
## 自我监控
|
### 自我监控
|
||||||
**上报“编译/运行”情况至“云端”:**
|
**上报“编译/运行”情况至“云端”:**
|
||||||
|
|
||||||
![BuildInfo](doc/BuildInfo.png)
|
![BuildInfo](doc/BuildInfo.png)
|
||||||
|
@ -46,34 +58,27 @@
|
||||||
|
|
||||||
![DataOnCloud](doc/data_on_cloud.png)
|
![DataOnCloud](doc/data_on_cloud.png)
|
||||||
|
|
||||||
## 为什么开发GuiLite?如何使用?
|
## 实例程序
|
||||||
任何UI框架都不是为你我而生的,只有掌握核心原理,对其深度定制,才能真正掌握自己的命运!因此,我们开发了GuiLite,希望用这5千行代码揭示UI的核心原理和定制方法。
|
GuiLite只是一个框架,本身并不能生成UI。为了能够展示如何用GuiLite开发App,我们提供了一些实例程序给大家参考。
|
||||||
|
- 点击[这里](https://gitee.com/idea4good/GuiLiteSamples)预览UI效果。
|
||||||
我们不推荐开发者全盘使用GuiLite;鼓励开发者在吃透代码后,根据自身业务特点,修改出更加丰富、个性的界面;或者发展出适合自己的UI框架。
|
- 实例程序的功能说明:
|
||||||
|
|
||||||
为了聚焦UI核心原理,GuiLite会一直保持单片机的代码体量。
|
|
||||||
|
|
||||||
## 快速上手
|
|
||||||
- 下载实例代码: `git clone https://gitee.com/idea4good/GuiLiteSamples`
|
|
||||||
- `cd GuiLiteSamples\HostMonitor`
|
|
||||||
- [编译/运行在任意平台上](https://gitee.com/idea4good/GuiLiteSamples/tree/master/HostMonitor/README.md)
|
|
||||||
|
|
||||||
|
| 实例名称 | 支持的平台 | 功能简介 | 编译方法 | 难度 |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| HelloGuiLite | Windows, Linux | 初始化GuiLite,加载资源,布局界面元素,按钮响应 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloGuiLite/README.md) | 初级 |
|
||||||
|
| HelloFont | Windows, Linux | 显示多种语言(不限:中、英文) | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloFont/README.md) | 初级 |
|
||||||
|
| HelloSlide | Windows, Linux | 滑屏界面的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloSlide/README.md) | 中级 |
|
||||||
|
| HostMonitor | iOS, Mac, Android, Windows, Linux | 创建复杂界面,扩展自定义控件,适配全平台 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HostMonitor/README.md) | 高级 |
|
||||||
## 开发文档
|
## 开发文档
|
||||||
[代码结构及注释](doc/CodeWalkthrough-cn.md)
|
- [如何编译?](doc/HowToBuild.md)
|
||||||
|
- [设计原理](doc/CodeWalkthrough-cn.md)
|
||||||
[如何编译?](doc/HowToBuild.md)
|
- [UML示意图](doc/UML.md)
|
||||||
|
- [如何布局UI?](doc/HowLayoutWork.md)
|
||||||
[如何布局UI?](doc/HowLayoutWork.md)
|
- [如何传递消息?](doc/HowMessageWork.md)
|
||||||
|
|
||||||
[如何传递消息?](doc/HowMessageWork.md)
|
|
||||||
|
|
||||||
## 视频链接:
|
## 视频链接:
|
||||||
[GuiLite简介](https://v.youku.com/v_show/id_XMzA5NTMzMTYyOA)
|
- [GuiLite简介](https://v.youku.com/v_show/id_XMzA5NTMzMTYyOA)
|
||||||
|
- [3D GuiLite](https://v.youku.com/v_show/id_XMzYxNTE3MTI0MA)
|
||||||
[3D GuiLite](https://v.youku.com/v_show/id_XMzYxNTE3MTI0MA)
|
|
||||||
|
|
||||||
## 实例代码链接
|
|
||||||
[GuiLiteSamples](https://gitee.com/idea4good/GuiLiteSamples)
|
|
||||||
|
|
||||||
## GitHub链接
|
## GitHub链接
|
||||||
[GitHub链接](https://github.com/idea4good/GuiLite)
|
[GitHub链接](https://github.com/idea4good/GuiLite)
|
||||||
|
|
|
@ -7,6 +7,7 @@ class c_hid_pipe;
|
||||||
class c_surface;
|
class c_surface;
|
||||||
|
|
||||||
class c_display {
|
class c_display {
|
||||||
|
friend class c_surface;
|
||||||
public:
|
public:
|
||||||
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
|
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
|
||||||
unsigned int surface_width, unsigned int surface_height,
|
unsigned int surface_width, unsigned int surface_height,
|
||||||
|
@ -16,13 +17,15 @@ public:
|
||||||
unsigned int get_width() { return m_width; }
|
unsigned int get_width() { return m_width; }
|
||||||
unsigned int get_height() { return m_height; }
|
unsigned int get_height() { return m_height; }
|
||||||
|
|
||||||
void* get_frame_buffer(int* width, int* height);
|
void* get_updated_fb(int* width, int* height, bool force_update = false);
|
||||||
int snap_shot(const char* file_name);
|
int snap_shot(const char* file_name);
|
||||||
private:
|
private:
|
||||||
unsigned int m_width; //in pixels
|
unsigned int m_width; //in pixels
|
||||||
unsigned int m_height; //in pixels
|
unsigned int m_height; //in pixels
|
||||||
unsigned int m_color_bytes; //16 bits, 32 bits only
|
unsigned int m_color_bytes; //16 bits, 32 bits only
|
||||||
void* m_phy_fb;
|
void* m_phy_fb;
|
||||||
|
int m_phy_read_index;
|
||||||
|
int m_phy_write_index;
|
||||||
c_surface* m_surface_group[SURFACE_CNT_MAX];
|
c_surface* m_surface_group[SURFACE_CNT_MAX];
|
||||||
unsigned int m_surface_cnt;
|
unsigned int m_surface_cnt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
||||||
|
|
||||||
void set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order);
|
void set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order);
|
||||||
int copy_layer_pixel_2_fb(int x, int y, unsigned int z_order);
|
int copy_layer_pixel_2_fb(int x, int y, unsigned int z_order);
|
||||||
c_surface(c_display* display, void* phy_fb, unsigned int width, unsigned int height, unsigned int color_bytes);
|
c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes);
|
||||||
int m_width; //in pixels
|
int m_width; //in pixels
|
||||||
int m_height; //in pixels
|
int m_height; //in pixels
|
||||||
int m_color_bytes; //16 bits, 32 bits only
|
int m_color_bytes; //16 bits, 32 bits only
|
||||||
|
@ -57,13 +57,14 @@ protected:
|
||||||
Z_ORDER_LEVEL m_max_zorder;
|
Z_ORDER_LEVEL m_max_zorder;
|
||||||
Z_ORDER_LEVEL m_top_zorder;
|
Z_ORDER_LEVEL m_top_zorder;
|
||||||
void* m_phy_fb;
|
void* m_phy_fb;
|
||||||
|
int* m_phy_write_index;
|
||||||
c_display* m_display;
|
c_display* m_display;
|
||||||
};
|
};
|
||||||
|
|
||||||
class c_surface_16bits : public c_surface {
|
class c_surface_16bits : public c_surface {
|
||||||
friend class c_display;
|
friend class c_display;
|
||||||
c_surface_16bits(c_display* display, void* phy_fb, unsigned int width, unsigned int height, unsigned int color_bytes) :
|
c_surface_16bits(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes) :
|
||||||
c_surface(display, phy_fb, width, height, color_bytes) {};
|
c_surface(display, width, height, color_bytes) {};
|
||||||
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
|
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
|
||||||
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
||||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||||
|
|
|
@ -22,6 +22,7 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
|
||||||
m_height = display_height;
|
m_height = display_height;
|
||||||
m_color_bytes = color_bytes;
|
m_color_bytes = color_bytes;
|
||||||
m_phy_fb = phy_fb;
|
m_phy_fb = phy_fb;
|
||||||
|
m_phy_read_index = m_phy_write_index = 0;
|
||||||
|
|
||||||
m_surface_cnt = surface_cnt;
|
m_surface_cnt = surface_cnt;
|
||||||
if (m_surface_cnt > SURFACE_CNT_MAX)
|
if (m_surface_cnt > SURFACE_CNT_MAX)
|
||||||
|
@ -31,8 +32,8 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
|
||||||
memset(m_surface_group, 0, sizeof(m_surface_group));
|
memset(m_surface_group, 0, sizeof(m_surface_group));
|
||||||
for (int i = 0; i < m_surface_cnt; i++)
|
for (int i = 0; i < m_surface_cnt; i++)
|
||||||
{
|
{
|
||||||
m_surface_group[i] = (color_bytes == 4) ? new c_surface(this, m_phy_fb, surface_width, surface_height, color_bytes) :
|
m_surface_group[i] = (color_bytes == 4) ? new c_surface(this, surface_width, surface_height, color_bytes) :
|
||||||
new c_surface_16bits(this, m_phy_fb, surface_width, surface_height, color_bytes);
|
new c_surface_16bits(this, surface_width, surface_height, color_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y
|
||||||
int surface_width = s0->get_width();
|
int surface_width = s0->get_width();
|
||||||
int surface_height = s0->get_height();
|
int surface_height = s0->get_height();
|
||||||
|
|
||||||
if (offset < 0 || offset >= surface_width || y0 < 0 || y0 >= surface_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)
|
y1 < 0 || y1 >= surface_height || x0 < 0 || x0 >= surface_width || x1 < 0 || x1 >= surface_width)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
|
@ -83,7 +84,7 @@ int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = (x1 - x0 + 1);
|
int width = (x1 - x0 + 1);
|
||||||
if (width < 0 || width >= surface_width || width < offset)
|
if (width < 0 || width > surface_width || width < offset)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -104,16 +105,26 @@ int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y
|
||||||
addr_d = ((char*)(m_phy_fb) + (y * m_width + x0 + (width - offset)) * 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);
|
memcpy(addr_d, addr_s, offset * m_color_bytes);
|
||||||
}
|
}
|
||||||
|
m_phy_write_index++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* c_display::get_frame_buffer(int* width, int* height)
|
void* c_display::get_updated_fb(int* width, int* height, bool force_update)
|
||||||
{
|
{
|
||||||
if (width && height)
|
if (width && height)
|
||||||
{
|
{
|
||||||
*width = get_width();
|
*width = get_width();
|
||||||
*height = get_height();
|
*height = get_height();
|
||||||
}
|
}
|
||||||
|
if (force_update)
|
||||||
|
{
|
||||||
|
return m_phy_fb;
|
||||||
|
}
|
||||||
|
if (m_phy_read_index == m_phy_write_index)
|
||||||
|
{//No update
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
m_phy_read_index = m_phy_write_index;
|
||||||
return m_phy_fb;
|
return m_phy_fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
c_surface::c_surface(c_display* display, void* phy_fb, unsigned int width, unsigned int height, unsigned int color_bytes)
|
c_surface::c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes)
|
||||||
{
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
m_color_bytes = color_bytes;
|
m_color_bytes = color_bytes;
|
||||||
m_display = display;
|
m_display = display;
|
||||||
m_phy_fb = phy_fb;
|
m_phy_fb = display->m_phy_fb;
|
||||||
|
m_phy_write_index = &display->m_phy_write_index;
|
||||||
m_fb = m_usr = NULL;
|
m_fb = m_usr = NULL;
|
||||||
m_top_zorder = m_max_zorder = Z_ORDER_LEVEL_0;
|
m_top_zorder = m_max_zorder = Z_ORDER_LEVEL_0;
|
||||||
m_is_active = false;
|
m_is_active = false;
|
||||||
|
@ -94,6 +95,7 @@ void c_surface::set_pixel(int x, int y, unsigned int rgb)
|
||||||
if (m_is_active && (x < display_width) && (y < display_height))
|
if (m_is_active && (x < display_width) && (y < display_height))
|
||||||
{
|
{
|
||||||
((unsigned int*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb;
|
((unsigned int*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb;
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +145,7 @@ void c_surface::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb
|
||||||
x = x0;
|
x = x0;
|
||||||
fb = &((unsigned int*)m_fb)[y0 * m_width + x];
|
fb = &((unsigned int*)m_fb)[y0 * m_width + x];
|
||||||
phy_fb = &((unsigned int*)m_phy_fb)[y0 * display_width + x];
|
phy_fb = &((unsigned int*)m_phy_fb)[y0 * display_width + x];
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
for (; x <= x1; x++)
|
for (; x <= x1; x++)
|
||||||
{
|
{
|
||||||
*fb++ = rgb;
|
*fb++ = rgb;
|
||||||
|
@ -361,6 +364,7 @@ int c_surface::copy_layer_pixel_2_fb(int x, int y, unsigned int z_order)
|
||||||
if (m_is_active && (x < display_width) && (y < display_height))
|
if (m_is_active && (x < display_width) && (y < display_height))
|
||||||
{
|
{
|
||||||
((unsigned int*)m_phy_fb)[y * display_width + x] = rgb;
|
((unsigned int*)m_phy_fb)[y * display_width + x] = rgb;
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else//16 bits
|
else//16 bits
|
||||||
|
@ -370,6 +374,7 @@ int c_surface::copy_layer_pixel_2_fb(int x, int y, unsigned int z_order)
|
||||||
if (m_is_active && (x < display_width) && (y < display_height))
|
if (m_is_active && (x < display_width) && (y < display_height))
|
||||||
{
|
{
|
||||||
((short*)m_phy_fb)[y * display_width + x] = rgb;
|
((short*)m_phy_fb)[y * display_width + x] = rgb;
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -435,6 +440,7 @@ int c_surface::flush_scrren(int left, int top, int right, int bottom)
|
||||||
void* d_addr = (char*)m_phy_fb + ((y * display_width + left) * m_color_bytes);
|
void* d_addr = (char*)m_phy_fb + ((y * display_width + left) * m_color_bytes);
|
||||||
memcpy(d_addr, s_addr, (right - left) * m_color_bytes);
|
memcpy(d_addr, s_addr, (right - left) * m_color_bytes);
|
||||||
}
|
}
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,6 +520,7 @@ void c_surface_16bits::set_pixel(int x, int y, unsigned int rgb)
|
||||||
if (m_is_active && (x < display_width) && (y < display_height))
|
if (m_is_active && (x < display_width) && (y < display_height))
|
||||||
{
|
{
|
||||||
((unsigned short*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb;
|
((unsigned short*)m_phy_fb)[y * (m_display->get_width()) + x] = rgb;
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,6 +569,7 @@ void c_surface_16bits::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned
|
||||||
x = x0;
|
x = x0;
|
||||||
fb = &((unsigned short*)m_fb)[y0 * m_width + x];
|
fb = &((unsigned short*)m_fb)[y0 * m_width + x];
|
||||||
phy_fb = &((unsigned short*)m_phy_fb)[y0 * display_width + x];
|
phy_fb = &((unsigned short*)m_phy_fb)[y0 * display_width + x];
|
||||||
|
*m_phy_write_index = *m_phy_write_index + 1;
|
||||||
for (; x <= x1; x++)
|
for (; x <= x1; x++)
|
||||||
{
|
{
|
||||||
*fb++ = rgb;
|
*fb++ = rgb;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 508 KiB |
|
@ -0,0 +1,4 @@
|
||||||
|
## Class structure
|
||||||
|
![class-structure](uml-class.png)
|
||||||
|
## UI process
|
||||||
|
![ui-process](uml-ui-process.png)
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
|
@ -5,12 +5,7 @@ typedef struct struct_font_info FONT_INFO;
|
||||||
typedef struct struct_color_rect COLOR_RECT;
|
typedef struct struct_color_rect COLOR_RECT;
|
||||||
typedef struct struct_bitmap_info BITMAP_INFO;
|
typedef struct struct_bitmap_info BITMAP_INFO;
|
||||||
|
|
||||||
//Redefine them to meet your need.
|
//Rebuild gui library once you change this file
|
||||||
#define DEFAULT_NORMAL_COLOR GL_RGB(211, 211, 211)
|
|
||||||
#define DEFAULT_FOCUS_COLOR GL_RGB(188, 185, 182)
|
|
||||||
#define DEFAULT_PUSH_COLOR GL_RGB(165, 162, 159)
|
|
||||||
#define DEFAULT_FONT_COLOR GL_RGB(0, 0, 0)
|
|
||||||
|
|
||||||
enum FONT_TYPE
|
enum FONT_TYPE
|
||||||
{
|
{
|
||||||
FONT_NULL,
|
FONT_NULL,
|
||||||
|
@ -26,14 +21,17 @@ enum FONT_TYPE
|
||||||
|
|
||||||
enum BITMAP_TYPE
|
enum BITMAP_TYPE
|
||||||
{
|
{
|
||||||
BITMAP_UP_BT_NORMAL,
|
BITMAP_UP_ARROW1,
|
||||||
BITMAP_UP_BT_FOCUS,
|
BITMAP_UP_ARROW2,
|
||||||
BITMAP_DOWN_BT_NORMAL,
|
BITMAP_DOWN_ARROW1,
|
||||||
BITMAP_DOWN_BT_FOCUS,
|
BITMAP_DOWN_ARROW2,
|
||||||
|
|
||||||
BITMAP_CUSTOM1,
|
BITMAP_CUSTOM1,
|
||||||
BITMAP_CUSTOM2,
|
BITMAP_CUSTOM2,
|
||||||
BITMAP_CUSTOM3,
|
BITMAP_CUSTOM3,
|
||||||
|
BITMAP_CUSTOM4,
|
||||||
|
BITMAP_CUSTOM5,
|
||||||
|
BITMAP_CUSTOM6,
|
||||||
|
|
||||||
BITMAP_MAX
|
BITMAP_MAX
|
||||||
};
|
};
|
||||||
|
@ -59,8 +57,8 @@ enum SHAPE_TYPE
|
||||||
|
|
||||||
enum COLOR_TYPE
|
enum COLOR_TYPE
|
||||||
{
|
{
|
||||||
CTRL_BACK_GROUND,
|
WND_BACKCOLOR,
|
||||||
CTRL_FORE_GROUND,
|
WND_FORECOLOR,
|
||||||
|
|
||||||
COLOR_MAX
|
COLOR_MAX
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,8 +13,8 @@ void c_button::pre_create_wnd()
|
||||||
{
|
{
|
||||||
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
||||||
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
||||||
m_font_color = c_my_resource::get_color(CTRL_FORE_GROUND);
|
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
|
||||||
m_bg_color = c_my_resource::get_color(CTRL_BACK_GROUND);
|
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_button::on_focus()
|
void c_button::on_focus()
|
||||||
|
|
|
@ -26,8 +26,8 @@ void c_edit::pre_create_wnd()
|
||||||
{
|
{
|
||||||
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER | KEY_BOARD_STYLE;
|
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER | KEY_BOARD_STYLE;
|
||||||
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
||||||
m_font_color = c_my_resource::get_color(CTRL_FORE_GROUND);
|
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
|
||||||
m_bg_color = c_my_resource::get_color(CTRL_BACK_GROUND);
|
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
|
||||||
|
|
||||||
memset(m_str_input, 0, sizeof(m_str_input));
|
memset(m_str_input, 0, sizeof(m_str_input));
|
||||||
memset(m_str, 0, sizeof(m_str));
|
memset(m_str, 0, sizeof(m_str));
|
||||||
|
|
|
@ -153,7 +153,7 @@ int c_gesture::flip_left()
|
||||||
int step = m_down_x - m_move_x;
|
int step = m_down_x - m_move_x;
|
||||||
c_rect rc;
|
c_rect rc;
|
||||||
m_slide_group->get_screen_rect(rc);
|
m_slide_group->get_screen_rect(rc);
|
||||||
while(step <= rc.Width())
|
while(step < rc.Width())
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
s1->get_display()->merge_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
||||||
step += FLIP_STEP;
|
step += FLIP_STEP;
|
||||||
|
@ -188,7 +188,7 @@ int c_gesture::flip_right()
|
||||||
c_rect rc;
|
c_rect rc;
|
||||||
m_slide_group->get_screen_rect(rc);
|
m_slide_group->get_screen_rect(rc);
|
||||||
int step = rc.Width() - (m_move_x - m_down_x);
|
int step = rc.Width() - (m_move_x - m_down_x);
|
||||||
while(step >= 0)
|
while(step > 0)
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
s1->get_display()->merge_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
||||||
step -= FLIP_STEP;
|
step -= FLIP_STEP;
|
||||||
|
|
|
@ -19,7 +19,7 @@ void c_list_box::pre_create_wnd()
|
||||||
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
||||||
memset(m_item_array, 0, sizeof(m_item_array));
|
memset(m_item_array, 0, sizeof(m_item_array));
|
||||||
m_item_total = 0;
|
m_item_total = 0;
|
||||||
m_font_color = c_my_resource::get_color(CTRL_FORE_GROUND);
|
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_list_box::on_init_children()
|
void c_list_box::on_init_children()
|
||||||
|
@ -27,8 +27,8 @@ void c_list_box::on_init_children()
|
||||||
m_item_total = 0;
|
m_item_total = 0;
|
||||||
m_selected_item = 0;
|
m_selected_item = 0;
|
||||||
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
||||||
m_font_color = c_my_resource::get_color(CTRL_FORE_GROUND);
|
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
|
||||||
m_bg_color = c_my_resource::get_color(CTRL_BACK_GROUND);
|
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_list_box::on_focus()
|
void c_list_box::on_focus()
|
||||||
|
|
|
@ -67,16 +67,6 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
|
||||||
new_surface->set_active(false);
|
new_surface->set_active(false);
|
||||||
set_surface(new_surface);
|
set_surface(new_surface);
|
||||||
slide->connect(this, resource_id ,0 , x, y, width, height, p_child_tree);
|
slide->connect(this, resource_id ,0 , x, y, width, height, p_child_tree);
|
||||||
|
|
||||||
c_rect rect_this, rect_page;
|
|
||||||
get_screen_rect(rect_this);
|
|
||||||
slide->get_screen_rect(rect_page);
|
|
||||||
if (!(rect_page == rect_this))
|
|
||||||
{
|
|
||||||
ASSERT(FALSE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_surface(old_surface);
|
set_surface(old_surface);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -85,7 +75,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
|
||||||
if(m_slides[i] == slide)
|
if(m_slides[i] == slide)
|
||||||
{//slide has lived
|
{//slide has lived
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return -3;
|
return -2;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +95,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
|
||||||
|
|
||||||
//no more slide can be add
|
//no more slide can be add
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return -4;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
|
int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
|
||||||
|
@ -121,16 +111,6 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
|
||||||
new_surface->set_active(false);
|
new_surface->set_active(false);
|
||||||
set_surface(new_surface);
|
set_surface(new_surface);
|
||||||
c_wnd* page_tmp = slide->connect_clone(this,resource_id,0,x,y,width,height,p_child_tree);
|
c_wnd* page_tmp = slide->connect_clone(this,resource_id,0,x,y,width,height,p_child_tree);
|
||||||
|
|
||||||
c_rect rect_this, rect_page;
|
|
||||||
get_screen_rect(rect_this);
|
|
||||||
page_tmp->get_screen_rect(rect_page);
|
|
||||||
if (!(rect_page == rect_this))
|
|
||||||
{
|
|
||||||
ASSERT(FALSE);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_surface(old_surface);
|
set_surface(old_surface);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -139,7 +119,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
|
||||||
if(m_slides[i] == page_tmp)
|
if(m_slides[i] == page_tmp)
|
||||||
{//slide has lived
|
{//slide has lived
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return -3;
|
return -2;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +139,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
|
||||||
|
|
||||||
//no more slide can be add
|
//no more slide can be add
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return -4;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void c_slide_group::disabel_all_slide()
|
void c_slide_group::disabel_all_slide()
|
||||||
|
|
|
@ -22,8 +22,8 @@ void c_spin_box::pre_create_wnd()
|
||||||
{
|
{
|
||||||
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
|
||||||
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
|
||||||
m_bg_color = c_my_resource::get_color(CTRL_BACK_GROUND);
|
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
|
||||||
m_font_color = c_my_resource::get_color(CTRL_FORE_GROUND);
|
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
|
||||||
|
|
||||||
m_max = 6;
|
m_max = 6;
|
||||||
m_min = 1;
|
m_min = 1;
|
||||||
|
@ -122,15 +122,15 @@ void c_spin_box::show_arrow_button()
|
||||||
fill_rect(m_bt_up_rect.m_left, m_bt_up_rect.m_top, m_bt_down_rect.m_right, m_bt_down_rect.m_bottom, GL_RGB(99,108,124));
|
fill_rect(m_bt_up_rect.m_left, m_bt_up_rect.m_top, m_bt_down_rect.m_right, m_bt_down_rect.m_bottom, GL_RGB(99,108,124));
|
||||||
|
|
||||||
m_bt_up.connect(this, ID_BT_ARROW_UP, 0, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
|
m_bt_up.connect(this, ID_BT_ARROW_UP, 0, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
|
||||||
m_bt_up.set_bitmap(c_my_resource::get_bmp(BITMAP_UP_BT_NORMAL));
|
m_bt_up.set_bitmap(c_my_resource::get_bmp(BITMAP_UP_ARROW1));
|
||||||
m_bt_up.set_focus_bitmap(c_my_resource::get_bmp(BITMAP_UP_BT_FOCUS));
|
m_bt_up.set_focus_bitmap(c_my_resource::get_bmp(BITMAP_UP_ARROW2));
|
||||||
m_bt_up.set_pushed_bitmap(c_my_resource::get_bmp(BITMAP_UP_BT_FOCUS));
|
m_bt_up.set_pushed_bitmap(c_my_resource::get_bmp(BITMAP_UP_ARROW2));
|
||||||
m_bt_up.show_window();
|
m_bt_up.show_window();
|
||||||
|
|
||||||
m_bt_down.connect(this, ID_BT_ARROW_DOWN, 0, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
|
m_bt_down.connect(this, ID_BT_ARROW_DOWN, 0, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
|
||||||
m_bt_down.set_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_BT_NORMAL));
|
m_bt_down.set_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_ARROW1));
|
||||||
m_bt_down.set_focus_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_BT_FOCUS));
|
m_bt_down.set_focus_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_ARROW2));
|
||||||
m_bt_down.set_pushed_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_BT_FOCUS));
|
m_bt_down.set_pushed_bitmap(c_my_resource::get_bmp(BITMAP_DOWN_ARROW2));
|
||||||
m_bt_down.show_window();
|
m_bt_down.show_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,5 @@ set raw_data=[{^
|
||||||
|
|
||||||
curl.exe --include --request POST --header "Content-Type: application/json" --data-binary^
|
curl.exe --include --request POST --header "Content-Type: application/json" --data-binary^
|
||||||
"%raw_data%" "%url%"
|
"%raw_data%" "%url%"
|
||||||
|
|
||||||
|
exit /B 0
|
Loading…
Reference in New Issue