From 0e537616ec5783f2f726d03d2c83878c1bbd8c57 Mon Sep 17 00:00:00 2001 From: raster Date: Fri, 30 Mar 2012 09:56:22 +0000 Subject: [PATCH] [popup] opensource mergie (r69790) From: cnook Subject: [E-devel] [patch][elementary] elc_popup, restack issue The elc_popup does not raise to the top of its layer even though evas_object_raise() is called with the popup object. Because the elm_widget_resize_object_set(); makes notify object which is internally used in the popup have a smart parent. Ultimately, the callback function for EVAS_CALLBACK_RESTACK of the notify is not called. So I removed elm_widget_resize_object_set(); from the popup and added some implementations to show the popup properly. Moreover, I have added test code also in the attached patch. Then, please review the patch and give any feedbacks. Thanks. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69790 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 Change-Id: Ie0040e77be7c160ef89a5c54ad0b700866a5dddf --- src/bin/test_popup.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elc_popup.c | 15 +++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/bin/test_popup.c b/src/bin/test_popup.c index d2e6e8d..03fd40a 100644 --- a/src/bin/test_popup.c +++ b/src/bin/test_popup.c @@ -8,6 +8,8 @@ static void _response_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { + Evas_Object *popup_data = evas_object_data_get(data, "im"); + if (popup_data) evas_object_del(popup_data); evas_object_hide(data); evas_object_del(data); } @@ -17,6 +19,8 @@ _block_clicked_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { printf("\nblock,clicked callback\n"); + Evas_Object *popup_data = evas_object_data_get(obj, "im"); + if (popup_data) evas_object_del(popup_data); evas_object_del(obj); } @@ -214,6 +218,55 @@ _popup_center_title_item_3button_cb(void *data, Evas_Object *obj __UNUSED__, evas_object_show(popup); } +static void +_restack_btn_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) +{ + Evas_Object *im; + char buf[PATH_MAX]; + void *popup_data; + + popup_data = evas_object_data_get(data, "im"); + if (popup_data) return; + + im = evas_object_image_filled_add(evas_object_evas_get(obj)); + snprintf(buf, sizeof(buf), "%s/images/%s", + elm_app_data_dir_get(), "twofish.jpg"); + evas_object_image_file_set(im, buf, NULL); + evas_object_move(im, 40, 40); + evas_object_resize(im, 320, 320); + evas_object_show(im); + evas_object_data_set((Evas_Object *)data, "im", im); + + evas_object_raise((Evas_Object *)data); +} + +static void +_popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Evas_Object *popup; + Evas_Object *btn, *btn2; + + popup = elm_popup_add(data); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(popup, "When you click the 'Restack' button, " + "an image will be located under this popup"); + elm_object_part_text_set(popup, "title,text", "Title"); + btn = elm_button_add(popup); + elm_object_text_set(btn, "Restack"); + elm_object_part_content_set(popup, "button1", btn); + evas_object_smart_callback_add(btn, "clicked", _restack_btn_clicked, popup); + evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, + NULL); + + btn2 = elm_button_add(popup); + elm_object_text_set(btn2, "Close"); + elm_object_part_content_set(popup, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup); + + evas_object_show(popup); +} + void test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) @@ -252,6 +305,8 @@ test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, NULL, _popup_center_title_content_3button_cb, win); elm_list_item_append(list, "popup-center-title + items + 3 buttons", NULL, NULL, _popup_center_title_item_3button_cb, win); + elm_list_item_append(list, "popup-center-title + text + 2 buttons (check restacking)", NULL, NULL, + _popup_center_title_text_2button_restack_cb, win); elm_list_go(list); evas_object_show(list); evas_object_show(win); diff --git a/src/lib/elc_popup.c b/src/lib/elc_popup.c index 2ab11c6..78a1d85 100644 --- a/src/lib/elc_popup.c +++ b/src/lib/elc_popup.c @@ -1198,6 +1198,18 @@ _item_signal_emit_hook(Elm_Object_Item *it, const char *emission, edje_object_signal_emit(VIEW(item), emission, source); } +static void +_popup_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, + void *event_info __UNUSED__) +{ + Widget_Data *wd; + + wd = elm_widget_data_get(obj); + if (!wd) return; + + evas_object_show(wd->notify); +} + EAPI Evas_Object * elm_popup_add(Evas_Object *parent) { @@ -1223,7 +1235,6 @@ elm_popup_add(Evas_Object *parent) evas_object_smart_callbacks_descriptions_set(obj, _signals); wd->notify = elm_notify_add(obj); - elm_widget_resize_object_set(obj, wd->notify); elm_notify_parent_set(wd->notify, parent); elm_notify_orient_set(wd->notify, ELM_NOTIFY_ORIENT_CENTER); elm_notify_allow_events_set(wd->notify, EINA_FALSE); @@ -1234,6 +1245,8 @@ elm_popup_add(Evas_Object *parent) evas_object_event_callback_add(wd->notify, EVAS_CALLBACK_RESIZE, _notify_resize, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _popup_show, + NULL); evas_object_event_callback_add(obj, EVAS_CALLBACK_RESTACK, _restack, NULL); wd->base = elm_layout_add(obj); evas_object_size_hint_weight_set(wd->base, EVAS_HINT_EXPAND, -- 2.7.4