summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-02 11:40:06 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-13 15:57:17 +0100
commitbbdab35a7a911859c2f6ed2e110c5f81d7455f4e (patch)
tree93413bd6be2aba2dd9d01a6ff2a56359e7616dd7
parent7c0ea3509706e20ab553ef514bd55845fc6210dd (diff)
efl_ui_timepicker: make 24h mode work
this is something which was never ever working before. However, while fixing the 24h mode, it also appeared that the theming was applied in the wrong spot, which resulted in signals beeing called on a not yet themed object, so the theming was also fixed. (Which is the theme_apply change). To sum up: - The theme is now applied by efl_ui_layout_base - the range is now correct for 24h mode - There is a quite major problem with the theme, see T8546 - As a quick fix, am / pm button can be disabled. ref T8546 Differential Revision: https://phab.enlightenment.org/D11004
-rw-r--r--src/bin/elementary/test_ui_timepicker.c6
-rw-r--r--src/lib/elementary/efl_ui_timepicker.c62
-rw-r--r--src/lib/elementary/efl_ui_timepicker.eo1
-rw-r--r--src/tests/elementary/efl_ui_test_timepicker.c45
4 files changed, 96 insertions, 18 deletions
diff --git a/src/bin/elementary/test_ui_timepicker.c b/src/bin/elementary/test_ui_timepicker.c
index 3249699bc8..f7b5d7d676 100644
--- a/src/bin/elementary/test_ui_timepicker.c
+++ b/src/bin/elementary/test_ui_timepicker.c
@@ -32,5 +32,11 @@ test_ui_timepicker(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
32 efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_TIME_CHANGED,_time_changed_cb, NULL), 32 efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_TIME_CHANGED,_time_changed_cb, NULL),
33 efl_pack(bx, efl_added)); 33 efl_pack(bx, efl_added));
34 34
35 efl_add(EFL_UI_TIMEPICKER_CLASS, bx,
36 efl_ui_timepicker_time_set(efl_added, 11, 35),
37 efl_ui_timepicker_is_24hour_set(efl_added, EINA_TRUE),
38 efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_TIME_CHANGED,_time_changed_cb, NULL),
39 efl_pack(bx, efl_added));
40
35 efl_gfx_entity_size_set(win, EINA_SIZE2D(150, 170)); 41 efl_gfx_entity_size_set(win, EINA_SIZE2D(150, 170));
36} 42}
diff --git a/src/lib/elementary/efl_ui_timepicker.c b/src/lib/elementary/efl_ui_timepicker.c
index 335e26230e..d66ed0e853 100644
--- a/src/lib/elementary/efl_ui_timepicker.c
+++ b/src/lib/elementary/efl_ui_timepicker.c
@@ -71,6 +71,10 @@ _field_value_update(Eo *obj)
71 efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR]); 71 efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR]);
72 } 72 }
73 } 73 }
74 else
75 {
76 efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR]);
77 }
74 78
75 efl_ui_range_value_set(pd->min, pd->cur_time[TIMEPICKER_MIN]); 79 efl_ui_range_value_set(pd->min, pd->cur_time[TIMEPICKER_MIN]);
76 80
@@ -112,12 +116,6 @@ _field_changed_cb(void *data, const Efl_Event *ev)
112static void 116static void
113_fields_init(Eo *obj) 117_fields_init(Eo *obj)
114{ 118{
115 const char *fmt;
116 char ch;
117 int i;
118 int field = 0;
119 char buf[FMT_LEN_MAX];
120
121 Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS); 119 Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
122 120
123 //Field create. 121 //Field create.
@@ -147,6 +145,25 @@ _fields_init(Eo *obj)
147 145
148 _field_value_update(obj); 146 _field_value_update(obj);
149 147
148}
149
150
151EOLIAN static Eina_Error
152_efl_ui_timepicker_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Timepicker_Data *pd)
153{
154 const char *fmt;
155 char ch;
156 int i;
157 char buf[FMT_LEN_MAX];
158 int field = 0;
159 Eina_Error ret = EFL_UI_THEME_APPLY_ERROR_NONE;
160
161 ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
162
163 if (ret != EFL_UI_THEME_APPLY_ERROR_NONE)
164 goto end;
165
166
150 fmt = efl_datetime_manager_format_get(pd->dt_manager); 167 fmt = efl_datetime_manager_format_get(pd->dt_manager);
151 if (!fmt) 168 if (!fmt)
152 { 169 {
@@ -171,7 +188,8 @@ _fields_init(Eo *obj)
171 else 188 else
172 { 189 {
173 //TODO: monitoring locale change and update field location. 190 //TODO: monitoring locale change and update field location.
174 if (field == 0) 191 //FIXME: disabled this code, as it caused issues, see T8546
192 /*if (field == 0)
175 { 193 {
176 elm_object_signal_emit(obj, "efl,colon_field1,visible,on", "efl"); 194 elm_object_signal_emit(obj, "efl,colon_field1,visible,on", "efl");
177 elm_object_signal_emit(obj, "efl,colon_field0,visible,off", "efl"); 195 elm_object_signal_emit(obj, "efl,colon_field0,visible,off", "efl");
@@ -182,8 +200,11 @@ _fields_init(Eo *obj)
182 elm_object_signal_emit(obj, "efl,colon_field1,visible,off", "efl"); 200 elm_object_signal_emit(obj, "efl,colon_field1,visible,off", "efl");
183 } 201 }
184 202
185 elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl"); 203 if (pd->is_24hour)
186 edje_object_message_signal_process(elm_layout_edje_get(obj)); 204 elm_layout_signal_emit(obj, "efl,ampm,visible,off", "efl");
205 else
206 elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl");
207 edje_object_message_signal_process(elm_layout_edje_get(obj));*/
187 efl_content_set(efl_part(obj, buf), pd->ampm); 208 efl_content_set(efl_part(obj, buf), pd->ampm);
188 } 209 }
189 210
@@ -193,8 +214,12 @@ _fields_init(Eo *obj)
193 } 214 }
194 fmt++; 215 fmt++;
195 } 216 }
217end:
218 return ret;
196} 219}
197 220
221
222
198EOLIAN static Eo * 223EOLIAN static Eo *
199_efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EINA_UNUSED) 224_efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EINA_UNUSED)
200{ 225{
@@ -204,12 +229,6 @@ _efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EI
204 elm_widget_theme_klass_set(obj, "timepicker"); 229 elm_widget_theme_klass_set(obj, "timepicker");
205 obj = efl_constructor(efl_super(obj, MY_CLASS)); 230 obj = efl_constructor(efl_super(obj, MY_CLASS));
206 231
207 if (elm_widget_theme_object_set(obj, wd->resize_obj,
208 elm_widget_theme_klass_get(obj),
209 elm_widget_theme_element_get(obj),
210 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
211 CRI("Failed to set layout!");
212
213 _fields_init(obj); 232 _fields_init(obj);
214 233
215 elm_widget_can_focus_set(obj, EINA_TRUE); 234 elm_widget_can_focus_set(obj, EINA_TRUE);
@@ -250,10 +269,17 @@ _efl_ui_timepicker_is_24hour_set(Eo *obj, Efl_Ui_Timepicker_Data *pd, Eina_Bool
250 if (pd->is_24hour == is_24hour) return; 269 if (pd->is_24hour == is_24hour) return;
251 270
252 pd->is_24hour = is_24hour; 271 pd->is_24hour = is_24hour;
253 if (pd->is_24hour == EINA_TRUE) 272 if (!pd->is_24hour)
254 elm_layout_signal_emit(obj, "efl,ampm,visible,off", "efl"); 273 {
274 efl_ui_widget_disabled_set(pd->ampm, EINA_FALSE);
275 efl_ui_range_limits_set(pd->hour, 1, 12);
276 }
255 else 277 else
256 elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl"); 278 {
279 efl_ui_widget_disabled_set(pd->ampm, EINA_TRUE);
280 efl_ui_range_limits_set(pd->hour, 0, 23);
281 }
282
257 _field_value_update(obj); 283 _field_value_update(obj);
258} 284}
259 285
diff --git a/src/lib/elementary/efl_ui_timepicker.eo b/src/lib/elementary/efl_ui_timepicker.eo
index d7aa8fcc23..9ced109efb 100644
--- a/src/lib/elementary/efl_ui_timepicker.eo
+++ b/src/lib/elementary/efl_ui_timepicker.eo
@@ -40,6 +40,7 @@ class Efl.Ui.Timepicker extends Efl.Ui.Layout_Base
40 implements { 40 implements {
41 Efl.Object.constructor; 41 Efl.Object.constructor;
42 Efl.Object.destructor; 42 Efl.Object.destructor;
43 Efl.Ui.Widget.theme_apply;
43 } 44 }
44 events { 45 events {
45 time,changed: void; [[Called when time is changed]] 46 time,changed: void; [[Called when time is changed]]
diff --git a/src/tests/elementary/efl_ui_test_timepicker.c b/src/tests/elementary/efl_ui_test_timepicker.c
new file mode 100644
index 0000000000..1aca88cc23
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_timepicker.c
@@ -0,0 +1,45 @@
1#define EFL_NOLEGACY_API_SUPPORT
2#ifdef HAVE_CONFIG_H
3# include "elementary_config.h"
4#endif
5#define EFL_LAYOUT_CALC_PROTECTED
6#include <Efl_Ui.h>
7#include "efl_ui_suite.h"
8
9EFL_START_TEST(check_all_times)
10{
11 Eo *win = win_add();
12 Eo *timepicker = efl_add(EFL_UI_TIMEPICKER_CLASS, win);
13
14 for (int min = 0; min < 60; ++min)
15 {
16 for (int hour = 0; hour < 24; ++hour)
17 {
18 efl_ui_timepicker_time_set(timepicker, hour, min);
19 }
20 }
21}
22EFL_END_TEST
23
24EFL_START_TEST(check_all_times_24_mode)
25{
26 Eo *win = win_add();
27 Eo *timepicker = efl_add(EFL_UI_TIMEPICKER_CLASS, win,
28 efl_ui_timepicker_is_24hour_set(efl_added, EINA_TRUE));
29
30 for (int min = 0; min < 60; ++min)
31 {
32 for (int hour = 0; hour < 24; ++hour)
33 {
34 efl_ui_timepicker_time_set(timepicker, hour, min);
35 }
36 }
37}
38EFL_END_TEST
39
40void efl_ui_test_timepicker(TCase *tc)
41{
42 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
43 tcase_add_test(tc, check_all_times);
44 tcase_add_test(tc, check_all_times_24_mode);
45}