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>
7 # define DATA_DIR "/usr/share/elementary"
11 _transit_flip(Elm_Transit *trans)
13 elm_transit_effect_flip_add(trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_X, EINA_TRUE);
17 _transit_blend(Elm_Transit *trans)
19 elm_transit_effect_blend_add(trans);
23 _transit_fade(Elm_Transit *trans)
25 elm_transit_effect_fade_add(trans);
29 _transit_resizable_flip(Elm_Transit *trans)
31 elm_transit_effect_resizable_flip_add(
32 trans, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
37 void (*transition_add_cb)(Elm_Transit *);
40 { "Flip", _transit_flip, EINA_FALSE },
41 { "Blend", _transit_blend, EINA_FALSE },
42 { "Fade", _transit_fade, EINA_FALSE },
43 { "Resizable Flip", _transit_resizable_flip, EINA_FALSE },
44 { NULL, NULL, EINA_FALSE }
48 on_done(void *data, Evas_Object *obj, void *event_info)
50 /* quit the mainloop (elm_run) */
55 _checkbox_transition_add(Evas_Object *box, const char *label, Eina_Bool *checked)
57 Evas_Object *check = elm_check_add(elm_object_parent_widget_get(box));
58 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
59 evas_object_size_hint_align_set(check, 0.0, 0.0);
60 elm_object_text_set(check, label);
61 elm_check_state_pointer_set(check, checked);
62 elm_box_pack_end(box, check);
63 evas_object_show(check);
67 _transit_start(void *data, Evas_Object *o, void *event_info)
69 Elm_Transit *trans = NULL;
70 Eina_List *objs = data, *l;
74 trans = elm_transit_add();
75 EINA_LIST_FOREACH(objs, l, obj)
76 elm_transit_object_add(trans, obj);
78 // FIXME: Should check if there's another transit going before starting a new
81 for (i = 0; _transitions[i].label; i++)
83 if (_transitions[i].checked)
84 _transitions[i].transition_add_cb(trans);
87 elm_transit_duration_set(trans, 2.0);
88 elm_transit_go(trans);
92 elm_main(int argc, char **argv)
94 Evas_Object *win, *bg, *obj, *icon, *box, *vbox, *btn, *dummy;
95 Eina_List *objs = NULL;
100 win = elm_win_add(NULL, "transit", ELM_WIN_BASIC);
101 elm_win_title_set(win, "Transit Example");
102 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
103 elm_win_autodel_set(win, EINA_TRUE);
105 /* add a scalable white background to this window */
106 bg = elm_bg_add(win);
107 elm_bg_color_set(bg, 255, 255, 255);
108 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109 evas_object_size_hint_min_set(bg, 640, 640);
110 evas_object_size_hint_max_set(bg, 640, 640);
111 elm_win_resize_object_add(win, bg);
112 evas_object_show(bg);
114 box = elm_box_add(win);
115 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
117 elm_win_resize_object_add(win, box);
118 evas_object_show(box);
120 dummy = elm_bg_add(win);
121 evas_object_size_hint_weight_set(dummy, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
122 elm_box_pack_end(box, dummy);
123 evas_object_show(dummy);
125 /* add an object that we are going to play with */
126 obj = elm_button_add(win);
127 elm_object_text_set(obj, "Transformed object!");
128 icon = elm_icon_add(win);
129 snprintf(buf, sizeof(buf), "%s/images/icon_07.png", DATA_DIR);
130 elm_icon_file_set(icon, buf, NULL);
131 elm_object_part_content_set(obj, "icon", icon);
132 evas_object_move(obj, 160, 60);
133 evas_object_resize(obj, 250, 100);
134 evas_object_show(obj);
136 objs = eina_list_append(objs, obj);
138 /* add another object that we are going to play with */
139 obj = elm_button_add(win);
140 elm_object_text_set(obj, "Another object!");
141 icon = elm_icon_add(win);
142 snprintf(buf, sizeof(buf), "%s/images/icon_08.png", DATA_DIR);
143 elm_icon_file_set(icon, buf, NULL);
144 elm_object_part_content_set(obj, "icon", icon);
145 evas_object_move(obj, 160, 60);
146 evas_object_resize(obj, 250, 100);
148 objs = eina_list_append(objs, obj);
150 btn = elm_button_add(win);
151 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
152 elm_object_text_set(btn, "Transit!");
153 elm_box_pack_end(box, btn);
154 evas_object_show(btn);
156 evas_object_smart_callback_add(btn, "clicked", _transit_start, objs);
158 vbox = elm_box_add(win);
159 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
160 evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, 0.0);
162 for (i = 0; _transitions[i].label; i++)
163 _checkbox_transition_add(vbox, _transitions[i].label, &_transitions[i].checked);
165 elm_box_pack_end(box, vbox);
166 evas_object_show(vbox);
168 evas_object_show(win);