diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6c8b5a..1afb164 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,15 +4,15 @@ PROJECT(GuiLite)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
-INCLUDE_DIRECTORIES(core widgets)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
# core
-FILE(GLOB CORE_SRC core/src/*.cpp)
-FILE(GLOB CORE_ADAPTER core/src/adapter/api_linux.cpp
- core/src/adapter/audio_linux.cpp
- core/src/adapter/msg_linux.cpp)
+FILE(GLOB CORE_SRC core/*.cpp)
+FILE(GLOB CORE_ADAPTER core/adapter/api_linux.cpp
+ core/adapter/audio_linux.cpp
+ core/adapter/msg_linux.cpp)
# gui
-FILE(GLOB WIDGETS_SRC widgets/src/*.cpp)
+FILE(GLOB WIDGETS_SRC widgets/*.cpp)
# build static library
ADD_LIBRARY(GuiLite STATIC ${CORE_SRC} ${CORE_ADAPTER} ${WIDGETS_SRC})
diff --git a/GuiLite.uvprojx b/GuiLite.uvprojx
index cff8452..f26d0e7 100644
--- a/GuiLite.uvprojx
+++ b/GuiLite.uvprojx
@@ -338,7 +338,7 @@
- .\core
+ ./
@@ -385,52 +385,52 @@
bitmap.cpp
8
- .\core\src\bitmap.cpp
+ .\core\bitmap.cpp
cmd_target.cpp
8
- .\core\src\cmd_target.cpp
+ .\core\cmd_target.cpp
display.cpp
8
- .\core\src\display.cpp
+ .\core\display.cpp
rect.cpp
8
- .\core\src\rect.cpp
+ .\core\rect.cpp
surface.cpp
8
- .\core\src\surface.cpp
-
-
- wnd.cpp
- 8
- .\core\src\wnd.cpp
-
-
- word.cpp
- 8
- .\core\src\word.cpp
-
-
- api_unknow.cpp
- 8
- .\core\src\adapter\api_unknow.cpp
-
-
- msg_unknow.cpp
- 8
- .\core\src\adapter\msg_unknow.cpp
+ .\core\surface.cpp
theme.cpp
8
- .\core\src\theme.cpp
+ .\core\theme.cpp
+
+
+ wnd.cpp
+ 8
+ .\core\wnd.cpp
+
+
+ word.cpp
+ 8
+ .\core\word.cpp
+
+
+ api_unknow.cpp
+ 8
+ .\core\adapter\api_unknow.cpp
+
+
+ msg_unknow.cpp
+ 8
+ .\core\adapter\msg_unknow.cpp
@@ -440,22 +440,22 @@
button.cpp
8
- .\widgets\src\button.cpp
+ .\widgets\button.cpp
label.cpp
8
- .\widgets\src\label.cpp
+ .\widgets\label.cpp
wave_buffer.cpp
8
- .\widgets\src\wave_buffer.cpp
+ .\widgets\wave_buffer.cpp
wave_ctrl.cpp
8
- .\widgets\src\wave_ctrl.cpp
+ .\widgets\wave_ctrl.cpp
diff --git a/GuiLite.vcxproj b/GuiLite.vcxproj
index eaa94bf..00e41e1 100644
--- a/GuiLite.vcxproj
+++ b/GuiLite.vcxproj
@@ -115,7 +115,7 @@
- core;widgets;%(AdditionalIncludeDirectories)
+ $(SolutionDir);%(AdditionalIncludeDirectories)
Debug/
EnableFastChecks
CompileAsCpp
@@ -151,7 +151,7 @@
- core;widgets;%(AdditionalIncludeDirectories)
+ $(SolutionDir);%(AdditionalIncludeDirectories)
Debug/
EnableFastChecks
CompileAsCpp
@@ -187,7 +187,7 @@
- core;widgets;%(AdditionalIncludeDirectories)
+ $(SolutionDir);%(AdditionalIncludeDirectories)
Release/
CompileAsCpp
Sync
@@ -223,7 +223,7 @@
- core;widgets;%(AdditionalIncludeDirectories)
+ $(SolutionDir);%(AdditionalIncludeDirectories)
Release/
CompileAsCpp
Sync
@@ -388,29 +388,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GuiLite.vcxproj.filters b/GuiLite.vcxproj.filters
index 1b3a9b7..9a0f08d 100644
--- a/GuiLite.vcxproj.filters
+++ b/GuiLite.vcxproj.filters
@@ -1,75 +1,75 @@
-
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ widgets
+
+
+ core
+
+
+ core
+
+
+ core
+
+
+ core
+
+
+ core
+
+
+ core
+
+
+ core
+
+
+ core
+
+
core\adapter
-
+
core\adapter
-
+
core\adapter
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- widgets
-
-
- core
-
-
- core
-
-
- core
-
-
- core
-
-
- core
-
-
- core
-
-
- core
-
-
- core
-
diff --git a/README.md b/README.md
index f404374..6869c18 100644
--- a/README.md
+++ b/README.md
@@ -16,10 +16,11 @@
- ⚙️希望GuiLite小到足够帮助大家掌握UI工作原理,从而摆脱UI框架的束缚,构建自己独一无二的UI
- 👑任何UI框架都不为你我而生,你才是自己真正的主人
-## 🔥新功能:星空效果
-
-- Hello Star 仅有[100+行代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloStar/UIcode/UIcode.cpp),用于向开发者展示:如何使用GuiLite开发“星空”效果。
-- 支持:MCU / Windows / Linux
+## 🔥新功能:控件的应用
+
+
+Hello Widgets 仅有[100多行代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloWidgets/UIcode/UIcode.cpp),用于向初学者展示:如何使用GuiLite自带的控件。
+- 支持:Windows / Linux
## 功能介绍
### 卓越的跨平台能力
@@ -63,7 +64,7 @@ GuiLite只是一个框架,本身并不能生成UI。为了能够展示如何
| HelloStar | Windows, Linux, STM32F103, STM32F429 | 星空效果的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloStar/README.md) | ★|
| HelloGuiLite | Windows, Linux | 初始化GuiLite,加载资源,布局界面元素,按钮响应 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloGuiLite/README.md) | ★★|
| HelloMario | Windows, Linux, STM32F103, STM32F429 | 多图层的UI系统 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloMario/README.md) | ★★|
-| HelloNavigation | Windows, Linux, STM32F103, STM32F429 | 用于非触摸屏场景,通过硬按键进行UI“导航” | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloNavigation/README.md) | ★★|
+| HelloNoTouch | Windows, Linux, STM32F103, STM32F429 | 用于非触摸屏场景,通过硬按键进行UI“导航” | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloNoTouch/README.md) | ★★|
| HelloFont | Windows, Linux | 显示多种语言(不限:中、英文) | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloFont/README.md) | ★★|
| HelloAnimation | Windows, Linux | 动画的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloAnimation/README.md) | ★★|
| HelloSlide | Windows, Linux | 滑屏界面的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloSlide/README.md) | ★★★|
diff --git a/core/src/adapter/api_linux.cpp b/core/adapter/api_linux.cpp
similarity index 100%
rename from core/src/adapter/api_linux.cpp
rename to core/adapter/api_linux.cpp
diff --git a/core/src/adapter/api_unknow.cpp b/core/adapter/api_unknow.cpp
similarity index 100%
rename from core/src/adapter/api_unknow.cpp
rename to core/adapter/api_unknow.cpp
diff --git a/core/src/adapter/api_win.cpp b/core/adapter/api_win.cpp
similarity index 100%
rename from core/src/adapter/api_win.cpp
rename to core/adapter/api_win.cpp
diff --git a/core/src/adapter/audio_linux.cpp b/core/adapter/audio_linux.cpp
similarity index 100%
rename from core/src/adapter/audio_linux.cpp
rename to core/adapter/audio_linux.cpp
diff --git a/core/src/adapter/audio_win.cpp b/core/adapter/audio_win.cpp
similarity index 100%
rename from core/src/adapter/audio_win.cpp
rename to core/adapter/audio_win.cpp
diff --git a/core/src/adapter/msg_linux.cpp b/core/adapter/msg_linux.cpp
similarity index 100%
rename from core/src/adapter/msg_linux.cpp
rename to core/adapter/msg_linux.cpp
diff --git a/core/src/adapter/msg_unknow.cpp b/core/adapter/msg_unknow.cpp
similarity index 100%
rename from core/src/adapter/msg_unknow.cpp
rename to core/adapter/msg_unknow.cpp
diff --git a/core/src/adapter/msg_win.cpp b/core/adapter/msg_win.cpp
similarity index 100%
rename from core/src/adapter/msg_win.cpp
rename to core/adapter/msg_win.cpp
diff --git a/core/src/bitmap.cpp b/core/bitmap.cpp
similarity index 100%
rename from core/src/bitmap.cpp
rename to core/bitmap.cpp
diff --git a/core/src/cmd_target.cpp b/core/cmd_target.cpp
similarity index 100%
rename from core/src/cmd_target.cpp
rename to core/cmd_target.cpp
diff --git a/core/src/display.cpp b/core/display.cpp
similarity index 100%
rename from core/src/display.cpp
rename to core/display.cpp
diff --git a/core/src/rect.cpp b/core/rect.cpp
similarity index 100%
rename from core/src/rect.cpp
rename to core/rect.cpp
diff --git a/core/src/surface.cpp b/core/surface.cpp
similarity index 100%
rename from core/src/surface.cpp
rename to core/surface.cpp
diff --git a/core/src/theme.cpp b/core/theme.cpp
similarity index 100%
rename from core/src/theme.cpp
rename to core/theme.cpp
diff --git a/core/src/wnd.cpp b/core/wnd.cpp
similarity index 85%
rename from core/src/wnd.cpp
rename to core/wnd.cpp
index 07d573a..80731f7 100644
--- a/core/src/wnd.cpp
+++ b/core/wnd.cpp
@@ -7,7 +7,7 @@
#include "../core_include/wnd.h"
c_wnd::c_wnd(): m_status(STATUS_NORMAL), m_style(GL_ATTR_VISIBLE), m_parent(NULL), m_top_child(NULL), m_prev_sibling(NULL), m_next_sibling(NULL),
- m_str(0), m_font_color(0), m_bg_color(0), m_resource_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(NULL), m_surface(NULL)
+m_str(0), m_font_color(0), m_bg_color(0), m_resource_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(NULL), m_surface(NULL)
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS;
}
@@ -22,6 +22,7 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
}
m_resource_id = resource_id;
+ set_str(str);
m_parent = parent;
m_status = STATUS_NORMAL;
@@ -47,7 +48,6 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
ASSERT(m_surface->is_valid(rect));
pre_create_wnd();
- set_str(str);
if ( 0 != parent )
{
@@ -100,6 +100,7 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
c_wnd* wnd = clone();
wnd->m_resource_id = resource_id;
+ wnd->set_str(str);
wnd->m_parent = parent;
wnd->m_status = STATUS_NORMAL;
@@ -129,8 +130,7 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
ASSERT(wnd->m_surface->is_valid(rect));
wnd->pre_create_wnd();
- wnd->set_str(str);
-
+
if ( 0 != parent )
{
parent->add_child_2_tail(wnd);
@@ -208,10 +208,9 @@ c_wnd* c_wnd::get_wnd_ptr(unsigned short id) const
return child;
}
-void c_wnd::modify_style(unsigned int add_style, unsigned int remove_style)
+void c_wnd::set_style(unsigned int style)
{
- m_style &= ~remove_style;
- m_style |= add_style;
+ m_style = style;
if ( GL_ATTR_DISABLED == (m_style & GL_ATTR_DISABLED) )
{
@@ -342,37 +341,6 @@ c_wnd* c_wnd::set_child_focus(c_wnd * focus_child)
return m_focus_child;
}
-int c_wnd::on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_param)
-{
- const GL_MSG_ENTRY *entry = FindMsgEntry(GetMSgEntries(), MSG_TYPE_WND, notify_code, ctrl_id);
- if ( NULL != entry )
- {
- MSGFUNCS msg_funcs;
- msg_funcs.func = entry->func;
-
- switch ( entry->callbackType)
- {
- case MSG_CALLBACK_VV:
- (this->*msg_funcs.func)();
- break;
- case MSG_CALLBACK_VVL:
- (this->*msg_funcs.func_vvl)(l_param);
- break;
- case MSG_CALLBACK_VWV:
- (this->*msg_funcs.func_vwv)(ctrl_id);
- break;
- case MSG_CALLBACK_VWL:
- (this->*msg_funcs.func_vwl)(ctrl_id, l_param);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
- return TRUE;
- }
- return FALSE;
-}
-
void c_wnd::add_child_2_tail(c_wnd *child)
{
if( NULL == child )return;
@@ -499,24 +467,36 @@ bool c_wnd::on_touch(int x, int y, TOUCH_ACTION action)
c_rect rect;
x -= m_wnd_rect.m_left;
y -= m_wnd_rect.m_top;
- c_wnd *pChild = m_top_child;
+ c_wnd* child = m_top_child;
- while ( pChild )
+ c_wnd* target_wnd = NULL;
+ int target_z_order = Z_ORDER_LEVEL_0;
+
+ while (child)
{
- if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE))
+ if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
{
- pChild->get_wnd_rect(rect);
- if ( TRUE == rect.PtInRect(x, y) )
+ child->get_wnd_rect(rect);
+ if (TRUE == rect.PtInRect(x, y) || child->m_style & GL_ATTR_PRIORITY)
{
- if ( TRUE == pChild->is_focus_wnd() )
+ if (TRUE == child->is_focus_wnd())
{
- pChild->on_touch(x, y, action);
+ if (child->m_z_order >= target_z_order)
+ {
+ target_wnd = child;
+ target_z_order = child->m_z_order;
+ }
}
}
}
- pChild = pChild->m_next_sibling;
+ child = child->m_next_sibling;
}
- return true;
+
+ if (target_wnd == NULL)
+ {
+ return false;
+ }
+ return target_wnd->on_touch(x, y, action);
}
bool c_wnd::on_key(KEY_TYPE key)
@@ -541,21 +521,21 @@ bool c_wnd::on_key(KEY_TYPE key)
}
if (!old_focus_wnd)
{// No current focus wnd, new one.
- c_wnd *pChild = m_top_child;
+ c_wnd *child = m_top_child;
c_wnd *new_focus_wnd = NULL;
- while (pChild)
+ while (child)
{
- if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE))
+ if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
{
- if (TRUE == pChild->is_focus_wnd())
+ if (TRUE == child->is_focus_wnd())
{
- new_focus_wnd = pChild;
+ new_focus_wnd = child;
new_focus_wnd->m_parent->set_child_focus(new_focus_wnd);
- pChild = pChild->m_top_child;
+ child = child->m_top_child;
continue;
}
}
- pChild = pChild->m_next_sibling;
+ child = child->m_next_sibling;
}
return true;
}
@@ -581,10 +561,37 @@ bool c_wnd::on_key(KEY_TYPE key)
return true;
}
-void c_wnd::notify_parent(unsigned short msg_id, unsigned int w_param, long l_param)
+void c_wnd::notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param)
{
- if (m_parent)
+ if (!m_parent)
{
- m_parent->on_notify(msg_id, w_param, l_param);
+ return;
+ }
+ const GL_MSG_ENTRY* entry = m_parent->FindMsgEntry(m_parent->GetMSgEntries(), MSG_TYPE_WND, msg_id, ctrl_id);
+ if (NULL == entry)
+ {
+ return;
+ }
+
+ MSGFUNCS msg_funcs;
+ msg_funcs.func = entry->func;
+
+ switch (entry->callbackType)
+ {
+ case MSG_CALLBACK_VV:
+ (m_parent->*msg_funcs.func)();
+ break;
+ case MSG_CALLBACK_VVL:
+ (m_parent->*msg_funcs.func_vvl)(param);
+ break;
+ case MSG_CALLBACK_VWV:
+ (m_parent->*msg_funcs.func_vwv)(ctrl_id);
+ break;
+ case MSG_CALLBACK_VWL:
+ (m_parent->*msg_funcs.func_vwl)(ctrl_id, param);
+ break;
+ default:
+ ASSERT(FALSE);
+ break;
}
}
diff --git a/core/src/word.cpp b/core/word.cpp
similarity index 100%
rename from core/src/word.cpp
rename to core/word.cpp
diff --git a/core/core_include/api.h b/core_include/api.h
similarity index 100%
rename from core/core_include/api.h
rename to core_include/api.h
diff --git a/core/core_include/audio.h b/core_include/audio.h
similarity index 100%
rename from core/core_include/audio.h
rename to core_include/audio.h
diff --git a/core/core_include/bitmap.h b/core_include/bitmap.h
similarity index 90%
rename from core/core_include/bitmap.h
rename to core_include/bitmap.h
index 93a8f4f..00ad63f 100644
--- a/core/core_include/bitmap.h
+++ b/core_include/bitmap.h
@@ -12,11 +12,6 @@ private:
static void draw_bitmap_565(c_surface* surface, int z_order, int x, int y, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
static void get_bitmap_pos(const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, int &x, int &y);
static void draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, int y, int width, int height, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
-
- c_bitmap(){}
- c_bitmap(const c_bitmap&);
- c_bitmap& operator=(const c_bitmap&);
- ~c_bitmap(){}
};
#endif
diff --git a/core/core_include/cmd_target.h b/core_include/cmd_target.h
similarity index 100%
rename from core/core_include/cmd_target.h
rename to core_include/cmd_target.h
diff --git a/core/core_include/display.h b/core_include/display.h
similarity index 100%
rename from core/core_include/display.h
rename to core_include/display.h
diff --git a/core/core_include/msg.h b/core_include/msg.h
similarity index 100%
rename from core/core_include/msg.h
rename to core_include/msg.h
diff --git a/core/core_include/rect.h b/core_include/rect.h
similarity index 100%
rename from core/core_include/rect.h
rename to core_include/rect.h
diff --git a/core/core_include/resource.h b/core_include/resource.h
similarity index 100%
rename from core/core_include/resource.h
rename to core_include/resource.h
diff --git a/core/core_include/surface.h b/core_include/surface.h
similarity index 100%
rename from core/core_include/surface.h
rename to core_include/surface.h
diff --git a/core/core_include/theme.h b/core_include/theme.h
similarity index 93%
rename from core/core_include/theme.h
rename to core_include/theme.h
index 5ee60e1..7f5f68a 100644
--- a/core/core_include/theme.h
+++ b/core_include/theme.h
@@ -21,11 +21,6 @@ enum FONT_TYPE
enum BITMAP_TYPE
{
- BITMAP_UP_ARROW1,
- BITMAP_UP_ARROW2,
- BITMAP_DOWN_ARROW1,
- BITMAP_DOWN_ARROW2,
-
BITMAP_CUSTOM1,
BITMAP_CUSTOM2,
BITMAP_CUSTOM3,
diff --git a/core/core_include/wnd.h b/core_include/wnd.h
similarity index 89%
rename from core/core_include/wnd.h
rename to core_include/wnd.h
index d7da42b..fba16a9 100644
--- a/core/core_include/wnd.h
+++ b/core_include/wnd.h
@@ -5,6 +5,7 @@
#define GL_ATTR_VISIBLE 0x80000000L
#define GL_ATTR_DISABLED 0x40000000L
#define GL_ATTR_FOCUS 0x20000000L
+#define GL_ATTR_PRIORITY 0x10000000L// Handle touch action at high priority
typedef struct struct_font_info FONT_INFO;
typedef struct struct_color_rect COLOR_RECT;
@@ -66,7 +67,7 @@ public:
int get_z_order() { return m_z_order; }
c_wnd* get_wnd_ptr(unsigned short id) const;
unsigned int get_style() const { return m_style; }
- virtual void modify_style(unsigned int add_style = 0, unsigned int remove_style = 0);
+ void set_style(unsigned int style);
void set_str(const char* str) { m_str = str; }
int is_focus_wnd() const;
@@ -90,11 +91,10 @@ public:
c_wnd* get_prev_sibling() const { return m_prev_sibling; }
c_wnd* get_next_sibling() const { return m_next_sibling; }
- void notify_parent(unsigned short msg_id, unsigned int w_param, long l_param);
- virtual int on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_param);
+ void notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param);
- virtual bool on_touch(int x, int y, TOUCH_ACTION action);
- virtual bool on_key(KEY_TYPE key);
+ virtual bool on_touch(int x, int y, TOUCH_ACTION action);// return true: handled; false: not be handled.
+ virtual bool on_key(KEY_TYPE key);// return false: skip handling by parent;
c_surface* get_surface() { return m_surface; }
void set_surface(c_surface* surface) { m_surface = surface; }
@@ -116,7 +116,7 @@ protected:
protected:
WND_STATUS m_status;
unsigned int m_style;
- c_rect m_wnd_rect;//position relative to parent wnd.
+ c_rect m_wnd_rect;// position relative to parent wnd.
c_wnd* m_parent;
c_wnd* m_top_child;
c_wnd* m_prev_sibling;
diff --git a/core/core_include/word.h b/core_include/word.h
similarity index 94%
rename from core/core_include/word.h
rename to core_include/word.h
index d9d5b56..26eca7f 100644
--- a/core/core_include/word.h
+++ b/core_include/word.h
@@ -18,11 +18,6 @@ private:
static const LATTICE* get_lattice(const FONT_INFO* font, unsigned int utf8_code);
static void get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y);
-private:
- c_word(){};
- c_word(const c_word&);
- c_word& operator=(const c_word&);
- ~c_word(){}
};
#endif
diff --git a/doc/HelloMario.gif b/doc/HelloMario.gif
deleted file mode 100644
index a73424c..0000000
Binary files a/doc/HelloMario.gif and /dev/null differ
diff --git a/doc/HelloNavigation.gif b/doc/HelloNavigation.gif
deleted file mode 100644
index 6f474b8..0000000
Binary files a/doc/HelloNavigation.gif and /dev/null differ
diff --git a/doc/HelloSlide.gif b/doc/HelloSlide.gif
deleted file mode 100644
index d92f2b0..0000000
Binary files a/doc/HelloSlide.gif and /dev/null differ
diff --git a/doc/HelloWidgets.gif b/doc/HelloWidgets.gif
new file mode 100644
index 0000000..4d59ee8
Binary files /dev/null and b/doc/HelloWidgets.gif differ
diff --git a/doc/MCU.gif b/doc/MCU.gif
deleted file mode 100644
index 414097f..0000000
Binary files a/doc/MCU.gif and /dev/null differ
diff --git a/widgets/src/button.cpp b/widgets/button.cpp
similarity index 97%
rename from widgets/src/button.cpp
rename to widgets/button.cpp
index 6ef9ea8..25850ca 100644
--- a/widgets/src/button.cpp
+++ b/widgets/button.cpp
@@ -42,7 +42,7 @@ bool c_button::on_touch(int x, int y, TOUCH_ACTION action)
on_paint();
notify_parent(GL_BN_CLICKED, get_id(), 0);
}
- return false;// Do not handle TOUCH_ACTION by other wnd.
+ return true;
}
bool c_button::on_key(KEY_TYPE key)
diff --git a/widgets/src/dialog.cpp b/widgets/dialog.cpp
similarity index 75%
rename from widgets/src/dialog.cpp
rename to widgets/dialog.cpp
index 416a3b1..65e734d 100644
--- a/widgets/src/dialog.cpp
+++ b/widgets/dialog.cpp
@@ -2,22 +2,17 @@
#include "core_include/rect.h"
#include "core_include/cmd_target.h"
#include "core_include/wnd.h"
-#include "core_include/msg.h"
#include "core_include/surface.h"
#include "core_include/display.h"
#include "core_include/resource.h"
-#include "core_include/bitmap.h"
#include "core_include/word.h"
#include "core_include/theme.h"
-#include "../widgets_include/button.h"
-#include "../widgets_include/dialog.h"
-
-#include
+#include "widgets_include/dialog.h"
DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX];
void c_dialog::pre_create_wnd()
{
- m_style = GL_ATTR_FOCUS;
+ m_style = 0;// no focus/visible
m_z_order = Z_ORDER_LEVEL_1;
m_bg_color = GL_RGB(33, 42, 53);
}
@@ -61,14 +56,14 @@ int c_dialog::open_dialog(c_dialog* p_dlg)
if(cur_dlg)
{
- cur_dlg->modify_style(0, GL_ATTR_VISIBLE);
+ cur_dlg->set_style(0);
}
c_rect rc;
p_dlg->get_screen_rect(rc);
p_dlg->get_surface()->set_frame_layer(rc, Z_ORDER_LEVEL_1);
- p_dlg->modify_style(GL_ATTR_VISIBLE, 0);
+ p_dlg->set_style(GL_ATTR_VISIBLE | GL_ATTR_FOCUS | GL_ATTR_PRIORITY);
p_dlg->show_window();
p_dlg->set_me_the_dialog();
return 1;
@@ -84,7 +79,7 @@ int c_dialog::close_dialog(c_surface* surface)
}
c_rect rc;
- dlg->modify_style(0, GL_ATTR_VISIBLE);
+ dlg->set_style(0);
surface->set_frame_layer(rc, dlg->m_z_order);
//clear the dialog
@@ -100,29 +95,6 @@ int c_dialog::close_dialog(c_surface* surface)
return -1;
}
-bool c_dialog::on_touch(int x, int y, TOUCH_ACTION action)
-{
- c_wnd *child = m_top_child;
- c_rect rect;
- get_wnd_rect(rect);
-
- if ( NULL != child )
- {
- while ( child )
- {
- if (child->m_z_order > m_z_order)
- {
- x -= rect.m_left;
- y -= rect.m_top;
- child->on_touch(x, y, action);
- return true;
- }
- child = child->m_next_sibling;
- }
- }
- return c_wnd::on_touch(x, y, action);
-}
-
int c_dialog::set_me_the_dialog()
{
c_surface* surface = get_surface();
diff --git a/widgets/src/edit.cpp b/widgets/edit.cpp
similarity index 97%
rename from widgets/src/edit.cpp
rename to widgets/edit.cpp
index 61d2795..838e948 100644
--- a/widgets/src/edit.cpp
+++ b/widgets/edit.cpp
@@ -30,6 +30,7 @@ void c_edit::pre_create_wnd()
memset(m_str_input, 0, sizeof(m_str_input));
memset(m_str, 0, sizeof(m_str));
+ set_text(c_wnd::m_str);
}
void c_edit::set_text(const char* str)
@@ -123,6 +124,7 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
+ m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
break;
@@ -132,6 +134,7 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
+ m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
break;
@@ -139,6 +142,7 @@ void c_edit::on_paint()
if (m_z_order == m_parent->get_z_order())
{
m_z_order++;
+ m_style |= GL_ATTR_PRIORITY;
show_keyboard();
}
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
diff --git a/widgets/src/gesture.cpp b/widgets/gesture.cpp
similarity index 100%
rename from widgets/src/gesture.cpp
rename to widgets/gesture.cpp
diff --git a/widgets/src/keyboard.cpp b/widgets/keyboard.cpp
similarity index 100%
rename from widgets/src/keyboard.cpp
rename to widgets/keyboard.cpp
diff --git a/widgets/src/label.cpp b/widgets/label.cpp
similarity index 100%
rename from widgets/src/label.cpp
rename to widgets/label.cpp
diff --git a/widgets/src/list_box.cpp b/widgets/list_box.cpp
similarity index 96%
rename from widgets/src/list_box.cpp
rename to widgets/list_box.cpp
index 008d202..d7b77cd 100644
--- a/widgets/src/list_box.cpp
+++ b/widgets/list_box.cpp
@@ -40,7 +40,6 @@ void c_list_box::on_paint()
{
c_rect rect, empty_rect;
get_screen_rect(rect);
- empty_rect.Empty();
switch(m_status)
{
@@ -49,6 +48,7 @@ void c_list_box::on_paint()
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
+ m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
break;
@@ -57,6 +57,7 @@ void c_list_box::on_paint()
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
+ m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
break;
@@ -72,6 +73,7 @@ void c_list_box::on_paint()
m_z_order++;
}
m_surface->set_frame_layer(m_list_screen_rect, m_z_order);
+ m_style |= GL_ATTR_PRIORITY;
show_list();
return;
}
@@ -113,7 +115,7 @@ void c_list_box::on_touch_down(int x, int y)
{
m_status = STATUS_FOCUSED;
on_paint();
- notify_parent(GL_LIST_CONFIRM, get_id(), 0);
+ notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
}
}
}
@@ -124,7 +126,6 @@ void c_list_box::on_touch_up(int x, int y)
{
m_status = STATUS_PUSHED;
on_paint();
- notify_parent(GL_LIST_SELECT, get_id(), 0);
}
else if (STATUS_PUSHED == m_status)
{
@@ -138,7 +139,7 @@ void c_list_box::on_touch_up(int x, int y)
m_status = STATUS_FOCUSED;
select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT);
on_paint();
- notify_parent(GL_LIST_CONFIRM, get_id(), 0);
+ notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
}
else
{
diff --git a/widgets/src/slide_group.cpp b/widgets/slide_group.cpp
similarity index 100%
rename from widgets/src/slide_group.cpp
rename to widgets/slide_group.cpp
diff --git a/widgets/src/spinbox.cpp b/widgets/spinbox.cpp
similarity index 64%
rename from widgets/src/spinbox.cpp
rename to widgets/spinbox.cpp
index d237b04..464cdf1 100644
--- a/widgets/src/spinbox.cpp
+++ b/widgets/spinbox.cpp
@@ -1,4 +1,4 @@
-#include "core_include/api.h"
+#include "core_include/api.h"
#include "core_include/rect.h"
#include "core_include/cmd_target.h"
#include "core_include/wnd.h"
@@ -47,65 +47,39 @@ void c_spin_box::pre_create_wnd()
bool c_spin_box::on_touch(int x, int y, TOUCH_ACTION action)
{
(action == TOUCH_DOWN) ? on_touch_down(x, y) : on_touch_up(x, y);
- return true;
+ return c_wnd::on_touch(x, y, action);
}
void c_spin_box::on_touch_down(int x, int y)
{
- c_rect arrow_rect = m_wnd_rect;
- arrow_rect.m_right = m_bt_down_rect.m_right;
- arrow_rect.m_bottom = m_bt_down_rect.m_bottom;
-
- if ( TRUE == m_wnd_rect.PtInRect(x, y) )
- {//click spin box
- if (STATUS_NORMAL == m_status)
- {
- m_parent->set_child_focus(this);
- }
+ if (FALSE == m_wnd_rect.PtInRect(x, y))
+ {//maybe click on up/down arrow button
+ return;
}
- else if (TRUE == arrow_rect.PtInRect(x, y))
- {//click arrow button
- c_wnd::on_touch(x, y, TOUCH_DOWN);
- }
- else
- {//click invalid place.
- if (STATUS_PUSHED == m_status)
- {
- if (m_value != m_cur_value)
- {
- m_value = m_cur_value;
- }
- m_status = STATUS_FOCUSED;
- on_paint();
- notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
- }
+ if (STATUS_NORMAL == m_status)
+ {
+ m_parent->set_child_focus(this);
}
}
void c_spin_box::on_touch_up(int x, int y)
{
+ if (FALSE == m_wnd_rect.PtInRect(x, y))
+ {//maybe click on up/down arrow button
+ return;
+ }
+
if (STATUS_FOCUSED == m_status)
{
m_status = STATUS_PUSHED;
on_paint();
- notify_parent(GL_SPIN_SELECT, get_id(), 0);
}
else if (STATUS_PUSHED == m_status)
{
- if (m_wnd_rect.PtInRect(x, y))
- {//click spin box.
- if (m_value != m_cur_value)
- {
- m_value = m_cur_value;
- }
- m_status = STATUS_FOCUSED;
- on_paint();
- notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
- }
- else
- {//click arrow button.
- c_wnd::on_touch(x, y, TOUCH_UP);
- }
+ m_value = m_cur_value;
+ m_status = STATUS_FOCUSED;
+ on_paint();
+ notify_parent(GL_SPIN_CONFIRM, get_id(), m_value);
}
}
@@ -124,30 +98,24 @@ void c_spin_box::on_kill_focus()
void c_spin_box::show_arrow_button()
{
- m_surface->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_z_order);
-
- 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_theme::get_bmp(BITMAP_UP_ARROW1));
- m_bt_up.set_focus_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
- m_bt_up.set_pushed_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
+ m_bt_up.connect(this, ID_BT_ARROW_UP, "\xe2\x96\xb2"/*▲*/, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
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.set_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW1));
- m_bt_down.set_focus_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
- m_bt_down.set_pushed_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
+ m_bt_down.connect(this, ID_BT_ARROW_DOWN, "\xe2\x96\xbc"/*▼*/, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
m_bt_down.show_window();
+
+ m_style |= GL_ATTR_PRIORITY;
}
void c_spin_box::hide_arrow_button()
{
m_bt_up.disconnect();
m_bt_down.disconnect();
+ m_style &= ~GL_ATTR_PRIORITY;
}
void c_spin_box::on_paint()
{
- c_rect rect,tmp_rect;
+ c_rect rect, tmp_rect, empty_rect;
get_screen_rect(rect);
tmp_rect.m_left = rect.m_left;
tmp_rect.m_right = rect.m_right;
@@ -158,8 +126,7 @@ void c_spin_box::on_paint()
if (m_z_order > m_parent->get_z_order())
{
hide_arrow_button();
- tmp_rect.Empty();
- m_surface->set_frame_layer(tmp_rect, m_z_order);
+ m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
@@ -168,8 +135,7 @@ void c_spin_box::on_paint()
if (m_z_order > m_parent->get_z_order())
{
hide_arrow_button();
- tmp_rect.Empty();
- m_surface->set_frame_layer(tmp_rect, m_z_order);
+ m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
@@ -199,26 +165,22 @@ void c_spin_box::on_paint()
void c_spin_box::on_arrow_up_bt_click(unsigned int ctr_id)
{
+ if (m_cur_value + m_step > m_max)
+ {
+ return;
+ }
m_cur_value += m_step;
- if (m_cur_value > m_max)
- {
- m_cur_value = m_max;
- }
- else
- {
- on_paint();
- }
+ notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
+ on_paint();
}
void c_spin_box::on_arrow_down_bt_click(unsigned int ctr_id)
{
+ if (m_cur_value - m_step < m_min)
+ {
+ return;
+ }
m_cur_value -= m_step;
- if (m_cur_value < m_min)
- {
- m_cur_value = m_min;
- }
- else
- {
- on_paint();
- }
+ notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
+ on_paint();
}
diff --git a/widgets/src/table.cpp b/widgets/table.cpp
similarity index 100%
rename from widgets/src/table.cpp
rename to widgets/table.cpp
diff --git a/widgets/src/wave_buffer.cpp b/widgets/wave_buffer.cpp
similarity index 100%
rename from widgets/src/wave_buffer.cpp
rename to widgets/wave_buffer.cpp
diff --git a/widgets/src/wave_ctrl.cpp b/widgets/wave_ctrl.cpp
similarity index 100%
rename from widgets/src/wave_ctrl.cpp
rename to widgets/wave_ctrl.cpp
diff --git a/widgets/widgets_include/button.h b/widgets_include/button.h
similarity index 100%
rename from widgets/widgets_include/button.h
rename to widgets_include/button.h
diff --git a/widgets/widgets_include/dialog.h b/widgets_include/dialog.h
similarity index 90%
rename from widgets/widgets_include/dialog.h
rename to widgets_include/dialog.h
index c3d99de..b524cb6 100644
--- a/widgets/widgets_include/dialog.h
+++ b/widgets_include/dialog.h
@@ -16,7 +16,6 @@ public:
static int open_dialog(c_dialog* p_dlg);
static int close_dialog(c_surface* surface);
static c_dialog* get_the_dialog(c_surface* surface);
- virtual bool on_touch(int x, int y, TOUCH_ACTION action);
protected:
virtual const char* get_class_name(void) const {return "c_dialog";}
virtual void pre_create_wnd();
diff --git a/widgets/widgets_include/edit.h b/widgets_include/edit.h
similarity index 100%
rename from widgets/widgets_include/edit.h
rename to widgets_include/edit.h
diff --git a/widgets/widgets_include/gesture.h b/widgets_include/gesture.h
similarity index 100%
rename from widgets/widgets_include/gesture.h
rename to widgets_include/gesture.h
diff --git a/widgets/widgets_include/keyboard.h b/widgets_include/keyboard.h
similarity index 100%
rename from widgets/widgets_include/keyboard.h
rename to widgets_include/keyboard.h
diff --git a/widgets/widgets_include/label.h b/widgets_include/label.h
similarity index 100%
rename from widgets/widgets_include/label.h
rename to widgets_include/label.h
diff --git a/widgets/widgets_include/list_box.h b/widgets_include/list_box.h
similarity index 53%
rename from widgets/widgets_include/list_box.h
rename to widgets_include/list_box.h
index d225d00..bb24094 100644
--- a/widgets/widgets_include/list_box.h
+++ b/widgets_include/list_box.h
@@ -1,20 +1,11 @@
#ifndef LIST_BOX_H
#define LIST_BOX_H
-#define MAX_ITEM_NUM 12
+#define MAX_ITEM_NUM 4
+#define GL_LIST_CONFIRM 0x1
-#define GL_LIST_SELECT 0x1
-#define GL_LIST_CONFIRM 0x2
-#define GL_LIST_ROTATION 0x3
-
-#define ON_LIST_SELECT(ctrlId, func) \
-{MSG_TYPE_WND, GL_LIST_SELECT, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast(&func)},
-
-#define ON_LIST_CONFIRM(ctrlId, func) \
-{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast(&func)},
-
-#define ON_LIST_ROTATION(ctrlId, func) \
-{MSG_TYPE_WND, GL_LIST_ROTATION, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWL, reinterpret_cast(&func)},
+#define ON_LIST_CONFIRM(ctrlId, func) \
+{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast(&func))},
class c_list_box : public c_wnd
{
diff --git a/widgets/widgets_include/slide_group.h b/widgets_include/slide_group.h
similarity index 100%
rename from widgets/widgets_include/slide_group.h
rename to widgets_include/slide_group.h
diff --git a/widgets/widgets_include/spinbox.h b/widgets_include/spinbox.h
similarity index 64%
rename from widgets/widgets_include/spinbox.h
rename to widgets_include/spinbox.h
index edc6af7..85c5158 100644
--- a/widgets/widgets_include/spinbox.h
+++ b/widgets_include/spinbox.h
@@ -1,18 +1,14 @@
#ifndef SPIN_BOX_H
#define SPIN_BOX_H
-#define GL_SPIN_SELECT 0x2222
-#define GL_SPIN_CONFIRM 0x3333
-#define GL_SPIN_ROTATION 0x4444
+#define GL_SPIN_CONFIRM 0x2222
+#define GL_SPIN_CHANGE 0x3333
-#define ON_SPIN_SELECT(ctrlId, func) \
-{MSG_TYPE_WND, GL_SPIN_SELECT, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast(&func))},
+#define ON_SPIN_CONFIRM(ctrlId, func) \
+{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast(&func))},
-#define ON_SPIN_CONFIRM(ctrlId, func) \
-{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast(&func))},
-
-#define ON_SPIN_ROTATION(ctrlId, func) \
-{MSG_TYPE_WND, GL_SPIN_ROTATION, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast(&func))},
+#define ON_SPIN_CHANGE(ctrlId, func) \
+{MSG_TYPE_WND, GL_SPIN_CHANGE, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast(&func))},
class c_spin_box : public c_wnd
{
diff --git a/widgets/widgets_include/table.h b/widgets_include/table.h
similarity index 100%
rename from widgets/widgets_include/table.h
rename to widgets_include/table.h
diff --git a/widgets/widgets_include/wave_buffer.h b/widgets_include/wave_buffer.h
similarity index 100%
rename from widgets/widgets_include/wave_buffer.h
rename to widgets_include/wave_buffer.h
diff --git a/widgets/widgets_include/wave_ctrl.h b/widgets_include/wave_ctrl.h
similarity index 100%
rename from widgets/widgets_include/wave_ctrl.h
rename to widgets_include/wave_ctrl.h