diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/edje/src/examples/edje-color-class.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/examples/edje-color-class.c | 140 |
1 files changed, 89 insertions, 51 deletions
diff --git a/libraries/edje/src/examples/edje-color-class.c b/libraries/edje/src/examples/edje-color-class.c index 9ac8653..8d073d0 100644 --- a/libraries/edje/src/examples/edje-color-class.c +++ b/libraries/edje/src/examples/edje-color-class.c | |||
@@ -10,10 +10,9 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifdef HAVE_CONFIG_H | 12 | #ifdef HAVE_CONFIG_H |
13 | #include "config.h" | 13 | # include "config.h" |
14 | #else | 14 | #else |
15 | #define PACKAGE_EXAMPLES_DIR "." | 15 | # define __UNUSED__ |
16 | #define __UNUSED__ | ||
17 | #endif | 16 | #endif |
18 | 17 | ||
19 | #include <Ecore.h> | 18 | #include <Ecore.h> |
@@ -23,13 +22,11 @@ | |||
23 | #define WIDTH (400) | 22 | #define WIDTH (400) |
24 | #define HEIGHT (400) | 23 | #define HEIGHT (400) |
25 | 24 | ||
26 | static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/color-class.edj"; | ||
27 | |||
28 | typedef int color[4]; /* rgba */ | 25 | typedef int color[4]; /* rgba */ |
29 | 26 | ||
30 | static Ecore_Evas *ee, *ee2; | 27 | static Ecore_Evas *ee1, *ee2; |
31 | static Evas *evas, *evas2; | 28 | static Evas *evas1, *evas2; |
32 | static Evas_Object *bg, *edje_obj, *bg2, *edje_obj2; | 29 | static Evas_Object *bg1, *edje_obj1, *bg2, *edje_obj2; |
33 | static const char *selected_class; | 30 | static const char *selected_class; |
34 | 31 | ||
35 | static color colors_init_data[] = | 32 | static color colors_init_data[] = |
@@ -96,21 +93,23 @@ _color_classes_print(void) | |||
96 | } | 93 | } |
97 | 94 | ||
98 | static void | 95 | static void |
99 | _on_destroy(Ecore_Evas *ee) | 96 | _on_destroy(Ecore_Evas *ee __UNUSED__) |
100 | { | 97 | { |
101 | ecore_main_loop_quit(); | 98 | ecore_main_loop_quit(); |
102 | } | 99 | } |
103 | 100 | ||
104 | static void | 101 | static void |
105 | _on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | 102 | _on_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) |
106 | { | 103 | { |
107 | Evas_Event_Mouse_Down *ev = event_info; | 104 | Evas_Event_Mouse_Down *ev = event_info; |
108 | 105 | ||
109 | if (ev->button == 1) | 106 | if (ev->button == 1) |
110 | if (obj == edje_obj) | 107 | { |
111 | edje_color_class_del(selected_class); | 108 | if (obj == edje_obj1) |
112 | else | 109 | edje_color_class_del(selected_class); |
113 | edje_object_color_class_del(edje_obj2, selected_class); | 110 | else |
111 | edje_object_color_class_del(edje_obj2, selected_class); | ||
112 | } | ||
114 | } | 113 | } |
115 | 114 | ||
116 | /* here just to keep our example's window size | 115 | /* here just to keep our example's window size |
@@ -122,10 +121,10 @@ _canvas_resize_cb(Ecore_Evas *_ee) | |||
122 | 121 | ||
123 | ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h); | 122 | ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h); |
124 | 123 | ||
125 | if (_ee == ee) | 124 | if (_ee == ee1) |
126 | { | 125 | { |
127 | evas_object_resize(bg, w, h); | 126 | evas_object_resize(bg1, w, h); |
128 | evas_object_resize(edje_obj, w, h); | 127 | evas_object_resize(edje_obj1, w, h); |
129 | } | 128 | } |
130 | else | 129 | else |
131 | { | 130 | { |
@@ -135,8 +134,8 @@ _canvas_resize_cb(Ecore_Evas *_ee) | |||
135 | } | 134 | } |
136 | 135 | ||
137 | static void | 136 | static void |
138 | _color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj, | 137 | _color_class_callback_delete(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, |
139 | const char *emission, void *source) | 138 | const char *emission, void *source __UNUSED__) |
140 | { | 139 | { |
141 | if (!strcmp(data, "process")) | 140 | if (!strcmp(data, "process")) |
142 | fprintf(stdout, "Color class: %s deleted on process level\n", emission); | 141 | fprintf(stdout, "Color class: %s deleted on process level\n", emission); |
@@ -144,32 +143,34 @@ _color_class_callback_delete(void *data, Evas *evas, Evas_Object *obj, | |||
144 | fprintf(stdout, "Color class: %s deleted on object level\n", emission); | 143 | fprintf(stdout, "Color class: %s deleted on object level\n", emission); |
145 | } | 144 | } |
146 | 145 | ||
147 | static void | 146 | static int |
148 | _create_windows(void) | 147 | _create_windows(const char *edje_file_path) |
149 | { | 148 | { |
150 | /* this will give you a window with an Evas canvas under the first | 149 | /* this will give you a window with an Evas canvas under the first |
151 | * engine available */ | 150 | * engine available */ |
152 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | 151 | ee1 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); |
152 | if (!ee1) | ||
153 | return 0; | ||
153 | ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | 154 | ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); |
155 | if (!ee2) | ||
156 | return 0; | ||
154 | 157 | ||
155 | ecore_evas_callback_destroy_set(ee, _on_destroy); | 158 | ecore_evas_callback_destroy_set(ee1, _on_destroy); |
156 | ecore_evas_callback_resize_set(ee, _canvas_resize_cb); | 159 | ecore_evas_callback_resize_set(ee1, _canvas_resize_cb); |
157 | ecore_evas_title_set(ee, "Edje Color Class Example"); | 160 | ecore_evas_title_set(ee1, "Edje Color Class Example"); |
158 | ecore_evas_show(ee); | ||
159 | 161 | ||
160 | ecore_evas_callback_destroy_set(ee2, _on_destroy); | 162 | ecore_evas_callback_destroy_set(ee2, _on_destroy); |
161 | ecore_evas_callback_resize_set(ee2, _canvas_resize_cb); | 163 | ecore_evas_callback_resize_set(ee2, _canvas_resize_cb); |
162 | ecore_evas_title_set(ee2, "Edje Object Color Class Example"); | 164 | ecore_evas_title_set(ee2, "Edje Object Color Class Example"); |
163 | ecore_evas_show(ee2); | ||
164 | 165 | ||
165 | evas = ecore_evas_get(ee); | 166 | evas1 = ecore_evas_get(ee1); |
166 | evas2 = ecore_evas_get(ee2); | 167 | evas2 = ecore_evas_get(ee2); |
167 | 168 | ||
168 | bg = evas_object_rectangle_add(evas); | 169 | bg1 = evas_object_rectangle_add(evas1); |
169 | evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ | 170 | evas_object_color_set(bg1, 255, 255, 255, 255); /* white bg */ |
170 | evas_object_move(bg, 0, 0); /* at canvas' origin */ | 171 | evas_object_move(bg1, 0, 0); /* at canvas' origin */ |
171 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | 172 | evas_object_resize(bg1, WIDTH, HEIGHT); /* covers full canvas */ |
172 | evas_object_show(bg); | 173 | evas_object_show(bg1); |
173 | 174 | ||
174 | bg2 = evas_object_rectangle_add(evas2); | 175 | bg2 = evas_object_rectangle_add(evas2); |
175 | evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */ | 176 | evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */ |
@@ -177,18 +178,18 @@ _create_windows(void) | |||
177 | evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */ | 178 | evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */ |
178 | evas_object_show(bg2); | 179 | evas_object_show(bg2); |
179 | 180 | ||
180 | edje_obj = edje_object_add(evas); | 181 | edje_obj1 = edje_object_add(evas1); |
181 | evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_MOUSE_DOWN, | 182 | evas_object_event_callback_add(edje_obj1, EVAS_CALLBACK_MOUSE_DOWN, |
182 | _on_mouse_down, NULL); | 183 | _on_mouse_down, NULL); |
183 | 184 | ||
184 | edje_object_file_set(edje_obj, edje_file_path, "example_color_class"); | 185 | edje_object_file_set(edje_obj1, edje_file_path, "example_color_class"); |
185 | evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ | 186 | evas_object_move(edje_obj1, 0, 0); /* at canvas' origin */ |
186 | evas_object_resize(edje_obj, WIDTH, HEIGHT); | 187 | evas_object_resize(edje_obj1, WIDTH, HEIGHT); |
187 | edje_object_part_text_set(edje_obj, "part_four", "EDJE EXAMPLE"); | 188 | edje_object_part_text_set(edje_obj1, "part_four", "EDJE EXAMPLE"); |
188 | edje_object_signal_callback_add(edje_obj, "color_class,del", "*", | 189 | edje_object_signal_callback_add(edje_obj1, "color_class,del", "*", |
189 | (Edje_Signal_Cb) _color_class_callback_delete, | 190 | (Edje_Signal_Cb) _color_class_callback_delete, |
190 | "process"); | 191 | "process"); |
191 | evas_object_show(edje_obj); | 192 | evas_object_show(edje_obj1); |
192 | 193 | ||
193 | edje_obj2 = edje_object_add(evas2); | 194 | edje_obj2 = edje_object_add(evas2); |
194 | evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN, | 195 | evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN, |
@@ -202,13 +203,18 @@ _create_windows(void) | |||
202 | (Edje_Signal_Cb) _color_class_callback_delete, | 203 | (Edje_Signal_Cb) _color_class_callback_delete, |
203 | "object"); | 204 | "object"); |
204 | evas_object_show(edje_obj2); | 205 | evas_object_show(edje_obj2); |
206 | |||
207 | return 1; | ||
205 | } | 208 | } |
206 | 209 | ||
207 | int | 210 | int |
208 | main(int argc, char *argv[]) | 211 | main(int argc, char *argv[]) |
209 | { | 212 | { |
210 | color c1, c2, c3; | 213 | char edje_file_path[PATH_MAX]; |
211 | int i; | 214 | const char *edje_file = "color-class.edj"; |
215 | Eina_Prefix *pfx; | ||
216 | color c1, c2, c3; | ||
217 | int i; | ||
212 | 218 | ||
213 | if (argc != 5) | 219 | if (argc != 5) |
214 | { | 220 | { |
@@ -218,7 +224,7 @@ main(int argc, char *argv[]) | |||
218 | for (i = 0; i < 8; i++) | 224 | for (i = 0; i < 8; i++) |
219 | fprintf(stderr, "%s\n", color_names[i]); | 225 | fprintf(stderr, "%s\n", color_names[i]); |
220 | 226 | ||
221 | return 1; | 227 | return EXIT_FAILURE; |
222 | } | 228 | } |
223 | 229 | ||
224 | selected_class = argv[1]; | 230 | selected_class = argv[1]; |
@@ -227,13 +233,30 @@ main(int argc, char *argv[]) | |||
227 | _get_color_from_name(argv[4], &c3))) | 233 | _get_color_from_name(argv[4], &c3))) |
228 | { | 234 | { |
229 | fprintf(stderr, "Color not available!\n"); | 235 | fprintf(stderr, "Color not available!\n"); |
230 | return 2; | 236 | return EXIT_FAILURE; |
231 | } | 237 | } |
232 | 238 | ||
233 | ecore_evas_init(); | 239 | if (!ecore_evas_init()) |
234 | edje_init(); | 240 | return EXIT_FAILURE; |
241 | |||
242 | if (!edje_init()) | ||
243 | goto shutdown_ecore_evas; | ||
244 | |||
245 | pfx = eina_prefix_new(argv[0], main, | ||
246 | "EDJE_EXAMPLES", | ||
247 | "edje/examples", | ||
248 | edje_file, | ||
249 | PACKAGE_BIN_DIR, | ||
250 | PACKAGE_LIB_DIR, | ||
251 | PACKAGE_DATA_DIR, | ||
252 | PACKAGE_DATA_DIR); | ||
253 | if (!pfx) | ||
254 | goto shutdown_edje; | ||
235 | 255 | ||
236 | _create_windows(); | 256 | snprintf(edje_file_path, sizeof(edje_file_path), |
257 | "%s/examples/%s", eina_prefix_data_get(pfx), edje_file); | ||
258 | if (!_create_windows(edje_file_path)) | ||
259 | goto free_prefix; | ||
237 | 260 | ||
238 | edje_color_class_set(argv[1], /* class name */ | 261 | edje_color_class_set(argv[1], /* class name */ |
239 | c1[0], c1[1], c1[2], c1[3], /* Object color */ | 262 | c1[0], c1[1], c1[2], c1[3], /* Object color */ |
@@ -248,10 +271,25 @@ main(int argc, char *argv[]) | |||
248 | 39, 90, 187, 255); /* Text shadow */ | 271 | 39, 90, 187, 255); /* Text shadow */ |
249 | 272 | ||
250 | _color_classes_print(); | 273 | _color_classes_print(); |
274 | |||
275 | ecore_evas_show(ee1); | ||
276 | ecore_evas_show(ee2); | ||
277 | |||
251 | ecore_main_loop_begin(); | 278 | ecore_main_loop_begin(); |
252 | ecore_evas_free(ee); | 279 | |
253 | ecore_evas_free(ee2); | 280 | eina_prefix_free(pfx); |
281 | ecore_evas_free(ee1); | ||
254 | ecore_evas_shutdown(); | 282 | ecore_evas_shutdown(); |
255 | edje_shutdown(); | 283 | edje_shutdown(); |
256 | return 0; | 284 | |
285 | return EXIT_SUCCESS; | ||
286 | |||
287 | free_prefix: | ||
288 | eina_prefix_free(pfx); | ||
289 | shutdown_edje: | ||
290 | edje_shutdown(); | ||
291 | shutdown_ecore_evas: | ||
292 | ecore_evas_shutdown(); | ||
293 | |||
294 | return EXIT_FAILURE; | ||
257 | } | 295 | } |