forked from enlightenment/efl
photocam: apply key binding
Summary: This patch applies key binding to elm_photocam. Test Plan: None Reviewers: Hermet, raster Differential Revision: https://phab.enlightenment.org/D735
This commit is contained in:
parent
660591102a
commit
10fb0a3f30
|
@ -1058,6 +1058,95 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Photocam";
|
||||
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: "Elc_Naviframe";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -1062,6 +1062,95 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Photocam";
|
||||
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: "Elc_Naviframe";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -1059,6 +1059,95 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Photocam";
|
||||
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: "Elc_Naviframe";
|
||||
group "key_bindings" list {
|
||||
|
|
|
@ -73,6 +73,15 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
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 inline void
|
||||
_photocam_image_file_set(Evas_Object *obj, Elm_Photocam_Data *sd)
|
||||
{
|
||||
|
@ -903,89 +912,100 @@ _scroll_cb(Evas_Object *obj,
|
|||
evas_object_smart_callback_call(obj, SIG_SCROLL, NULL);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_photocam_elm_widget_event(Eo *obj, Elm_Photocam_Data *_pd EINA_UNUSED, 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;
|
||||
|
||||
double zoom;
|
||||
Evas_Coord x = 0;
|
||||
Evas_Coord y = 0;
|
||||
Evas_Coord v_w = 0;
|
||||
Evas_Coord v_h = 0;
|
||||
Evas_Coord step_x = 0;
|
||||
Evas_Coord step_y = 0;
|
||||
Evas_Coord page_x = 0;
|
||||
Evas_Coord page_y = 0;
|
||||
|
||||
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(&v_w, &v_h));
|
||||
elm_interface_scrollable_content_viewport_size_get(NULL, &v_h));
|
||||
|
||||
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 * v_h) / 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 * v_h) / 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)
|
||||
{
|
||||
const char *dir = params;
|
||||
double zoom;
|
||||
|
||||
if (!strcmp(dir, "in"))
|
||||
{
|
||||
zoom = elm_photocam_zoom_get(obj);
|
||||
zoom -= 0.5;
|
||||
elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
|
||||
elm_photocam_zoom_set(obj, zoom);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else if ((!strcmp(ev->key, "KP_Subtract")))
|
||||
else if (!strcmp(dir, "out"))
|
||||
{
|
||||
zoom = elm_photocam_zoom_get(obj);
|
||||
zoom += 0.5;
|
||||
elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
|
||||
elm_photocam_zoom_set(obj, zoom);
|
||||
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_photocam_elm_widget_event(Eo *obj, Elm_Photocam_Data *_pd 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue