From: Michal Skorupinski Date: Thu, 13 Apr 2017 10:44:11 +0000 (+0200) Subject: [UI] Reaction to btn press events in the 'datetime' widgets. X-Git-Tag: submit/tizen/20170425.100558~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F25%2F125025%2F3;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git [UI] Reaction to btn press events in the 'datetime' widgets. Change-Id: I9e57173a5bdfe4d6110a732e504de43e710bb8c3 Signed-off-by: Michal Skorupinski --- diff --git a/res/widget/spinner.edc b/res/widget/spinner.edc index 1bdcd3c..8b971a5 100644 --- a/res/widget/spinner.edc +++ b/res/widget/spinner.edc @@ -595,6 +595,11 @@ group { name: "elm/spinner/base/settings.datetime"; rel1.relative: 0.0 0.0; rel2.relative: 1.0 0.0; rel2.to: "elm.swallow.text_button"; + visible: 0; + } + description { state: "active" 0.0; + inherit: "default" 0.0; + visible: 1; } } part { name: "elm.swallow.dec_button"; @@ -605,6 +610,11 @@ group { name: "elm/spinner/base/settings.datetime"; rel1.relative: 0.0 1.0; rel1.to: "elm.swallow.text_button"; rel2.relative: 1.0 1.0; + visible: 0; + } + description { state: "active" 0.0; + inherit: "default" 0.0; + visible: 1; } } part { name: "elm.swallow.text_button"; @@ -648,6 +658,24 @@ group { name: "elm/spinner/base/settings.datetime"; } } programs { + program { + name: "clicked"; + signal: "inc_dec,show"; + source: "elm"; + action: STATE_SET "active" 0.0; + target: "elm.swallow.entry"; + target: "elm.swallow.inc_button"; + target: "elm.swallow.dec_button"; + } + program { + name: "unfocused"; + signal: "inc_dec,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.inc_button"; + target: "elm.swallow.dec_button"; + } + program { name: "entry_active"; signal: "elm,state,entry,active"; source: "elm"; diff --git a/src/view/system/view_clock.c b/src/view/system/view_clock.c index 38653c1..df6a082 100755 --- a/src/view/system/view_clock.c +++ b/src/view/system/view_clock.c @@ -58,6 +58,8 @@ typedef struct { } clock_view_priv_data; +static bool date_settting_on = false; + enum input_handler_type { INPUT_HANDLER_TYPE_BTN_DONE, INPUT_HANDLER_TYPE_BTN_CANCEL, @@ -82,6 +84,17 @@ static void _disable_manual_settings(bool disable, const clock_view_priv_data *p static void _get_time_from_controls(struct tm *result, const clock_view_priv_data *priv); /* When auto/manual setup dropdown is active, focus should be only on it*/ +static void _datetime_btn_clicked_cb(int id, void *data, Evas_Object *obj); +static void _datetime_btn_unfocused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item); +static void _datetime_btn_focused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item); + +static input_handler datetime_btn_handler = { + .clicked = _datetime_btn_clicked_cb, + .unfocused = _datetime_btn_unfocused_cb, + .focused = _datetime_btn_focused_cb, +}; + + static void _dt_focused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item) { SETTING_TRACE_BEGIN @@ -252,7 +265,7 @@ static void _set_spinner_style(Evas_Object *datetime) } } -static Evas_Object *_get_spinner_button(Evas_Object *datetime, int field) +static Evas_Object *_get_spinner(Evas_Object *datetime, int field) { char buf[255]; snprintf(buf, 255, "field%d", field); @@ -263,6 +276,12 @@ static Evas_Object *_get_spinner_button(Evas_Object *datetime, int field) NULL; } + return spinner; +} + +static Evas_Object *_get_spinner_button(Evas_Object *datetime, int field) +{ + Evas_Object *spinner = _get_spinner(datetime, field); return elm_object_part_content_get(spinner, "elm.swallow.text_button"); } @@ -373,6 +392,60 @@ static void _set_focus_chain(clock_view_priv_data *priv) _dbg_obj_focus(priv->done, -1); } +static void _datetime_btn_clicked_cb(int id, void *data, Evas_Object *obj) +{ + Evas_Object *spinner = (Evas_Object *)data; + elm_object_signal_emit(spinner, "inc_dec,show", "elm"); + + if (!date_settting_on) { + date_settting_on = true; + } else { + if (elm_object_focus_next_object_get(obj, ELM_FOCUS_RIGHT) == obj) + elm_object_focus_next(obj, ELM_FOCUS_DOWN); + else + elm_object_focus_next(obj, ELM_FOCUS_RIGHT); + } + + dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] CLICKED", __FILE__, __LINE__); +} + +static void _datetime_btn_unfocused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item) +{ + Evas_Object *spinner = (Evas_Object *)data; + elm_object_signal_emit(spinner, "inc_dec,hide", "elm"); + dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] UNFOCUSED", __FILE__, __LINE__); +} + +static void _datetime_btn_focused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item) +{ + if (!date_settting_on) + return; + + Evas_Object *spinner = (Evas_Object *)data; + elm_object_signal_emit(spinner, "inc_dec,show", "elm"); + dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] FOCUSED", __FILE__, __LINE__); +} + +static void _set_spinner_btn_callbacks(Evas_Object *dt, int start_field, int end_field) +{ + Evas_Object *btn; + Evas_Object *spinner = NULL; + + int i; + for (i = start_field; i <= end_field; ++i) { + btn = _get_spinner_button(dt, i); + spinner = _get_spinner(dt, i); + + inputmgr_add_callback(btn, i, &datetime_btn_handler, spinner); + } +} + +static void _set_callbacks(clock_view_priv_data *priv) +{ + _set_spinner_btn_callbacks(priv->date_part, 0, 2); + _set_spinner_btn_callbacks(priv->time_part, 0, 2); +} + static bool _add_clock_setting(clock_view_priv_data *priv) { SETTING_TRACE_BEGIN @@ -446,6 +519,9 @@ static bool _add_clock_setting(clock_view_priv_data *priv) inputmgr_add_callback(priv->time_part, INPUT_HANDLER_TYPE_DATE_TIME, &date_time_handler, priv); + _set_callbacks(priv); + + return true; } @@ -539,6 +615,7 @@ static void _show(void *data) return; } + date_settting_on = false; display_mode = priv->view_mode_on_show ? TYPE_AUTO : TYPE_MANUAL; if (!settings_clock_get_current_time(¤t_time))