Commit 8994330d authored by JinYong Park's avatar JinYong Park Committed by Jean-Philippe Andre

Ctxpopup: resizing ctxpopup after its content is removed

Summary:
When ctxpopup's content is removed,
ctxpopup doesn't recalculate its size, so empty space is remaind.
To fix this problem, ctxpopup recalculate its size when content is removed.
This patch is about T6327

@fix

Test Plan:
1. run elementary_test -to ctxpopup
2. select 10st item
3. click button in ctxpopup

Reviewers: jpeg, Jaehyun_Cho, zmike

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5462
parent d1e5e3ff
......@@ -45,6 +45,14 @@ _btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
printf("Button Clicked\n");
}
static void
_btn_remove_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
printf("Button Remove\n");
evas_object_del(obj);
}
static void
_ctxpopup_item_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
{
......@@ -370,6 +378,94 @@ _list_item_cb8(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
_print_current_dir(ctxpopup);
}
static void
_ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
{
const char *text = NULL;
Evas_Object *icon = NULL;
Elm_Object_Item *it = (Elm_Object_Item *)data;
text = elm_object_item_part_text_get((Elm_Object_Item *)event_info, "default");
if (!strcmp(text, "Text NULL"))
{
elm_object_item_part_text_set(it, "default", NULL);
}
else if (!strcmp(text, "Text Set"))
{
elm_object_item_part_text_set(it, "default", "Save file");
}
else if (!strcmp(text, "Icon NULL"))
{
elm_object_item_part_content_set(it, "icon", NULL);
}
else if (!strcmp(text, "Icon Set"))
{
icon = elm_icon_add(obj);
elm_icon_standard_set(icon, "file");
elm_image_resizable_set(icon, EINA_FALSE, EINA_FALSE);
elm_object_item_part_content_set(it, "icon", icon);
}
else
{
icon = elm_object_item_part_content_unset(it, "icon");
if (icon) evas_object_del(icon);
}
}
static void
_list_item_cb9(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *ctxpopup;
Elm_Object_Item *it = NULL;
Evas_Coord x,y;
if (list_mouse_down > 0) return;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
evas_object_smart_callback_add(ctxpopup, "geometry,update", _geometry_update, NULL);
it = elm_ctxpopup_item_append(ctxpopup, NULL, NULL, _ctxpopup_item_cb, NULL);
elm_ctxpopup_item_append(ctxpopup, "Text NULL", NULL, _ctxpopup_item_select_cb, it);
elm_ctxpopup_item_append(ctxpopup, "Text Set", NULL, _ctxpopup_item_select_cb, it);
elm_ctxpopup_item_append(ctxpopup, "Icon NULL", NULL, _ctxpopup_item_select_cb, it);
elm_ctxpopup_item_append(ctxpopup, "Icon Set", NULL, _ctxpopup_item_select_cb, it);
elm_ctxpopup_item_append(ctxpopup, "Icon Unset", NULL, _ctxpopup_item_select_cb, it);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_item_cb10(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *ctxpopup, *btn;
Evas_Coord x,y;
if (list_mouse_down > 0) return;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
evas_object_smart_callback_add(ctxpopup, "geometry,update", _geometry_update, NULL);
btn = elm_button_add(ctxpopup);
elm_object_text_set(btn, "Click to remove");
evas_object_size_hint_min_set(btn, 150, 150);
evas_object_smart_callback_add(btn, "clicked", _btn_remove_cb, ctxpopup);
elm_object_content_set(ctxpopup, btn);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
......@@ -429,6 +525,10 @@ test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
_list_item_cb7, NULL);
elm_list_item_append(list, "Ctxpopup with auto hide disabled mode", NULL, NULL,
_list_item_cb8, NULL);
elm_list_item_append(list, "Ctxpopup with part text & content function", NULL, NULL,
_list_item_cb9, NULL);
elm_list_item_append(list, "Ctxpopup with user content (enable to remove)", NULL, NULL,
_list_item_cb10, NULL);
evas_object_show(list);
elm_list_go(list);
......
......@@ -730,6 +730,19 @@ _parent_detach(Evas_Object *obj)
(sd->parent, EVAS_CALLBACK_RESIZE, _on_parent_resize, obj);
}
static void
_on_content_del(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
ELM_CTXPOPUP_DATA_GET(data, sd);
sd->content = NULL;
elm_box_recalculate(sd->box);
elm_layout_sizing_eval(data);
}
static void
_on_content_resized(void *data,
Evas *e EINA_UNUSED,
......@@ -799,6 +812,8 @@ _elm_ctxpopup_content_set(Eo *obj, Elm_Ctxpopup_Data *sd, const char *part, Evas
sd->content = content;
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
evas_object_event_callback_add(content, EVAS_CALLBACK_DEL, _on_content_del, obj);
if (sd->visible) elm_layout_sizing_eval(obj);
return EINA_TRUE;
......@@ -824,6 +839,8 @@ _elm_ctxpopup_content_unset(Eo *obj, Elm_Ctxpopup_Data *sd, const char *part)
content = sd->content;
if (!content) return content;
evas_object_event_callback_del(sd->content, EVAS_CALLBACK_DEL, _on_content_del);
elm_box_unpack(sd->box, content);
sd->content = NULL;
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
......@@ -1138,6 +1155,7 @@ _elm_ctxpopup_efl_canvas_group_group_del(Eo *obj, Elm_Ctxpopup_Data *sd)
evas_object_event_callback_del_full
(sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
evas_object_event_callback_del(sd->content, EVAS_CALLBACK_DEL, _on_content_del);
_parent_detach(obj);
elm_ctxpopup_clear(obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment