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.
5 #include <Elementary.h>
8 _transit_flip(Elm_Transit *trans)
10 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
14 _transit_blend(Elm_Transit *trans)
16 elm_transit_effect_blend_add(trans);
20 _transit_fade(Elm_Transit *trans)
22 elm_transit_effect_fade_add(trans);
26 _transit_resizable_flip(Elm_Transit *trans)
28 elm_transit_effect_resizable_flip_add(
29 trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
34 void (*transition_add_cb)(Elm_Transit *);
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 }
45 on_done(void *data, Evas_Object *obj, void *event_info)
47 /* quit the mainloop (elm_run) */
52 _checkbox_transition_add(Evas_Object *box, const char *label, Eina_Bool *checked)
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);
64 _transit_start(void *data, Evas_Object *o, void *event_info)
66 Elm_Transit *trans = NULL;
67 Eina_List *objs = data, *l;
71 trans = elm_transit_add();
72 EINA_LIST_FOREACH(objs, l, obj)
73 elm_transit_object_add(trans, obj);
75 // FIXME: Should check if there's another transit going before starting a new
78 for (i = 0; _transitions[i].label; i++)
80 if (_transitions[i].checked)
81 _transitions[i].transition_add_cb(trans);
84 elm_transit_duration_set(trans, 2.0);
85 elm_transit_go(trans);
89 elm_main(int argc, char **argv)
91 Evas_Object *win, *bg, *obj, *icon, *box, *vbox, *btn, *dummy;
92 Eina_List *objs = NULL;
96 elm_app_info_set(elm_main, "elementary", "images/icon_07.png");
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);
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);
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);
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);
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);
134 objs = eina_list_append(objs, obj);
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);
146 objs = eina_list_append(objs, obj);
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);
154 evas_object_smart_callback_add(btn, "clicked", _transit_start, objs);
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);
160 for (i = 0; _transitions[i].label; i++)
161 _checkbox_transition_add(vbox, _transitions[i].label, &_transitions[i].checked);
163 elm_box_pack_end(box, vbox);
164 evas_object_show(vbox);
166 evas_object_show(win);