forked from enlightenment/efl
focus: add the focus region show mode
When the focus is move to the object in scroller, it is scrolled to show the focus region as a widget. If the focus region want to be shown as an item, set the mode ELM_FOCUS_REGION_SHOW_ITEM. If then, it will be scrolled as an item. TODO: Widgets have items are added on_focus_region function. @feature
This commit is contained in:
parent
0aa54f3756
commit
b3a86fc230
|
@ -29,6 +29,7 @@ struct _api_data
|
|||
unsigned int state; /* What state we are testing */
|
||||
Evas_Object *box; /* Use this to get box content */
|
||||
Evas_Object *grid;
|
||||
Evas_Object *grid2;
|
||||
Elm_Gengrid_Item_Field_Type field_type;
|
||||
};
|
||||
typedef struct _api_data api_data;
|
||||
|
@ -1643,6 +1644,19 @@ _gg_focus_focus_animate_changed_cb(void *data,
|
|||
elm_check_state_get(obj));
|
||||
}
|
||||
|
||||
static void
|
||||
_gg_focus_region_show_item_cb(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
if (elm_check_state_get(obj))
|
||||
elm_object_focus_region_show_mode_set((Evas_Object *)data,
|
||||
ELM_FOCUS_REGION_SHOW_ITEM);
|
||||
else
|
||||
elm_object_focus_region_show_mode_set((Evas_Object *)data,
|
||||
ELM_FOCUS_REGION_SHOW_WIDGET);
|
||||
}
|
||||
|
||||
static void
|
||||
_grid_reorder_mode(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -1675,7 +1689,7 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *bx_horiz, *gengrid, *btn, *fr, *bx_mv, *bx_opt, *ck, *rdg, *rd;
|
||||
Evas_Object *win, *bx, *bx_horiz, *in_bx, *scr, *gengrid, *gengrid2, *btn, *fr, *bx_mv, *bx_opt, *ck, *rdg, *rd;
|
||||
Elm_Gengrid_Item_Class *ic;
|
||||
Item_Data *id;
|
||||
char buf[PATH_MAX];
|
||||
|
@ -1711,13 +1725,26 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
evas_object_show(btn);
|
||||
elm_object_focus_set(btn, EINA_TRUE);
|
||||
|
||||
gengrid = elm_gengrid_add(bx);
|
||||
scr = elm_scroller_add(bx);
|
||||
evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, scr);
|
||||
evas_object_show(scr);
|
||||
|
||||
in_bx = elm_box_add(scr);
|
||||
evas_object_size_hint_weight_set(in_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(in_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_content_set(scr, in_bx);
|
||||
evas_object_show(in_bx);
|
||||
|
||||
gengrid = elm_gengrid_add(in_bx);
|
||||
elm_gengrid_item_size_set(gengrid,
|
||||
ELM_SCALE_SIZE(150),
|
||||
ELM_SCALE_SIZE(150));
|
||||
evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, gengrid);
|
||||
evas_object_size_hint_min_set(gengrid, 0, ELM_SCALE_SIZE(600));
|
||||
elm_box_pack_end(in_bx, gengrid);
|
||||
evas_object_show(gengrid);
|
||||
evas_object_smart_callback_add(gengrid, "item,focused", _gengrid_focus_item_cb, "item,focused");
|
||||
evas_object_smart_callback_add(gengrid, "item,unfocused", _gengrid_focus_item_cb, "item,unfocused");
|
||||
|
@ -1728,6 +1755,24 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
evas_object_smart_callback_add(gengrid, "unhighlighted", _gengrid_focus_item_cb, "unhighlighted");
|
||||
evas_object_event_callback_add(gengrid, EVAS_CALLBACK_KEY_DOWN, _gengrid_focus_key_down_cb, NULL);
|
||||
|
||||
gengrid2 = elm_gengrid_add(in_bx);
|
||||
elm_gengrid_item_size_set(gengrid2,
|
||||
ELM_SCALE_SIZE(150),
|
||||
ELM_SCALE_SIZE(150));
|
||||
evas_object_size_hint_weight_set(gengrid2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(gengrid2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_min_set(gengrid2, 0, ELM_SCALE_SIZE(600));
|
||||
elm_box_pack_end(in_bx, gengrid2);
|
||||
evas_object_show(gengrid2);
|
||||
evas_object_smart_callback_add(gengrid2, "item,focused", _gengrid_focus_item_cb, "item,focused");
|
||||
evas_object_smart_callback_add(gengrid2, "item,unfocused", _gengrid_focus_item_cb, "item,unfocused");
|
||||
evas_object_smart_callback_add(gengrid2, "selected", _gengrid_focus_item_cb, "selected");
|
||||
evas_object_smart_callback_add(gengrid2, "unselected", _gengrid_focus_item_cb, "unselected");
|
||||
evas_object_smart_callback_add(gengrid2, "activated", _gengrid_focus_item_cb, "activated");
|
||||
evas_object_smart_callback_add(gengrid2, "highlighted", _gengrid_focus_item_cb, "highlighted");
|
||||
evas_object_smart_callback_add(gengrid2, "unhighlighted", _gengrid_focus_item_cb, "unhighlighted");
|
||||
evas_object_event_callback_add(gengrid2, EVAS_CALLBACK_KEY_DOWN, _gengrid_focus_key_down_cb, NULL);
|
||||
|
||||
btn = elm_button_add(bx);
|
||||
elm_object_text_set(btn, "Down");
|
||||
elm_box_pack_end(bx, btn);
|
||||
|
@ -1791,10 +1836,24 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
elm_box_pack_end(bx_opt, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(bx_opt);
|
||||
elm_object_text_set(ck, "Focus Region Show as Item");
|
||||
elm_check_state_set(ck, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(ck, "changed",
|
||||
_gg_focus_region_show_item_cb,
|
||||
gengrid);
|
||||
evas_object_smart_callback_add(ck, "changed",
|
||||
_gg_focus_region_show_item_cb,
|
||||
gengrid2);
|
||||
elm_box_pack_end(bx_opt, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
ck = elm_check_add(bx_opt);
|
||||
elm_object_text_set(ck, "Horizontal Mode");
|
||||
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(ck, "changed", _horizontal_grid, gengrid);
|
||||
evas_object_smart_callback_add(ck, "changed", _horizontal_grid, gengrid2);
|
||||
elm_box_pack_end(bx_opt, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
|
@ -1802,6 +1861,7 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
elm_object_text_set(ck, "Rorder mode enable");
|
||||
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_smart_callback_add(ck, "changed", _grid_reorder_mode, gengrid);
|
||||
evas_object_smart_callback_add(ck, "changed", _grid_reorder_mode, gengrid2);
|
||||
elm_box_pack_end(bx_opt, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
|
@ -1882,6 +1942,19 @@ test_gengrid_focus(void *data EINA_UNUSED,
|
|||
if (i == 4)
|
||||
elm_object_item_disabled_set(id->item, EINA_TRUE);
|
||||
}
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 24; i++)
|
||||
{
|
||||
id = calloc(1, sizeof(Item_Data));
|
||||
snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
|
||||
n = (n + 1) % 9;
|
||||
id->mode = i;
|
||||
id->path = eina_stringshare_add(buf);
|
||||
id->item = elm_gengrid_item_append(gengrid2, ic, id, NULL, NULL);
|
||||
if (i == 4)
|
||||
elm_object_item_disabled_set(id->item, EINA_TRUE);
|
||||
}
|
||||
elm_gengrid_item_class_free(ic);
|
||||
|
||||
evas_object_resize(win, 600, 600);
|
||||
|
|
|
@ -48,6 +48,17 @@ typedef enum
|
|||
ELM_FOCUS_LEFT /**< left direction */
|
||||
} Elm_Focus_Direction;
|
||||
|
||||
/**
|
||||
* Focus region show mode.
|
||||
*
|
||||
* @ingroup Focus
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ELM_FOCUS_REGION_SHOW_WIDGET, /**< as a widget */
|
||||
ELM_FOCUS_REGION_SHOW_ITEM, /**< as an item */
|
||||
} Elm_Focus_Region_Show_Mode;
|
||||
|
||||
/**
|
||||
* Get the whether an Elementary object has the focus or not.
|
||||
*
|
||||
|
@ -371,3 +382,36 @@ EAPI void elm_object_focus_move_policy_set(Evas_Object *obj, Elm
|
|||
* @ingroup Focus
|
||||
*/
|
||||
EAPI Elm_Focus_Move_Policy elm_object_focus_move_policy_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Set the focus region show mode to a given Elementary object.
|
||||
*
|
||||
* @param obj The Elementary object to operate on
|
||||
* @param mode A mode to show the focus region
|
||||
*
|
||||
* @see elm_object_focus_region_show_mode_get
|
||||
*
|
||||
* When the focus is move to the object in scroller, it is scrolled
|
||||
* to show the focus region as a widget. If the focus region want to be shown
|
||||
* as an item, set the mode ELM_FOCUS_REGION_SHOW_ITEM.
|
||||
* If then, it will be scrolled as an item.
|
||||
*
|
||||
* @since 1.16
|
||||
*
|
||||
* @ingroup Focus
|
||||
*/
|
||||
EAPI void elm_object_focus_region_show_mode_set(Evas_Object *obj, Elm_Focus_Region_Show_Mode mode);
|
||||
|
||||
/**
|
||||
* Get the focus region show mode to a given Elementary object.
|
||||
*
|
||||
* @param obj The Elementary object to get the information from
|
||||
* @return The focus region shown mode
|
||||
*
|
||||
* @see elm_object_focus_region_show_mode_set
|
||||
*
|
||||
* @since 1.16
|
||||
*
|
||||
* @ingroup Focus
|
||||
*/
|
||||
EAPI Elm_Focus_Region_Show_Mode elm_object_focus_region_show_mode_get(const Evas_Object *obj);
|
||||
|
|
|
@ -3577,6 +3577,25 @@ _elm_gengrid_elm_widget_on_focus(Eo *obj, Elm_Gengrid_Data *sd)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_gengrid_elm_widget_on_focus_region(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
||||
{
|
||||
if (!sd->focused_item) return EINA_FALSE;
|
||||
if (elm_object_focus_region_show_mode_get(obj) == ELM_FOCUS_REGION_SHOW_ITEM)
|
||||
{
|
||||
Evas_Coord vx, vy;
|
||||
ELM_GENGRID_ITEM_DATA_GET(sd->focused_item, focus_it);
|
||||
evas_object_geometry_get(VIEW(focus_it), x, y, w, h);
|
||||
evas_object_geometry_get(obj, &vx, &vy, NULL, NULL);
|
||||
|
||||
*x -= vx;
|
||||
*y -= vy;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool _elm_gengrid_smart_focus_next_enable = EINA_FALSE;
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
|
@ -3891,6 +3910,7 @@ _elm_gengrid_item_elm_widget_item_focus_set(Eo *eo_it, Elm_Gen_Item *it, Eina_Bo
|
|||
return;
|
||||
_elm_gengrid_item_unfocused(eo_it);
|
||||
}
|
||||
elm_widget_focus_region_show(obj);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
|
|
|
@ -697,6 +697,7 @@ class Elm.Gengrid (Elm.Layout, Elm_Interface_Scrollable,
|
|||
Elm.Widget.access;
|
||||
Elm.Widget.focus_next;
|
||||
Elm.Widget.on_focus;
|
||||
Elm.Widget.on_focus_region;
|
||||
Elm.Widget.event;
|
||||
Elm.Widget.focus_highlight_geometry_get;
|
||||
Elm.Widget.focused_item.get;
|
||||
|
|
|
@ -1748,3 +1748,15 @@ elm_object_focused_item_get(const Evas_Object *obj)
|
|||
return elm_widget_focused_item_get(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_object_focus_region_show_mode_set(Evas_Object *obj, Elm_Focus_Region_Show_Mode mode)
|
||||
{
|
||||
elm_widget_focus_region_show_mode_set(obj, mode);
|
||||
}
|
||||
|
||||
EAPI Elm_Focus_Region_Show_Mode
|
||||
elm_object_focus_region_show_mode_get(const Evas_Object *obj)
|
||||
{
|
||||
return elm_widget_focus_region_show_mode_get(obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -349,6 +349,7 @@ _elm_widget_evas_object_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
|
|||
priv->obj = obj;
|
||||
priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale
|
||||
* settings */
|
||||
priv->focus_region_show_mode = ELM_FOCUS_REGION_SHOW_WIDGET;
|
||||
elm_widget_can_focus_set(obj, EINA_TRUE);
|
||||
priv->is_mirrored = elm_config_mirrored_get();
|
||||
priv->focus_move_policy = _elm_config->focus_move_policy;
|
||||
|
@ -3992,6 +3993,18 @@ _elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EIN
|
|||
return NULL;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_widget_focus_region_show_mode_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, Elm_Focus_Region_Show_Mode mode)
|
||||
{
|
||||
_pd->focus_region_show_mode = mode;
|
||||
}
|
||||
|
||||
EOLIAN static Elm_Focus_Region_Show_Mode
|
||||
_elm_widget_focus_region_show_mode_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
|
||||
{
|
||||
return _pd->focus_region_show_mode;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_activate(Evas_Object *obj, Elm_Activate act)
|
||||
{
|
||||
|
|
|
@ -182,6 +182,16 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible, Elm_Inte
|
|||
highlight: bool; [[highlight]]
|
||||
}
|
||||
}
|
||||
@property focus_region_show_mode {
|
||||
[[Control the focus_region_show mode.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
mode: Elm_Focus_Region_Show_Mode;
|
||||
}
|
||||
}
|
||||
@property parent_highlight {
|
||||
set {
|
||||
}
|
||||
|
|
|
@ -420,6 +420,7 @@ typedef struct _Elm_Widget_Smart_Data
|
|||
|
||||
int orient_mode; /* -1 is disabled */
|
||||
Elm_Focus_Move_Policy focus_move_policy;
|
||||
Elm_Focus_Region_Show_Mode focus_region_show_mode;
|
||||
|
||||
Eina_Bool drag_x_locked : 1;
|
||||
Eina_Bool drag_y_locked : 1;
|
||||
|
@ -773,6 +774,8 @@ EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object
|
|||
void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it);
|
||||
EAPI void elm_widget_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy);
|
||||
EAPI Elm_Focus_Move_Policy elm_widget_focus_move_policy_get(const Evas_Object *obj);
|
||||
EAPI void elm_widget_focus_region_show_mode_set(Evas_Object *obj, Elm_Focus_Region_Show_Mode mode);
|
||||
EAPI Elm_Focus_Region_Show_Mode elm_widget_focus_region_show_mode_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Function to operate on a given widget's scrollabe children when necessary.
|
||||
|
|
Loading…
Reference in New Issue