!17 Support UI navigation by hardware button
This commit is contained in:
parent
53ce424766
commit
1f128b379c
|
@ -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)
|
||||
## 🔥新功能:硬按键“导航”
|
||||

|
||||
|
||||
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) | ★★★|
|
||||
|
|
|
@ -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);
|
||||
|
|
185
core/src/wnd.cpp
185
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()
|
||||
c_wnd* c_wnd::set_child_focus(c_wnd * focus_child)
|
||||
{
|
||||
if (m_active_child)
|
||||
{
|
||||
m_active_child->on_focus();
|
||||
}
|
||||
}
|
||||
ASSERT(NULL != focus_child);
|
||||
ASSERT(focus_child->m_parent == this);
|
||||
|
||||
void c_wnd::on_kill_focus()
|
||||
{
|
||||
if (m_active_child)
|
||||
c_wnd *old_focus_child = m_focus_child;
|
||||
if (focus_child->is_focus_wnd())
|
||||
{
|
||||
m_active_child->on_kill_focus();
|
||||
m_active_child = 0;
|
||||
}
|
||||
}
|
||||
|
||||
c_wnd* c_wnd::set_focus(c_wnd * new_active_child)
|
||||
{
|
||||
ASSERT(NULL != new_active_child);
|
||||
ASSERT(new_active_child->get_parent() == this);
|
||||
|
||||
c_wnd *old_focus_child = m_active_child;
|
||||
if (new_active_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)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,5 +151,4 @@ void c_slide_group::disabel_all_slide()
|
|||
m_slides[i]->get_surface()->set_active(false);
|
||||
}
|
||||
}
|
||||
m_active_child = NULL;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<void (c_cmd_target::*)(unsigned int)>(&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;
|
||||
|
|
Loading…
Reference in New Issue