[naviframe] sync test
authorMike McCormack <mj.mccormack@samsung.com>
Fri, 18 Nov 2011 06:46:20 +0000 (15:46 +0900)
committerMike McCormack <mj.mccormack@samsung.com>
Fri, 18 Nov 2011 06:46:20 +0000 (15:46 +0900)
src/bin/test_naviframe.c

index 37c5e77..59432c6 100644 (file)
@@ -4,6 +4,22 @@
 #endif
 #ifndef ELM_LIB_QUICKLAUNCH
 
+static const char *img1 = PACKAGE_DATA_DIR"/images/logo.png";
+static const char *img2 = PACKAGE_DATA_DIR"/images/plant_01.jpg";
+static const char *img3 = PACKAGE_DATA_DIR"/images/rock_01.jpg";
+static const char *img4 = PACKAGE_DATA_DIR"/images/rock_02.jpg";
+static const char *img5 = PACKAGE_DATA_DIR"/images/sky_01.jpg";
+
+Evas_Object *
+_content_new(Evas_Object *parent, const char *img)
+{
+   Evas_Object *photo = elm_photo_add(parent);
+   elm_photo_file_set(photo, img);
+   elm_photo_fill_inside_set(photo, EINA_TRUE);
+   elm_object_style_set(photo, "shadow");
+   return photo;
+}
+
 void
 _navi_pop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
@@ -11,6 +27,13 @@ _navi_pop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 }
 
 void
+_navi_it_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   elm_naviframe_item_del(data);
+}
+
+
+void
 _title_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    printf("Title Clicked!\n");
@@ -24,17 +47,36 @@ _title_visible(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
 }
 
 void
-_page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_page5(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
-   Evas_Object *bt, *bt2, *ic, *nf = data;
-   char buf[PATH_MAX];
+   Evas_Object *bt, *content, *nf = data;
    Elm_Object_Item *it;
 
    bt = elm_button_add(nf);
    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_object_text_set(bt, "Prev");
+
+   content = _content_new(nf, img5);
+   it = elm_naviframe_item_insert_after(elm_naviframe_top_item_get(nf),
+                                        "Page 5",
+                                        bt,
+                                        NULL,
+                                        content,
+                                        NULL);
+
+   evas_object_smart_callback_add(bt, "clicked", _navi_it_del, it);
+}
+
+void
+_page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Evas_Object *bt, *ic, *content, *nf = data;
+   char buf[PATH_MAX];
+   Elm_Object_Item *it;
 
    ic = elm_icon_add(nf);
-   snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
+   snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png",
+            elm_app_data_dir_get());
    elm_icon_file_set(ic, buf, NULL);
    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
 
@@ -43,20 +85,13 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_object_content_part_set(bt, "icon", ic);
 
-   bt2 = elm_button_add(nf);
-   evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_object_text_set(bt2, "Naviframe Test");
-
-   ic = elm_icon_add(nf);
-   snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
-   elm_icon_file_set(ic, buf, NULL);
-   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+   content = _content_new(nf, img4);
 
    it = elm_naviframe_item_push(nf,
                                 "Page 4",
                                 NULL,
                                 bt,
-                                bt2,
+                                content,
                                 NULL);
    ic = elm_icon_add(nf);
    snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
@@ -65,13 +100,13 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
    elm_object_item_content_part_set(it, "icon", ic);
    elm_naviframe_item_title_visible_set(it, EINA_FALSE);
-   evas_object_smart_callback_add(bt2, "clicked", _title_visible, it);
+   evas_object_smart_callback_add(content, "clicked", _title_visible, it);
 }
 
 void
 _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
-   Evas_Object *bt, *bt2, *bt3, *ic, *nf = data;
+   Evas_Object *bt, *bt2, *ic, *content, *nf = data;
    char buf[PATH_MAX];
    Elm_Object_Item *it;
 
@@ -85,10 +120,14 @@ _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    elm_object_text_set(bt2, "Next");
    evas_object_smart_callback_add(bt2, "clicked", _page4, nf);
 
-   bt3 = elm_button_add(nf);
-   evas_object_size_hint_align_set(bt3, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_object_text_set(bt3, "Naviframe Test");
+   content = _content_new(nf, img3);
 
+   it = elm_naviframe_item_push(nf,
+                                "Page 3",
+                                bt,
+                                bt2,
+                                content,
+                                NULL);
    ic = elm_icon_add(nf);
    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
    elm_icon_file_set(ic, buf, NULL);
@@ -100,7 +139,7 @@ _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 void
 _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
-   Evas_Object *bt, *bt2, *ic, *nf = data;
+   Evas_Object *bt, *content, *ic, *nf = data;
    char buf[PATH_MAX];
    Elm_Object_Item *it;
 
@@ -108,12 +147,9 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_smart_callback_add(bt, "clicked", _page3, nf);
 
-   bt2 = elm_button_add(nf);
-   evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_object_text_set(bt2, "Naviframe Test");
-
    ic = elm_icon_add(nf);
-   snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
+   snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png",
+            elm_app_data_dir_get());
    elm_icon_file_set(ic, buf, NULL);
    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
    elm_object_content_part_set(bt, "icon", ic);
@@ -127,7 +163,7 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 void
 test_naviframe(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
-   Evas_Object *win, *bg, *nf, *btn;
+   Evas_Object *win, *bg, *nf, *btn, *content;
 
    win = elm_win_add(NULL, "naviframe", ELM_WIN_BASIC);
    elm_win_title_set(win, "Naviframe");
@@ -141,21 +177,18 @@ test_naviframe(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
 
    nf = elm_naviframe_add(win);
    elm_win_resize_object_add(win, nf);
+   evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_show(nf);
    evas_object_smart_callback_add(nf, "title,clicked", _title_clicked, 0);
 
    btn = elm_button_add(nf);
    evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_smart_callback_add(btn, "clicked", _page2, nf);
-   elm_object_text_set(btn, "Naviframe Test");
+   elm_object_text_set(btn, "Next");
    evas_object_show(btn);
 
-   elm_naviframe_item_push(nf,
-                           "Page 1",
-                           NULL,
-                           NULL,
-                           btn,
-                           NULL);
+   content = _content_new(nf, img1);
+   elm_naviframe_item_push(nf, "Page 1", NULL, btn, content, NULL);
 
    evas_object_resize(win, 400, 600);
    evas_object_show(win);