fixed plugin image size problem
[framework/uifw/elementary.git] / src / bin / test_naviframe.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 #define BUTTON_TEXT_SET(BT, TEXT) \
8    elm_object_text_set((BT), (TEXT)); \
9    elm_object_tooltip_text_set((BT), (TEXT)); \
10    elm_object_tooltip_window_mode_set((BT), EINA_TRUE)
11
12 static const char *img1 = PACKAGE_DATA_DIR "/images/logo.png";
13 static const char *img2 = PACKAGE_DATA_DIR "/images/plant_01.jpg";
14 static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg";
15 static const char *img4 = PACKAGE_DATA_DIR "/images/rock_02.jpg";
16 static const char *img5 = PACKAGE_DATA_DIR "/images/sky_01.jpg";
17 static const char *img6 = PACKAGE_DATA_DIR "/images/sky_02.jpg";
18 static const char *img7 = PACKAGE_DATA_DIR "/images/sky_03.jpg";
19
20 Evas_Object *
21 _content_new(Evas_Object *parent, const char *img)
22 {
23    Evas_Object *photo = elm_photo_add(parent);
24    elm_photo_file_set(photo, img);
25    elm_photo_fill_inside_set(photo, EINA_TRUE);
26    elm_object_style_set(photo, "shadow");
27    return photo;
28 }
29
30 void
31 _navi_pop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
32 {
33    elm_naviframe_item_pop(data);
34 }
35
36 void
37 _navi_it_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
38 {
39    elm_object_item_del(data);
40 }
41
42 void
43 _title_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
44 {
45    printf("Title Clicked!\n");
46 }
47
48 void
49 _title_visible(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
50 {
51    elm_naviframe_item_title_visible_set(data,
52                                !elm_naviframe_item_title_visible_get(data));
53 }
54
55 void
56 _promote(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
57 {
58    elm_naviframe_item_promote(data);
59 }
60
61 void
62 _page7(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
63 {
64    Evas_Object *bt, *bt2, *content, *nf = data;
65    Elm_Object_Item *it;
66
67    bt = elm_button_add(nf);
68    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
69    BUTTON_TEXT_SET(bt, "Page 6");
70
71    bt2 = elm_button_add(nf);
72    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
73    BUTTON_TEXT_SET(bt2, "Page 1");
74    evas_object_smart_callback_add(bt2, "clicked", _promote,
75                                   evas_object_data_get(nf, "page1"));
76    content = _content_new(nf, img6);
77    it = elm_naviframe_item_push(nf, "Page 7", bt, bt2, content, "overlap");
78    elm_object_item_part_text_set(it, "subtitle", "Overlap style!");
79
80    evas_object_smart_callback_add(bt, "clicked", _navi_pop, nf);
81 }
82
83 void
84 _page6(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
85 {
86    Evas_Object *bt, *bt2, *content, *nf = data;
87    Elm_Object_Item *it;
88
89    bt = elm_button_add(nf);
90    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
91    BUTTON_TEXT_SET(bt, "Page 5");
92
93    bt2 = elm_button_add(nf);
94    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
95    BUTTON_TEXT_SET(bt2, "Page 7");
96    evas_object_smart_callback_add(bt2, "clicked", _page7, nf);
97
98    content = _content_new(nf, img7);
99    it = elm_naviframe_item_push(nf, "Page 6", bt, bt2, content, "overlap");
100    elm_object_item_part_text_set(it, "subtitle", "Overlap style!");
101
102    evas_object_smart_callback_add(bt, "clicked", _navi_pop, nf);
103 }
104
105 void
106 _page5(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
107 {
108    Evas_Object *bt, *bt2, *content, *nf = data;
109    Elm_Object_Item *it;
110
111    bt = elm_button_add(nf);
112    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
113    BUTTON_TEXT_SET(bt, "Page 4");
114
115    bt2 = elm_button_add(nf);
116    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
117    BUTTON_TEXT_SET(bt2, "Page 6");
118    evas_object_smart_callback_add(bt2, "clicked", _page6, nf);
119
120    content = _content_new(nf, img5);
121    it = elm_naviframe_item_insert_after(nf,
122                                         elm_naviframe_top_item_get(nf),
123                                         "Page 5",
124                                         bt,
125                                         bt2,
126                                         content,
127                                         NULL);
128    elm_object_item_part_text_set(it, "subtitle", "This page is inserted without transition");
129    evas_object_smart_callback_add(bt, "clicked", _navi_it_del, it);
130 }
131
132 void
133 _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
134 {
135    Evas_Object *bt, *ic, *content, *nf = data;
136    char buf[PATH_MAX];
137    Elm_Object_Item *it;
138
139    ic = elm_icon_add(nf);
140    snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png",
141             elm_app_data_dir_get());
142    elm_icon_file_set(ic, buf, NULL);
143    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
144
145    bt = elm_button_add(nf);
146    evas_object_smart_callback_add(bt, "clicked", _page5, nf);
147    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
148    elm_object_part_content_set(bt, "icon", ic);
149
150    content = _content_new(nf, img4);
151
152    it = elm_naviframe_item_push(nf,
153                                 "Page 4",
154                                 NULL,
155                                 bt,
156                                 content,
157                                 NULL);
158    elm_object_item_part_text_set(it, "subtitle", "Title area visibility test");
159
160    ic = elm_icon_add(nf);
161    snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
162             elm_app_data_dir_get());
163    elm_icon_file_set(ic, buf, NULL);
164    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
165    elm_object_item_part_content_set(it, "icon", ic);
166    elm_naviframe_item_title_visible_set(it, EINA_FALSE);
167    evas_object_smart_callback_add(content, "clicked", _title_visible, it);
168 }
169
170 void
171 _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
172 {
173    Evas_Object *bt, *bt2, *ic, *content, *nf = data;
174    char buf[PATH_MAX];
175    Elm_Object_Item *it;
176
177    bt = elm_button_add(nf);
178    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
179    BUTTON_TEXT_SET(bt, "Prev");
180    evas_object_smart_callback_add(bt, "clicked", _navi_pop, nf);
181
182    bt2 = elm_button_add(nf);
183    evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
184    BUTTON_TEXT_SET(bt2, "Next");
185    evas_object_smart_callback_add(bt2, "clicked", _page4, nf);
186
187    content = _content_new(nf, img3);
188
189    it = elm_naviframe_item_push(nf,
190                                 "Page 3",
191                                 bt,
192                                 bt2,
193                                 content,
194                                 NULL);
195    ic = elm_icon_add(nf);
196    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
197    elm_icon_file_set(ic, buf, NULL);
198    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
199
200    elm_object_item_part_content_set(it, "icon", ic);
201 }
202
203 void
204 _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
205 {
206    Evas_Object *bt, *content, *ic, *nf = data;
207    char buf[PATH_MAX];
208    Elm_Object_Item *it;
209
210    bt = elm_button_add(nf);
211    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
212    evas_object_smart_callback_add(bt, "clicked", _page3, nf);
213
214    ic = elm_icon_add(nf);
215    snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png",
216             elm_app_data_dir_get());
217    elm_icon_file_set(ic, buf, NULL);
218    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
219    elm_object_part_content_set(bt, "icon", ic);
220
221    content = _content_new(nf, img2);
222
223    it = elm_naviframe_item_push(nf, "Page 2", NULL, bt, content,  NULL);
224    elm_object_item_part_text_set(it, "subtitle", "Here is sub-title part!");
225 }
226
227 void
228 test_naviframe(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
229 {
230    Evas_Object *win, *nf, *btn, *content;
231    Elm_Object_Item *it;
232
233    win = elm_win_util_standard_add("naviframe", "Naviframe");
234    elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
235    elm_win_autodel_set(win, EINA_TRUE);
236
237    nf = elm_naviframe_add(win);
238    evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
239    elm_win_resize_object_add(win, nf);
240    evas_object_show(nf);
241    evas_object_smart_callback_add(nf, "title,clicked", _title_clicked, 0);
242
243    btn = elm_button_add(nf);
244    evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
245    evas_object_smart_callback_add(btn, "clicked", _page2, nf);
246    BUTTON_TEXT_SET(btn, "Next");
247    evas_object_show(btn);
248
249    content = _content_new(nf, img1);
250    it = elm_naviframe_item_push(nf, "Page 1", NULL, btn, content, NULL);
251    evas_object_data_set(nf, "page1", it);
252
253    evas_object_resize(win, 400, 600);
254    evas_object_show(win);
255 }
256 #endif