diff options
-rw-r--r-- | config/default/base.src | 29 | ||||
-rw-r--r-- | config/mobile/base.src | 29 | ||||
-rw-r--r-- | config/standard/base.src | 29 | ||||
-rw-r--r-- | src/lib/elm_flipselector.c | 44 |
4 files changed, 115 insertions, 16 deletions
diff --git a/config/default/base.src b/config/default/base.src index 3b3db466c..64e3026c5 100644 --- a/config/default/base.src +++ b/config/default/base.src @@ -655,6 +655,35 @@ group "Elm_Config" struct { } } group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Flipselector"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Gengrid"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/config/mobile/base.src b/config/mobile/base.src index 0244c9cff..8f3355706 100644 --- a/config/mobile/base.src +++ b/config/mobile/base.src @@ -659,6 +659,35 @@ group "Elm_Config" struct { } } group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Flipselector"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Gengrid"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/config/standard/base.src b/config/standard/base.src index 4b91a91b0..e4b903baf 100644 --- a/config/standard/base.src +++ b/config/standard/base.src @@ -656,6 +656,35 @@ group "Elm_Config" struct { } } group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Flipselector"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Up"; + value "action" string: "flip"; + value "params" string: "up"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Down"; + value "action" string: "flip"; + value "params" string: "down"; + } + } + } + group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Gengrid"; group "key_bindings" list { group "Elm_Config_Binding_Key" struct { diff --git a/src/lib/elm_flipselector.c b/src/lib/elm_flipselector.c index fd7137c01..cd09946ef 100644 --- a/src/lib/elm_flipselector.c +++ b/src/lib/elm_flipselector.c @@ -47,6 +47,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {NULL, NULL} }; +static Eina_Bool _key_action_flip(Evas_Object *obj, const char *params); + +static const Elm_Action key_actions[] = { + {"flip", _key_action_flip}, + {NULL, NULL} +}; + EOLIAN static void _elm_flipselector_elm_layout_sizing_eval(Eo *obj, Elm_Flipselector_Data *sd) { @@ -427,21 +434,11 @@ _flip_down(Elm_Flipselector_Data *sd) _send_msg(sd, MSG_FLIP_DOWN, (char *)item->label); } -EOLIAN static Eina_Bool -_elm_flipselector_elm_widget_event(Eo *obj EINA_UNUSED, Elm_Flipselector_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info) +static Eina_Bool +_key_action_flip(Evas_Object *obj, const char *params) { - Eina_Bool is_up = EINA_TRUE; - - Evas_Event_Key_Down *ev = event_info; - (void) src; - - if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - - if ((!strcmp(ev->key, "Down")) || (!strcmp(ev->key, "KP_Down"))) - is_up = EINA_FALSE; - else if ((strcmp(ev->key, "Up")) && (strcmp(ev->key, "KP_Up"))) - return EINA_FALSE; + ELM_FLIPSELECTOR_DATA_GET(obj, sd); + const char *dir = params; ELM_SAFE_FREE(sd->spin, ecore_timer_del); @@ -449,10 +446,25 @@ _elm_flipselector_elm_widget_event(Eo *obj EINA_UNUSED, Elm_Flipselector_Data *s these calls by flip_{next,prev} */ _flipselector_walk(sd); - if (is_up) _flip_up(sd); - else _flip_down(sd); + if (!strcmp(dir, "up")) _flip_up(sd); + else if (!strcmp(dir, "down")) _flip_down(sd); + else return EINA_FALSE; _flipselector_unwalk(sd); + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_elm_flipselector_elm_widget_event(Eo *obj EINA_UNUSED, Elm_Flipselector_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + (void) src; + + if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; + + if (!_elm_config_key_binding_call(obj, ev, key_actions)) + return EINA_FALSE; ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; |