summaryrefslogtreecommitdiff
path: root/src/examples/elementary/box_example_02.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/examples/elementary/box_example_02.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/examples/elementary/box_example_02.c')
-rw-r--r--src/examples/elementary/box_example_02.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/examples/elementary/box_example_02.c b/src/examples/elementary/box_example_02.c
new file mode 100644
index 0000000000..24c502d2b4
--- /dev/null
+++ b/src/examples/elementary/box_example_02.c
@@ -0,0 +1,163 @@
1//Compile with:
2//gcc -g box_example_02.c -o box_example_02 `pkg-config --cflags --libs elementary`
3
4#include <Elementary.h>
5
6typedef struct
7{
8 Eina_List *transitions;
9 Evas_Object *box;
10 Evas_Object_Box_Layout last_layout;
11} Transitions_Data;
12
13static void
14_add_cb(void *data, Evas_Object *obj, void *ev)
15{
16 Evas_Object *btn;
17 Eina_List *children;
18 Transitions_Data *tdata = data;
19
20 btn = elm_button_add(tdata->box);
21 elm_object_text_set(btn, "I do nothing");
22 children = (Eina_List *)elm_box_children_get(tdata->box);
23 if (children)
24 {
25 elm_box_pack_after(tdata->box, btn, (Evas_Object *)children->data);
26 eina_list_free(children);
27 }
28 else
29 elm_box_pack_end(tdata->box, btn);
30 evas_object_show(btn);
31}
32
33static void
34_clear_cb(void *data, Evas_Object *obj, void *ev)
35{
36 Transitions_Data *tdata = data;
37 elm_box_clear(tdata->box);
38}
39
40static void
41_unpack_cb(void *data, Evas_Object *obj, void *ev)
42{
43 Transitions_Data *tdata = data;
44 elm_box_unpack(tdata->box, obj);
45 evas_object_move(obj, 0, 50);
46 evas_object_color_set(obj, 128, 64, 0, 128);
47}
48
49static void
50_test_box_transition_change(void *data)
51{
52 Transitions_Data *tdata = data;
53 Elm_Box_Transition *layout_data;
54 Evas_Object_Box_Layout next_layout;
55
56 if (!data) return;
57 next_layout = eina_list_data_get(tdata->transitions);
58 layout_data = elm_box_transition_new(2.0, tdata->last_layout,
59 NULL, NULL, next_layout, NULL, NULL,
60 _test_box_transition_change, tdata);
61 elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data,
62 elm_box_transition_free);
63 tdata->last_layout = next_layout;
64
65 tdata->transitions = eina_list_demote_list(tdata->transitions,
66 tdata->transitions);
67}
68
69EAPI_MAIN int
70elm_main(int argc, char *argv[])
71{
72 Evas_Object *win, *bigbox, *bx, *bt;
73 static Transitions_Data tdata = {
74 .transitions = NULL,
75 .box = NULL,
76 .last_layout = NULL
77 };
78
79 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
80
81 win = elm_win_util_standard_add("box-transition", "Box Transition");
82 elm_win_autodel_set(win, EINA_TRUE);
83
84 bigbox = elm_box_add(win);
85 evas_object_size_hint_weight_set(bigbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86 elm_win_resize_object_add(win, bigbox);
87 evas_object_show(bigbox);
88
89 bx = elm_box_add(win);
90 elm_box_horizontal_set(bx, EINA_TRUE);
91 elm_box_pack_end(bigbox, bx);
92 evas_object_show(bx);
93
94 bt = elm_button_add(win);
95 elm_object_text_set(bt, "Add");
96 elm_box_pack_end(bx, bt);
97 evas_object_show(bt);
98 evas_object_smart_callback_add(bt, "clicked", _add_cb, &tdata);
99
100 bt = elm_button_add(win);
101 elm_object_text_set(bt, "Clear");
102 elm_box_pack_end(bx, bt);
103 evas_object_show(bt);
104 evas_object_smart_callback_add(bt, "clicked", _clear_cb, &tdata);
105
106 bx = elm_box_add(win);
107 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
108 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
109 elm_box_pack_end(bigbox, bx);
110 evas_object_show(bx);
111
112 bt = elm_button_add(win);
113 elm_object_text_set(bt, "Button 1");
114 evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
115 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
117 elm_box_pack_end(bx, bt);
118 evas_object_show(bt);
119
120 bt = elm_button_add(win);
121 elm_object_text_set(bt, "Button 2");
122 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
123 evas_object_size_hint_align_set(bt, 1.0, 0.5);
124 evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
125 elm_box_pack_end(bx, bt);
126 evas_object_show(bt);
127
128 bt = elm_button_add(win);
129 elm_object_text_set(bt, "Button 3");
130 evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
131 elm_box_pack_end(bx, bt);
132 evas_object_show(bt);
133
134 tdata.box = bx;
135 tdata.last_layout = evas_object_box_layout_horizontal;
136 tdata.transitions = eina_list_append(tdata.transitions,
137 evas_object_box_layout_vertical);
138 tdata.transitions = eina_list_append(tdata.transitions,
139 evas_object_box_layout_horizontal);
140 tdata.transitions = eina_list_append(tdata.transitions,
141 evas_object_box_layout_stack);
142 tdata.transitions = eina_list_append(tdata.transitions,
143 evas_object_box_layout_homogeneous_vertical);
144 tdata.transitions = eina_list_append(tdata.transitions,
145 evas_object_box_layout_homogeneous_horizontal);
146 tdata.transitions = eina_list_append(tdata.transitions,
147 evas_object_box_layout_flow_vertical);
148 tdata.transitions = eina_list_append(tdata.transitions,
149 evas_object_box_layout_flow_horizontal);
150 tdata.transitions = eina_list_append(tdata.transitions,
151 evas_object_box_layout_stack);
152
153 elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
154 _test_box_transition_change(&tdata);
155
156 evas_object_resize(win, 300, 320);
157 evas_object_show(win);
158
159 elm_run();
160
161 return 0;
162}
163ELM_MAIN()