From: Kim Shinwoo <kimcinoo.efl@gmail.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 11 Jan 2012 03:00:23 +0000 (03:00 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 11 Jan 2012 03:00:23 +0000 (03:00 +0000)
Subject: Re: [E-devel] [Patch] elc_ctxpopup, add restacking feature

I have attached example code for checking restacking feature of ctxpopup.
Please review the code and give any feedbacks. Thanks.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@67037 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/test_ctxpopup.c

index 3bcc6fe..8e5ebe6 100644 (file)
@@ -8,6 +8,14 @@
 static void
 _dismissed(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
 {
+   void *ctxpopup_data;
+   ctxpopup_data = evas_object_data_get(obj, "im");
+   if(ctxpopup_data)
+     {
+        evas_object_hide(ctxpopup_data);
+        evas_object_del(ctxpopup_data);
+     }
+
    evas_object_del(obj);
 }
 
@@ -38,9 +46,33 @@ _print_current_dir(Evas_Object *obj)
 }
 
 static void
-_btn_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_btn_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
 {
    printf("Button Clicked\n");
+
+   Evas_Object *im;
+   char buf[PATH_MAX];
+   void *ctxpopup_data;
+
+   ctxpopup_data = evas_object_data_get(data, "id");
+   if(!ctxpopup_data) return;
+
+   if(!strcmp("list_item_6", (char *) ctxpopup_data))
+     {
+        ctxpopup_data = evas_object_data_get(data, "im");
+        if(ctxpopup_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
@@ -211,9 +243,48 @@ _list_item_cb5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
    evas_object_show(ctxpopup);
    _print_current_dir(ctxpopup);
 
-   evas_object_smart_callback_add(btn, "clicked", _btn_clicked, ctxpopup);
+   evas_object_smart_callback_add(btn, "clicked", _btn_clicked, "list_item_5");
 }
 
+static void
+_list_item_cb6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Evas_Object *ctxpopup, *btn, *sc, *bx;
+   Evas_Coord x,y;
+
+   bx = elm_box_add(obj);
+   evas_object_size_hint_min_set(bx, 200, 150);
+
+   sc = elm_scroller_add(bx);
+   elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
+   evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_show(sc);
+
+   btn = elm_button_add(sc);
+   elm_object_text_set(btn, "Ctxpop will be on the top of layer");
+   evas_object_size_hint_min_set(btn, 190, 140);
+
+   elm_object_content_set(sc, btn);
+
+   elm_box_pack_end(bx, sc);
+
+   ctxpopup = elm_ctxpopup_add(obj);
+   evas_object_smart_callback_add(ctxpopup,
+                                  "dismissed",
+                                  _dismissed,
+                                  NULL);
+
+   elm_object_content_set(ctxpopup, bx);
+
+   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);
+
+   evas_object_data_set(ctxpopup, "id", "list_item_6");
+   evas_object_smart_callback_add(btn, "clicked", _btn_clicked, ctxpopup);
+}
 
 static void _list_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
 {
@@ -251,6 +322,8 @@ test_ctxpopup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
                         _list_item_cb4, NULL);
    elm_list_item_append(list, "Ctxpopup with user content", NULL, NULL,
                         _list_item_cb5, NULL);
+   elm_list_item_append(list, "Ctxpopup with restacking", NULL, NULL,
+                        _list_item_cb6, NULL);
    evas_object_show(list);
    elm_list_go(list);