aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/bin/test_slideshow.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/elementary/src/bin/test_slideshow.c')
-rw-r--r--libraries/elementary/src/bin/test_slideshow.c218
1 files changed, 218 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_slideshow.c b/libraries/elementary/src/bin/test_slideshow.c
new file mode 100644
index 0000000..85ae340
--- /dev/null
+++ b/libraries/elementary/src/bin/test_slideshow.c
@@ -0,0 +1,218 @@
1#include "elementary_config.h"
2#include <Elementary.h>
3#ifndef ELM_LIB_QUICKLAUNCH
4
5static Evas_Object *slideshow, *bt_start, *bt_stop;
6static Elm_Slideshow_Item_Class itc;
7static const char *img1 = PACKAGE_DATA_DIR"/images/logo.png";
8static const char *img2 = PACKAGE_DATA_DIR"/images/plant_01.jpg";
9static const char *img3 = PACKAGE_DATA_DIR"/images/rock_01.jpg";
10static const char *img4 = PACKAGE_DATA_DIR"/images/rock_02.jpg";
11static const char *img5 = PACKAGE_DATA_DIR"/images/sky_01.jpg";
12static const char *img6 = PACKAGE_DATA_DIR"/images/sky_04.jpg";
13static const char *img7 = PACKAGE_DATA_DIR"/images/wood_01.jpg";
14static const char *img8 = PACKAGE_DATA_DIR"/images/mystrale.jpg";
15static const char *img9 = PACKAGE_DATA_DIR"/images/mystrale_2.jpg";
16
17static 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
23static void
24_next(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
25{
26 elm_slideshow_next(data);
27}
28
29static void
30_previous(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
31{
32 elm_slideshow_previous(data);
33}
34
35static 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
43static 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
49static void
50_hv_select(void *data, Evas_Object *obj, void *event_info __UNUSED__)
51{
52 elm_slideshow_transition_set(slideshow, data);
53 elm_object_text_set(obj, data);
54}
55
56static void
57_layout_select(void *data, Evas_Object *obj, void *event_info __UNUSED__)
58{
59 elm_slideshow_layout_set(slideshow, data);
60 elm_object_text_set(obj, data);
61}
62
63static 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
72static 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
80static 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
87static 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
102static void
103_slide_transition(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
104{
105 Elm_Object_Item *slide_it = (Elm_Object_Item *) event_info;
106 if (data == slide_it)
107 printf("Reaches to End of slides\n");
108}
109
110void
111test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
112{
113 Evas_Object *win, *notify, *bx, *bt, *hv, *spin;
114 const Eina_List *l;
115 const char *transition, *layout;
116 Elm_Object_Item *slide_last_it;
117
118 win = elm_win_util_standard_add("slideshow", "Slideshow");
119 elm_win_autodel_set(win, EINA_TRUE);
120
121 slideshow = elm_slideshow_add(win);
122 elm_slideshow_loop_set(slideshow, EINA_TRUE);
123 elm_win_resize_object_add(win, slideshow);
124 evas_object_size_hint_weight_set(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
125 evas_object_show(slideshow);
126
127 itc.func.get = _get;
128 itc.func.del = NULL;
129
130 elm_slideshow_item_add(slideshow, &itc, img1);
131 elm_slideshow_item_add(slideshow, &itc, img2);
132 elm_slideshow_item_add(slideshow, &itc, img3);
133 elm_slideshow_item_add(slideshow, &itc, img4);
134 elm_slideshow_item_add(slideshow, &itc, img9);
135 elm_slideshow_item_add(slideshow, &itc, img5);
136 elm_slideshow_item_add(slideshow, &itc, img6);
137 elm_slideshow_item_add(slideshow, &itc, img7);
138 slide_last_it = elm_slideshow_item_add(slideshow, &itc, img8);
139 evas_object_smart_callback_add(slideshow, "transition,end", _slide_transition, slide_last_it);
140
141 notify = elm_notify_add(win);
142 elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
143 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
144 elm_win_resize_object_add(win, notify);
145 elm_notify_timeout_set(notify, 3.0);
146
147 bx = elm_box_add(win);
148 elm_box_horizontal_set(bx, EINA_TRUE);
149 elm_object_content_set(notify, bx);
150 evas_object_show(bx);
151
152 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
153 notify);
154 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
155 notify);
156
157 bt = elm_button_add(win);
158 elm_object_text_set(bt, "Previous");
159 evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
160 elm_box_pack_end(bx, bt);
161 evas_object_show(bt);
162
163 bt = elm_button_add(win);
164 elm_object_text_set(bt, "Next");
165 evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
166 elm_box_pack_end(bx, bt);
167 evas_object_show(bt);
168
169 hv = elm_hoversel_add(win);
170 elm_box_pack_end(bx, hv);
171 elm_hoversel_hover_parent_set(hv, win);
172 EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
173 elm_hoversel_item_add(hv, transition, NULL, 0, _hv_select, transition);
174 elm_object_text_set(hv, eina_list_data_get(elm_slideshow_transitions_get(slideshow)));
175 evas_object_show(hv);
176
177 hv = elm_hoversel_add(win);
178 elm_box_pack_end(bx, hv);
179 elm_hoversel_hover_parent_set(hv, win);
180 EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
181 elm_hoversel_item_add(hv, layout, NULL, 0, _layout_select, layout);
182 elm_object_text_set(hv, elm_slideshow_layout_get(slideshow));
183 evas_object_show(hv);
184
185 spin = elm_spinner_add(win);
186 elm_spinner_label_format_set(spin, "%2.0f secs.");
187 evas_object_smart_callback_add(spin, "changed", _spin, spin);
188 elm_spinner_step_set(spin, 1);
189 elm_spinner_min_max_set(spin, 1, 30);
190 elm_spinner_value_set(spin, 3);
191 elm_box_pack_end(bx, spin);
192 evas_object_show(spin);
193
194 bt = elm_button_add(win);
195 bt_start = bt;
196 elm_object_text_set(bt, "Start");
197 evas_object_smart_callback_add(bt, "clicked", _start, spin);
198 elm_box_pack_end(bx, bt);
199 evas_object_show(bt);
200
201 bt = elm_button_add(win);
202 bt_stop = bt;
203 elm_object_text_set(bt, "Stop");
204 evas_object_smart_callback_add(bt, "clicked", _stop, spin);
205 elm_box_pack_end(bx, bt);
206 elm_object_disabled_set(bt, EINA_TRUE);
207 evas_object_show(bt);
208
209 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
210 _notify_show, notify);
211 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
212 _notify_show, notify);
213
214 evas_object_resize(win, 500, 400);
215 evas_object_show(win);
216}
217
218#endif