toolbar: Check disabled status of an item in nearest visible item.
Summary: Also - corrected the code for getting the toolbar item from the list. - added a test for it. Test Plan: elementary_test -> "Toolbar Focus" Reviewers: seoz CC: seoz Differential Revision: https://phab.enlightenment.org/D653
This commit is contained in:
parent
3788c314a5
commit
35ead0992d
|
@ -1099,18 +1099,25 @@ _focus_timer_cb(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
_test_toolbar_focus_item_set_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
_test_toolbar_focus_item_set_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
ecore_timer_del(timer);
|
||||
timer = ecore_timer_add(1.5, _focus_timer_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_test_toolbar_focus_disable_item_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_object_item_disabled_set(data, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx, *toolbar, *fr, *btn, *bx_opt, *chk;
|
||||
Elm_Object_Item *tb_it, *it_3;
|
||||
Elm_Object_Item *tb_it, *it_0, *it_3;
|
||||
|
||||
win = elm_win_util_standard_add("toolbar-focus", "Toolbar Focus");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
@ -1132,7 +1139,7 @@ test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
toolbar = elm_toolbar_add(win);
|
||||
elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL);
|
||||
evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0.0);
|
||||
elm_toolbar_item_append(toolbar, "document-print", "Print", NULL, NULL);
|
||||
it_0 = elm_toolbar_item_append(toolbar, "document-print", "Print", NULL, NULL);
|
||||
elm_toolbar_item_append(toolbar, "folder-new", "Folder", NULL, NULL);
|
||||
it_3 = elm_toolbar_item_append(toolbar, "clock", "Clock", NULL, NULL);
|
||||
elm_toolbar_item_append(toolbar, "refresh", "Update", NULL, NULL);
|
||||
|
@ -1213,6 +1220,16 @@ test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
_test_toolbar_focus_item_set_btn_cb,
|
||||
it_3);
|
||||
|
||||
btn = elm_button_add(bx_opt);
|
||||
elm_object_text_set(btn, "Disable 1st item.");
|
||||
evas_object_size_hint_weight_set(btn, 0.0, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx_opt, btn);
|
||||
evas_object_show(btn);
|
||||
evas_object_smart_callback_add(btn, "clicked",
|
||||
_test_toolbar_focus_disable_item_btn_cb,
|
||||
it_0);
|
||||
|
||||
evas_object_resize(win, 420, 200);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -646,25 +646,38 @@ _elm_toolbar_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
|
|||
Eina_List *item_list = NULL;
|
||||
Elm_Object_Item *item = NULL;
|
||||
ELM_TOOLBAR_DATA_GET(obj, sd);
|
||||
Eina_Bool search_next = EINA_FALSE;
|
||||
Evas_Object *it_obj;
|
||||
|
||||
if (!it) return NULL;
|
||||
|
||||
evas_object_geometry_get(obj, &vx, &vy, &vw, &vh);
|
||||
evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih);
|
||||
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
|
||||
return it;
|
||||
|
||||
item_list = evas_object_box_children_get(sd->bx);
|
||||
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
|
||||
{
|
||||
if (!elm_object_item_disabled_get(it))
|
||||
return it;
|
||||
else
|
||||
search_next = EINA_TRUE;
|
||||
}
|
||||
|
||||
if ((sd->vertical && (iy < vy)) ||
|
||||
(!sd->vertical && (iw < vw)))
|
||||
(!sd->vertical && (iw < vw)) ||
|
||||
search_next)
|
||||
{
|
||||
while ((item_list = eina_list_next(item_list)))
|
||||
{
|
||||
item = eina_list_data_get(item_list);
|
||||
it_obj = eina_list_data_get(item_list);
|
||||
if (it_obj)
|
||||
item = evas_object_data_get(it_obj, "item");
|
||||
if (!item)
|
||||
break;
|
||||
evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch))
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
|
||||
!elm_object_item_disabled_get(item))
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
@ -672,9 +685,14 @@ _elm_toolbar_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
|
|||
{
|
||||
while ((item_list = eina_list_prev(item_list)))
|
||||
{
|
||||
item = eina_list_data_get(item_list);
|
||||
it_obj = eina_list_data_get(item_list);
|
||||
if (it_obj)
|
||||
item = evas_object_data_get(it_obj, "item");
|
||||
if (!item)
|
||||
break;
|
||||
evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch))
|
||||
if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
|
||||
!elm_object_item_disabled_get(item))
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue