f337bfc084b2bac5a16cf81ae8284e6a0965b680
[framework/uifw/elementary.git] / src / bin / test_slideshow.c
1 #include <Elementary.h>
2 #include <elementary_config.h>
3 #ifndef ELM_LIB_QUICKLAUNCH
4
5 static Evas_Object *slideshow, *bt_start, *bt_stop;
6 static Elm_Slideshow_Item_Class itc;
7 static const char *img1 = PACKAGE_DATA_DIR"/images/logo.png";
8 static const char *img2 = PACKAGE_DATA_DIR"/images/plant_01.jpg";
9 static const char *img3 = PACKAGE_DATA_DIR"/images/rock_01.jpg";
10 static const char *img4 = PACKAGE_DATA_DIR"/images/rock_02.jpg";
11 static const char *img5 = PACKAGE_DATA_DIR"/images/sky_01.jpg";
12 static const char *img6 = PACKAGE_DATA_DIR"/images/sky_04.jpg";
13 static const char *img7 = PACKAGE_DATA_DIR"/images/wood_01.jpg";
14 static const char *img8 = PACKAGE_DATA_DIR"/images/mystrale.jpg";
15 static const char *img9 = PACKAGE_DATA_DIR"/images/mystrale_2.jpg";
16
17 static void
18 _notify_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
19 {
20    evas_object_show(data);
21 }
22
23 static void
24 _next(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
25 {
26    elm_slideshow_next(data);
27 }
28
29 static void
30 _previous(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
31 {
32    elm_slideshow_previous(data);
33 }
34
35 static void
36 _mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
37 {
38    elm_notify_timeout_set(data, 0.0);
39    evas_object_show(data);
40 }
41
42
43 static void
44 _mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
45 {
46    elm_notify_timeout_set(data, 3.0);
47 }
48
49 static void
50 _hv_select(void *data, Evas_Object *obj, void *event_info __UNUSED__)
51 {
52    elm_slideshow_transition_set(slideshow, data);
53    elm_hoversel_label_set(obj, data);
54 }
55
56 static void
57 _layout_select(void *data, Evas_Object *obj, void *event_info __UNUSED__)
58 {
59    elm_slideshow_layout_set(slideshow, data);
60    elm_hoversel_label_set(obj, data);
61 }
62
63 static void
64 _start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
65 {
66    elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
67
68    elm_object_disabled_set(bt_start, EINA_TRUE);
69    elm_object_disabled_set(bt_stop, EINA_FALSE);
70 }
71
72 static void
73 _stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
74 {
75    elm_slideshow_timeout_set(slideshow, 0.0);
76    elm_object_disabled_set(bt_start, EINA_FALSE);
77    elm_object_disabled_set(bt_stop, EINA_TRUE);
78 }
79
80 static void
81 _spin(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
82 {
83    if (elm_slideshow_timeout_get(slideshow) > 0)
84      elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
85 }
86
87 static Evas_Object *
88 _get(void *data, Evas_Object *obj)
89 {
90    //Evas_Object *photo = elm_photocam_add(obj);
91    //elm_photocam_file_set(photo, data);
92    //elm_photocam_zoom_mode_set(photo, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
93
94    Evas_Object *photo = elm_photo_add(obj);
95    elm_photo_file_set(photo, data);
96    elm_photo_fill_inside_set(photo, EINA_TRUE);
97    elm_object_style_set(photo, "shadow");
98
99    return photo;
100 }
101
102
103
104 void
105 test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
106 {
107    Evas_Object *win, *bg, *notify, *bx, *bt, *hv, *spin;
108    const Eina_List *l;
109    const char *transition, *layout;
110
111    win = elm_win_add(NULL, "Slideshow", ELM_WIN_BASIC);
112    elm_win_title_set(win, "Slideshow");
113    elm_win_autodel_set(win, 1);
114
115    bg = elm_bg_add(win);
116    elm_win_resize_object_add(win, bg);
117    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
118    evas_object_show(bg);
119
120    slideshow = elm_slideshow_add(win);
121    elm_slideshow_loop_set(slideshow, EINA_TRUE);
122    elm_win_resize_object_add(win, slideshow);
123    evas_object_size_hint_weight_set(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124    evas_object_show(slideshow);
125
126    itc.func.get = _get;
127    itc.func.del = NULL;
128
129    elm_slideshow_item_add(slideshow, &itc, img1);
130    elm_slideshow_item_add(slideshow, &itc, img2);
131    elm_slideshow_item_add(slideshow, &itc, img3);
132    elm_slideshow_item_add(slideshow, &itc, img4);
133    elm_slideshow_item_add(slideshow, &itc, img9);
134    elm_slideshow_item_add(slideshow, &itc, img5);
135    elm_slideshow_item_add(slideshow, &itc, img6);
136    elm_slideshow_item_add(slideshow, &itc, img7);
137    elm_slideshow_item_add(slideshow, &itc, img8);
138
139    notify = elm_notify_add(win);
140    elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
141    elm_win_resize_object_add(win, notify);
142    elm_notify_timeout_set(notify, 3.0);
143
144    bx = elm_box_add(win);
145    elm_box_horizontal_set(bx, EINA_TRUE);
146    elm_notify_content_set(notify, bx);
147    evas_object_show(bx);
148
149    evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
150                                   notify);
151    evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
152                                   notify);
153
154    bt = elm_button_add(win);
155    elm_button_label_set(bt, "Previous");
156    evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
157    elm_box_pack_end(bx, bt);
158    evas_object_show(bt);
159
160    bt = elm_button_add(win);
161    elm_button_label_set(bt, "Next");
162    evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
163    elm_box_pack_end(bx, bt);
164    evas_object_show(bt);
165
166    hv = elm_hoversel_add(win);
167    elm_box_pack_end(bx, hv);
168    elm_hoversel_hover_parent_set(hv, win);
169    EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
170       elm_hoversel_item_add(hv, transition, NULL, 0, _hv_select, transition);
171    elm_hoversel_label_set(hv, eina_list_data_get(elm_slideshow_transitions_get(slideshow)));
172    evas_object_show(hv);
173
174    hv = elm_hoversel_add(win);
175    elm_box_pack_end(bx, hv);
176    elm_hoversel_hover_parent_set(hv, win);
177    EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
178        elm_hoversel_item_add(hv, layout,  NULL, 0, _layout_select, layout);
179    elm_hoversel_label_set(hv, elm_slideshow_layout_get(slideshow));
180    evas_object_show(hv);
181
182    spin = elm_spinner_add(win);
183    elm_spinner_label_format_set(spin, "%2.0f secs.");
184    evas_object_smart_callback_add(spin, "changed", _spin, spin);
185    elm_spinner_step_set(spin, 1);
186    elm_spinner_min_max_set(spin, 1, 30);
187    elm_spinner_value_set(spin, 3);
188    elm_box_pack_end(bx, spin);
189    evas_object_show(spin);
190
191    bt = elm_button_add(win);
192    bt_start = bt;
193    elm_button_label_set(bt, "Start");
194    evas_object_smart_callback_add(bt, "clicked", _start, spin);
195    elm_box_pack_end(bx, bt);
196    evas_object_show(bt);
197
198    bt = elm_button_add(win);
199    bt_stop = bt;
200    elm_button_label_set(bt, "Stop");
201    evas_object_smart_callback_add(bt, "clicked", _stop, spin);
202    elm_box_pack_end(bx, bt);
203    elm_object_disabled_set(bt, EINA_TRUE);
204    evas_object_show(bt);
205
206    evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
207                                   _notify_show, notify);
208    evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
209                                   _notify_show, notify);
210
211    evas_object_resize(win, 500, 400);
212    evas_object_show(win);
213 }
214
215 #endif