summaryrefslogtreecommitdiff
path: root/src/lib/elm_slider.c
diff options
context:
space:
mode:
authorWooHyun Jung <woohyun0705@gmail.com>2012-01-02 08:56:19 +0000
committerWooHyun Jung <woohyun0705@gmail.com>2012-01-02 08:56:19 +0000
commit26f88ba415cac537d2fe8671c868f25c8ea1fbdf (patch)
treef367ab9157d7e3757194f3dc0ea60eb6ca38bc3b /src/lib/elm_slider.c
parent5ddd911eea87823f294ffa03007ebd50b5390ba5 (diff)
elementary/elm_slider : Changed codes for not using feed events. This
codes are for the feature that "mouse down on slider bar" -> "button move to the down position" -> "button will be dragged by mouse move". SVN revision: 66733
Diffstat (limited to '')
-rw-r--r--src/lib/elm_slider.c71
1 files changed, 57 insertions, 14 deletions
diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c
index ed6cedea7..d681f02bd 100644
--- a/src/lib/elm_slider.c
+++ b/src/lib/elm_slider.c
@@ -28,6 +28,7 @@ struct _Widget_Data
28 Eina_Bool horizontal : 1; 28 Eina_Bool horizontal : 1;
29 Eina_Bool inverted : 1; 29 Eina_Bool inverted : 1;
30 Eina_Bool indicator_show : 1; 30 Eina_Bool indicator_show : 1;
31 Eina_Bool spacer_down : 1;
31}; 32};
32 33
33#define ELM_SLIDER_INVERTED_FACTOR (-1.0) 34#define ELM_SLIDER_INVERTED_FACTOR (-1.0)
@@ -50,7 +51,9 @@ static void _drag_down(void *data, Evas_Object *obj,
50 const char *emission, const char *source); 51 const char *emission, const char *source);
51static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, 52static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
52 Evas_Callback_Type type, void *event_info); 53 Evas_Callback_Type type, void *event_info);
53static void _spacer_cb(void *data, Evas * e, Evas_Object * obj, void *event_info); 54static void _spacer_down_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
55static void _spacer_move_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
56static void _spacer_up_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
54 57
55static const char SIG_CHANGED[] = "changed"; 58static const char SIG_CHANGED[] = "changed";
56static const char SIG_DELAY_CHANGED[] = "delay,changed"; 59static const char SIG_DELAY_CHANGED[] = "delay,changed";
@@ -446,18 +449,15 @@ _drag_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSE
446} 449}
447 450
448static void 451static void
449_spacer_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) 452_spacer_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
450{ 453{
451 Widget_Data *wd = elm_widget_data_get(data); 454 Widget_Data *wd = elm_widget_data_get(data);
452 Evas_Event_Mouse_Down *ev = event_info; 455 Evas_Event_Mouse_Down *ev = event_info;
453 Evas_Coord x, y, w, h; 456 Evas_Coord x, y, w, h;
454 double button_x, button_y; 457 double button_x = 0.0, button_y = 0.0;
455 double prev_button_x, prev_button_y;
456 458
459 wd->spacer_down = EINA_TRUE;
457 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h); 460 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
458 edje_object_part_drag_value_get(wd->slider, "elm.dragable.slider", &prev_button_x, &prev_button_y);
459 button_x = prev_button_x;
460 button_y = prev_button_y;
461 if (wd->horizontal) 461 if (wd->horizontal)
462 { 462 {
463 button_x = ((double)ev->canvas.x - (double)x) / (double)w; 463 button_x = ((double)ev->canvas.x - (double)x) / (double)w;
@@ -470,16 +470,57 @@ _spacer_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev
470 if (button_y > 1) button_y = 1; 470 if (button_y > 1) button_y = 1;
471 if (button_y < 0) button_y = 0; 471 if (button_y < 0) button_y = 0;
472 } 472 }
473 if (button_x != prev_button_x || button_y != prev_button_y) 473 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
474 _val_fetch(data);
475 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
476 _units_set(data);
477 _indicator_set(data);
478 elm_widget_scroll_freeze_push(data);
479 edje_object_signal_emit(wd->slider, "elm,state,indicator,show", "elm");
480}
481
482static void
483_spacer_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
484{
485 Widget_Data *wd = elm_widget_data_get(data);
486 Evas_Event_Mouse_Move *ev = event_info;
487 Evas_Coord x, y, w, h;
488 double button_x = 0.0, button_y = 0.0;
489
490 if (wd->spacer_down)
474 { 491 {
492 evas_object_geometry_get(wd->spacer, &x, &y, &w, &h);
493 if (wd->horizontal)
494 {
495 button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w;
496 if (button_x > 1) button_x = 1;
497 if (button_x < 0) button_x = 0;
498 }
499 else
500 {
501 button_y = ((double)ev->cur.canvas.y - (double)y) / (double)h;
502 if (button_y > 1) button_y = 1;
503 if (button_y < 0) button_y = 0;
504 }
475 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y); 505 edje_object_part_drag_value_set(wd->slider, "elm.dragable.slider", button_x, button_y);
506 _val_fetch(data);
507 _units_set(data);
508 _indicator_set(data);
476 } 509 }
510}
511
512static void
513_spacer_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
514{
515 Widget_Data *wd = elm_widget_data_get(data);
477 516
478 //What is a purpose of these two mouse events? 517 if (wd->spacer_down) wd->spacer_down = EINA_FALSE;
479 //I don't know the reason but these calls cause infinite loop. 518 _val_fetch(data);
480 //So blocked them. 519 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
481 //evas_event_feed_mouse_cancel(e, 0, NULL); 520 _units_set(data);
482 //evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL); 521 _indicator_set(data);
522 elm_widget_scroll_freeze_pop(data);
523 edje_object_signal_emit(wd->slider, "elm,state,indicator,hide", "elm");
483} 524}
484 525
485static void 526static void
@@ -712,7 +753,9 @@ elm_slider_add(Evas_Object *parent)
712 evas_object_pass_events_set(wd->spacer, EINA_TRUE); 753 evas_object_pass_events_set(wd->spacer, EINA_TRUE);
713 elm_widget_sub_object_add(obj, wd->spacer); 754 elm_widget_sub_object_add(obj, wd->spacer);
714 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer); 755 edje_object_part_swallow(wd->slider, "elm.swallow.bar", wd->spacer);
715 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_cb, obj); 756 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_down_cb, obj);
757 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj);
758 evas_object_event_callback_add(wd->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj);
716 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj); 759 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
717 760
718 _mirrored_set(obj, elm_widget_mirrored_get(obj)); 761 _mirrored_set(obj, elm_widget_mirrored_get(obj));