elm - add test for efl ui win stacking api
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Fri, 9 Dec 2016 06:27:55 +0000 (15:27 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Fri, 16 Dec 2016 07:16:53 +0000 (16:16 +0900)
src/Makefile_Elementary.am
src/bin/elementary/test.c
src/bin/elementary/test_win_stack.c [new file with mode: 0644]

index 14dd674..a50cc8b 100644 (file)
@@ -841,6 +841,7 @@ bin/elementary/test_win_wm_rotation.c \
 bin/elementary/test_win_dialog.c \
 bin/elementary/test_win_modal.c \
 bin/elementary/test_efl_ui_text.c \
+bin/elementary/test_win_stack.c \
 bin/elementary/test.h
 
 bin_elementary_elementary_test_LDADD = @USE_ELEMENTARY_LIBS@
index 224e01e..2f53a10 100644 (file)
@@ -161,6 +161,7 @@ void test_gengrid_disabled_item_focus(void *data, Evas_Object *obj, void *event_
 void test_gengrid_item_custom_size(void *data, Evas_Object *obj, void *event_info);
 void test_win_state(void *data, Evas_Object *obj, void *event_info);
 void test_win_state2(void *data, Evas_Object *obj, void *event_info);
+void test_win_stack(void *data, Evas_Object *obj, void *event_info);
 void test_progressbar(void *data, Evas_Object *obj, void *event_info);
 void test_progressbar2(void *data, Evas_Object *obj, void *event_info);
 void test_fileselector(void *data, Evas_Object *obj, void *event_info);
@@ -647,6 +648,7 @@ add_tests:
    ADD_TEST(NULL, "Window / Background", "Window Standard/Dialog", test_win_dialog);
    ADD_TEST(NULL, "Window / Background", "Window Keygrab Set", test_win_keygrab);
    ADD_TEST(NULL, "Window / Background", "Window Modal", test_win_modal);
+   ADD_TEST(NULL, "Window / Background", "Window Stack", test_win_stack);
 
    //------------------------------//
    ADD_TEST(NULL, "Images", "Icon", test_icon);
diff --git a/src/bin/elementary/test_win_stack.c b/src/bin/elementary/test_win_stack.c
new file mode 100644 (file)
index 0000000..2273c7a
--- /dev/null
@@ -0,0 +1,100 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+static int level = 0;
+
+static void _bt_pressed(void *data, Evas_Object *obj, void *event_info);
+
+static Evas_Object *
+_win_new(Evas_Object *stack_top, const char *title)
+{
+   Evas_Object *bg, *bx, *bt, *lb, *win;
+
+   if (level >= 3)
+     win = elm_win_add(NULL, "window-stack", ELM_WIN_DIALOG_BASIC);
+   else
+     win = elm_win_add(NULL, "window-stack", ELM_WIN_BASIC);
+   elm_win_title_set(win, title);
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   bg = elm_bg_add(win);
+   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bg);
+   evas_object_show(bg);
+
+   bx = elm_box_add(win);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bx);
+   evas_object_show(bx);
+
+   lb = elm_label_add(win);
+   elm_object_text_set(lb, "Press below to push another window on the stack");
+   evas_object_size_hint_weight_set(lb, 1.0, 1.0);
+   evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(bx, lb);
+   evas_object_show(lb);
+
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Push");
+   evas_object_smart_callback_add(bt, "clicked", _bt_pressed, stack_top);
+   evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+
+   evas_object_resize(win, 280, 400);
+   return win;
+}
+
+static void
+_bt_pressed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Evas_Object *win;
+   char buf[100];
+
+   level++;
+   snprintf(buf, sizeof(buf), "Level %i", level);
+   win = _win_new(data, buf);
+   elm_win_stack_master_id_set(win, elm_win_stack_id_get(data));
+   evas_object_show(win);
+}
+
+void
+test_win_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Evas_Object *bg, *bx, *bt, *lb, *win;
+
+   win = elm_win_add(NULL, "window-stack", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Window Stack");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   bg = elm_bg_add(win);
+   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bg);
+   evas_object_show(bg);
+
+   bx = elm_box_add(win);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bx);
+   evas_object_show(bx);
+
+   lb = elm_label_add(win);
+   elm_object_text_set(lb, "Press below to push another window on the stack");
+   evas_object_size_hint_weight_set(lb, 1.0, 1.0);
+   evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(bx, lb);
+   evas_object_show(lb);
+
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Push");
+   evas_object_smart_callback_add(bt, "clicked", _bt_pressed, win);
+   evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+
+   evas_object_resize(win, 320, 480);
+   evas_object_show(win);
+}