summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2019-08-20 09:09:14 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-08-20 09:09:14 -0400
commitebae12f06a944259b9b4c094bdb009c6391c67ea (patch)
tree5e4dc38924b23a99e40688f2cda8a02a9605fdf6
parent81a7b792359eb21f7318d0de7d52ac7c0a0f995c (diff)
elm_slider: remove dependency with efl_ui_slider
Summary: This commit includes follwoing works. 1. change parent class from EFL_UI_SLIDER_INTERVAL to EFL_UI_LAYOUT_BASE 2. get all necessary codes from efl_ui_slider and efl_ui_slider_interval to elm_slider 3. add callbacks to slider test code ref T7893 Test Plan: 1. elementary_test 2. slider 3. operate sliders on the window Reviewers: bu5hm4n, segfaultxavi, eagleeye, zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7893 Differential Revision: https://phab.enlightenment.org/D9623
-rw-r--r--src/bin/elementary/test_slider.c16
-rw-r--r--src/lib/elementary/elm_slider.c837
-rw-r--r--src/lib/elementary/elm_slider_eo.c2
-rw-r--r--src/lib/elementary/elm_widget_slider.h13
-rw-r--r--src/tests/elementary/elm_test_slider.c8
5 files changed, 577 insertions, 299 deletions
diff --git a/src/bin/elementary/test_slider.c b/src/bin/elementary/test_slider.c
index 1b0b299..10c2144 100644
--- a/src/bin/elementary/test_slider.c
+++ b/src/bin/elementary/test_slider.c
@@ -24,6 +24,18 @@ _change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
24 elm_slider_value_set(data, val); 24 elm_slider_value_set(data, val);
25} 25}
26 26
27void
28_drag_start_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
29{
30 printf("drag,started! slider value : %d\n", (int)round(elm_slider_value_get(obj)));
31}
32
33void
34_drag_stop_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
35{
36 printf("drag,stopped! slider value : %d\n", (int)round(elm_slider_value_get(obj)));
37}
38
27static void 39static void
28_ok_btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, 40_ok_btn_clicked(void *data, Evas_Object *obj EINA_UNUSED,
29 void *event_info EINA_UNUSED) 41 void *event_info EINA_UNUSED)
@@ -244,6 +256,10 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
244 evas_object_show(ic); 256 evas_object_show(ic);
245 evas_object_show(sl); 257 evas_object_show(sl);
246 258
259 evas_object_smart_callback_add(sl, "slider,drag,start", _drag_start_cb, NULL);
260 evas_object_smart_callback_add(sl, "slider,drag,stop", _drag_stop_cb, NULL);
261
262
247 // horizontally inverted slider 263 // horizontally inverted slider
248 ic = elm_icon_add(bx); 264 ic = elm_icon_add(bx);
249 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 265 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
diff --git a/src/lib/elementary/elm_slider.c b/src/lib/elementary/elm_slider.c
index eab59c1..cc09ed1 100644
--- a/src/lib/elementary/elm_slider.c
+++ b/src/lib/elementary/elm_slider.c
@@ -81,7 +81,6 @@ _is_horizontal(Efl_Ui_Layout_Orientation dir)
81static void 81static void
82_units_set(Evas_Object *obj) 82_units_set(Evas_Object *obj)
83{ 83{
84 EFL_UI_SLIDER_DATA_GET(obj, sd2);
85 ELM_SLIDER_DATA_GET(obj, sd); 84 ELM_SLIDER_DATA_GET(obj, sd);
86 85
87 if (sd->format_cb) 86 if (sd->format_cb)
@@ -92,7 +91,7 @@ _units_set(Evas_Object *obj)
92 91
93 eina_strbuf_reset(sd->format_strbuf); 92 eina_strbuf_reset(sd->format_strbuf);
94 if (!sd->intvl_enable) 93 if (!sd->intvl_enable)
95 eina_value_set(&val, sd2->val); 94 eina_value_set(&val, sd->val);
96 else 95 else
97 { 96 {
98 double v1, v2; 97 double v1, v2;
@@ -126,8 +125,6 @@ _units_set(Evas_Object *obj)
126static void 125static void
127_indicator_set(Evas_Object *obj) 126_indicator_set(Evas_Object *obj)
128{ 127{
129 EFL_UI_SLIDER_DATA_GET(obj, sd2);
130 EFL_UI_SLIDER_INTERVAL_DATA_GET(obj, pd);
131 ELM_SLIDER_DATA_GET(obj, sd); 128 ELM_SLIDER_DATA_GET(obj, sd);
132 129
133 Eina_Value val; 130 Eina_Value val;
@@ -138,7 +135,7 @@ _indicator_set(Evas_Object *obj)
138 eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE); 135 eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
139 eina_strbuf_reset(sd->indi_format_strbuf); 136 eina_strbuf_reset(sd->indi_format_strbuf);
140 137
141 eina_value_set(&val, sd2->val); 138 eina_value_set(&val, sd->val);
142 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val); 139 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val);
143 140
144 str = eina_strbuf_string_get(sd->indi_format_strbuf); 141 str = eina_strbuf_string_get(sd->indi_format_strbuf);
@@ -151,7 +148,7 @@ _indicator_set(Evas_Object *obj)
151 if (sd->popup2) 148 if (sd->popup2)
152 { 149 {
153 eina_strbuf_reset(sd->indi_format_strbuf); 150 eina_strbuf_reset(sd->indi_format_strbuf);
154 eina_value_set(&val, pd->intvl_to); 151 eina_value_set(&val, sd->intvl_to);
155 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val); 152 sd->indi_format_cb(sd->indi_format_cb_data, sd->indi_format_strbuf, val);
156 str = eina_strbuf_string_get(sd->indi_format_strbuf); 153 str = eina_strbuf_string_get(sd->indi_format_strbuf);
157 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", str); 154 elm_layout_text_set(obj, "elm.dragable2.slider:elm.indicator", str);
@@ -164,7 +161,6 @@ _indicator_set(Evas_Object *obj)
164static void 161static void
165_min_max_set(Evas_Object *obj) 162_min_max_set(Evas_Object *obj)
166{ 163{
167 EFL_UI_SLIDER_DATA_GET(obj, sd2);
168 ELM_SLIDER_DATA_GET(obj, sd); 164 ELM_SLIDER_DATA_GET(obj, sd);
169 Eina_Strbuf *str; 165 Eina_Strbuf *str;
170 Eina_Value val; 166 Eina_Value val;
@@ -174,13 +170,13 @@ _min_max_set(Evas_Object *obj)
174 170
175 str = eina_strbuf_new(); 171 str = eina_strbuf_new();
176 172
177 eina_value_set(&val, sd2->val_max); 173 eina_value_set(&val, sd->val_max);
178 sd->format_cb(sd->format_cb_data, str, val); 174 sd->format_cb(sd->format_cb_data, str, val);
179 elm_layout_text_set(obj, "elm.units.min", eina_strbuf_string_get(str)); 175 elm_layout_text_set(obj, "elm.units.min", eina_strbuf_string_get(str));
180 176
181 eina_strbuf_reset(str); 177 eina_strbuf_reset(str);
182 178
183 eina_value_set(&val, sd2->val_min); 179 eina_value_set(&val, sd->val_min);
184 sd->format_cb(sd->format_cb_data, str, val); 180 sd->format_cb(sd->format_cb_data, str, val);
185 elm_layout_text_set(obj, "elm.units.max", eina_strbuf_string_get(str)); 181 elm_layout_text_set(obj, "elm.units.max", eina_strbuf_string_get(str));
186 182
@@ -294,6 +290,190 @@ _wheel_indicator_timer_cb(void *data)
294} 290}
295 291
296static void 292static void
293_val_set(Evas_Object *obj)
294{
295 double pos, pos2;
296
297 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
298 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
299
300 if (sd->val_max > sd->val_min)
301 {
302 pos = (sd->val - sd->val_min) / (sd->val_max - sd->val_min);
303 pos2 = (sd->intvl_to - sd->val_min) / (sd->val_max - sd->val_min);
304 }
305 else
306 {
307 pos = 0.0;
308 pos2 = 0.0;
309 }
310
311 if (pos < 0.0) pos = 0.0;
312 else if (pos > 1.0)
313 pos = 1.0;
314
315 if (pos2 < 0.0) pos2 = 0.0;
316 else if (pos2 > 1.0)
317 pos2 = 1.0;
318
319 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
320 {
321 pos = 1.0 - pos;
322 pos2 = 1.0 - pos2;
323 }
324
325 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
326 pos, pos);
327 if (sd->intvl_enable)
328 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
329 pos2, pos2);
330
331 // emit accessibility event also if value was changed by API
332 if (_elm_config->atspi_mode)
333 efl_access_value_changed_signal_emit(obj);
334
335 evas_object_smart_changed(obj);
336}
337
338static void
339_val_fetch(Evas_Object *obj, Eina_Bool user_event)
340{
341 double posx = 0.0, posy = 0.0, pos = 0.0, val;
342 double posx2 = 0.0, posy2 = 0.0, pos2 = 0.0, val2 = 0.0;
343 Eina_Bool inverted = EINA_FALSE;
344 Eina_Bool evented = EINA_FALSE;
345
346 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
347 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
348
349 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"),
350 &posx, &posy);
351 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE)) pos = posx;
352 else pos = posy;
353
354 if (sd->intvl_enable)
355 {
356 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable2.slider"),
357 &posx2, &posy2);
358 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE)) pos2 = posx2;
359 else pos2 = posy2;
360 }
361
362 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
363 {
364 pos = 1.0 - pos;
365 pos2 = 1.0 - pos2;
366 inverted = EINA_TRUE;
367 }
368
369 val = (pos * (sd->val_max - sd->val_min)) + sd->val_min;
370
371 if (sd->intvl_enable)
372 {
373 val2 = (pos2 * (sd->val_max - sd->val_min)) + sd->val_min;
374 if (!inverted)
375 {
376 if (val > sd->intvl_to)
377 {
378 val = sd->intvl_to;
379 _val_set(obj);
380 }
381 else if (val2 < sd->intvl_from)
382 {
383 val2 = sd->intvl_from;
384 _val_set(obj);
385 }
386 }
387 else
388 {
389 if (val < sd->intvl_to)
390 {
391 val = sd->intvl_to;
392 _val_set(obj);
393 }
394 else if (val2 > sd->intvl_from)
395 {
396 val2 = sd->intvl_from;
397 _val_set(obj);
398 }
399 }
400 }
401 if (fabs(val - sd->val) > DBL_EPSILON)
402 {
403 sd->val = val;
404 sd->intvl_from = val;
405 if (user_event)
406 {
407 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
408 ecore_timer_del(sd->delay);
409 sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj);
410 evented = EINA_TRUE;
411 }
412 }
413
414 if (sd->intvl_enable && fabs(val2 - sd->intvl_to) > DBL_EPSILON)
415 {
416 sd->intvl_to = val2;
417 /* avoid emitting two events and setting a timer twice */
418 if (user_event && (!evented))
419 {
420 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
421 ecore_timer_del(sd->delay);
422 sd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj);
423 }
424 }
425}
426
427static void
428_slider_update(Evas_Object *obj, Eina_Bool user_event)
429{
430 _val_fetch(obj, user_event);
431 evas_object_smart_changed(obj);
432}
433
434static void
435_drag(void *data,
436 Evas_Object *obj EINA_UNUSED,
437 const char *emission EINA_UNUSED,
438 const char *source EINA_UNUSED)
439{
440 _slider_update(data, EINA_TRUE);
441}
442
443static void
444_drag_start(void *data,
445 Evas_Object *obj EINA_UNUSED,
446 const char *emission EINA_UNUSED,
447 const char *source EINA_UNUSED)
448{
449 if (!efl_ui_focus_object_focus_get(data))
450 elm_object_focus_set(data, EINA_TRUE);
451 _slider_update(data, EINA_TRUE);
452 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
453 elm_widget_scroll_freeze_push(data);
454}
455
456static void
457_drag_stop(void *data,
458 Evas_Object *obj EINA_UNUSED,
459 const char *emission EINA_UNUSED,
460 const char *source EINA_UNUSED)
461{
462 _slider_update(data, EINA_TRUE);
463 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
464 elm_widget_scroll_freeze_pop(data);
465}
466
467static void
468_drag_step(void *data,
469 Evas_Object *obj EINA_UNUSED,
470 const char *emission EINA_UNUSED,
471 const char *source EINA_UNUSED)
472{
473 _slider_update(data, EINA_TRUE);
474}
475
476static void
297_drag_up(void *data, 477_drag_up(void *data,
298 Evas_Object *obj EINA_UNUSED, 478 Evas_Object *obj EINA_UNUSED,
299 const char *emission EINA_UNUSED, 479 const char *emission EINA_UNUSED,
@@ -301,7 +481,7 @@ _drag_up(void *data,
301{ 481{
302 double step; 482 double step;
303 483
304 EFL_UI_SLIDER_DATA_GET(data, sd); 484 ELM_SLIDER_DATA_GET(data, sd);
305 step = sd->step; 485 step = sd->step;
306 486
307 if (efl_ui_layout_orientation_is_inverted(sd->dir)) step *= -1.0; 487 if (efl_ui_layout_orientation_is_inverted(sd->dir)) step *= -1.0;
@@ -319,7 +499,7 @@ _drag_down(void *data,
319{ 499{
320 double step; 500 double step;
321 501
322 EFL_UI_SLIDER_DATA_GET(data, sd); 502 ELM_SLIDER_DATA_GET(data, sd);
323 step = -sd->step; 503 step = -sd->step;
324 504
325 if (efl_ui_layout_orientation_is_inverted(sd->dir)) step *= -1.0; 505 if (efl_ui_layout_orientation_is_inverted(sd->dir)) step *= -1.0;
@@ -332,7 +512,7 @@ _drag_down(void *data,
332static Eina_Bool 512static Eina_Bool
333_key_action_drag(Evas_Object *obj, const char *params) 513_key_action_drag(Evas_Object *obj, const char *params)
334{ 514{
335 EFL_UI_SLIDER_DATA_GET(obj, sd); 515 ELM_SLIDER_DATA_GET(obj, sd);
336 const char *dir = params; 516 const char *dir = params;
337 517
338 if (!strcmp(dir, "left")) 518 if (!strcmp(dir, "left"))
@@ -405,7 +585,7 @@ _elm_slider_efl_ui_widget_widget_input_event_handler(Eo *obj, Elm_Slider_Data *s
405 else return EINA_FALSE; 585 else return EINA_FALSE;
406 586
407 _popup_show(obj, NULL, NULL, NULL); 587 _popup_show(obj, NULL, NULL, NULL);
408 efl_ui_slider_val_fetch(obj, EINA_TRUE); 588 _val_fetch(obj, EINA_TRUE);
409 evas_object_smart_changed(obj); 589 evas_object_smart_changed(obj);
410 590
411 return EINA_TRUE; 591 return EINA_TRUE;
@@ -466,10 +646,9 @@ _track2_resize_cb(void *data,
466static void 646static void
467_popup_update(Evas_Object *obj, Elm_Slider_Data *sd, Evas_Object *popup) 647_popup_update(Evas_Object *obj, Elm_Slider_Data *sd, Evas_Object *popup)
468{ 648{
469 EFL_UI_SLIDER_DATA_GET(obj, sd2);
470 if (elm_widget_is_legacy(obj)) 649 if (elm_widget_is_legacy(obj))
471 { 650 {
472 if (_is_horizontal(sd2->dir)) 651 if (_is_horizontal(sd->dir))
473 elm_widget_theme_object_set(obj, popup, "slider", "horizontal/popup", elm_widget_style_get(obj)); 652 elm_widget_theme_object_set(obj, popup, "slider", "horizontal/popup", elm_widget_style_get(obj));
474 else 653 else
475 elm_widget_theme_object_set(obj, popup, "slider", "vertical/popup", elm_widget_style_get(obj)); 654 elm_widget_theme_object_set(obj, popup, "slider", "vertical/popup", elm_widget_style_get(obj));
@@ -479,7 +658,7 @@ _popup_update(Evas_Object *obj, Elm_Slider_Data *sd, Evas_Object *popup)
479 edje_object_scale_set(popup, efl_gfx_entity_scale_get(obj) * 658 edje_object_scale_set(popup, efl_gfx_entity_scale_get(obj) *
480 elm_config_scale_get()); 659 elm_config_scale_get());
481 660
482 if (!efl_ui_layout_orientation_is_inverted(sd2->dir)) 661 if (!efl_ui_layout_orientation_is_inverted(sd->dir))
483 edje_object_signal_emit(popup, "elm,state,inverted,off", "elm"); 662 edje_object_signal_emit(popup, "elm,state,inverted,off", "elm");
484 else 663 else
485 edje_object_signal_emit(popup, "elm,state,inverted,on", "elm"); 664 edje_object_signal_emit(popup, "elm,state,inverted,on", "elm");
@@ -534,242 +713,14 @@ _popup_add(Elm_Slider_Data *sd, Eo *obj, Evas_Object **popup,
534 } 713 }
535} 714}
536 715
537void
538_elm_slider_val_fetch(Evas_Object *obj, Elm_Slider_Data *pd, Eina_Bool user_event)
539{
540 double posx = 0.0, posy = 0.0, pos = 0.0, val;
541 double posx2 = 0.0, posy2 = 0.0, pos2 = 0.0, val2 = 0.0;
542 Eina_Bool inverted = EINA_FALSE;
543 Eina_Bool evented = EINA_FALSE;
544
545 EFL_UI_SLIDER_DATA_GET(obj, sd);
546 EFL_UI_SLIDER_INTERVAL_DATA_GET(obj, id);
547 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
548
549 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"),
550 &posx, &posy);
551 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE)) pos = posx;
552 else pos = posy;
553
554 if (pd->intvl_enable)
555 {
556 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable2.slider"),
557 &posx2, &posy2);
558 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE)) pos2 = posx2;
559 else pos2 = posy2;
560 }
561
562 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
563 {
564 pos = 1.0 - pos;
565 pos2 = 1.0 - pos2;
566 inverted = EINA_TRUE;
567 }
568
569 val = (pos * (sd->val_max - sd->val_min)) + sd->val_min;
570
571 if (pd->intvl_enable)
572 {
573 val2 = (pos2 * (sd->val_max - sd->val_min)) + sd->val_min;
574 if (!inverted)
575 {
576 if (val > id->intvl_to)
577 {
578 val = id->intvl_to;
579 efl_ui_slider_val_set(obj);
580 }
581 else if (val2 < id->intvl_from)
582 {
583 val2 = id->intvl_from;
584 efl_ui_slider_val_set(obj);
585 }
586 }
587 else
588 {
589 if (val < id->intvl_to)
590 {
591 val = id->intvl_to;
592 efl_ui_slider_val_set(obj);
593 }
594 else if (val2 > id->intvl_from)
595 {
596 val2 = id->intvl_from;
597 efl_ui_slider_val_set(obj);
598 }
599 }
600 }
601 if (fabs(val - sd->val) > DBL_EPSILON)
602 {
603 sd->val = val;
604 id->intvl_from = val;
605 if (user_event)
606 {
607 efl_event_callback_legacy_call(obj, EFL_UI_RANGE_EVENT_CHANGED, NULL);
608 ecore_timer_del(pd->delay);
609 pd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj);
610 evented = EINA_TRUE;
611 }
612 }
613
614 if (pd->intvl_enable && fabs(val2 - id->intvl_to) > DBL_EPSILON)
615 {
616 id->intvl_to = val2;
617 /* avoid emitting two events and setting a timer twice */
618 if (user_event && (!evented))
619 {
620 efl_event_callback_legacy_call(obj, EFL_UI_RANGE_EVENT_CHANGED, NULL);
621 ecore_timer_del(pd->delay);
622 pd->delay = ecore_timer_add(SLIDER_DELAY_CHANGED_INTERVAL, _delay_change, obj);
623 }
624 }
625}
626
627void
628_elm_slider_val_set(Evas_Object *obj, Elm_Slider_Data *pd)
629{
630 double pos, pos2;
631
632 EFL_UI_SLIDER_DATA_GET(obj, sd);
633 EFL_UI_SLIDER_INTERVAL_DATA_GET(obj, id);
634 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
635
636 if (sd->val_max > sd->val_min)
637 {
638 pos = (sd->val - sd->val_min) / (sd->val_max - sd->val_min);
639 pos2 = (id->intvl_to - sd->val_min) / (sd->val_max - sd->val_min);
640 }
641 else
642 {
643 pos = 0.0;
644 pos2 = 0.0;
645 }
646
647 if (pos < 0.0) pos = 0.0;
648 else if (pos > 1.0)
649 pos = 1.0;
650
651 if (pos2 < 0.0) pos2 = 0.0;
652 else if (pos2 > 1.0)
653 pos2 = 1.0;
654
655 if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
656 {
657 pos = 1.0 - pos;
658 pos2 = 1.0 - pos2;
659 }
660
661 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
662 pos, pos);
663 if (pd->intvl_enable)
664 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
665 pos2, pos2);
666
667 // emit accessibility event also if value was changed by API
668 if (_elm_config->atspi_mode)
669 efl_access_value_changed_signal_emit(obj);
670
671 evas_object_smart_changed(obj);
672}
673void
674_elm_slider_down_knob(Evas_Object *obj, Elm_Slider_Data *pd, double button_x, double button_y)
675{
676 EFL_UI_SLIDER_DATA_GET(obj, sd);
677 EFL_UI_SLIDER_INTERVAL_DATA_GET(obj, id);
678 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
679
680 if (!pd->intvl_enable)
681 {
682 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
683 button_x, button_y);
684 }
685 else
686 {
687 double posx = 0.0, posy = 0.0, posx2 = 0.0, posy2 = 0.0, diff1, diff2, diff3;
688
689 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"),
690 &posx, &posy);
691 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable2.slider"),
692 &posx2, &posy2);
693
694 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE))
695 {
696 diff1 = fabs(button_x - posx);
697 diff2 = fabs(button_x - posx2);
698 diff3 = button_x - posx;
699 }
700 else
701 {
702 diff1 = fabs(button_y - posy);
703 diff2 = fabs(button_y - posy2);
704 diff3 = button_y - posy;
705 }
706
707 if (diff1 < diff2)
708 {
709 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
710 button_x, button_y);
711 id->intvl_flag = 1;
712 }
713 else if (diff1 > diff2)
714 {
715 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
716 button_x, button_y);
717 id->intvl_flag = 2;
718 }
719 else
720 {
721 if (diff3 < 0)
722 {
723 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
724 button_x, button_y);
725 id->intvl_flag = 1;
726 }
727 else
728 {
729 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
730 button_x, button_y);
731 id->intvl_flag = 2;
732 }
733 }
734 }
735}
736
737void
738_elm_slider_move_knob(Evas_Object *obj, Elm_Slider_Data *pd, double button_x, double button_y)
739{
740 EFL_UI_SLIDER_INTERVAL_DATA_GET(obj, id);
741 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
742
743 if (!pd->intvl_enable)
744 {
745 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
746 button_x, button_y);
747 }
748 else
749 {
750 if (id->intvl_flag == 1)
751 {
752 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
753 button_x, button_y);
754 }
755 else if (id->intvl_flag == 2)
756 {
757 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
758 button_x, button_y);
759 }
760
761 }
762}
763
764static char * 716static char *
765_elm_slider_theme_group_get(Evas_Object *obj, Elm_Slider_Data *sd) 717_elm_slider_theme_group_get(Evas_Object *obj EINA_UNUSED, Elm_Slider_Data *sd)
766{ 718{
767 EFL_UI_SLIDER_DATA_GET(obj, sd2);
768 Eina_Strbuf *new_group = eina_strbuf_new(); 719 Eina_Strbuf *new_group = eina_strbuf_new();
769 720
770 if (sd->intvl_enable) 721 if (sd->intvl_enable)
771 eina_strbuf_append(new_group, "range/"); 722 eina_strbuf_append(new_group, "range/");
772 if (_is_horizontal(sd2->dir)) 723 if (_is_horizontal(sd->dir))
773 eina_strbuf_append(new_group, "horizontal"); 724 eina_strbuf_append(new_group, "horizontal");
774 else 725 else
775 eina_strbuf_append(new_group, "vertical"); 726 eina_strbuf_append(new_group, "vertical");
@@ -782,7 +733,6 @@ _elm_slider_efl_ui_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
782{ 733{
783 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; 734 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
784 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC); 735 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
785 EFL_UI_SLIDER_DATA_GET_OR_RETURN(obj, sd2, EFL_UI_THEME_APPLY_ERROR_GENERIC);
786 char *group; 736 char *group;
787 737
788 group = _elm_slider_theme_group_get(obj, sd); 738 group = _elm_slider_theme_group_get(obj, sd);
@@ -795,13 +745,13 @@ _elm_slider_efl_ui_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
795 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 745 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
796 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; 746 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
797 747
798 if (_is_horizontal(sd2->dir)) 748 if (_is_horizontal(sd->dir))
799 evas_object_size_hint_min_set 749 evas_object_size_hint_min_set
800 (sd2->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) * 750 (sd->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) *
801 elm_config_scale_get(), 1); 751 elm_config_scale_get(), 1);
802 else 752 else
803 evas_object_size_hint_min_set 753 evas_object_size_hint_min_set
804 (sd2->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) * 754 (sd->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) *
805 elm_config_scale_get()); 755 elm_config_scale_get());
806 756
807 if (sd->intvl_enable) 757 if (sd->intvl_enable)
@@ -809,7 +759,7 @@ _elm_slider_efl_ui_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
809 else 759 else
810 elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); 760 elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm");
811 761
812 if (efl_ui_layout_orientation_is_inverted(sd2->dir)) 762 if (efl_ui_layout_orientation_is_inverted(sd->dir))
813 elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm"); 763 elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
814 else 764 else
815 elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm"); 765 elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm");
@@ -834,6 +784,7 @@ _elm_slider_efl_ui_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
834 _min_max_set(obj); 784 _min_max_set(obj);
835 _units_set(obj); 785 _units_set(obj);
836 _indicator_set(obj); 786 _indicator_set(obj);
787 _val_set(obj);
837 788
838 edje_object_message_signal_process(wd->resize_obj); 789 edje_object_message_signal_process(wd->resize_obj);
839 if (sd->popup) 790 if (sd->popup)
@@ -850,12 +801,96 @@ static void
850_spacer_down_cb(void *data, 801_spacer_down_cb(void *data,
851 Evas *e EINA_UNUSED, 802 Evas *e EINA_UNUSED,
852 Evas_Object *obj EINA_UNUSED, 803 Evas_Object *obj EINA_UNUSED,
853 void *event_info EINA_UNUSED) 804 void *event_info)
854{ 805{
855 ELM_SLIDER_DATA_GET(data, sd); 806 ELM_SLIDER_DATA_GET_OR_RETURN(data, sd);
807 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
808
809 Evas_Event_Mouse_Down *ev = event_info;
810 Eina_Rect sr;
811 double button_x = 0.0, button_y = 0.0;
856 812
857 sd->spacer_down = EINA_TRUE; 813 sd->spacer_down = EINA_TRUE;
814 sr = efl_gfx_entity_geometry_get(sd->spacer);
815 sd->downx = ev->canvas.x - sr.x;
816 sd->downy = ev->canvas.y - sr.y;
817 if (_is_horizontal(sd->dir))
818 {
819 button_x = ((double)ev->canvas.x - (double)sr.x) / (double)sr.w;
820 if (button_x > 1) button_x = 1;
821 if (button_x < 0) button_x = 0;
822 }
823 else
824 {
825 button_y = ((double)ev->canvas.y - (double)sr.y) / (double)sr.h;
826 if (button_y > 1) button_y = 1;
827 if (button_y < 0) button_y = 0;
828 }
829
830 if (!sd->intvl_enable)
831 {
832 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
833 button_x, button_y);
834 }
835 else
836 {
837 double posx = 0.0, posy = 0.0, posx2 = 0.0, posy2 = 0.0, diff1, diff2, diff3;
838
839 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"),
840 &posx, &posy);
841 efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable2.slider"),
842 &posx2, &posy2);
843
844 if (efl_ui_layout_orientation_is_horizontal(sd->dir, EINA_TRUE))
845 {
846 diff1 = fabs(button_x - posx);
847 diff2 = fabs(button_x - posx2);
848 diff3 = button_x - posx;
849 }
850 else
851 {
852 diff1 = fabs(button_y - posy);
853 diff2 = fabs(button_y - posy2);
854 diff3 = button_y - posy;
855 }
856
857 if (diff1 < diff2)
858 {
859 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
860 button_x, button_y);
861 sd->intvl_flag = 1;
862 }
863 else if (diff1 > diff2)
864 {
865 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
866 button_x, button_y);
867 sd->intvl_flag = 2;
868 }
869 else
870 {
871 if (diff3 < 0)
872 {
873 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
874 button_x, button_y);
875 sd->intvl_flag = 1;
876 }
877 else
878 {
879 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
880 button_x, button_y);
881 sd->intvl_flag = 2;
882 }
883 }
884 }
885
886 if (!efl_ui_focus_object_focus_get(data))
887 elm_object_focus_set(data, EINA_TRUE);
888
889 _slider_update(data, EINA_TRUE);
890
858 elm_layout_signal_emit(data, "elm,state,indicator,show", "elm"); 891 elm_layout_signal_emit(data, "elm,state,indicator,show", "elm");
892
893 evas_object_smart_callback_call(data, SIG_DRAG_START, NULL);
859} 894}
860 895
861static void 896static void
@@ -864,17 +899,80 @@ _spacer_move_cb(void *data,
864 Evas_Object *obj EINA_UNUSED, 899 Evas_Object *obj EINA_UNUSED,
865 void *event_info) 900 void *event_info)
866{ 901{
867 ELM_SLIDER_DATA_GET(data, sd); 902 ELM_SLIDER_DATA_GET_OR_RETURN(data, sd);
903 ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
904
868 Evas_Event_Mouse_Move *ev = event_info; 905 Evas_Event_Mouse_Move *ev = event_info;
906 Eina_Rect sr;
907 double button_x = 0.0, button_y = 0.0;
869 908
870 if (sd->spacer_down) 909 if (sd->spacer_down)
871 { 910 {
911 Evas_Coord d = 0;
912
913 sr = efl_gfx_entity_geometry_get(sd->spacer);
914 if (_is_horizontal(sd->dir))
915 d = abs(ev->cur.canvas.x - sr.x - sd->downx);
916 else d = abs(ev->cur.canvas.y - sr.y - sd->downy);
917 if (d > (_elm_config->thumbscroll_threshold - 1))
918 {
919 if (!sd->frozen)
920 {
921 elm_widget_scroll_freeze_push(data);
922 sd->frozen = EINA_TRUE;
923 }
924 ev->event_flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
925 }
926
872 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) 927 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
873 { 928 {
874 if (sd->spacer_down) sd->spacer_down = EINA_FALSE; 929 if (sd->spacer_down) sd->spacer_down = EINA_FALSE;
930 _slider_update(data, EINA_TRUE);
931
932 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
933
934 if (sd->frozen)
935 {
936 elm_widget_scroll_freeze_pop(data);
937 sd->frozen = EINA_FALSE;
938 }
875 elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); 939 elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm");
876 return; 940 return;
877 } 941 }
942 if (_is_horizontal(sd->dir))
943 {
944 button_x = ((double)ev->cur.canvas.x - (double)sr.x) / (double)sr.w;
945 if (button_x > 1) button_x = 1;
946 if (button_x < 0) button_x = 0;
947 }
948 else
949 {
950 button_y = ((double)ev->cur.canvas.y - (double)sr.y) / (double)sr.h;
951 if (button_y > 1) button_y = 1;
952 if (button_y < 0) button_y = 0;
953 }
954
955 if (!sd->intvl_enable)
956 {
957 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
958 button_x, button_y);
959 }
960 else
961 {
962 if (sd->intvl_flag == 1)
963 {
964 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable.slider"),
965 button_x, button_y);
966 }
967 else if (sd->intvl_flag == 2)
968 {
969 efl_ui_drag_value_set(efl_part(wd->resize_obj, "elm.dragable2.slider"),
970 button_x, button_y);
971 }
972
973 }
974
975 _slider_update(data, EINA_TRUE);
878 } 976 }
879} 977}
880 978
@@ -889,25 +987,52 @@ _spacer_up_cb(void *data,
889 if (!sd->spacer_down) return; 987 if (!sd->spacer_down) return;
890 if (sd->spacer_down) sd->spacer_down = EINA_FALSE; 988 if (sd->spacer_down) sd->spacer_down = EINA_FALSE;
891 989
990 _slider_update(data, EINA_TRUE);
991
992 evas_object_smart_callback_call(data, SIG_DRAG_STOP, NULL);
993
994 if (sd->frozen)
995 {
996 elm_widget_scroll_freeze_pop(data);
997 sd->frozen = EINA_FALSE;
998 }
892 elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm"); 999 elm_layout_signal_emit(data, "elm,state,indicator,hide", "elm");
893} 1000}
894 1001
1002static void
1003_mouse_in_cb(void *data EINA_UNUSED,
1004 Evas *e EINA_UNUSED,
1005 Evas_Object *obj,
1006 void *event_info EINA_UNUSED)
1007{
1008 efl_ui_widget_scroll_hold_push(obj);
1009}
1010
1011static void
1012_mouse_out_cb(void *data EINA_UNUSED,
1013 Evas *e EINA_UNUSED,
1014 Evas_Object *obj,
1015 void *event_info EINA_UNUSED)
1016{
1017 efl_ui_widget_scroll_hold_pop(obj);
1018}
1019
895EOLIAN static void 1020EOLIAN static void
896_elm_slider_efl_canvas_group_group_calculate(Eo *obj, Elm_Slider_Data *sd) 1021_elm_slider_efl_canvas_group_group_calculate(Eo *obj, Elm_Slider_Data *sd)
897{ 1022{
898 efl_canvas_group_need_recalculate_set(obj, EINA_FALSE); 1023 efl_canvas_group_need_recalculate_set(obj, EINA_FALSE);
899 edje_object_freeze(obj); 1024 edje_object_freeze(obj);
900 EFL_UI_SLIDER_DATA_GET(obj, sd2);
901 1025
902 if (_is_horizontal(sd2->dir)) 1026 if (_is_horizontal(sd->dir))
903 evas_object_size_hint_min_set 1027 evas_object_size_hint_min_set
904 (sd2->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) * 1028 (sd->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) *
905 elm_config_scale_get(), 1); 1029 elm_config_scale_get(), 1);
906 else 1030 else
907 evas_object_size_hint_min_set 1031 evas_object_size_hint_min_set
908 (sd2->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) * 1032 (sd->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) *
909 elm_config_scale_get()); 1033 elm_config_scale_get());
910 1034
1035 _val_fetch(obj, EINA_FALSE); // need to check whether this should be called here
911 _min_max_set(obj); 1036 _min_max_set(obj);
912 _units_set(obj); 1037 _units_set(obj);
913 _indicator_set(obj); 1038 _indicator_set(obj);
@@ -925,46 +1050,117 @@ _on_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
925 _popup_show(obj, NULL, NULL, NULL); 1050 _popup_show(obj, NULL, NULL, NULL);
926} 1051}
927 1052
1053static char *
1054_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
1055{
1056 const char *txt = elm_widget_access_info_get(obj);
1057
1058 if (!txt) txt = elm_layout_text_get(obj, NULL);
1059 if (txt) return strdup(txt);
1060
1061 return NULL;
1062}
1063
1064static char *
1065_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
1066{
1067 char *ret;
1068 Eina_Strbuf *buf = eina_strbuf_new();
1069
1070 if (elm_widget_disabled_get(obj))
1071 eina_strbuf_append(buf, " state: disabled");
1072
1073 if (eina_strbuf_length_get(buf))
1074 {
1075 ret = eina_strbuf_string_steal(buf);
1076 eina_strbuf_free(buf);
1077 return ret;
1078 }
1079
1080 eina_strbuf_free(buf);
1081 return NULL;
1082}
1083
928EOLIAN static Eo * 1084EOLIAN static Eo *
929_elm_slider_efl_object_constructor(Eo *obj, Elm_Slider_Data *priv) 1085_elm_slider_efl_object_constructor(Eo *obj, Elm_Slider_Data *priv)
930{ 1086{
931 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); 1087 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
932 EFL_UI_SLIDER_DATA_GET_OR_RETURN(obj, sd, NULL) 1088 char *group;
933 1089
934 if (!elm_widget_theme_klass_get(obj)) 1090 if (!elm_widget_theme_klass_get(obj))
935 elm_widget_theme_klass_set(obj, "slider"); 1091 elm_widget_theme_klass_set(obj, "slider");
936 obj = efl_constructor(efl_super(obj, MY_CLASS)); 1092 obj = efl_constructor(efl_super(obj, MY_CLASS));
1093
1094 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_SLIDER);
937 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 1095 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
938 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 1096 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
939 1097
1098 group = _elm_slider_theme_group_get(obj, priv);
1099 if (elm_widget_theme_object_set(obj, wd->resize_obj,
1100 elm_widget_theme_klass_get(obj),
1101 group,
1102 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
1103 CRI("Failed to set layout!");
1104
1105 free(group);
1106
1107 priv->dir = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
1108 priv->val_max = 1.0;
1109 priv->step = SLIDER_STEP;
940 priv->indicator_show = EINA_TRUE; 1110 priv->indicator_show = EINA_TRUE;
941 priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get(); 1111 priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get();
942 //TODO: customize this time duration from api or theme data. 1112 //TODO: customize this time duration from api or theme data.
943 priv->wheel_indicator_duration = 0.25; 1113 priv->wheel_indicator_duration = 0.25;
944 1114
945 elm_layout_signal_callback_add(obj, "popup,show", "elm", _popup_show, obj); // XXX: for compat 1115 priv->spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, obj,
946 elm_layout_signal_callback_add(obj, "popup,hide", "elm", _popup_hide, obj); // XXX: for compat 1116 efl_gfx_color_set(efl_added, 0, 0, 0, 0));
947 elm_layout_signal_callback_add(obj, "elm,popup,show", "elm", _popup_show, obj); 1117 efl_content_set(efl_part(obj, "elm.swallow.bar"), priv->spacer);
948 elm_layout_signal_callback_add(obj, "elm,popup,hide", "elm", _popup_hide, obj);
949 elm_layout_signal_callback_add(obj, "*", "popup,emit", _popup_emit, obj);
950 1118
951 if (!priv->intvl_enable) 1119 if (!priv->intvl_enable)
952 _popup_add(priv, obj, &priv->popup, &priv->track, priv->intvl_enable); 1120 _popup_add(priv, obj, &priv->popup, &priv->track, priv->intvl_enable);
953 else 1121 else
954 _popup_add(priv, obj, &priv->popup2, &priv->track2, priv->intvl_enable); 1122 _popup_add(priv, obj, &priv->popup2, &priv->track2, priv->intvl_enable);
955 1123
956 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL); 1124 efl_ui_format_string_set(efl_part(obj, "indicator"), "%0.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
957 1125
958 elm_widget_can_focus_set(obj, EINA_TRUE); 1126 elm_widget_can_focus_set(obj, EINA_TRUE);
959 1127
960 efl_ui_format_string_set(efl_part(obj, "indicator"), "%0.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE); 1128 // accessiblity
1129 _elm_access_object_register(obj, wd->resize_obj);
1130 _elm_access_text_set
1131 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("slider"));
1132 _elm_access_callback_set
1133 (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
1134 _elm_access_callback_set
1135 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
1136
1137 // add callbacks
1138 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL);
1139
1140 elm_layout_signal_callback_add(obj, "popup,show", "elm", _popup_show, obj); // XXX: for compat
1141 elm_layout_signal_callback_add(obj, "popup,hide", "elm", _popup_hide, obj); // XXX: for compat
1142 elm_layout_signal_callback_add(obj, "elm,popup,show", "elm", _popup_show, obj);
1143 elm_layout_signal_callback_add(obj, "elm,popup,hide", "elm", _popup_hide, obj);
1144 elm_layout_signal_callback_add(obj, "*", "popup,emit", _popup_emit, obj);
1145
1146 efl_layout_signal_callback_add(obj, "drag", "*", obj, _drag, NULL);
1147 efl_layout_signal_callback_add(obj, "drag,start", "*", obj, _drag_start, NULL);
1148 efl_layout_signal_callback_add(obj, "drag,stop", "*", obj, _drag_stop, NULL);
1149 efl_layout_signal_callback_add(obj, "drag,step", "*", obj, _drag_step, NULL);
1150 efl_layout_signal_callback_add(obj, "drag,page", "*", obj, _drag_stop, NULL);
961 1151
962 evas_object_event_callback_add 1152 evas_object_event_callback_add
963 (sd->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_down_cb, obj); 1153 (priv->spacer, EVAS_CALLBACK_MOUSE_DOWN, _spacer_down_cb, obj);
1154 evas_object_event_callback_add
1155 (priv->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj);
1156 evas_object_event_callback_add
1157 (priv->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj);
964 evas_object_event_callback_add 1158 evas_object_event_callback_add
965 (sd->spacer, EVAS_CALLBACK_MOUSE_MOVE, _spacer_move_cb, obj); 1159 (obj, EVAS_CALLBACK_MOUSE_IN, _mouse_in_cb, obj);
966 evas_object_event_callback_add 1160 evas_object_event_callback_add
967 (sd->spacer, EVAS_CALLBACK_MOUSE_UP, _spacer_up_cb, obj); 1161 (obj, EVAS_CALLBACK_MOUSE_OUT, _mouse_out_cb, obj);
1162
1163 evas_object_smart_changed(obj);
968 1164
969 return obj; 1165 return obj;
970} 1166}
@@ -1220,68 +1416,88 @@ EAPI void
1220elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) 1416elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1221{ 1417{
1222 Efl_Ui_Layout_Orientation dir; 1418 Efl_Ui_Layout_Orientation dir;
1223 EFL_UI_SLIDER_DATA_GET_OR_RETURN(obj, sd2); 1419 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1224 1420
1225 dir = horizontal ? EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL : EFL_UI_LAYOUT_ORIENTATION_VERTICAL; 1421 dir = horizontal ? EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL : EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
1226 dir |= (sd2->dir & EFL_UI_LAYOUT_ORIENTATION_INVERTED); 1422 dir |= (sd->dir & EFL_UI_LAYOUT_ORIENTATION_INVERTED);
1423
1424 sd->dir = dir;
1227 1425
1228 efl_ui_layout_orientation_set(obj, dir); 1426 efl_ui_widget_theme_apply(obj);
1229} 1427}
1230 1428
1231EAPI Eina_Bool 1429EAPI Eina_Bool
1232elm_slider_horizontal_get(const Evas_Object *obj) 1430elm_slider_horizontal_get(const Evas_Object *obj)
1233{ 1431{
1234 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE); 1432 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1433 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
1235 1434
1236 Efl_Ui_Layout_Orientation dir; 1435 return _is_horizontal(sd->dir);
1237 dir = efl_ui_layout_orientation_get(obj);
1238
1239 return _is_horizontal(dir);
1240} 1436}
1241 1437
1242EAPI void 1438EAPI void
1243elm_slider_step_set(Evas_Object *obj, double step) 1439elm_slider_step_set(Evas_Object *obj, double step)
1244{ 1440{
1245 efl_ui_range_step_set(obj, step); 1441 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1442
1443 if (step <= 0)
1444 {
1445 ERR("Wrong param. The step(%lf) should be greater than 0.0", step);
1446 return;
1447 }
1448 if (sd->step == step) return;
1449
1450 sd->step = step;
1246} 1451}
1247 1452
1248EAPI double 1453EAPI double
1249elm_slider_step_get(const Evas_Object *obj) 1454elm_slider_step_get(const Evas_Object *obj)
1250{ 1455{
1251 return efl_ui_range_step_get(obj); 1456 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd, 0.0);
1457 return sd->step;
1252} 1458}
1253 1459
1254EAPI void 1460EAPI void
1255elm_slider_value_set(Evas_Object *obj, double val) 1461elm_slider_value_set(Evas_Object *obj, double val)
1256{ 1462{
1257 efl_ui_range_value_set(obj, val); 1463 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1464 if (EINA_DBL_EQ(val, sd->val)) return;
1465
1466 sd->val = val;
1467
1468 if (sd->val < sd->val_min) sd->val = sd->val_min;
1469 if (sd->val > sd->val_max) sd->val = sd->val_max;
1470
1471 _val_set(obj);
1258} 1472}
1259 1473
1260EAPI double 1474EAPI double
1261elm_slider_value_get(const Evas_Object *obj) 1475elm_slider_value_get(const Evas_Object *obj)
1262{ 1476{
1263 return efl_ui_range_value_get(obj); 1477 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd, 0.0);
1478 return sd->val;
1264} 1479}
1265 1480
1266EAPI void 1481EAPI void
1267elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted) 1482elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
1268{ 1483{
1269 Efl_Ui_Layout_Orientation dir; 1484 Efl_Ui_Layout_Orientation dir;
1270 EFL_UI_SLIDER_DATA_GET_OR_RETURN(obj, sd2); 1485 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1271 1486
1272 dir = sd2->dir & EFL_UI_LAYOUT_ORIENTATION_AXIS_BITMASK; 1487 dir = sd->dir & EFL_UI_LAYOUT_ORIENTATION_AXIS_BITMASK;
1273 if (inverted) dir |= EFL_UI_LAYOUT_ORIENTATION_INVERTED; 1488 if (inverted) dir |= EFL_UI_LAYOUT_ORIENTATION_INVERTED;
1274 1489
1275 efl_ui_layout_orientation_set(obj, dir); 1490 sd->dir = dir;
1491
1492 efl_ui_widget_theme_apply(obj);
1276} 1493}
1277 1494
1278EAPI Eina_Bool 1495EAPI Eina_Bool
1279elm_slider_inverted_get(const Evas_Object *obj) 1496elm_slider_inverted_get(const Evas_Object *obj)
1280{ 1497{
1281 Efl_Ui_Layout_Orientation dir; 1498 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
1282 dir = efl_ui_layout_orientation_get(obj);
1283 1499
1284 return efl_ui_layout_orientation_is_inverted(dir); 1500 return efl_ui_layout_orientation_is_inverted(sd->dir);
1285} 1501}
1286 1502
1287typedef struct 1503typedef struct
@@ -1360,25 +1576,60 @@ elm_slider_range_enabled_get(const Evas_Object *obj)
1360EAPI void 1576EAPI void
1361elm_slider_range_set(Evas_Object *obj, double from, double to) 1577elm_slider_range_set(Evas_Object *obj, double from, double to)
1362{ 1578{
1363 efl_ui_slider_interval_value_set(obj, from, to); 1579 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1580 sd->intvl_from = from;
1581 sd->val = from;
1582 sd->intvl_to = to;
1583
1584 if (sd->intvl_from < sd->val_min) {
1585 sd->intvl_from = sd->val_min;
1586 sd->val = sd->val_min;
1587 }
1588 if (sd->intvl_to > sd->val_max) sd->intvl_to = sd->val_max;
1589
1590 _val_set(obj);
1364} 1591}
1365 1592
1366EAPI void 1593EAPI void
1367elm_slider_range_get(const Evas_Object *obj, double *from, double *to) 1594elm_slider_range_get(const Evas_Object *obj, double *from, double *to)
1368{ 1595{
1369 efl_ui_slider_interval_value_get(obj, from, to); 1596 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1597
1598 if (from) *from = fmin(sd->intvl_from, sd->intvl_to);
1599 if (to) *to = fmax(sd->intvl_from, sd->intvl_to);
1370} 1600}
1371 1601
1372EAPI void 1602EAPI void
1373elm_slider_min_max_set(Evas_Object *obj, double min, double max) 1603elm_slider_min_max_set(Evas_Object *obj, double min, double max)
1374{ 1604{
1375 efl_ui_range_limits_set(obj, min, max); 1605 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1606
1607 if (max < min)
1608 {
1609 ERR("Wrong params. min(%lf) is greater than max(%lf).", min, max);
1610 return;
1611 }
1612 if (EINA_DBL_EQ(max, min))
1613 {
1614 ERR("min and max must have a different value");
1615 return;
1616 }
1617 if ((EINA_DBL_EQ(sd->val_min, min)) && (EINA_DBL_EQ(sd->val_max, max))) return;
1618 sd->val_min = min;
1619 sd->val_max = max;
1620 if (sd->val < sd->val_min) sd->val = sd->val_min;
1621 if (sd->val > sd->val_max) sd->val = sd->val_max;
1622
1623 _val_set(obj);
1376} 1624}
1377 1625
1378EAPI void 1626EAPI void
1379elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max) 1627elm_slider_min_max_get(const Evas_Object *obj, double *min, double *max)
1380{ 1628{
1381 efl_ui_range_limits_get(obj, min, max); 1629 ELM_SLIDER_DATA_GET_OR_RETURN(obj, sd);
1630
1631 if (min) *min = sd->val_min;
1632 if (max) *max = sd->val_max;
1382} 1633}
1383 1634
1384EAPI void 1635EAPI void
@@ -1478,10 +1729,6 @@ void _elm_slider_efl_ui_format_apply_formatted_value(Eo *obj EINA_UNUSED, Elm_Sl
1478ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(elm_slider) 1729ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(elm_slider)
1479 1730
1480#define ELM_SLIDER_EXTRA_OPS \ 1731#define ELM_SLIDER_EXTRA_OPS \
1481 ELM_LAYOUT_CONTENT_ALIASES_OPS(elm_slider), \ 1732 ELM_LAYOUT_CONTENT_ALIASES_OPS(elm_slider)
1482 EFL_UI_SLIDER_VAL_FETCH_OPS(elm_slider), \
1483 EFL_UI_SLIDER_VAL_SET_OPS(elm_slider), \
1484 EFL_UI_SLIDER_DOWN_KNOB_OPS(elm_slider), \
1485 EFL_UI_SLIDER_MOVE_KNOB_OPS(elm_slider)
1486 1733
1487#include "elm_slider_eo.c" 1734#include "elm_slider_eo.c"
diff --git a/src/lib/elementary/elm_slider_eo.c b/src/lib/elementary/elm_slider_eo.c
index 524235b..220f1ac 100644
--- a/src/lib/elementary/elm_slider_eo.c
+++ b/src/lib/elementary/elm_slider_eo.c
@@ -86,4 +86,4 @@ static const Efl_Class_Description _elm_slider_class_desc = {
86 NULL 86 NULL
87}; 87};
88 88
89EFL_DEFINE_CLASS(elm_slider_class_get, &_elm_slider_class_desc, EFL_UI_SLIDER_INTERVAL_CLASS, ELM_LAYOUT_MIXIN, EFL_UI_LEGACY_INTERFACE, EFL_TEXT_INTERFACE, EFL_TEXT_MARKUP_INTERFACE, EFL_UI_FORMAT_MIXIN, NULL); 89EFL_DEFINE_CLASS(elm_slider_class_get, &_elm_slider_class_desc, EFL_UI_LAYOUT_BASE_CLASS, ELM_LAYOUT_MIXIN, EFL_UI_LEGACY_INTERFACE, EFL_TEXT_INTERFACE, EFL_TEXT_MARKUP_INTERFACE, EFL_UI_FORMAT_MIXIN, NULL);
diff --git a/src/lib/elementary/elm_widget_slider.h b/src/lib/elementary/elm_widget_slider.h
index c12ed7c..8290045 100644
--- a/src/lib/elementary/elm_widget_slider.h
+++ b/src/lib/elementary/elm_widget_slider.h
@@ -26,10 +26,18 @@
26typedef struct _Elm_Slider_Data Elm_Slider_Data; 26typedef struct _Elm_Slider_Data Elm_Slider_Data;
27struct _Elm_Slider_Data 27struct _Elm_Slider_Data
28{ 28{
29 Evas_Object *popup, *popup2, *track, *track2; 29 Evas_Object *popup, *popup2, *track, *track2, *spacer;
30 30
31 Ecore_Timer *wheel_indicator_timer, *delay; 31 double val, val_min, val_max, step;
32 double intvl_from, intvl_to;
32 double wheel_indicator_duration; 33 double wheel_indicator_duration;
34 int intvl_flag;
35
36 Evas_Coord downx, downy;
37 Efl_Ui_Layout_Orientation dir;
38
39 Ecore_Timer *wheel_indicator_timer, *delay;
40
33 Elm_Slider_Indicator_Visible_Mode indicator_visible_mode; /**< indicator_visible_mode of the slider. 41 Elm_Slider_Indicator_Visible_Mode indicator_visible_mode; /**< indicator_visible_mode of the slider.
34 This indicates when to show an indicator */ 42 This indicates when to show an indicator */
35 43
@@ -52,6 +60,7 @@ struct _Elm_Slider_Data
52 Eina_Bool popup_visible : 1; 60 Eina_Bool popup_visible : 1;
53 Eina_Bool intvl_enable : 1; 61 Eina_Bool intvl_enable : 1;
54 Eina_Bool spacer_down : 1; 62 Eina_Bool spacer_down : 1;
63 Eina_Bool frozen : 1;
55}; 64};
56 65
57/** 66/**
diff --git a/src/tests/elementary/elm_test_slider.c b/src/tests/elementary/elm_test_slider.c
index 76201fa..337b754 100644
--- a/src/tests/elementary/elm_test_slider.c
+++ b/src/tests/elementary/elm_test_slider.c
@@ -98,6 +98,10 @@ slider_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
98 if (event_counter == 1) 98 if (event_counter == 1)
99 evas_object_smart_callback_del(obj, "changed", slider_changed); 99 evas_object_smart_callback_del(obj, "changed", slider_changed);
100 else if (event_counter == 2) 100 else if (event_counter == 2)
101 evas_object_smart_callback_del(obj, "slider,drag,start", slider_changed);
102 else if (event_counter == 3)
103 evas_object_smart_callback_del(obj, "slider,drag,stop", slider_changed);
104 else if (event_counter == 4)
101 ecore_main_loop_quit(); 105 ecore_main_loop_quit();
102} 106}
103 107
@@ -112,6 +116,8 @@ EFL_START_TEST(elm_slider_events)
112 slider = elm_slider_add(win); 116 slider = elm_slider_add(win);
113 evas_object_smart_callback_add(slider, "changed", slider_changed, NULL); 117 evas_object_smart_callback_add(slider, "changed", slider_changed, NULL);
114 evas_object_smart_callback_add(slider, "delay,changed", slider_changed, NULL); 118 evas_object_smart_callback_add(slider, "delay,changed", slider_changed, NULL);
119 evas_object_smart_callback_add(slider, "slider,drag,start", slider_changed, NULL);
120 evas_object_smart_callback_add(slider, "slider,drag,stop", slider_changed, NULL);
115 evas_object_show(slider); 121 evas_object_show(slider);
116 evas_object_show(win); 122 evas_object_show(win);
117 evas_object_resize(slider, 400, 100); 123 evas_object_resize(slider, 400, 100);
@@ -131,7 +137,7 @@ EFL_START_TEST(elm_slider_events)
131 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL); 137 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL);
132 evas_event_feed_mouse_up(e, 1, 0, 0, NULL); 138 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
133 ecore_main_loop_begin(); 139 ecore_main_loop_begin();
134 ck_assert_int_eq(event_counter, 2); 140 ck_assert_int_eq(event_counter, 4);
135} 141}
136EFL_END_TEST 142EFL_END_TEST
137 143