[elc_popup] - Added focus support on popup-base's swallow parts.

Summary:
 Currently the focus was only on popup-content and popup-action area.
New API elm_layout_content_swallow_list_get() which returns the list of
swallow parts.

Test Plan: elementary_test -to popup. click on "subpopup + X button"

Reviewers: seoz, raster, woohyun

Reviewed By: raster

CC: nirajkr, aryarockstar, kashish

Differential Revision: https://phab.enlightenment.org/D375
This commit is contained in:
Amitesh Singh 2013-12-28 17:33:10 +09:00 committed by Carsten Haitzler (Rasterman)
parent 5a3fea6a28
commit 0be8dbcaae
7 changed files with 155 additions and 1 deletions

View File

@ -453,3 +453,46 @@ group { name: "elm/popup/item/popup/default";
}
}
}
group { name: "elm/popup/base/subpopup";
inherit: "elm/popup/base/default";
parts {
part { name: "pad.closebtn"; type: SPACER;
description { state: "default" 0.0;
rel1.to: "base";
rel1.relative: 1 0;
rel2.to: "base";
rel2.relative: 1 0;
min: 2 2;
max: 2 2;
fixed: 1 1;
align: 0 1;
}
}
part { name: "elm.swallow.closebtn"; type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
rel1.to: "pad.closebtn";
rel1.relative: 1 0;
rel2.to: "pad.closebtn";
rel2.relative: 1 0;
align: 0 1;
fixed: 1 1;
}
}
}
}
group { name: "elm/popup/content/popup/subpopup";
inherit: "elm/popup/content/popup/default";
}
group { name: "elm/popup/buttons1/popup/subpopup";
inherit: "elm/popup/buttons1/popup/default";
}
group { name: "elm/popup/buttons2/popup/subpopup";
inherit: "elm/popup/buttons2/popup/default";
}
group { name: "elm/popup/buttons3/popup/subpopup";
inherit: "elm/popup/buttons3/popup/default";
}

View File

@ -592,6 +592,40 @@ _popup_center_title_list_content_1button_cb(void *data, Evas_Object *obj EINA_UN
evas_object_show(popup);
}
static void
_subpopup_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *popup;
Evas_Object *btn, *btnclose;
popup = elm_popup_add(data);
elm_object_style_set(popup, "subpopup");
elm_object_part_text_set(popup, "title,text", "Title");
// button as a popup content
btn = elm_button_add(popup);
elm_object_text_set(btn, "content");
elm_object_part_content_set(popup, "elm.swallow.content", btn);
// popup buttons
btn = elm_button_add(popup);
elm_object_text_set(btn, "OK");
elm_object_part_content_set(popup, "button1", btn);
evas_object_smart_callback_add(btn, "clicked", _popup_close_cb, popup);
//popup-base close button
btnclose = elm_button_add(popup);
//TODO: write a X style button theme
elm_object_text_set(btnclose, "x");
elm_object_part_content_set(popup, "elm.swallow.closebtn", btnclose);
evas_object_smart_callback_add(btnclose, "clicked", _popup_close_cb, popup);
// popup show should be called after adding all the contents and the buttons
// of popup to set the focus into popup's contents correctly.
evas_object_show(popup);
}
void
test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@ -599,6 +633,8 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Evas_Object *win, *list;
win = elm_win_util_standard_add("popup", "Popup");
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_animate_set(win, EINA_TRUE);
elm_win_autodel_set(win, EINA_TRUE);
list = elm_list_add(win);
@ -641,6 +677,9 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
elm_list_item_append(list, "popup-center-title + list content + 1 button",
NULL, NULL, _popup_center_title_list_content_1button_cb,
win);
elm_list_item_append(list, "subpopup + X button",
NULL, NULL, _subpopup_cb,
win);
elm_list_go(list);
evas_object_show(list);

View File

@ -1262,6 +1262,12 @@ _elm_popup_smart_content_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
content = _action_button_get(obj, i);
}
else
{
eo_do_super(obj, MY_CLASS,
elm_obj_container_content_get(part, &content));
}
if (!content)
goto err;
*ret = content;
@ -1355,6 +1361,7 @@ _elm_popup_smart_focus_next(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Evas_Object *ao;
Eina_List *items = NULL;
Eina_List *base_items = NULL;
Elm_Popup_Smart_Data *sd = _pd;
@ -1382,8 +1389,14 @@ _elm_popup_smart_focus_next(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
/* action area */
if (sd->action_area) items = eina_list_append(items, sd->action_area);
/* base */
eo_do_super(obj, MY_CLASS, elm_obj_container_content_swallow_list_get(&base_items));
items = eina_list_merge(items, base_items);
if (!elm_widget_focus_list_next_get(obj, items, eina_list_data_get, dir, next))
*next = obj;
eina_list_free(items);
return;
}
@ -1400,7 +1413,7 @@ _elm_popup_smart_focus_direction(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Evas_Object *ao;
Eina_List *items = NULL;
Eina_List *base_items = NULL;
Elm_Popup_Smart_Data *sd = _pd;
Evas_Object *base = va_arg(*list, Evas_Object *);
@ -1429,8 +1442,14 @@ _elm_popup_smart_focus_direction(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
/* action area */
if (sd->action_area) items = eina_list_append(items, sd->action_area);
/* base*/
eo_do_super(obj, MY_CLASS, elm_obj_container_content_swallow_list_get(&base_items));
items = eina_list_merge(items, base_items);
elm_widget_focus_list_direction_get
(obj, base, items, eina_list_data_get, degree, direction, weight);
eina_list_free(items);
return;
}

View File

@ -16,6 +16,7 @@ static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET, "Set the content on part of a given container widget."),
EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET, "Get the content on a part of a given container widget"),
EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET, "Unset the content on a part of a given container widget"),
EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET, "Get the list of swallow parts of a given container widget"),
EO_OP_DESCRIPTION_SENTINEL
};

View File

@ -1170,6 +1170,33 @@ _elm_layout_smart_content_unset(Eo *obj, void *_pd, va_list *list)
}
}
EAPI Eina_List *
elm_layout_content_swallow_list_get(const Evas_Object *obj)
{
ELM_LAYOUT_CHECK(obj) NULL;
Eina_List *ret = NULL;
eo_do(obj, elm_obj_container_content_swallow_list_get(&ret));
return ret;
}
static void
_elm_layout_smart_content_swallow_list_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
Elm_Layout_Smart_Data *sd = _pd;
Eina_List **ret = va_arg(*list, Eina_List **);
if (ret) *ret = NULL;
Elm_Layout_Sub_Object_Data *sub_d = NULL;
Eina_List *l = NULL;
EINA_LIST_FOREACH(sd->subs, l, sub_d)
{
if (sub_d->type == SWALLOW)
*ret = eina_list_append(*ret, sub_d->obj);
}
}
EAPI Eina_Bool
elm_layout_text_set(Evas_Object *obj,
const char *part,
@ -2243,6 +2270,7 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET), _elm_layout_smart_content_set),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET), _elm_layout_smart_content_get),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET), _elm_layout_smart_content_unset),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET), _elm_layout_smart_content_swallow_list_get),
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_FILE_SET), _elm_layout_smart_file_set),
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_THEME_SET), _elm_layout_smart_theme_set),

View File

@ -638,3 +638,15 @@ EAPI Eina_Bool elm_layout_text_set(Evas_Object *obj, const ch
*/
EAPI const char *elm_layout_text_get(const Evas_Object *obj, const char *part);
/**
* Get the list of swallow parts of a given container widget
*
* @param obj The layout object
*
* @return list of swallow parts which should be freed by the user program with elm_list_free()
*
* @since 1.9
*
* @ingroup Layout
*/
EAPI Eina_List *elm_layout_content_swallow_list_get(const Evas_Object *obj);

View File

@ -41,6 +41,7 @@ enum
ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET,
ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET,
ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET,
ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET,
ELM_OBJ_CONTAINER_SUB_ID_LAST
};
/**
@ -87,4 +88,15 @@ enum
*/
#define elm_obj_container_content_unset(name, ret) ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET), EO_TYPECHECK(const char*, name), EO_TYPECHECK(Evas_Object **,ret)
/**
* @def elm_obj_container_content_list_get
* @since 1.9
*
* No description supplied by the EAPI.
*
* @param[out] ret Eina_List **
*
*/
#define elm_obj_container_content_swallow_list_get(ret) ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET), EO_TYPECHECK(Eina_List **,ret)
#endif