summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-01 13:55:06 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-03 20:40:11 +0200
commit7869778d02d862a0efd11857c3299cd391245551 (patch)
treec8c17dbd069c5aad48075b2f1d0995273274adc4
parent42bbe0e58ffcfda31d142dbaab9be99f7d84f1c7 (diff)
efl_ui_spin: move the step implementation to spin_button
having efl_ui_spin implementing efl.ui.range_interactive does not make sense. Efl.Ui.Spin is a not interactive widget, so it should not implement that interface. ref T7897 Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D9475
-rw-r--r--src/bin/elementary/test_ui_spin.c7
-rw-r--r--src/lib/elementary/efl_ui_spin.c19
-rw-r--r--src/lib/elementary/efl_ui_spin.eo5
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c25
-rw-r--r--src/lib/elementary/efl_ui_spin_button.eo4
-rw-r--r--src/lib/elementary/efl_ui_spin_button_private.h2
-rw-r--r--src/lib/elementary/efl_ui_spin_private.h1
-rw-r--r--src/tests/elementary/spec/efl_test_range_interactive.c4
8 files changed, 31 insertions, 36 deletions
diff --git a/src/bin/elementary/test_ui_spin.c b/src/bin/elementary/test_ui_spin.c
index b57dfac..6f325bb 100644
--- a/src/bin/elementary/test_ui_spin.c
+++ b/src/bin/elementary/test_ui_spin.c
@@ -4,6 +4,8 @@
4#include <Efl_Ui.h> 4#include <Efl_Ui.h>
5#include <Elementary.h> 5#include <Elementary.h>
6 6
7#define STEP_SIZE 2
8
7static void 9static void
8_spin_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev) 10_spin_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
9{ 11{
@@ -23,13 +25,13 @@ _spin_max_reached_cb(void *data EINA_UNUSED, const Efl_Event *ev)
23static void 25static void
24_inc_clicked(void *data, const Efl_Event *ev EINA_UNUSED) 26_inc_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
25{ 27{
26 efl_ui_range_value_set(data, (efl_ui_range_value_get(data) + efl_ui_range_step_get(data))); 28 efl_ui_range_value_set(data, (efl_ui_range_value_get(data) + STEP_SIZE));
27} 29}
28 30
29static void 31static void
30_dec_clicked(void *data, const Efl_Event *ev EINA_UNUSED) 32_dec_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
31{ 33{
32 efl_ui_range_value_set(data, (efl_ui_range_value_get(data) - efl_ui_range_step_get(data))); 34 efl_ui_range_value_set(data, (efl_ui_range_value_get(data) - STEP_SIZE));
33} 35}
34 36
35void 37void
@@ -49,7 +51,6 @@ test_ui_spin(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
49 sp = efl_add(EFL_UI_SPIN_CLASS, bx, 51 sp = efl_add(EFL_UI_SPIN_CLASS, bx,
50 efl_ui_range_limits_set(efl_added, 0, 10), 52 efl_ui_range_limits_set(efl_added, 0, 10),
51 efl_ui_range_value_set(efl_added, 6), 53 efl_ui_range_value_set(efl_added, 6),
52 efl_ui_range_step_set(efl_added, 2),
53 efl_ui_format_string_set(efl_added, "test %d", EFL_UI_FORMAT_STRING_TYPE_SIMPLE), 54 efl_ui_format_string_set(efl_added, "test %d", EFL_UI_FORMAT_STRING_TYPE_SIMPLE),
54 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_CHANGED,_spin_changed_cb, NULL), 55 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_CHANGED,_spin_changed_cb, NULL),
55 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_MIN_REACHED,_spin_min_reached_cb, NULL), 56 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_MIN_REACHED,_spin_min_reached_cb, NULL),
diff --git a/src/lib/elementary/efl_ui_spin.c b/src/lib/elementary/efl_ui_spin.c
index 0e50457..b8dfa16 100644
--- a/src/lib/elementary/efl_ui_spin.c
+++ b/src/lib/elementary/efl_ui_spin.c
@@ -39,7 +39,6 @@ _efl_ui_spin_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Data *sd)
39 obj = efl_constructor(efl_super(obj, MY_CLASS)); 39 obj = efl_constructor(efl_super(obj, MY_CLASS));
40 40
41 sd->val_max = 100.0; 41 sd->val_max = 100.0;
42 sd->step = 1.0;
43 42
44 if (elm_widget_theme_object_set(obj, wd->resize_obj, 43 if (elm_widget_theme_object_set(obj, wd->resize_obj,
45 elm_widget_theme_klass_get(obj), 44 elm_widget_theme_klass_get(obj),
@@ -98,24 +97,6 @@ _efl_ui_spin_efl_ui_range_display_range_limits_get(const Eo *obj EINA_UNUSED, Ef
98} 97}
99 98
100EOLIAN static void 99EOLIAN static void
101_efl_ui_spin_efl_ui_range_interactive_range_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Spin_Data *sd, double step)
102{
103 if (step <= 0)
104 {
105 ERR("Wrong param. The step(%lf) should be bigger than 0.0", step);
106 return;
107 }
108
109 sd->step = step;
110}
111
112EOLIAN static double
113_efl_ui_spin_efl_ui_range_interactive_range_step_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spin_Data *sd)
114{
115 return sd->step;
116}
117
118EOLIAN static void
119_efl_ui_spin_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Spin_Data *sd, double val) 100_efl_ui_spin_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Spin_Data *sd, double val)
120{ 101{
121 if (val < sd->val_min) 102 if (val < sd->val_min)
diff --git a/src/lib/elementary/efl_ui_spin.eo b/src/lib/elementary/efl_ui_spin.eo
index 717c569..9f55338 100644
--- a/src/lib/elementary/efl_ui_spin.eo
+++ b/src/lib/elementary/efl_ui_spin.eo
@@ -1,5 +1,5 @@
1class @beta Efl.Ui.Spin extends Efl.Ui.Layout_Base implements Efl.Ui.Range_Interactive, Efl.Ui.Format, 1class @beta Efl.Ui.Spin extends Efl.Ui.Layout_Base implements Efl.Ui.Range_Display,
2 Efl.Access.Value, Efl.Access.Widget.Action 2Efl.Ui.Format, Efl.Access.Value, Efl.Access.Widget.Action
3{ 3{
4 [[A Spin. 4 [[A Spin.
5 5
@@ -10,7 +10,6 @@ class @beta Efl.Ui.Spin extends Efl.Ui.Layout_Base implements Efl.Ui.Range_Inter
10 Efl.Object.constructor; 10 Efl.Object.constructor;
11 Efl.Object.destructor; 11 Efl.Object.destructor;
12 Efl.Ui.Range_Display.range_limits { get; set; } 12 Efl.Ui.Range_Display.range_limits { get; set; }
13 Efl.Ui.Range_Interactive.range_step { get; set; }
14 Efl.Ui.Range_Display.range_value { get; set; } 13 Efl.Ui.Range_Display.range_value { get; set; }
15 Efl.Ui.Format.apply_formatted_value; 14 Efl.Ui.Format.apply_formatted_value;
16 } 15 }
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index 0419022..d71e101 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -404,7 +404,7 @@ _entry_toggle_cb(void *data EINA_UNUSED,
404static void 404static void
405_spin_value(Efl_Ui_Spin *obj, Eina_Bool inc) 405_spin_value(Efl_Ui_Spin *obj, Eina_Bool inc)
406{ 406{
407 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS); 407 Efl_Ui_Spin_Button_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_BUTTON_CLASS);
408 408
409 int absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step); 409 int absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step);
410 410
@@ -643,6 +643,7 @@ _efl_ui_spin_button_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Button_Data *sd)
643 643
644 obj = efl_constructor(efl_super(obj, MY_CLASS)); 644 obj = efl_constructor(efl_super(obj, MY_CLASS));
645 _sync_widget_theme_klass(obj, sd); 645 _sync_widget_theme_klass(obj, sd);
646 sd->step = 1.0;
646 647
647 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); 648 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
648 649
@@ -788,10 +789,8 @@ _efl_ui_spin_button_efl_access_value_range_get(const Eo *obj EINA_UNUSED, Efl_Ui
788} 789}
789 790
790EOLIAN static double 791EOLIAN static double
791_efl_ui_spin_button_efl_access_value_increment_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spin_Button_Data *sd EINA_UNUSED) 792_efl_ui_spin_button_efl_access_value_increment_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spin_Button_Data *pd)
792{ 793{
793 Efl_Ui_Spin_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_CLASS);
794
795 return pd->step; 794 return pd->step;
796} 795}
797 796
@@ -812,6 +811,24 @@ _efl_ui_spin_button_efl_ui_format_apply_formatted_value(Eo *obj, Efl_Ui_Spin_But
812 efl_canvas_group_change(obj); 811 efl_canvas_group_change(obj);
813} 812}
814 813
814EOLIAN static void
815_efl_ui_spin_button_efl_ui_range_interactive_range_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Spin_Button_Data *sd, double step)
816{
817 if (step <= 0)
818 {
819 ERR("Wrong param. The step(%lf) should be bigger than 0.0", step);
820 return;
821 }
822
823 sd->step = step;
824}
825
826EOLIAN static double
827_efl_ui_spin_button_efl_ui_range_interactive_range_step_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spin_Button_Data *sd)
828{
829 return sd->step;
830}
831
815// A11Y Accessibility - END 832// A11Y Accessibility - END
816 833
817#include "efl_ui_spin_button.eo.c" 834#include "efl_ui_spin_button.eo.c"
diff --git a/src/lib/elementary/efl_ui_spin_button.eo b/src/lib/elementary/efl_ui_spin_button.eo
index 45b16b7..06a57f1 100644
--- a/src/lib/elementary/efl_ui_spin_button.eo
+++ b/src/lib/elementary/efl_ui_spin_button.eo
@@ -1,5 +1,4 @@
1class @beta Efl.Ui.Spin_Button extends Efl.Ui.Spin implements Efl.Ui.Focus.Composition, Efl.Ui.Layout_Orientable, 1class @beta Efl.Ui.Spin_Button extends Efl.Ui.Spin implements Efl.Ui.Focus.Composition, Efl.Ui.Layout_Orientable, Efl.Ui.Range_Interactive, Efl.Access.Widget.Action
2 Efl.Access.Widget.Action
3{ 2{
4 [[A Button Spin. 3 [[A Button Spin.
5 4
@@ -73,5 +72,6 @@ class @beta Efl.Ui.Spin_Button extends Efl.Ui.Spin implements Efl.Ui.Focus.Compo
73 Efl.Access.Value.increment { get; } 72 Efl.Access.Value.increment { get; }
74 Efl.Access.Widget.Action.elm_actions { get; } 73 Efl.Access.Widget.Action.elm_actions { get; }
75 Efl.Ui.Format.apply_formatted_value; 74 Efl.Ui.Format.apply_formatted_value;
75 Efl.Ui.Range_Interactive.range_step { get; set; }
76 } 76 }
77} 77}
diff --git a/src/lib/elementary/efl_ui_spin_button_private.h b/src/lib/elementary/efl_ui_spin_button_private.h
index daab1ad..642b08e 100644
--- a/src/lib/elementary/efl_ui_spin_button_private.h
+++ b/src/lib/elementary/efl_ui_spin_button_private.h
@@ -8,7 +8,7 @@ struct _Efl_Ui_Spin_Button_Data
8 Eina_Future *delay_change_timer; /**< a timer for a delay,changed smart callback */ 8 Eina_Future *delay_change_timer; /**< a timer for a delay,changed smart callback */
9 9
10 Efl_Ui_Layout_Orientation dir; 10 Efl_Ui_Layout_Orientation dir;
11 11 double step;
12 Eina_Bool entry_visible : 1; 12 Eina_Bool entry_visible : 1;
13 Eina_Bool entry_reactivate : 1; 13 Eina_Bool entry_reactivate : 1;
14 Eina_Bool editable : 1; 14 Eina_Bool editable : 1;
diff --git a/src/lib/elementary/efl_ui_spin_private.h b/src/lib/elementary/efl_ui_spin_private.h
index 3dbc06b..e67f326 100644
--- a/src/lib/elementary/efl_ui_spin_private.h
+++ b/src/lib/elementary/efl_ui_spin_private.h
@@ -7,7 +7,6 @@ typedef struct _Efl_Ui_Spin_Data Efl_Ui_Spin_Data;
7struct _Efl_Ui_Spin_Data 7struct _Efl_Ui_Spin_Data
8{ 8{
9 double val, val_min, val_max; 9 double val, val_min, val_max;
10 double step; /**< step for the value change. 1 by default. */
11}; 10};
12 11
13#endif 12#endif
diff --git a/src/tests/elementary/spec/efl_test_range_interactive.c b/src/tests/elementary/spec/efl_test_range_interactive.c
index b7fd4ad..c900524 100644
--- a/src/tests/elementary/spec/efl_test_range_interactive.c
+++ b/src/tests/elementary/spec/efl_test_range_interactive.c
@@ -10,7 +10,7 @@
10 10
11/* spec-meta-start 11/* spec-meta-start
12 {"test-interface":"Efl.Ui.Range_Display_Interactive", 12 {"test-interface":"Efl.Ui.Range_Display_Interactive",
13 "test-widgets": ["Efl.Ui.Spin", "Efl.Ui.Slider", "Efl.Ui.Spin_Button"]} 13 "test-widgets": ["Efl.Ui.Slider", "Efl.Ui.Spin_Button"]}
14 spec-meta-end */ 14 spec-meta-end */
15 15
16EFL_START_TEST(step_setting) 16EFL_START_TEST(step_setting)
@@ -52,8 +52,6 @@ EFL_START_TEST(steady_event)
52 Evas *e; 52 Evas *e;
53 int count = 0; 53 int count = 0;
54 54
55 if (efl_isa(widget, EFL_UI_SPIN_CLASS)) return;
56
57 efl_event_callback_add(widget, EFL_UI_RANGE_EVENT_STEADY, _steady_cb, &count), 55 efl_event_callback_add(widget, EFL_UI_RANGE_EVENT_STEADY, _steady_cb, &count),
58 efl_ui_range_limits_set(widget, 0, 100); 56 efl_ui_range_limits_set(widget, 0, 100);
59 efl_ui_range_step_set(widget, 10); 57 efl_ui_range_step_set(widget, 10);