diff options
Diffstat (limited to 'libraries/elementary/src/examples/transit_example_04.c')
-rw-r--r-- | libraries/elementary/src/examples/transit_example_04.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/transit_example_04.c b/libraries/elementary/src/examples/transit_example_04.c new file mode 100644 index 0000000..cf0338f --- /dev/null +++ b/libraries/elementary/src/examples/transit_example_04.c | |||
@@ -0,0 +1,173 @@ | |||
1 | //Compile with: | ||
2 | //gcc -o transit_example_04 transit_example_04.c `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\"" | ||
3 | //where directory is the a path where images/icon_07.png can be found. | ||
4 | |||
5 | #include <Elementary.h> | ||
6 | |||
7 | static void | ||
8 | _transit_flip(Elm_Transit *trans) | ||
9 | { | ||
10 | elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE); | ||
11 | } | ||
12 | |||
13 | static void | ||
14 | _transit_blend(Elm_Transit *trans) | ||
15 | { | ||
16 | elm_transit_effect_blend_add(trans); | ||
17 | } | ||
18 | |||
19 | static void | ||
20 | _transit_fade(Elm_Transit *trans) | ||
21 | { | ||
22 | elm_transit_effect_fade_add(trans); | ||
23 | } | ||
24 | |||
25 | static void | ||
26 | _transit_resizable_flip(Elm_Transit *trans) | ||
27 | { | ||
28 | elm_transit_effect_resizable_flip_add( | ||
29 | trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE); | ||
30 | } | ||
31 | |||
32 | static struct { | ||
33 | const char *label; | ||
34 | void (*transition_add_cb)(Elm_Transit *); | ||
35 | Eina_Bool checked; | ||
36 | } _transitions[] = { | ||
37 | { "Flip", _transit_flip, EINA_FALSE }, | ||
38 | { "Blend", _transit_blend, EINA_FALSE }, | ||
39 | { "Fade", _transit_fade, EINA_FALSE }, | ||
40 | { "Resizable Flip", _transit_resizable_flip, EINA_FALSE }, | ||
41 | { NULL, NULL, EINA_FALSE } | ||
42 | }; | ||
43 | |||
44 | static void | ||
45 | on_done(void *data, Evas_Object *obj, void *event_info) | ||
46 | { | ||
47 | /* quit the mainloop (elm_run) */ | ||
48 | elm_exit(); | ||
49 | } | ||
50 | |||
51 | static void | ||
52 | _checkbox_transition_add(Evas_Object *box, const char *label, Eina_Bool *checked) | ||
53 | { | ||
54 | Evas_Object *check = elm_check_add(elm_object_parent_widget_get(box)); | ||
55 | evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
56 | evas_object_size_hint_align_set(check, 0.0, 0.0); | ||
57 | elm_object_text_set(check, label); | ||
58 | elm_check_state_pointer_set(check, checked); | ||
59 | elm_box_pack_end(box, check); | ||
60 | evas_object_show(check); | ||
61 | } | ||
62 | |||
63 | static void | ||
64 | _transit_start(void *data, Evas_Object *o, void *event_info) | ||
65 | { | ||
66 | Elm_Transit *trans = NULL; | ||
67 | Eina_List *objs = data, *l; | ||
68 | Evas_Object *obj; | ||
69 | int i; | ||
70 | |||
71 | trans = elm_transit_add(); | ||
72 | EINA_LIST_FOREACH(objs, l, obj) | ||
73 | elm_transit_object_add(trans, obj); | ||
74 | |||
75 | // FIXME: Should check if there's another transit going before starting a new | ||
76 | // one | ||
77 | |||
78 | for (i = 0; _transitions[i].label; i++) | ||
79 | { | ||
80 | if (_transitions[i].checked) | ||
81 | _transitions[i].transition_add_cb(trans); | ||
82 | } | ||
83 | |||
84 | elm_transit_duration_set(trans, 2.0); | ||
85 | elm_transit_go(trans); | ||
86 | } | ||
87 | |||
88 | EAPI_MAIN int | ||
89 | elm_main(int argc, char **argv) | ||
90 | { | ||
91 | Evas_Object *win, *bg, *obj, *icon, *box, *vbox, *btn, *dummy; | ||
92 | Eina_List *objs = NULL; | ||
93 | char buf[PATH_MAX]; | ||
94 | int i; | ||
95 | |||
96 | elm_app_info_set(elm_main, "elementary", "images/icon_07.png"); | ||
97 | /* add a window */ | ||
98 | win = elm_win_add(NULL, "transit", ELM_WIN_BASIC); | ||
99 | elm_win_title_set(win, "Transit Example"); | ||
100 | evas_object_smart_callback_add(win, "delete,request", on_done, NULL); | ||
101 | elm_win_autodel_set(win, EINA_TRUE); | ||
102 | |||
103 | /* add a scalable white background to this window */ | ||
104 | bg = elm_bg_add(win); | ||
105 | elm_bg_color_set(bg, 255, 255, 255); | ||
106 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
107 | evas_object_size_hint_min_set(bg, 640, 640); | ||
108 | evas_object_size_hint_max_set(bg, 640, 640); | ||
109 | elm_win_resize_object_add(win, bg); | ||
110 | evas_object_show(bg); | ||
111 | |||
112 | box = elm_box_add(win); | ||
113 | evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
114 | evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
115 | elm_win_resize_object_add(win, box); | ||
116 | evas_object_show(box); | ||
117 | |||
118 | dummy = elm_bg_add(win); | ||
119 | evas_object_size_hint_weight_set(dummy, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
120 | elm_box_pack_end(box, dummy); | ||
121 | evas_object_show(dummy); | ||
122 | |||
123 | /* add an object that we are going to play with */ | ||
124 | obj = elm_button_add(win); | ||
125 | elm_object_text_set(obj, "Transformed object!"); | ||
126 | icon = elm_icon_add(win); | ||
127 | snprintf(buf, sizeof(buf), "%s/images/icon_07.png", elm_app_data_dir_get()); | ||
128 | elm_icon_file_set(icon, buf, NULL); | ||
129 | elm_object_part_content_set(obj, "icon", icon); | ||
130 | evas_object_move(obj, 160, 60); | ||
131 | evas_object_resize(obj, 250, 100); | ||
132 | evas_object_show(obj); | ||
133 | |||
134 | objs = eina_list_append(objs, obj); | ||
135 | |||
136 | /* add another object that we are going to play with */ | ||
137 | obj = elm_button_add(win); | ||
138 | elm_object_text_set(obj, "Another object!"); | ||
139 | icon = elm_icon_add(win); | ||
140 | snprintf(buf, sizeof(buf), "%s/images/icon_08.png", elm_app_data_dir_get()); | ||
141 | elm_icon_file_set(icon, buf, NULL); | ||
142 | elm_object_part_content_set(obj, "icon", icon); | ||
143 | evas_object_move(obj, 160, 60); | ||
144 | evas_object_resize(obj, 250, 100); | ||
145 | |||
146 | objs = eina_list_append(objs, obj); | ||
147 | |||
148 | btn = elm_button_add(win); | ||
149 | evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
150 | elm_object_text_set(btn, "Transit!"); | ||
151 | elm_box_pack_end(box, btn); | ||
152 | evas_object_show(btn); | ||
153 | |||
154 | evas_object_smart_callback_add(btn, "clicked", _transit_start, objs); | ||
155 | |||
156 | vbox = elm_box_add(win); | ||
157 | evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
158 | evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, 0.0); | ||
159 | |||
160 | for (i = 0; _transitions[i].label; i++) | ||
161 | _checkbox_transition_add(vbox, _transitions[i].label, &_transitions[i].checked); | ||
162 | |||
163 | elm_box_pack_end(box, vbox); | ||
164 | evas_object_show(vbox); | ||
165 | |||
166 | evas_object_show(win); | ||
167 | |||
168 | elm_run(); | ||
169 | elm_shutdown(); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | ELM_MAIN() | ||