elementary - slider, scroller, progressbar, radio
[framework/uifw/elementary.git] / src / bin / test_scroller.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 void
7 my_bt_go_300_300(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
8 {
9    elm_scroller_region_bring_in((Evas_Object *)data, 300, 300, 318, 318);
10 }
11
12 void
13 my_bt_go_900_300(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
14 {
15    elm_scroller_region_bring_in((Evas_Object *)data, 900, 300, 318, 318);
16 }
17
18 void
19 my_bt_go_300_900(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
20 {
21    elm_scroller_region_bring_in((Evas_Object *)data, 300, 900, 318, 318);
22 }
23
24 void
25 my_bt_go_900_900(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
26 {
27    elm_scroller_region_bring_in((Evas_Object *)data, 900, 900, 318, 318);
28 }
29
30 void
31 test_scroller(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
32 {
33    Evas_Object *win, *bg2, *tb, *tb2, *bg, *sc, *bt;
34    int i, j, n;
35    char buf[PATH_MAX];
36    const char *img[9] =
37      {
38         "panel_01.jpg",
39           "plant_01.jpg",
40           "rock_01.jpg",
41           "rock_02.jpg",
42           "sky_01.jpg",
43           "sky_02.jpg",
44           "sky_03.jpg",
45           "sky_04.jpg",
46           "wood_01.jpg"
47      };
48
49    win = elm_win_add(NULL, "scroller", ELM_WIN_BASIC);
50    elm_win_title_set(win, "Scroller");
51    elm_win_autodel_set(win, EINA_TRUE);
52
53    bg = elm_bg_add(win);
54    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55    elm_win_resize_object_add(win, bg);
56    evas_object_show(bg);
57
58    tb = elm_table_add(win);
59    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60
61    n = 0;
62    for (j = 0; j < 12; j++)
63      {
64         for (i = 0; i < 12; i++)
65           {
66              bg2 = elm_bg_add(win);
67              snprintf(buf, sizeof(buf), "%s/images/%s",
68                       elm_app_data_dir_get(), img[n]);
69              n++;
70              if (n >= 9) n = 0;
71              elm_bg_file_set(bg2, buf, NULL);
72              evas_object_size_hint_weight_set(bg2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73              evas_object_size_hint_align_set(bg2, EVAS_HINT_FILL, EVAS_HINT_FILL);
74              evas_object_size_hint_min_set(bg2, 318, 318);
75              elm_table_pack(tb, bg2, i, j, 1, 1);
76              evas_object_show(bg2);
77           }
78      }
79
80    sc = elm_scroller_add(win);
81    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82    elm_win_resize_object_add(win, sc);
83
84    elm_object_content_set(sc, tb);
85    evas_object_show(tb);
86
87    elm_scroller_page_relative_set(sc, 1.0, 1.0);
88    evas_object_show(sc);
89
90    tb2 = elm_table_add(win);
91    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92    elm_win_resize_object_add(win, tb2);
93
94    bt = elm_button_add(win);
95    elm_object_text_set(bt, "to 300 300");
96    evas_object_smart_callback_add(bt, "clicked", my_bt_go_300_300, sc);
97    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
98    evas_object_size_hint_align_set(bt, 0.1, 0.1);
99    elm_table_pack(tb2, bt, 0, 0, 1, 1);
100    evas_object_show(bt);
101
102    bt = elm_button_add(win);
103    elm_object_text_set(bt, "to 900 300");
104    evas_object_smart_callback_add(bt, "clicked", my_bt_go_900_300, sc);
105    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
106    evas_object_size_hint_align_set(bt, 0.9, 0.1);
107    elm_table_pack(tb2, bt, 1, 0, 1, 1);
108    evas_object_show(bt);
109
110    bt = elm_button_add(win);
111    elm_object_text_set(bt, "to 300 900");
112    evas_object_smart_callback_add(bt, "clicked", my_bt_go_300_900, sc);
113    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114    evas_object_size_hint_align_set(bt, 0.1, 0.9);
115    elm_table_pack(tb2, bt, 0, 1, 1, 1);
116    evas_object_show(bt);
117
118    bt = elm_button_add(win);
119    elm_object_text_set(bt, "to 900 900");
120    evas_object_smart_callback_add(bt, "clicked", my_bt_go_900_900, sc);
121    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
122    evas_object_size_hint_align_set(bt, 0.9, 0.9);
123    elm_table_pack(tb2, bt, 1, 1, 1, 1);
124    evas_object_show(bt);
125
126    evas_object_show(tb2);
127
128    evas_object_resize(win, 320, 320);
129    evas_object_show(win);
130 }
131
132 void
133 click_through(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
134 {
135    printf("click went through on %p\n", obj);
136 }
137
138 void
139 test_scroller2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
140 {
141    Evas_Object *win, *bt, *bx, *bx2, *bg, *sc, *tb, *tb2, *rc;
142    int i, j;
143
144    win = elm_win_add(NULL, "scroller2", ELM_WIN_BASIC);
145    elm_win_title_set(win, "Scroller 2");
146    elm_win_autodel_set(win, EINA_TRUE);
147
148    bg = elm_bg_add(win);
149    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
150    elm_win_resize_object_add(win, bg);
151    evas_object_show(bg);
152
153    bx = elm_box_add(win);
154    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
155    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.0);
156
157    /* { */
158    for (i = 0; i < 3; i++)
159      {
160         bt = elm_button_add(win);
161         elm_object_text_set(bt, "Vertical");
162         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
163         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
164         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
165         elm_box_pack_end(bx, bt);
166         evas_object_show(bt);
167      }
168    /* } */
169
170    /* { */
171    sc = elm_scroller_add(win);
172    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.0);
173    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, 0.5);
174    elm_scroller_bounce_set(sc, 1, 0);
175    elm_scroller_content_min_limit(sc, 0, 1);
176    elm_box_pack_end(bx, sc);
177    evas_object_show(sc);
178
179    bx2 = elm_box_add(win);
180    elm_box_horizontal_set(bx2, EINA_TRUE);
181
182    for (i = 0; i < 10; i++)
183      {
184         bt = elm_button_add(win);
185         elm_object_text_set(bt, "... Horizontal scrolling ...");
186         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
187         elm_box_pack_end(bx2, bt);
188         evas_object_show(bt);
189      }
190
191    elm_object_content_set(sc, bx2);
192    evas_object_show(bx2);
193    /* } */
194
195    /* { */
196    for (i = 0; i < 3; i++)
197      {
198         bt = elm_button_add(win);
199         elm_object_text_set(bt, "Vertical");
200         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
201         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
202         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
203         elm_box_pack_end(bx, bt);
204         evas_object_show(bt);
205      }
206    /* } */
207
208    /* { */
209    tb = elm_table_add(win);
210    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
212    elm_box_pack_end(bx, tb);
213    evas_object_show(tb);
214
215    rc = evas_object_rectangle_add(evas_object_evas_get(win));
216    evas_object_size_hint_min_set(rc, 200, 120);
217    elm_table_pack(tb, rc, 0, 0, 1, 1);
218
219    sc = elm_scroller_add(win);
220    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
222    elm_table_pack(tb, sc, 0, 0, 1, 1);
223    evas_object_show(sc);
224
225    tb2 = elm_table_add(win);
226
227    for (j = 0; j < 16; j++)
228      {
229         for (i = 0; i < 16; i++)
230           {
231              bt = elm_button_add(win);
232              elm_object_text_set(bt, "Both");
233              evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
234              elm_table_pack(tb2, bt, i, j, 1, 1);
235              evas_object_show(bt);
236           }
237      }
238
239    elm_object_content_set(sc, tb2);
240    evas_object_show(tb2);
241    /* } */
242
243    for (i = 0; i < 24; i++)
244      {
245         bt = elm_button_add(win);
246         elm_object_text_set(bt, "Vertical");
247         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
248         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
249         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
250         elm_box_pack_end(bx, bt);
251         evas_object_show(bt);
252      }
253
254    sc = elm_scroller_add(win);
255    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
256    elm_scroller_bounce_set(sc, 0, 1);
257    elm_win_resize_object_add(win, sc);
258    elm_object_content_set(sc, bx);
259    evas_object_show(bx);
260    evas_object_show(sc);
261
262    evas_object_resize(win, 320, 480);
263    evas_object_show(win);
264 }
265 #endif