fix widget hide/enable issue and add on_changed in slider widget.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@899 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
814ac8fb22
commit
3c975d6922
@ -33,6 +33,8 @@ struct rtgui_slider
|
|||||||
rt_size_t thumb_width;
|
rt_size_t thumb_width;
|
||||||
|
|
||||||
int orient;
|
int orient;
|
||||||
|
|
||||||
|
void (*on_changed)(struct rtgui_widget* widget, struct rtgui_event *event);
|
||||||
};
|
};
|
||||||
typedef struct rtgui_slider rtgui_slider_t;
|
typedef struct rtgui_slider rtgui_slider_t;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
|||||||
{
|
{
|
||||||
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event;
|
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event;
|
||||||
|
|
||||||
if (RTGUI_WIDGET_IS_HIDE(widget)) RT_FALSE;
|
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
|
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
|
||||||
{
|
{
|
||||||
if (RTGUI_KBD_IS_DOWN(ekbd))
|
if (RTGUI_KBD_IS_DOWN(ekbd))
|
||||||
@ -111,7 +111,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
if (RTGUI_WIDGET_IS_HIDE(widget)) RT_FALSE;
|
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
{
|
{
|
||||||
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
|
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ void rtgui_progressbar_set_value(struct rtgui_progressbar *bar, int value)
|
|||||||
{
|
{
|
||||||
RT_ASSERT(bar != RT_NULL);
|
RT_ASSERT(bar != RT_NULL);
|
||||||
|
|
||||||
|
if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar))) return;
|
||||||
|
|
||||||
bar->position = value;
|
bar->position = value;
|
||||||
|
|
||||||
rtgui_theme_draw_progressbar(bar);
|
rtgui_theme_draw_progressbar(bar);
|
||||||
|
@ -40,6 +40,10 @@ static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui
|
|||||||
RT_ASSERT(radiobox != RT_NULL);
|
RT_ASSERT(radiobox != RT_NULL);
|
||||||
RT_ASSERT(event != RT_NULL);
|
RT_ASSERT(event != RT_NULL);
|
||||||
|
|
||||||
|
/* widget is hide, return */
|
||||||
|
if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(radiobox)) ||
|
||||||
|
!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(radiobox))) return;
|
||||||
|
|
||||||
if (event->button & RTGUI_MOUSE_BUTTON_DOWN &&
|
if (event->button & RTGUI_MOUSE_BUTTON_DOWN &&
|
||||||
event->button & RTGUI_MOUSE_BUTTON_LEFT)
|
event->button & RTGUI_MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
@ -97,6 +101,8 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_KBD:
|
case RTGUI_EVENT_KBD:
|
||||||
|
if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(radiobox))) return RT_FALSE;
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
||||||
else
|
else
|
||||||
|
@ -286,7 +286,7 @@ rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_widget * widget,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
if (RTGUI_WIDGET_IS_ENABLE(widget))
|
if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget))
|
||||||
{
|
{
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_mouseclick != RT_NULL)
|
if (widget->on_mouseclick != RT_NULL)
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2009-10-16 Bernard first version
|
* 2009-10-16 Bernard first version
|
||||||
|
* 2010-09-10 Bernard fix hide issue
|
||||||
*/
|
*/
|
||||||
#include <rtgui/dc.h>
|
#include <rtgui/dc.h>
|
||||||
#include <rtgui/rtgui_theme.h>
|
#include <rtgui/rtgui_theme.h>
|
||||||
@ -37,6 +38,7 @@ static void _rtgui_slider_constructor(rtgui_slider_t *slider)
|
|||||||
|
|
||||||
slider->ticks = 10;
|
slider->ticks = 10;
|
||||||
slider->thumb_width = 8;
|
slider->thumb_width = 8;
|
||||||
|
slider->on_changed = RT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtgui_type_t *rtgui_slider_type_get(void)
|
rtgui_type_t *rtgui_slider_type_get(void)
|
||||||
@ -95,6 +97,8 @@ static void rtgui_slider_onmouse(struct rtgui_slider* slider, struct rtgui_event
|
|||||||
|
|
||||||
rtgui_widget_focus(RTGUI_WIDGET(slider));
|
rtgui_widget_focus(RTGUI_WIDGET(slider));
|
||||||
rtgui_slider_set_value(slider, sel);
|
rtgui_slider_set_value(slider, sel);
|
||||||
|
if (slider->on_changed != RT_NULL) /* invoke callback function */
|
||||||
|
slider->on_changed(RTGUI_WIDGET(slider), RT_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +123,8 @@ static void rtgui_slider_onkey(struct rtgui_slider* slider, struct rtgui_event_k
|
|||||||
|
|
||||||
/* update widget */
|
/* update widget */
|
||||||
rtgui_widget_update(RTGUI_WIDGET(slider));
|
rtgui_widget_update(RTGUI_WIDGET(slider));
|
||||||
|
if (slider->on_changed != RT_NULL) /* invoke callback function */
|
||||||
|
slider->on_changed(RTGUI_WIDGET(slider), RT_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
|
rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
|
||||||
@ -139,6 +145,8 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_KBD:
|
case RTGUI_EVENT_KBD:
|
||||||
|
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
||||||
else
|
else
|
||||||
@ -149,6 +157,8 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
|
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event);
|
if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event);
|
||||||
else
|
else
|
||||||
@ -195,13 +205,16 @@ void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value)
|
|||||||
{
|
{
|
||||||
RT_ASSERT(slider != RT_NULL);
|
RT_ASSERT(slider != RT_NULL);
|
||||||
|
|
||||||
if (value < slider->min) value = slider->min;
|
if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(slider)))
|
||||||
if (value > slider->max) value = slider->max;
|
|
||||||
|
|
||||||
if (slider->value != value)
|
|
||||||
{
|
{
|
||||||
slider->value = value;
|
if (value < slider->min) value = slider->min;
|
||||||
rtgui_theme_draw_slider(slider);
|
if (value > slider->max) value = slider->max;
|
||||||
|
|
||||||
|
if (slider->value != value)
|
||||||
|
{
|
||||||
|
slider->value = value;
|
||||||
|
rtgui_theme_draw_slider(slider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,8 @@ rt_bool_t rtgui_textbox_event_handler(struct rtgui_widget* widget, struct rtgui_
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
|
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event);
|
if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event);
|
||||||
else
|
else
|
||||||
@ -281,6 +283,8 @@ rt_bool_t rtgui_textbox_event_handler(struct rtgui_widget* widget, struct rtgui_
|
|||||||
return RT_TRUE;
|
return RT_TRUE;
|
||||||
|
|
||||||
case RTGUI_EVENT_KBD:
|
case RTGUI_EVENT_KBD:
|
||||||
|
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
if (widget->on_key != RT_NULL) widget->on_key(widget, event);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user