From 320978113f0292ded0ca20db3e4c6a5f3f768f93 Mon Sep 17 00:00:00 2001 From: Sohyun Kim Date: Tue, 12 Oct 2010 22:07:04 +0900 Subject: [PATCH] [elm_bubble]add sweep event --- src/lib/Elementary.h.in | 13 +++++++++---- src/lib/elm_bubble.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/lib/elm_datefield.c | 1 + 3 files changed, 50 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/lib/Elementary.h.in mode change 100644 => 100755 src/lib/elm_bubble.c mode change 100644 => 100755 src/lib/elm_datefield.c diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in old mode 100644 new mode 100755 index 29cd89b..0cdcce6 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -938,7 +938,7 @@ extern "C" { /* smart callbacks called: * "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorblock_Info */ - + EAPI Evas_Object *elm_bubble_add(Evas_Object *parent); EAPI void elm_bubble_label_set(Evas_Object *obj, const char *label); EAPI const char *elm_bubble_label_get(const Evas_Object *obj); @@ -951,6 +951,8 @@ extern "C" { EAPI Evas_Object *elm_bubble_icon_get(const Evas_Object *obj); EAPI void elm_bubble_corner_set(Evas_Object *obj, const char *corner); /* smart callbacks called: + * "sweep,left,right" - when bubble is sweeped from left to right, this signal is sent. + * "sweep,right,left" - when bubble is sweeped from right to left, this signal is sent. */ EAPI Evas_Object *elm_photo_add(Evas_Object *parent); @@ -1986,7 +1988,7 @@ extern "C" { ELM_DATEFIELD_LAYOUT_DATE, ELM_DATEFIELD_LAYOUT_DATEANDTIME } Elm_Datefield_Layout; - + EAPI Evas_Object *elm_datefield_add(Evas_Object *parent); EAPI void elm_datefield_layout_set(Evas_Object *obj, Elm_Datefield_Layout layout); EAPI Elm_Datefield_Layout elm_datefield_layout_get(Evas_Object *obj); @@ -1997,8 +1999,11 @@ extern "C" { EAPI void elm_datefield_date_format_set(Evas_Object *obj, const char *fmt); EAPI const char *elm_datefield_date_format_get(Evas_Object *obj); EAPI void elm_datefield_input_panel_state_callback_add(Evas_Object *obj, void (*pEventCallbackFunc) (void *data, Evas_Object *obj, int value), void *data); - EAPI void elm_datefield_input_panel_state_callback_del(Evas_Object *obj, void (*pEventCallbackFunc) (void *data, Evas_Object *obj, int value)); - + EAPI void elm_datefield_input_panel_state_callback_del(Evas_Object *obj, void (*pEventCallbackFunc) (void *data, Evas_Object *obj, int value)); + /* smart callbacks called: + * "changed" - when datefield entry is changed, this signal is sent. + */ + /* titlebar */ EAPI Evas_Object *elm_titlebar_add(Evas_Object *parent); EAPI void elm_titlebar_label_set(Evas_Object *obj, const char *label); diff --git a/src/lib/elm_bubble.c b/src/lib/elm_bubble.c old mode 100644 new mode 100755 index 011ecfe..29e1031 --- a/src/lib/elm_bubble.c +++ b/src/lib/elm_bubble.c @@ -16,8 +16,13 @@ struct _Widget_Data Evas_Object *bbl; Evas_Object *content, *icon; const char *label, *info; + + Eina_Bool down:1; + Evas_Coord_Point down_point; }; +#define SWEEP_THRESHOLD 100 + static const char *widtype = NULL; static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); @@ -84,6 +89,35 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info) _sizing_eval(obj); } +static void +_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Widget_Data *wd = elm_widget_data_get(data); + Evas_Event_Mouse_Down *ev = event_info; + + wd->down = EINA_TRUE; + wd->down_point.x = ev->canvas.x; + wd->down_point.y = ev->canvas.y; +} + +static void +_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Widget_Data *wd = elm_widget_data_get(data); + Evas_Event_Mouse_Up *ev = event_info; + + if (!wd->down) return; + + if (ev->canvas.x - wd->down_point.x > SWEEP_THRESHOLD) + evas_object_smart_callback_call(data, "sweep,left,right", NULL); + else if (wd->down_point.x - ev->canvas.x > SWEEP_THRESHOLD) + evas_object_smart_callback_call(data, "sweep,right,left", NULL); + + wd->down = EINA_FALSE; + wd->down_point.x = 0; + wd->down_point.y = 0; +} + /** * Add a new bubble to the parent * @@ -116,6 +150,12 @@ elm_bubble_add(Evas_Object *parent) elm_widget_resize_object_set(obj, wd->bbl); evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj); + evas_object_event_callback_add(wd->bbl, EVAS_CALLBACK_MOUSE_UP, _mouse_up, obj); + evas_object_event_callback_add(wd->bbl, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, obj); + + wd->down = EINA_FALSE; + wd->down_point.x = 0; + wd->down_point.y = 0; _sizing_eval(obj); return obj; diff --git a/src/lib/elm_datefield.c b/src/lib/elm_datefield.c old mode 100644 new mode 100755 index 4e1873a..fc1a5e9 --- a/src/lib/elm_datefield.c +++ b/src/lib/elm_datefield.c @@ -382,6 +382,7 @@ _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info) edje_object_signal_emit(wd->base, "elm,state,min,focus,out", "elm"); } edje_object_signal_emit(wd->base, "elm,state,focus,out", "elm"); + evas_object_smart_callback_call(data, "changed", NULL); } static void -- 2.7.4