2 //gcc -g -DPACKAGE_DATA_DIR="\"<directory>\"" `pkg-config --cflags --libs elementary` transit_example_04.c -o transit_example_04
3 // where directory is the a path where images/plant_01.jpg can be found.
6 #include <Elementary.h>
8 # include "elementary_config.h"
14 _transit_flip(Elm_Transit *trans)
16 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
20 _transit_blend(Elm_Transit *trans)
22 elm_transit_effect_blend_add(trans);
26 _transit_fade(Elm_Transit *trans)
28 elm_transit_effect_fade_add(trans);
32 _transit_resizable_flip(Elm_Transit *trans)
34 elm_transit_effect_resizable_flip_add(
35 trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
40 void (*transition_add_cb)(Elm_Transit *);
43 { "Flip", _transit_flip, EINA_FALSE },
44 { "Blend", _transit_blend, EINA_FALSE },
45 { "Fade", _transit_fade, EINA_FALSE },
46 { "Resizable Flip", _transit_resizable_flip, EINA_FALSE },
47 { NULL, NULL, EINA_FALSE }
51 on_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
53 /* quit the mainloop (elm_run) */
58 _checkbox_transition_add(Evas_Object *box, const char *label, Eina_Bool *checked)
60 Evas_Object *check = elm_check_add(elm_object_parent_widget_get(box));
61 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62 evas_object_size_hint_align_set(check, 0.0, 0.0);
63 elm_object_text_set(check, label);
64 elm_check_state_pointer_set(check, checked);
65 elm_box_pack_end(box, check);
66 evas_object_show(check);
70 _transit_start(void *data, Evas_Object *o, void *event_info)
72 Elm_Transit *trans = NULL;
73 Eina_List *objs = data, *l;
77 trans = elm_transit_add();
78 EINA_LIST_FOREACH(objs, l, obj)
79 elm_transit_object_add(trans, obj);
81 // FIXME: Should check if there's another transit going before starting a new
84 for (i = 0; _transitions[i].label; i++)
86 if (_transitions[i].checked)
87 _transitions[i].transition_add_cb(trans);
90 elm_transit_duration_set(trans, 2.0);
91 elm_transit_go(trans);
95 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
97 Evas_Object *win, *bg, *obj, *icon, *box, *vbox, *btn, *fr, *dummy;
99 Eina_List *objs = NULL;
104 win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
105 elm_win_title_set(win, "Transit Example");
106 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
107 elm_win_autodel_set(win, EINA_TRUE);
109 /* add a scalable white background to this window */
110 bg = elm_bg_add(win);
111 elm_bg_color_set(bg, 255, 255, 255);
112 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
113 evas_object_size_hint_min_set(bg, 640, 640);
114 evas_object_size_hint_max_set(bg, 640, 640);
115 elm_win_resize_object_add(win, bg);
116 evas_object_show(bg);
118 box = elm_box_add(win);
119 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
121 elm_win_resize_object_add(win, box);
122 evas_object_show(box);
124 dummy = elm_bg_add(win);
125 evas_object_size_hint_weight_set(dummy, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 elm_box_pack_end(box, dummy);
127 evas_object_show(dummy);
129 /* add an object that we are going to play with */
130 obj = elm_button_add(win);
131 elm_object_text_set(obj, "Transformed object!");
132 icon = elm_icon_add(win);
133 snprintf(buf, sizeof(buf), "%s/images/icon_07.png", PACKAGE_DATA_DIR);
134 elm_icon_file_set(icon, buf, NULL);
135 elm_button_icon_set(obj, icon);
136 evas_object_move(obj, 160, 60);
137 evas_object_resize(obj, 250, 100);
138 evas_object_show(obj);
140 objs = eina_list_append(objs, obj);
142 /* add another object that we are going to play with */
143 obj = elm_button_add(win);
144 elm_object_text_set(obj, "Another object!");
145 icon = elm_icon_add(win);
146 snprintf(buf, sizeof(buf), "%s/images/icon_08.png", PACKAGE_DATA_DIR);
147 elm_icon_file_set(icon, buf, NULL);
148 elm_button_icon_set(obj, icon);
149 evas_object_move(obj, 160, 60);
150 evas_object_resize(obj, 250, 100);
152 objs = eina_list_append(objs, obj);
154 btn = elm_button_add(win);
155 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
156 elm_object_text_set(btn, "Transit!");
157 elm_box_pack_end(box, btn);
158 evas_object_show(btn);
160 evas_object_smart_callback_add(btn, "clicked", _transit_start, objs);
162 vbox = elm_box_add(win);
163 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
164 evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, 0.0);
166 for (i = 0; _transitions[i].label; i++)
167 _checkbox_transition_add(vbox, _transitions[i].label, &_transitions[i].checked);
169 elm_box_pack_end(box, vbox);
170 evas_object_show(vbox);
172 evas_object_show(win);
176 eina_list_free(objs);