forked from enlightenment/efl
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
This commit is contained in:
parent
7c0ea35097
commit
bbdab35a7a
|
@ -32,5 +32,11 @@ test_ui_timepicker(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_TIME_CHANGED,_time_changed_cb, NULL),
|
||||
efl_pack(bx, efl_added));
|
||||
|
||||
efl_add(EFL_UI_TIMEPICKER_CLASS, bx,
|
||||
efl_ui_timepicker_time_set(efl_added, 11, 35),
|
||||
efl_ui_timepicker_is_24hour_set(efl_added, EINA_TRUE),
|
||||
efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_TIME_CHANGED,_time_changed_cb, NULL),
|
||||
efl_pack(bx, efl_added));
|
||||
|
||||
efl_gfx_entity_size_set(win, EINA_SIZE2D(150, 170));
|
||||
}
|
||||
|
|
|
@ -71,6 +71,10 @@ _field_value_update(Eo *obj)
|
|||
efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR]);
|
||||
}
|
||||
|
||||
efl_ui_range_value_set(pd->min, pd->cur_time[TIMEPICKER_MIN]);
|
||||
|
||||
|
@ -112,12 +116,6 @@ _field_changed_cb(void *data, const Efl_Event *ev)
|
|||
static void
|
||||
_fields_init(Eo *obj)
|
||||
{
|
||||
const char *fmt;
|
||||
char ch;
|
||||
int i;
|
||||
int field = 0;
|
||||
char buf[FMT_LEN_MAX];
|
||||
|
||||
Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
||||
|
||||
//Field create.
|
||||
|
@ -147,6 +145,25 @@ _fields_init(Eo *obj)
|
|||
|
||||
_field_value_update(obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
EOLIAN static Eina_Error
|
||||
_efl_ui_timepicker_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Timepicker_Data *pd)
|
||||
{
|
||||
const char *fmt;
|
||||
char ch;
|
||||
int i;
|
||||
char buf[FMT_LEN_MAX];
|
||||
int field = 0;
|
||||
Eina_Error ret = EFL_UI_THEME_APPLY_ERROR_NONE;
|
||||
|
||||
ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
|
||||
|
||||
if (ret != EFL_UI_THEME_APPLY_ERROR_NONE)
|
||||
goto end;
|
||||
|
||||
|
||||
fmt = efl_datetime_manager_format_get(pd->dt_manager);
|
||||
if (!fmt)
|
||||
{
|
||||
|
@ -171,7 +188,8 @@ _fields_init(Eo *obj)
|
|||
else
|
||||
{
|
||||
//TODO: monitoring locale change and update field location.
|
||||
if (field == 0)
|
||||
//FIXME: disabled this code, as it caused issues, see T8546
|
||||
/*if (field == 0)
|
||||
{
|
||||
elm_object_signal_emit(obj, "efl,colon_field1,visible,on", "efl");
|
||||
elm_object_signal_emit(obj, "efl,colon_field0,visible,off", "efl");
|
||||
|
@ -182,8 +200,11 @@ _fields_init(Eo *obj)
|
|||
elm_object_signal_emit(obj, "efl,colon_field1,visible,off", "efl");
|
||||
}
|
||||
|
||||
elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl");
|
||||
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
||||
if (pd->is_24hour)
|
||||
elm_layout_signal_emit(obj, "efl,ampm,visible,off", "efl");
|
||||
else
|
||||
elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl");
|
||||
edje_object_message_signal_process(elm_layout_edje_get(obj));*/
|
||||
efl_content_set(efl_part(obj, buf), pd->ampm);
|
||||
}
|
||||
|
||||
|
@ -193,8 +214,12 @@ _fields_init(Eo *obj)
|
|||
}
|
||||
fmt++;
|
||||
}
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EOLIAN static Eo *
|
||||
_efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EINA_UNUSED)
|
||||
{
|
||||
|
@ -204,12 +229,6 @@ _efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EI
|
|||
elm_widget_theme_klass_set(obj, "timepicker");
|
||||
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
||||
|
||||
if (elm_widget_theme_object_set(obj, wd->resize_obj,
|
||||
elm_widget_theme_klass_get(obj),
|
||||
elm_widget_theme_element_get(obj),
|
||||
elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
|
||||
CRI("Failed to set layout!");
|
||||
|
||||
_fields_init(obj);
|
||||
|
||||
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
|
|||
if (pd->is_24hour == is_24hour) return;
|
||||
|
||||
pd->is_24hour = is_24hour;
|
||||
if (pd->is_24hour == EINA_TRUE)
|
||||
elm_layout_signal_emit(obj, "efl,ampm,visible,off", "efl");
|
||||
if (!pd->is_24hour)
|
||||
{
|
||||
efl_ui_widget_disabled_set(pd->ampm, EINA_FALSE);
|
||||
efl_ui_range_limits_set(pd->hour, 1, 12);
|
||||
}
|
||||
else
|
||||
elm_layout_signal_emit(obj, "efl,ampm,visible,on", "efl");
|
||||
{
|
||||
efl_ui_widget_disabled_set(pd->ampm, EINA_TRUE);
|
||||
efl_ui_range_limits_set(pd->hour, 0, 23);
|
||||
}
|
||||
|
||||
_field_value_update(obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class Efl.Ui.Timepicker extends Efl.Ui.Layout_Base
|
|||
implements {
|
||||
Efl.Object.constructor;
|
||||
Efl.Object.destructor;
|
||||
Efl.Ui.Widget.theme_apply;
|
||||
}
|
||||
events {
|
||||
time,changed: void; [[Called when time is changed]]
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#define EFL_NOLEGACY_API_SUPPORT
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "elementary_config.h"
|
||||
#endif
|
||||
#define EFL_LAYOUT_CALC_PROTECTED
|
||||
#include <Efl_Ui.h>
|
||||
#include "efl_ui_suite.h"
|
||||
|
||||
EFL_START_TEST(check_all_times)
|
||||
{
|
||||
Eo *win = win_add();
|
||||
Eo *timepicker = efl_add(EFL_UI_TIMEPICKER_CLASS, win);
|
||||
|
||||
for (int min = 0; min < 60; ++min)
|
||||
{
|
||||
for (int hour = 0; hour < 24; ++hour)
|
||||
{
|
||||
efl_ui_timepicker_time_set(timepicker, hour, min);
|
||||
}
|
||||
}
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(check_all_times_24_mode)
|
||||
{
|
||||
Eo *win = win_add();
|
||||
Eo *timepicker = efl_add(EFL_UI_TIMEPICKER_CLASS, win,
|
||||
efl_ui_timepicker_is_24hour_set(efl_added, EINA_TRUE));
|
||||
|
||||
for (int min = 0; min < 60; ++min)
|
||||
{
|
||||
for (int hour = 0; hour < 24; ++hour)
|
||||
{
|
||||
efl_ui_timepicker_time_set(timepicker, hour, min);
|
||||
}
|
||||
}
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void efl_ui_test_timepicker(TCase *tc)
|
||||
{
|
||||
tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
|
||||
tcase_add_test(tc, check_all_times);
|
||||
tcase_add_test(tc, check_all_times_24_mode);
|
||||
}
|
Loading…
Reference in New Issue