map: apply key binding

Summary: This patch applies key binding to elm_map.

Test Plan: None

Reviewers: Hermet, raster

Reviewed By: Hermet

Differential Revision: https://phab.enlightenment.org/D733
This commit is contained in:
Jaeun Choi 2014-04-15 14:52:06 +09:00 committed by ChunEon Park
parent 3449c44221
commit d8d53f4268
4 changed files with 315 additions and 26 deletions

View File

@ -946,6 +946,95 @@ group "Elm_Config" struct {
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Map";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Add";
value "action" string: "zoom";
value "params" string: "in";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Subtract";
value "action" string: "zoom";
value "params" string: "out";
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Panel";
group "key_bindings" list {

View File

@ -950,6 +950,95 @@ group "Elm_Config" struct {
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Map";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Add";
value "action" string: "zoom";
value "params" string: "in";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Subtract";
value "action" string: "zoom";
value "params" string: "out";
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Panel";
group "key_bindings" list {

View File

@ -947,6 +947,95 @@ group "Elm_Config" struct {
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Map";
group "key_bindings" list {
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Left";
value "action" string: "move";
value "params" string: "left";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Right";
value "action" string: "move";
value "params" string: "right";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Up";
value "action" string: "move";
value "params" string: "up";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Down";
value "action" string: "move";
value "params" string: "down";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Prior";
value "action" string: "move";
value "params" string: "prior";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Next";
value "action" string: "move";
value "params" string: "next";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Add";
value "action" string: "zoom";
value "params" string: "in";
}
group "Elm_Config_Binding_Key" struct {
value "context" int: 0;
value "key" string: "KP_Subtract";
value "action" string: "zoom";
value "params" string: "out";
}
}
}
group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Panel";
group "key_bindings" list {

View File

@ -48,6 +48,15 @@
#define NOMINATIM_ATTR_LAT "lat"
#define NOMINATIM_ATTR_ADDRESS "display_name"
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params);
static const Elm_Action key_actions[] = {
{"move", _key_action_move},
{"zoom", _key_action_zoom},
{NULL, NULL}
};
static char *
_mapnik_url_cb(const Evas_Object *obj EINA_UNUSED,
int x,
@ -3805,77 +3814,90 @@ _elm_map_elm_widget_theme_apply(Eo *obj, Elm_Map_Data *sd EINA_UNUSED)
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_elm_map_elm_widget_event(Eo *obj, Elm_Map_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
static Eina_Bool
_key_action_move(Evas_Object *obj, const char *params)
{
(void) src;
Evas_Event_Key_Down *ev = event_info;
const char *dir = params;
Evas_Coord vh;
Evas_Coord x, y;
Evas_Coord step_x, step_y, page_x, page_y;
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
eo_do(obj,
elm_interface_scrollable_content_pos_get(&x, &y),
elm_interface_scrollable_step_size_get(&step_x, &step_y),
elm_interface_scrollable_page_size_get(&page_x, &page_y),
elm_interface_scrollable_content_viewport_size_get(NULL, &vh));
if ((!strcmp(ev->key, "Left")) ||
((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
if (!strcmp(dir, "left"))
{
x -= step_x;
}
else if ((!strcmp(ev->key, "Right")) ||
((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
else if (!strcmp(dir, "right"))
{
x += step_x;
}
else if ((!strcmp(ev->key, "Up")) ||
((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
else if (!strcmp(dir, "up"))
{
y -= step_y;
}
else if ((!strcmp(ev->key, "Down")) ||
((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
else if (!strcmp(dir, "down"))
{
y += step_y;
}
else if ((!strcmp(ev->key, "Prior")) ||
((!strcmp(ev->key, "KP_Prior")) && (!ev->string)))
else if (!strcmp(dir, "prior"))
{
if (page_y < 0)
y -= -(page_y * vh) / 100;
else
y -= page_y;
}
else if ((!strcmp(ev->key, "Next")) ||
((!strcmp(ev->key, "KP_Next")) && (!ev->string)))
else if (!strcmp(dir, "next"))
{
if (page_y < 0)
y += -(page_y * vh) / 100;
else
y += page_y;
}
else if (!strcmp(ev->key, "KP_Add"))
else return EINA_FALSE;
eo_do(obj, elm_interface_scrollable_content_pos_set(x, y, EINA_TRUE));
return EINA_TRUE;
}
static Eina_Bool
_key_action_zoom(Evas_Object *obj, const char *params)
{
ELM_MAP_DATA_GET(obj, sd);
const char *dir = params;
if (!strcmp(dir, "in"))
{
_zoom_with_animation(sd, sd->zoom + 1, 10);
return EINA_TRUE;
}
else if (!strcmp(ev->key, "KP_Subtract"))
else if (!strcmp(dir, "out"))
{
_zoom_with_animation(sd, sd->zoom - 1, 10);
return EINA_TRUE;
}
else return EINA_FALSE;
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
eo_do(obj, elm_interface_scrollable_content_pos_set(x, y, EINA_TRUE));
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_elm_map_elm_widget_event(Eo *obj, Elm_Map_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
{
(void) src;
Evas_Event_Key_Down *ev = event_info;
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
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;
}