diff --git a/README.md b/README.md index 2af1d1f41b8d0c670d839ff6e92184569d71b044..1b09c6e742b79453770788fb421d5f7d5c32318c 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,10 @@ - ⚙️希望GuiLite小到足够帮助大家掌握UI工作原理,从而摆脱UI框架的束缚,构建自己独一无二的UI - 👑任何UI框架都不为你我而生,你才是自己真正的主人 -## 🔥新功能:Golang + GuiLite -为了演示GuiLite与Golang协同开发,我们为[HostMonitor](https://gitee.com/idea4good/GuiLiteSamples/tree/master/HostMonitor)增加了[Golang版本](https://gitee.com/idea4good/GuiLiteSamples/tree/master/HostMonitor/BuildGo) +## 🔥新功能:硬按键“导航” +![HelloNavigation](doc/HelloNavigation.gif) + +Hello Navigation 仅有[100+行代码](https://gitee.com/idea4good/GuiLiteSamples/tree/master/HelloNavigation/UIcode/UIcode.cpp),用于向开发者展示:如何使用硬按键进行:“移动焦点”和“点击”操作。 ## 功能介绍 ### 卓越的跨平台能力 @@ -60,6 +62,7 @@ GuiLite只是一个框架,本身并不能生成UI。为了能够展示如何 | HelloParticle | Windows, Linux, STM32F103, STM32F429 | 粒子效果的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloParticle/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) | ★★| | 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/core_include/wnd.h b/core/core_include/wnd.h index 7a46a2415cea7a275494cf3e1e72cae097c42540..d7da42b89cecd09c495902fe52a34794b783b249 100644 --- a/core/core_include/wnd.h +++ b/core/core_include/wnd.h @@ -1,10 +1,10 @@ -#ifndef GUI_WND_H -#define GUI_WND_H +#ifndef WND_H +#define WND_H //Window attribution #define GL_ATTR_VISIBLE 0x80000000L -#define GL_ATTR_DISABLED 0x40000000L -#define GL_ATTR_FOCUS 0x20000000L +#define GL_ATTR_DISABLED 0x40000000L +#define GL_ATTR_FOCUS 0x20000000L typedef struct struct_font_info FONT_INFO; typedef struct struct_color_rect COLOR_RECT; @@ -20,6 +20,19 @@ typedef enum STATUS_DISABLED }WND_STATUS; +typedef enum +{ + KEY_FORWARD, + KEY_BACKWARD, + KEY_ENTER +}KEY_TYPE; + +typedef enum +{ + TOUCH_DOWN, + TOUCH_UP +}TOUCH_ACTION; + typedef struct struct_wnd_tree { c_wnd* p_wnd; @@ -69,7 +82,7 @@ public: void get_wnd_rect(c_rect &rect) const; void get_screen_rect(c_rect &rect) const; - c_wnd* set_focus(c_wnd *new_active_child); + c_wnd* set_child_focus(c_wnd *focus_child); c_wnd* get_parent() const { return m_parent; } c_wnd* get_last_child() const; @@ -80,16 +93,13 @@ public: 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); - virtual void on_touch_up(int x, int y); - virtual void on_touch_down(int x, int y); - - c_wnd* get_active_child() const { return m_active_child; } + virtual bool on_touch(int x, int y, TOUCH_ACTION action); + virtual bool on_key(KEY_TYPE key); c_surface* get_surface() { return m_surface; } void set_surface(c_surface* surface) { m_surface = surface; } protected: - virtual void pre_create_wnd(); - void add_child_2_head(c_wnd *child); + virtual void pre_create_wnd() {}; void add_child_2_tail(c_wnd *child); void wnd2screen(int &x, int &y) const; @@ -99,10 +109,10 @@ protected: int load_child_wnd(WND_TREE *p_child_tree); int load_clone_child_wnd(WND_TREE *p_child_tree); - void set_active_child(c_wnd* child) { m_active_child = child; } + void set_active_child(c_wnd* child) { m_focus_child = child; } - virtual void on_focus(); - virtual void on_kill_focus(); + virtual void on_focus() {}; + virtual void on_kill_focus() {}; protected: WND_STATUS m_status; unsigned int m_style; @@ -120,7 +130,7 @@ protected: unsigned short m_resource_id; int m_z_order; - c_wnd* m_active_child; + c_wnd* m_focus_child;//current focused wnd c_surface* m_surface; private: c_wnd(const c_wnd &win); diff --git a/core/src/wnd.cpp b/core/src/wnd.cpp index 62b8ca93d2922718783541936c22210749b6c065..07d573ae1aa37f949b0328aa951365ee2e594978 100644 --- a/core/src/wnd.cpp +++ b/core/src/wnd.cpp @@ -7,12 +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_active_child(NULL), m_surface(NULL) -{ - m_wnd_rect.Empty(); -} - -void c_wnd::pre_create_wnd() + 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; } @@ -192,7 +187,7 @@ void c_wnd::disconnect() { m_parent->unlink_child(this); } - m_active_child = 0; + m_focus_child = 0; m_resource_id = 0; } @@ -278,21 +273,18 @@ void c_wnd::wnd2screen(int &x, int &y) const x += rect.m_left; y += rect.m_top; - parent = parent->get_parent(); + parent = parent->m_parent; } } void c_wnd::wnd2screen(c_rect &rect) const { - int l, t, r, b; - - l = rect.m_left; - t = rect.m_top; + int l = rect.m_left; + int t = rect.m_top; wnd2screen(l, t); - r = (l + rect.Width() - 1); - b = (t + rect.Height() - 1); - + int r = (l + rect.Width() - 1); + int b = (t + rect.Height() - 1); rect.SetRect(l, t, r, b); } @@ -309,65 +301,45 @@ void c_wnd::screen2wnd(short &x, short &y) const parent->get_wnd_rect(rect); x -= rect.m_left; y -= rect.m_top; - parent = parent->get_parent(); + parent = parent->m_parent; } } void c_wnd::screen2wnd(c_rect &rect) const { - short l, t, r, b; - - l = rect.m_left; - t = rect.m_top; + short l = rect.m_left; + short t = rect.m_top; screen2wnd(l, t); - r = l + rect.Width() - 1; - b = t + rect.Height() - 1; - + short r = l + rect.Width() - 1; + short b = t + rect.Height() - 1; rect.SetRect(l, t, r, b); } -void c_wnd::on_focus() -{ - if (m_active_child) - { - m_active_child->on_focus(); - } -} - -void c_wnd::on_kill_focus() -{ - if (m_active_child) - { - m_active_child->on_kill_focus(); - m_active_child = 0; - } -} - -c_wnd* c_wnd::set_focus(c_wnd * new_active_child) +c_wnd* c_wnd::set_child_focus(c_wnd * focus_child) { - ASSERT(NULL != new_active_child); - ASSERT(new_active_child->get_parent() == this); + ASSERT(NULL != focus_child); + ASSERT(focus_child->m_parent == this); - c_wnd *old_focus_child = m_active_child; - if (new_active_child->is_focus_wnd()) + c_wnd *old_focus_child = m_focus_child; + if (focus_child->is_focus_wnd()) { - if ( new_active_child != old_focus_child ) + if (focus_child != old_focus_child ) { - if (0 != old_focus_child) + if (old_focus_child) { old_focus_child->on_kill_focus(); } - m_active_child = new_active_child; + m_focus_child = focus_child; - if (get_parent()) + if (m_parent) { - get_parent()->set_focus(this); + m_parent->set_child_focus(this); } - m_active_child->on_focus(); + m_focus_child->on_focus(); } } - return m_active_child; + return m_focus_child; } int c_wnd::on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_param) @@ -401,26 +373,6 @@ int c_wnd::on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_ return FALSE; } -void c_wnd::add_child_2_head(c_wnd *child) -{ - if( NULL == child )return; - if(child == get_wnd_ptr(child->m_resource_id))return; - - if ( NULL == m_top_child ) - { - m_top_child = child; - child->m_prev_sibling = NULL; - child->m_next_sibling = NULL; - } - else - { - child->m_next_sibling = m_top_child; - child->m_prev_sibling = NULL; - m_top_child->m_prev_sibling = child; - m_top_child = child; - } -} - void c_wnd::add_child_2_tail(c_wnd *child) { if( NULL == child )return; @@ -465,7 +417,7 @@ c_wnd* c_wnd::get_last_child() const int c_wnd::unlink_child(c_wnd *child) { if ((NULL == child) - || (this != child->get_parent())) + || (this != child->m_parent)) { return -1; } @@ -510,9 +462,9 @@ int c_wnd::unlink_child(c_wnd *child) if (TRUE == find) { - if (m_active_child == child) + if (m_focus_child == child) { - m_active_child = NULL; + m_focus_child = NULL; } child->m_next_sibling = NULL; @@ -542,58 +494,91 @@ void c_wnd::show_window() } } -void c_wnd::on_touch_down(int x, int y) +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; - if ( pChild != NULL ) + while ( pChild ) { - while ( pChild ) + if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE)) { - if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE)) + pChild->get_wnd_rect(rect); + if ( TRUE == rect.PtInRect(x, y) ) { - pChild->get_wnd_rect(rect); - if ( TRUE == rect.PtInRect(x, y) ) + if ( TRUE == pChild->is_focus_wnd() ) { - if ( TRUE == pChild->is_focus_wnd() ) - { - pChild->on_touch_down(x, y); - } + pChild->on_touch(x, y, action); } } - pChild = pChild->get_next_sibling(); } + pChild = pChild->m_next_sibling; } + return true; } -void c_wnd::on_touch_up(int x, int y) +bool c_wnd::on_key(KEY_TYPE key) { - c_rect rect; - x -= m_wnd_rect.m_left; - y -= m_wnd_rect.m_top; - c_wnd *pChild = m_top_child; + ASSERT(key == KEY_FORWARD || key == KEY_BACKWARD || key == KEY_ENTER); - if ( pChild != NULL ) + // Find current focus wnd. + c_wnd* old_focus_wnd = m_focus_child; + while (m_focus_child && m_focus_child->m_focus_child) { - while ( pChild ) + old_focus_wnd = m_focus_child->m_focus_child; + } + if (old_focus_wnd && !old_focus_wnd->on_key(key)) + { + return true; + } + + // Default moving focus(Default handle KEY_FOWARD/KEY_BACKWARD) + if (key == KEY_ENTER) + { + return true; + } + if (!old_focus_wnd) + {// No current focus wnd, new one. + c_wnd *pChild = m_top_child; + c_wnd *new_focus_wnd = NULL; + while (pChild) { if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE)) { - pChild->get_wnd_rect(rect); - if ( TRUE == rect.PtInRect(x, y) ) + if (TRUE == pChild->is_focus_wnd()) { - if ( TRUE == pChild->is_focus_wnd() ) - { - pChild->on_touch_up(x, y); - } + new_focus_wnd = pChild; + new_focus_wnd->m_parent->set_child_focus(new_focus_wnd); + pChild = pChild->m_top_child; + continue; } } - pChild = pChild->get_next_sibling(); + pChild = pChild->m_next_sibling; + } + return true; + } + + // Move focus from old wnd to next wnd + c_wnd* next_focus_wnd = (key == KEY_FORWARD) ? old_focus_wnd->m_next_sibling : old_focus_wnd->m_prev_sibling; + while (next_focus_wnd && (!next_focus_wnd->is_focus_wnd())) + {// Search neighbor of old focus wnd + next_focus_wnd = (key == KEY_FORWARD) ? next_focus_wnd->m_next_sibling : next_focus_wnd->m_prev_sibling; + } + if (!next_focus_wnd) + {// Search whole brother wnd + next_focus_wnd = (key == KEY_FORWARD) ? old_focus_wnd->m_parent->m_top_child : old_focus_wnd->m_parent->get_last_child(); + while (next_focus_wnd && (!next_focus_wnd->is_focus_wnd())) + { + next_focus_wnd = (key == KEY_FORWARD) ? next_focus_wnd->m_next_sibling : next_focus_wnd->m_prev_sibling; } } + if (next_focus_wnd) + { + next_focus_wnd->m_parent->set_child_focus(next_focus_wnd); + } + return true; } void c_wnd::notify_parent(unsigned short msg_id, unsigned int w_param, long l_param) diff --git a/doc/HelloNavigation.gif b/doc/HelloNavigation.gif new file mode 100644 index 0000000000000000000000000000000000000000..6f474b8925b4f420441ff305ac13a3d52d1a9c13 Binary files /dev/null and b/doc/HelloNavigation.gif differ diff --git a/widgets/src/button.cpp b/widgets/src/button.cpp index d54d31e032b65a5806a367764e5b3055beb20db3..6ef9ea8f3b7d80702402022ae419abb34369f07a 100644 --- a/widgets/src/button.cpp +++ b/widgets/src/button.cpp @@ -28,22 +28,31 @@ void c_button::on_kill_focus() on_paint(); } -void c_button::on_touch_down(int x, int y) +bool c_button::on_touch(int x, int y, TOUCH_ACTION action) { - get_parent()->set_focus(this); - m_status = STATUS_PUSHED; - on_paint(); -} - -void c_button::on_touch_up(int x, int y) -{ - if (STATUS_PUSHED == m_status) + if (action == TOUCH_DOWN) + { + m_parent->set_child_focus(this); + m_status = STATUS_PUSHED; + on_paint(); + } + else { m_status = STATUS_FOCUSED; on_paint(); + notify_parent(GL_BN_CLICKED, get_id(), 0); + } + return false;// Do not handle TOUCH_ACTION by other wnd. +} +bool c_button::on_key(KEY_TYPE key) +{ + if (key == KEY_ENTER) + { notify_parent(GL_BN_CLICKED, get_id(), 0); + return false;// Do not handle KEY_ENTER by other wnd. } + return true;// Handle KEY_FOWARD/KEY_BACKWARD by parent wnd. } void c_button::on_paint() diff --git a/widgets/src/dialog.cpp b/widgets/src/dialog.cpp index df4b206f53c0b4f4de8828f841eb070dd3d5966e..416a3b1f45d2bba7c4acdf8160f9bb971e743f30 100644 --- a/widgets/src/dialog.cpp +++ b/widgets/src/dialog.cpp @@ -100,7 +100,7 @@ int c_dialog::close_dialog(c_surface* surface) return -1; } -void c_dialog::on_touch_down(int x, int y) +bool c_dialog::on_touch(int x, int y, TOUCH_ACTION action) { c_wnd *child = m_top_child; c_rect rect; @@ -114,34 +114,13 @@ void c_dialog::on_touch_down(int x, int y) { x -= rect.m_left; y -= rect.m_top; - child->on_touch_down(x, y); - return; + child->on_touch(x, y, action); + return true; } child = child->m_next_sibling; } } - c_wnd::on_touch_down(x, y); -} - -void c_dialog::on_touch_up(int x, int y) -{ - 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; - return child->on_touch_up(x, y); - } - child = child->m_next_sibling; - } - } - c_wnd::on_touch_up(x, y); + return c_wnd::on_touch(x, y, action); } int c_dialog::set_me_the_dialog() diff --git a/widgets/src/edit.cpp b/widgets/src/edit.cpp index 1fb3047aba947a8d5cdcd0423fa2ff0fede9ad1c..61d27954256ca782ad83c33829fcc006f2f2ea6f 100644 --- a/widgets/src/edit.cpp +++ b/widgets/src/edit.cpp @@ -40,6 +40,12 @@ void c_edit::set_text(const char* str) } } +bool c_edit::on_touch(int x, int y, TOUCH_ACTION action) +{ + (action == TOUCH_DOWN) ? on_touch_down(x, y) : on_touch_up(x, y); + return true; +} + void c_edit::on_touch_down(int x, int y) { c_rect kb_rect_relate_2_edit_parent; @@ -53,12 +59,12 @@ void c_edit::on_touch_down(int x, int y) {//click edit box if (STATUS_NORMAL == m_status) { - get_parent()->set_focus(this); + m_parent->set_child_focus(this); } } else if (kb_rect_relate_2_edit_parent.PtInRect(x,y)) {//click key board - c_wnd::on_touch_down(x, y); + c_wnd::on_touch(x, y, TOUCH_DOWN); } else { @@ -86,7 +92,7 @@ void c_edit::on_touch_up(int x, int y) } else { - c_wnd::on_touch_up(x, y); + c_wnd::on_touch(x, y, TOUCH_UP); } } } diff --git a/widgets/src/gesture.cpp b/widgets/src/gesture.cpp index edd10703de103f0fc795588ab6d4deb6b7b66965..96ad2c486ecbe8e5633aef4a7295923191a562bb 100644 --- a/widgets/src/gesture.cpp +++ b/widgets/src/gesture.cpp @@ -243,10 +243,10 @@ void c_gesture::handle_hid_msg(MSG_INFO &msg) switch(msg.dwMsgId) { case 0x4700://MOUSE_LBUTTONDOWN - m_root->on_touch_down(msg.dwParam1, msg.dwParam2); + m_root->on_touch(msg.dwParam1, msg.dwParam2, TOUCH_DOWN); break; case 0x4600://MOUSE_LBUTTONUP - m_root->on_touch_up(msg.dwParam1, msg.dwParam2); + m_root->on_touch(msg.dwParam1, msg.dwParam2, TOUCH_UP); break; } } diff --git a/widgets/src/label.cpp b/widgets/src/label.cpp index af31d65722834d29e036a7a772162157c18ca882..6d16f7a1ac1381116d491c4ad614164f160cb381 100644 --- a/widgets/src/label.cpp +++ b/widgets/src/label.cpp @@ -24,7 +24,7 @@ void c_label::on_paint() if (m_str) { - m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, get_parent()->get_bg_color(), m_z_order); + m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_parent->get_bg_color(), m_z_order); c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style); } } diff --git a/widgets/src/list_box.cpp b/widgets/src/list_box.cpp index b679138f68b621810118cb0b476abc69f917c3e6..008d20238d88f1570909d01b94c63a5c48551d16 100644 --- a/widgets/src/list_box.cpp +++ b/widgets/src/list_box.cpp @@ -88,18 +88,24 @@ void c_list_box::on_paint() } } +bool c_list_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; +} + void c_list_box::on_touch_down(int x, int y) { if (m_wnd_rect.PtInRect(x, y) ) {//click base if (STATUS_NORMAL == m_status) { - get_parent()->set_focus(this); + m_parent->set_child_focus(this); } } else if (m_list_wnd_rect.PtInRect(x, y)) {//click extend list - c_wnd::on_touch_down(x, y); + c_wnd::on_touch(x, y, TOUCH_DOWN); } else { @@ -136,7 +142,7 @@ void c_list_box::on_touch_up(int x, int y) } else { - c_wnd::on_touch_up(x, y); + c_wnd::on_touch(x, y, TOUCH_UP); } } } diff --git a/widgets/src/slide_group.cpp b/widgets/src/slide_group.cpp index a09596f84c277117815763fbc3b5243db175dce8..399f327b5b252c3c9042342cd290d69aeddd8fa5 100644 --- a/widgets/src/slide_group.cpp +++ b/widgets/src/slide_group.cpp @@ -151,5 +151,4 @@ void c_slide_group::disabel_all_slide() m_slides[i]->get_surface()->set_active(false); } } - m_active_child = NULL; } diff --git a/widgets/src/spinbox.cpp b/widgets/src/spinbox.cpp index 7553631b86eff2523898e3f39f1cebe7bed66eab..d237b0487b6df1a3dd2dae2030d1e8c1b2cd1f77 100644 --- a/widgets/src/spinbox.cpp +++ b/widgets/src/spinbox.cpp @@ -44,6 +44,12 @@ void c_spin_box::pre_create_wnd() m_bt_down_rect.m_bottom = m_bt_down_rect.m_top + ARROW_BT_HEIGHT; } +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; +} + void c_spin_box::on_touch_down(int x, int y) { c_rect arrow_rect = m_wnd_rect; @@ -54,12 +60,12 @@ void c_spin_box::on_touch_down(int x, int y) {//click spin box if (STATUS_NORMAL == m_status) { - get_parent()->set_focus(this); + m_parent->set_child_focus(this); } } else if (TRUE == arrow_rect.PtInRect(x, y)) {//click arrow button - c_wnd::on_touch_down(x, y); + c_wnd::on_touch(x, y, TOUCH_DOWN); } else {//click invalid place. @@ -98,7 +104,7 @@ void c_spin_box::on_touch_up(int x, int y) } else {//click arrow button. - c_wnd::on_touch_up(x, y); + c_wnd::on_touch(x, y, TOUCH_UP); } } } diff --git a/widgets/widgets_include/button.h b/widgets/widgets_include/button.h index b9a4c3952704d39dabbf1747b16f3cafd08971ac..b1a511a3bd1d86698b2f5b494e69da4a7e3a94a4 100644 --- a/widgets/widgets_include/button.h +++ b/widgets/widgets_include/button.h @@ -20,10 +20,11 @@ protected: virtual void on_paint(); virtual void on_focus(); virtual void on_kill_focus(); - virtual void on_touch_down(int x, int y); - virtual void on_touch_up(int x, int y); virtual void pre_create_wnd(); + virtual bool on_touch(int x, int y, TOUCH_ACTION action); + virtual bool on_key(KEY_TYPE key); + const BITMAP_INFO* m_bitmap_normal; const BITMAP_INFO* m_bitmap_focus; const BITMAP_INFO* m_bitmap_pushed; diff --git a/widgets/widgets_include/dialog.h b/widgets/widgets_include/dialog.h index 9753ba8fd80c6b8adf3a41172102adbfa6b4c05d..c3d99de8c3486ef39623baf8dc99d0aed2c09001 100644 --- a/widgets/widgets_include/dialog.h +++ b/widgets/widgets_include/dialog.h @@ -16,8 +16,7 @@ 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 void on_touch_down(int x, int y); - virtual void on_touch_up(int x, int y); + 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/widgets_include/edit.h index 91904a746ba1579cfdb33ae3d9e964ec8cebea13..d32a116bb547b02b43074f6d76218100b4a497ee 100644 --- a/widgets/widgets_include/edit.h +++ b/widgets/widgets_include/edit.h @@ -19,13 +19,14 @@ protected: virtual void on_paint(); virtual void on_focus(); virtual void on_kill_focus(); - virtual void on_touch_down(int x, int y); - virtual void on_touch_up(int x, int y); + virtual bool on_touch(int x, int y, TOUCH_ACTION action); void on_key_board_click(unsigned int ctrl_id, long param); GL_DECLARE_MESSAGE_MAP() private: void show_keyboard(); + void on_touch_down(int x, int y); + void on_touch_up(int x, int y); char m_str_input[MAX_EDIT_STRLEN]; char m_str[MAX_EDIT_STRLEN]; diff --git a/widgets/widgets_include/list_box.h b/widgets/widgets_include/list_box.h index eb4bcccabc3af4c673747c21c8900456196d0c94..d225d00aacb3e8681f849ad5ecaef8be579e7002 100644 --- a/widgets/widgets_include/list_box.h +++ b/widgets/widgets_include/list_box.h @@ -30,12 +30,13 @@ protected: virtual void on_paint(); virtual void on_focus(); virtual void on_kill_focus(); - virtual void on_touch_down(int x, int y); - virtual void on_touch_up(int x, int y); + virtual bool on_touch(int x, int y, TOUCH_ACTION action); private: void update_list_size(); void show_list(); + void on_touch_down(int x, int y); + void on_touch_up(int x, int y); short m_selected_item; short m_item_total; diff --git a/widgets/widgets_include/spinbox.h b/widgets/widgets_include/spinbox.h index 176a9e8a865b7b8afe2930ce10f402b09e42e3c8..edc6af759cf1d9247d46fa34fd0810e9c004a44f 100644 --- a/widgets/widgets_include/spinbox.h +++ b/widgets/widgets_include/spinbox.h @@ -1,9 +1,9 @@ #ifndef SPIN_BOX_H #define SPIN_BOX_H -#define GL_SPIN_SELECT 0x2222 +#define GL_SPIN_SELECT 0x2222 #define GL_SPIN_CONFIRM 0x3333 -#define GL_SPIN_ROTATION 0x4444 +#define GL_SPIN_ROTATION 0x4444 #define ON_SPIN_SELECT(ctrlId, func) \ {MSG_TYPE_WND, GL_SPIN_SELECT, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast(&func))}, @@ -35,12 +35,9 @@ protected: virtual void on_paint(); virtual void on_focus(); virtual void on_kill_focus(); - - virtual void on_touch_down(int x, int y); - virtual void on_touch_up(int x, int y); virtual void pre_create_wnd(); + virtual bool on_touch(int x, int y, TOUCH_ACTION action); -protected: void on_arrow_up_bt_click(unsigned int ctr_id); void on_arrow_down_bt_click(unsigned int ctr_id); @@ -49,6 +46,8 @@ protected: private: void show_arrow_button(); void hide_arrow_button(); + void on_touch_down(int x, int y); + void on_touch_up(int x, int y); protected: short m_cur_value;