[segment_control] fix click event bug
authorjaehwan <jae.hwan.kim@samsung.com>
Mon, 16 Aug 2010 12:37:38 +0000 (21:37 +0900)
committerjaehwan <jae.hwan.kim@samsung.com>
Mon, 16 Aug 2010 12:37:38 +0000 (21:37 +0900)
src/lib/elm_controlbar.c
src/lib/elm_segment_control.c

index ba327ac..b961392 100644 (file)
@@ -883,6 +883,7 @@ item_exchange_animation_cb(void *data, Evas_Object * obj)
        printf("animation error\n");
        wd->animating = 0;
      }
+   evas_object_map_enable_set(obj, EINA_FALSE);
 }
 
 static void
@@ -924,6 +925,7 @@ item_change_animation_cb(void *data, Evas_Object * obj)
        printf("animation error\n");
        wd->animating = 0;
      }
+   evas_object_map_enable_set(obj, EINA_FALSE);
    evas_object_geometry_get(obj, &x, &y, &w, &h);
    set_evas_map(obj, x, y, 0, 0);
    evas_object_move(obj, -1000, -1000);
@@ -1487,6 +1489,7 @@ bar_item_move_end_cb(void *data, Evas_Object * obj)
        wd->animating = 0;
      }
    evas_object_data_set(obj, "animating", 0);
+   evas_object_map_enable_set(obj, EINA_FALSE);
 }
        
 static int
@@ -1578,8 +1581,10 @@ bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
    Widget_Data * wd = (Widget_Data *) data;
    evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
    tx = ev->output.x - w / 2;
+   wd->animating++;
+   evas_object_data_set(wd->moving_obj, "animating", (void *)1);
    move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
-                              move_evas_map, NULL, NULL);
+                              move_evas_map, bar_item_move_end_cb, wd);
    ecore_timer_add(0.1, bar_item_animation_end_check, wd);
    return;
 }
index d0d30e3..c0c073b 100755 (executable)
@@ -73,32 +73,6 @@ _on_focus_hook(void *data, Evas_Object *obj)
 }
 
 static void
-_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-   Elm_Segment_Item *item = (Elm_Segment_Item *) data;
-   Widget_Data *wd = elm_widget_data_get(item->obj);
-
-   if (!wd) return;
-
-   if(wd->selected == EINA_TRUE)
-     {
-         wd->selected = EINA_FALSE;
-         return;
-     }
-
-   if(wd->longpressed == EINA_FALSE)
-     {
-       edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
-       edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
-     }
-   if (item->long_timer)
-     {
-       ecore_timer_del(item->long_timer);
-       item->long_timer = NULL;
-     }
-}
-
-static void
 _signal_segment_on(void *data)
 {
    Elm_Segment_Item *item = (Elm_Segment_Item *) data;
@@ -106,6 +80,8 @@ _signal_segment_on(void *data)
 
    if (!wd) return;
 
+   wd->selected = EINA_TRUE;
+
    if (item->long_timer)
      {
        ecore_timer_del(item->long_timer);
@@ -140,6 +116,67 @@ _signal_segment_on(void *data)
 }
 
 static void
+_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Elm_Segment_Item *item = (Elm_Segment_Item *) data;
+   Widget_Data *wd = elm_widget_data_get(item->obj);
+   Evas_Event_Mouse_Up * ev = event_info;
+   Evas_Coord x, y, w, h;
+
+   if (!wd) return;
+
+   evas_object_geometry_get(obj, &x, &y, &w, &h);
+   if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h && wd->selected == EINA_FALSE)
+     {
+       _signal_segment_on(item);
+     }
+   else
+     {
+         wd->selected = EINA_FALSE;
+         return;
+     }
+
+   if(wd->longpressed == EINA_FALSE)
+     {
+       edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
+       edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
+     }
+   if (item->long_timer)
+     {
+       ecore_timer_del(item->long_timer);
+       item->long_timer = NULL;
+     }
+}
+
+static void
+_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+   Elm_Segment_Item *item = (Elm_Segment_Item *) data;
+   Widget_Data *wd = elm_widget_data_get(item->obj);
+   Evas_Event_Mouse_Move * ev = event_info;
+   Evas_Coord x, y, w, h;
+
+   if (!wd) return;
+
+   evas_object_geometry_get(obj, &x, &y, &w, &h);
+   if(ev->cur.output.x > x && ev->cur.output.x < x+w && ev->cur.output.y > y && ev->cur.output.y < y+h)
+     {
+       return;
+     }
+
+       if(wd->longpressed == EINA_FALSE)
+     {
+       edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
+       edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
+     }
+   if (item->long_timer)
+     {
+       ecore_timer_del(item->long_timer);
+       item->long_timer = NULL;
+     }
+}
+
+static void
 _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
 {
    Elm_Segment_Item *item = (Elm_Segment_Item *) data;
@@ -546,6 +583,7 @@ elm_segment_control_add_segment(Evas_Object *obj, Evas_Object *icon, const char
    wd->id = eina_list_count(wd->seg_ctrl);
    _update_list(obj);
    evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
+   evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
    evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
    wd->insert_index = 0;
    wd->del_index = 0;