diff options
author | Vitalii Vorobiov <vi.vorobiov@samsung.com> | 2015-02-16 12:03:19 +0100 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-02-16 12:10:07 +0100 |
commit | bd2304cf3b99dd0aaf340c59b9ebdbfd961e7b2b (patch) | |
tree | 13b11382fcaee73f031963209797d3fb583ca769 | |
parent | 14e65920ffad432239614b6e59226b9a3c9600b8 (diff) |
edje: Edje_Edit - add examples for it's API using for BOX part and items
Summary:
Some little example about how and when edje_edit functions can be applied.
In this example there is a box part with items in edj, and by using edje_edit
program actually changes edj file directly. (adding items,
changing layouts of box, changing params of items, etc).
It is pushed as a reference for people who would like to do there own
Edje editor. Normal application should not use that API.
Reviewers: Hermet, raster, seoz, cedric
Reviewed By: cedric
Subscribers: cedric, reutskiy.v.v
Differential Revision: https://phab.enlightenment.org/D1969
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r-- | src/examples/edje/Makefile.am | 9 | ||||
-rw-r--r-- | src/examples/edje/box_example.edc | 109 | ||||
-rw-r--r-- | src/examples/edje/edje-edit-part-box.c | 379 |
3 files changed, 494 insertions, 3 deletions
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am index 9bc26d0e08..cfdcc5f9cf 100644 --- a/src/examples/edje/Makefile.am +++ b/src/examples/edje/Makefile.am | |||
@@ -43,7 +43,8 @@ sigtest.edc \ | |||
43 | swallow.edc \ | 43 | swallow.edc \ |
44 | table.edc \ | 44 | table.edc \ |
45 | text.edc \ | 45 | text.edc \ |
46 | toggle_using_filter.edc | 46 | toggle_using_filter.edc \ |
47 | box_example.edc | ||
47 | 48 | ||
48 | DIST_EDCS = $(EDCS) | 49 | DIST_EDCS = $(EDCS) |
49 | 50 | ||
@@ -99,7 +100,8 @@ animations2.c \ | |||
99 | edje-basic2.c \ | 100 | edje-basic2.c \ |
100 | signals2.c \ | 101 | signals2.c \ |
101 | edje-swallow2.c \ | 102 | edje-swallow2.c \ |
102 | edje-multisense.c | 103 | edje-multisense.c \ |
104 | edje-edit-part-box.c | ||
103 | 105 | ||
104 | EXTRA_DIST = $(DIST_EDCS) $(DATA_FILES) | 106 | EXTRA_DIST = $(DIST_EDCS) $(DATA_FILES) |
105 | 107 | ||
@@ -167,7 +169,8 @@ sigtest \ | |||
167 | animations2 \ | 169 | animations2 \ |
168 | edje-basic2 \ | 170 | edje-basic2 \ |
169 | signals2 \ | 171 | signals2 \ |
170 | edje-swallow2 | 172 | edje-swallow2 \ |
173 | edje-edit-part-box | ||
171 | 174 | ||
172 | if ENABLE_MULTISENSE | 175 | if ENABLE_MULTISENSE |
173 | EXTRA_PROGRAMS += edje-multisense | 176 | EXTRA_PROGRAMS += edje-multisense |
diff --git a/src/examples/edje/box_example.edc b/src/examples/edje/box_example.edc new file mode 100644 index 0000000000..0c56994007 --- /dev/null +++ b/src/examples/edje/box_example.edc | |||
@@ -0,0 +1,109 @@ | |||
1 | collections { | ||
2 | images { | ||
3 | image: "bubble-blue.png" COMP; | ||
4 | } | ||
5 | group { name: "red_group"; | ||
6 | parts { | ||
7 | part { name: "red"; | ||
8 | type: RECT; | ||
9 | description { state: "default" 0.0; | ||
10 | color: 255 0 0 255; | ||
11 | } | ||
12 | } | ||
13 | } | ||
14 | } | ||
15 | group { name: "blue_group"; | ||
16 | parts { | ||
17 | part { name: "blue"; | ||
18 | type: RECT; | ||
19 | description { state: "default" 0.0; | ||
20 | color: 0 0 255 255; | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | } | ||
25 | group { name: "green_group"; | ||
26 | parts { | ||
27 | part { name: "green"; | ||
28 | type: RECT; | ||
29 | description { state: "default" 0.0; | ||
30 | color: 0 255 0 255; | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | group { name: "complex_group"; | ||
36 | parts { | ||
37 | part { name: "green"; | ||
38 | type: RECT; | ||
39 | description { state: "default" 0.0; | ||
40 | color: 255 0 255 255; | ||
41 | } | ||
42 | } | ||
43 | part { | ||
44 | type: IMAGE; | ||
45 | name: "bg"; | ||
46 | description { | ||
47 | state: "default" 0.0; | ||
48 | image { | ||
49 | normal: "bubble-blue.png"; | ||
50 | } | ||
51 | rel1.relative: 0.25 0.25; | ||
52 | rel2.relative: 0.75 0.75; | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | group { name: "box_group"; | ||
59 | parts { | ||
60 | part { name: "bg"; | ||
61 | type: RECT; | ||
62 | description { state: "default" 0.0; | ||
63 | visible: 1; | ||
64 | color: 0 0 0 255; | ||
65 | } | ||
66 | } | ||
67 | part { name: "green"; | ||
68 | type: BOX; | ||
69 | box { | ||
70 | items { | ||
71 | item { | ||
72 | type: GROUP; | ||
73 | name: "x1"; | ||
74 | source: "red_group"; | ||
75 | min: 100 100; | ||
76 | max: 200 200; | ||
77 | align: 0 0; | ||
78 | weight: 20 10; | ||
79 | } | ||
80 | item { | ||
81 | type: GROUP; | ||
82 | name: "x2"; | ||
83 | source: "blue_group"; | ||
84 | min: 200 200; | ||
85 | max: 800 800; | ||
86 | } | ||
87 | item { | ||
88 | type: GROUP; | ||
89 | name: "x3"; | ||
90 | source: "green_group"; | ||
91 | min: 20 20; | ||
92 | max: 100 100; | ||
93 | align: 0.3 0.7; | ||
94 | weight: 5 15; | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | description { state: "default" 0.0; | ||
99 | visible: 1; | ||
100 | color: 255 255 255 255; | ||
101 | box { | ||
102 | layout: "horizontal"; | ||
103 | padding: 5 5; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
diff --git a/src/examples/edje/edje-edit-part-box.c b/src/examples/edje/edje-edit-part-box.c new file mode 100644 index 0000000000..e7f3b6b45d --- /dev/null +++ b/src/examples/edje/edje-edit-part-box.c | |||
@@ -0,0 +1,379 @@ | |||
1 | /** | ||
2 | * Simple Edje Edit example illustrating BOX part's and it's items editing. | ||
3 | * | ||
4 | * This example is intended for people who want to write an Edje editor. There | ||
5 | * is no other application that should use it, EVER ! If you don't plan to write | ||
6 | * an Edje editor please move away from this file. | ||
7 | * | ||
8 | * See stdout/stderr for output. | ||
9 | * | ||
10 | * @verbatim | ||
11 | * edje_cc box_example.edc && gcc -o edje-edit-part-box edje-edit-part-box.c `pkg-config --libs --cflags evas ecore ecore-evas edje eina` | ||
12 | * @endverbatim | ||
13 | */ | ||
14 | |||
15 | #ifdef HAVE_CONFIG_H | ||
16 | # include "config.h" | ||
17 | #else | ||
18 | # define EINA_UNUSED | ||
19 | #endif | ||
20 | |||
21 | #ifndef PACKAGE_DATA_DIR | ||
22 | #define PACKAGE_DATA_DIR "." | ||
23 | #endif | ||
24 | |||
25 | #define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT | ||
26 | #include <Ecore.h> | ||
27 | #include <Ecore_Evas.h> | ||
28 | #include <Edje_Edit.h> | ||
29 | #include <Edje.h> | ||
30 | |||
31 | #define WIDTH (500) | ||
32 | #define HEIGHT (300) | ||
33 | |||
34 | static const char commands[] = \ | ||
35 | "commands are:\n" | ||
36 | "\tl - change box layout\n" | ||
37 | "\tL - change box alternative layout\n" | ||
38 | "\ti - append one/remove item\n" | ||
39 | "\tg - change source of middle item\n" | ||
40 | "\tM - change max of middle item\n" | ||
41 | "\tm - change min of middle item\n" | ||
42 | "\ts - change spread (w and h) of middle item\n" | ||
43 | "\tb - change paddings of middle item\n" | ||
44 | "\tw - change weight of middle item\n" | ||
45 | "\tn - change align of middle item\n" | ||
46 | "\tp - print resulted source code of edj file (after changing with edje edit)\n" | ||
47 | "\th - print help\n" | ||
48 | "\tEsc - exit\n"; | ||
49 | |||
50 | static int group_number = 0; | ||
51 | static const char *groups[] = | ||
52 | { | ||
53 | "blue_group", "red_group", "green_group", "complex_group" | ||
54 | }; | ||
55 | |||
56 | static int layout_number = 0; | ||
57 | static int alt_layout_number = 0; | ||
58 | static char *layouts[] = | ||
59 | { | ||
60 | "horizontal", "vertical", "horizontal_homogeneous", "vertical_homogeneous", | ||
61 | "horizontal_max", "vertical_max", "horizontal_flow", "vertical_flow", "stack", | ||
62 | NULL | ||
63 | }; | ||
64 | |||
65 | static void | ||
66 | _on_delete(Ecore_Evas *ee EINA_UNUSED) | ||
67 | { | ||
68 | ecore_main_loop_quit(); | ||
69 | } | ||
70 | |||
71 | static void | ||
72 | _on_bg_key_down(void *data EINA_UNUSED, | ||
73 | Evas *e EINA_UNUSED, | ||
74 | Evas_Object *o, | ||
75 | void *event_info) | ||
76 | { | ||
77 | const char *edje_file = PACKAGE_DATA_DIR"/box_example.edj"; | ||
78 | Evas_Event_Key_Down *ev; | ||
79 | Evas_Object *edje_edit_obj = o; | ||
80 | |||
81 | ev = (Evas_Event_Key_Down *)event_info; | ||
82 | |||
83 | if (!strcmp(ev->key, "h")) | ||
84 | { | ||
85 | fprintf(stdout, commands); | ||
86 | return; | ||
87 | } | ||
88 | if (!strcmp(ev->key, "p")) | ||
89 | { | ||
90 | fprintf(stdout, "SOURCE CODE:\n%s \n", edje_edit_source_generate(edje_edit_obj)); | ||
91 | return; | ||
92 | } | ||
93 | if (!strcmp(ev->key, "n")) | ||
94 | { | ||
95 | double align_x = edje_edit_part_item_align_x_get(edje_edit_obj, "green", "x2"); | ||
96 | double align_y = edje_edit_part_item_align_y_get(edje_edit_obj, "green", "x2"); | ||
97 | |||
98 | align_x += 0.1; align_y += 0.2; | ||
99 | if (align_x >= 1.0) align_x = 0.0; | ||
100 | if (align_y >= 1.0) align_y = 0.0; | ||
101 | |||
102 | fprintf(stdout, "Changing align to x[%f] y[%f] \n", align_x, align_y); | ||
103 | |||
104 | if (!edje_edit_part_item_align_x_set(edje_edit_obj, "green", "x2", align_x)) | ||
105 | fprintf(stderr, "Couldn't set align x for item x2, something is absolutely wrong!!!\n"); | ||
106 | if (!edje_edit_part_item_align_y_set(edje_edit_obj, "green", "x2", align_y)) | ||
107 | fprintf(stderr, "Couldn't set align y for item x2, something is absolutely wrong!!!\n"); | ||
108 | |||
109 | edje_edit_save_all(edje_edit_obj); | ||
110 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
111 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
112 | |||
113 | return; | ||
114 | } | ||
115 | if (!strcmp(ev->key, "w")) | ||
116 | { | ||
117 | double weight_x = edje_edit_part_item_weight_x_get(edje_edit_obj, "green", "x2"); | ||
118 | double weight_y = edje_edit_part_item_weight_y_get(edje_edit_obj, "green", "x2"); | ||
119 | |||
120 | weight_x += 5.0; weight_y += 10.0; | ||
121 | if (weight_x >= 30.0) weight_x = 0.0; | ||
122 | if (weight_y >= 30.0) weight_y = 0.0; | ||
123 | |||
124 | fprintf(stdout, "Changing weight to x[%f] y[%f] \n", weight_x, weight_y); | ||
125 | |||
126 | if (!edje_edit_part_item_weight_x_set(edje_edit_obj, "green", "x2", weight_x)) | ||
127 | fprintf(stderr, "Couldn't set weight x for item x2, something is absolutely wrong!!!\n"); | ||
128 | if (!edje_edit_part_item_weight_y_set(edje_edit_obj, "green", "x2", weight_y)) | ||
129 | fprintf(stderr, "Couldn't set weight y for item x2, something is absolutely wrong!!!\n"); | ||
130 | |||
131 | edje_edit_save_all(edje_edit_obj); | ||
132 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
133 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
134 | |||
135 | return; | ||
136 | } | ||
137 | if (!strcmp(ev->key, "b")) | ||
138 | { | ||
139 | Evas_Coord l, r, t, b; | ||
140 | edje_edit_part_item_padding_get(edje_edit_obj, "green", "x2", &l, &r, &t, &b); | ||
141 | |||
142 | l += 1; r += 2; t += 4; b += 8; | ||
143 | if (l >= 32) l = 0; | ||
144 | if (r >= 32) r = 0; | ||
145 | if (t >= 32) t = 0; | ||
146 | if (b >= 32) b = 0; | ||
147 | |||
148 | fprintf(stdout, "Changing paddings. left[%d], right[%d], top[%d], bottom[%d]\n", l, r, t, b); | ||
149 | |||
150 | if (!edje_edit_part_item_padding_set(edje_edit_obj, "green", "x2", l, r, t, b)) | ||
151 | fprintf(stderr, "Couldn't set paddings for item x2, something is absolutely wrong!!!\n"); | ||
152 | |||
153 | edje_edit_save_all(edje_edit_obj); | ||
154 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
155 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
156 | |||
157 | return; | ||
158 | } | ||
159 | if (!strcmp(ev->key, "s")) | ||
160 | { | ||
161 | /* numbder of spread item is (spread_w * spread_h) */ | ||
162 | int spread_w = edje_edit_part_item_spread_w_get(edje_edit_obj, "green", "x2"); | ||
163 | int spread_h = edje_edit_part_item_spread_h_get(edje_edit_obj, "green", "x2"); | ||
164 | |||
165 | spread_w++; | ||
166 | if (spread_w >= 5) | ||
167 | { | ||
168 | spread_w = 1; | ||
169 | spread_h++; | ||
170 | if (spread_h >= 5) | ||
171 | spread_h = 1; | ||
172 | } | ||
173 | |||
174 | fprintf(stdout, "Changing spread to w[%d] h[%d] \n", spread_w, spread_h); | ||
175 | |||
176 | if (!edje_edit_part_item_spread_w_set(edje_edit_obj, "green", "x2", spread_w)) | ||
177 | fprintf(stderr, "Couldn't set spread w for item x2, something is absolutely wrong!!!\n"); | ||
178 | if (!edje_edit_part_item_spread_h_set(edje_edit_obj, "green", "x2", spread_h)) | ||
179 | fprintf(stderr, "Couldn't set spread h for item x2, something is absolutely wrong!!!\n"); | ||
180 | |||
181 | edje_edit_save_all(edje_edit_obj); | ||
182 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
183 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
184 | |||
185 | return; | ||
186 | } | ||
187 | if (!strcmp(ev->key, "m")) | ||
188 | { | ||
189 | int min_w = edje_edit_part_item_min_w_get(edje_edit_obj, "green", "x2"); | ||
190 | int min_h = edje_edit_part_item_min_h_get(edje_edit_obj, "green", "x2"); | ||
191 | |||
192 | min_w += 100; min_h += 100; | ||
193 | if (min_w >= 500) min_w = 200; | ||
194 | if (min_h >= 500) min_h = 200; | ||
195 | |||
196 | fprintf(stdout, "Changing min to w[%d] h[%d] \n", min_w, min_h); | ||
197 | |||
198 | if (!edje_edit_part_item_min_w_set(edje_edit_obj, "green", "x2", min_w)) | ||
199 | fprintf(stderr, "Couldn't set min w for item x2, something is absolutely wrong!!!\n"); | ||
200 | if (!edje_edit_part_item_min_h_set(edje_edit_obj, "green", "x2", min_h)) | ||
201 | fprintf(stderr, "Couldn't set min h for item x2, something is absolutely wrong!!!\n"); | ||
202 | |||
203 | edje_edit_save_all(edje_edit_obj); | ||
204 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
205 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
206 | |||
207 | return; | ||
208 | } | ||
209 | if (!strcmp(ev->key, "M")) | ||
210 | { | ||
211 | int max_w = edje_edit_part_item_max_w_get(edje_edit_obj, "green", "x2"); | ||
212 | int max_h = edje_edit_part_item_max_h_get(edje_edit_obj, "green", "x2"); | ||
213 | |||
214 | max_w -= 100; max_h -= 100; | ||
215 | if (max_w <= 0) max_w = 800; | ||
216 | if (max_h <= 0) max_h = 800; | ||
217 | |||
218 | fprintf(stdout, "Changing max to w[%d] h[%d] \n", max_w, max_h); | ||
219 | |||
220 | if (!edje_edit_part_item_max_w_set(edje_edit_obj, "green", "x2", max_w)) | ||
221 | fprintf(stderr, "Couldn't set max w for item x2, something is absolutely wrong!!!\n"); | ||
222 | if (!edje_edit_part_item_max_h_set(edje_edit_obj, "green", "x2", max_h)) | ||
223 | fprintf(stderr, "Couldn't set max h for item x2, something is absolutely wrong!!!\n"); | ||
224 | |||
225 | edje_edit_save_all(edje_edit_obj); | ||
226 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
227 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
228 | |||
229 | return; | ||
230 | } | ||
231 | if (!strcmp(ev->key, "g")) | ||
232 | { | ||
233 | Eina_Stringshare *source = edje_edit_part_item_source_get(edje_edit_obj, "green", "x2"); | ||
234 | const char *new_source = NULL; | ||
235 | |||
236 | group_number++; | ||
237 | if (group_number > 3) | ||
238 | group_number = 0; | ||
239 | new_source = groups[group_number]; | ||
240 | |||
241 | fprintf(stdout, "Changing item's source from [%s] to [%s] \n", source, new_source); | ||
242 | |||
243 | if (!edje_edit_part_item_source_set(edje_edit_obj, "green", "x2", new_source)) | ||
244 | fprintf(stderr, "Couldn't change item's source, something is absolutely wrong!!!\n"); | ||
245 | |||
246 | edje_edit_save_all(edje_edit_obj); | ||
247 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
248 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
249 | |||
250 | eina_stringshare_del(source); | ||
251 | return; | ||
252 | } | ||
253 | if (!strcmp(ev->key, "i")) | ||
254 | { | ||
255 | if (!edje_edit_part_item_append(edje_edit_obj, "green", "x_new", "complex_group")) | ||
256 | { | ||
257 | edje_edit_part_item_del(edje_edit_obj, "green", "x_new"); | ||
258 | fprintf(stdout, "Successfully removed new item!\n"); | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | if (!edje_edit_part_item_min_w_set(edje_edit_obj, "green", "x_new", 200)) | ||
263 | fprintf(stderr, "Couldn't set min w for item x_new, something is absolutely wrong!!!\n"); | ||
264 | if (!edje_edit_part_item_min_h_set(edje_edit_obj, "green", "x_new", 200)) | ||
265 | fprintf(stderr, "Couldn't set min h for item x_new, something is absolutely wrong!!!\n"); | ||
266 | fprintf(stdout, "Successfully added new item!\n"); | ||
267 | } | ||
268 | |||
269 | edje_edit_save_all(edje_edit_obj); | ||
270 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
271 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
272 | |||
273 | return; | ||
274 | } | ||
275 | if (!strcmp(ev->key, "l")) | ||
276 | { | ||
277 | Eina_Stringshare *layout = edje_edit_state_box_layout_get(edje_edit_obj, "green", "default", 0.0); | ||
278 | char *new_layout = NULL; | ||
279 | |||
280 | layout_number++; | ||
281 | if (layout_number > 9) | ||
282 | layout_number = 0; | ||
283 | new_layout = layouts[layout_number]; | ||
284 | |||
285 | fprintf(stdout, "Changing box's layout from [%s] to [%s] \n", layout, new_layout); | ||
286 | |||
287 | if (!edje_edit_state_box_layout_set(edje_edit_obj, "green", "default", 0.0, new_layout)) | ||
288 | fprintf(stderr, "Couldn't change layout, something is absolutely wrong!!!\n"); | ||
289 | |||
290 | edje_edit_save_all(edje_edit_obj); | ||
291 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
292 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
293 | |||
294 | eina_stringshare_del(layout); | ||
295 | return; | ||
296 | } | ||
297 | if (!strcmp(ev->key, "L")) | ||
298 | { | ||
299 | Eina_Stringshare *layout = edje_edit_state_box_alt_layout_get(edje_edit_obj, "green", "default", 0.0); | ||
300 | char *new_layout = NULL; | ||
301 | |||
302 | alt_layout_number++; | ||
303 | if (alt_layout_number > 9) | ||
304 | alt_layout_number = 0; | ||
305 | new_layout = layouts[alt_layout_number]; | ||
306 | |||
307 | fprintf(stdout, "Changing box's alternative layout from [%s] to [%s] \n", layout, new_layout); | ||
308 | |||
309 | if (!edje_edit_state_box_alt_layout_set(edje_edit_obj, "green", "default", 0.0, new_layout)) | ||
310 | fprintf(stderr, "Couldn't change alternative layout, something is absolutely wrong!!!\n"); | ||
311 | |||
312 | edje_edit_save_all(edje_edit_obj); | ||
313 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
314 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
315 | |||
316 | eina_stringshare_del(layout); | ||
317 | return; | ||
318 | } | ||
319 | else if (!strcmp(ev->key, "Escape")) | ||
320 | ecore_main_loop_quit(); | ||
321 | } | ||
322 | |||
323 | int | ||
324 | main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED) | ||
325 | { | ||
326 | const char *edje_file = PACKAGE_DATA_DIR"/box_example.edj"; | ||
327 | Ecore_Evas *ee; | ||
328 | Evas *evas; | ||
329 | Evas_Object *edje_edit_obj; | ||
330 | |||
331 | if (!ecore_evas_init()) | ||
332 | return EXIT_FAILURE; | ||
333 | |||
334 | if (!edje_init()) | ||
335 | goto shutdown_ecore_evas; | ||
336 | |||
337 | /* this will give you a window with an Evas canvas under the first | ||
338 | * engine available */ | ||
339 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
340 | if (!ee) goto shutdown_edje; | ||
341 | |||
342 | ecore_evas_callback_delete_request_set(ee, _on_delete); | ||
343 | |||
344 | ecore_evas_title_set(ee, "Edje Edit Example: BOX part"); | ||
345 | |||
346 | evas = ecore_evas_get(ee); | ||
347 | |||
348 | /* loading edje edit object here */ | ||
349 | edje_edit_obj = edje_edit_object_add(evas); | ||
350 | if (!edje_object_file_set(edje_edit_obj, edje_file, "box_group")) | ||
351 | fprintf(stdout, "Couldn't load edje edit object! \n"); | ||
352 | |||
353 | evas_object_resize(edje_edit_obj, WIDTH, HEIGHT); | ||
354 | evas_object_show(edje_edit_obj); | ||
355 | |||
356 | ecore_evas_data_set(ee, "background", edje_edit_obj); | ||
357 | ecore_evas_object_associate(ee, edje_edit_obj, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); | ||
358 | evas_object_focus_set(edje_edit_obj, EINA_TRUE); | ||
359 | evas_object_event_callback_add(edje_edit_obj, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee); | ||
360 | |||
361 | fprintf(stdout, commands); | ||
362 | |||
363 | ecore_evas_show(ee); | ||
364 | |||
365 | ecore_main_loop_begin(); | ||
366 | |||
367 | ecore_evas_free(ee); | ||
368 | ecore_evas_shutdown(); | ||
369 | edje_shutdown(); | ||
370 | |||
371 | return EXIT_SUCCESS; | ||
372 | |||
373 | shutdown_edje: | ||
374 | edje_shutdown(); | ||
375 | shutdown_ecore_evas: | ||
376 | ecore_evas_shutdown(); | ||
377 | |||
378 | return EXIT_FAILURE; | ||
379 | } | ||