aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJinYong Park <j4939.park@samsung.com>2017-11-15 16:46:01 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-15 16:46:01 +0900
commitd96f3bb4f398590adeb95d05110cf95b757a429c (patch)
tree8548ec40bd1e12ae68f5732ee9be0bd735e76893
parentefl_ui_win.c: send bounds changed signal on window rotation (diff)
downloadefl-d96f3bb4f398590adeb95d05110cf95b757a429c.tar.gz
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 https://phab.enlightenment.org/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
-rw-r--r--src/bin/elementary/test_ctxpopup.c35
-rw-r--r--src/lib/elementary/elc_ctxpopup.c18
2 files changed, 53 insertions, 0 deletions
diff --git a/src/bin/elementary/test_ctxpopup.c b/src/bin/elementary/test_ctxpopup.c
index f7512bffcd..fbef93974f 100644
--- a/src/bin/elementary/test_ctxpopup.c
+++ b/src/bin/elementary/test_ctxpopup.c
@@ -46,6 +46,14 @@ _btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
}
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)
{
printf("Item selected status: %d\n", efl_ui_item_selected_get(event_info));
@@ -437,6 +445,31 @@ _list_item_cb9(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
}
static void
+_list_item_cb10(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+ Evas_Object *ctxpopup, *btn, *sc, *bx;
+ 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)
{
elm_list_item_selected_set(event_info, EINA_FALSE);
@@ -497,6 +530,8 @@ test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
_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);
diff --git a/src/lib/elementary/elc_ctxpopup.c b/src/lib/elementary/elc_ctxpopup.c
index bbe9132871..717ca175e2 100644
--- a/src/lib/elementary/elc_ctxpopup.c
+++ b/src/lib/elementary/elc_ctxpopup.c
@@ -641,6 +641,19 @@ _parent_detach(Evas_Object *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,
Evas_Object *obj EINA_UNUSED,
@@ -709,6 +722,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;
@@ -734,6 +749,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;
@@ -1087,6 +1104,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);