aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/examples/edje-animations.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:19:23 +1000
committerDavid Walter Seikel2012-04-22 09:19:23 +1000
commitc963d75dfdeec11f82e79e727062fbf89afa2c04 (patch)
tree895633dbf641110be46f117c29890c49b3ffc0bd /libraries/edje/src/examples/edje-animations.c
parentAdding the new extantz viewer and grid manager. (diff)
downloadSledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz
Update EFL to latest beta.
Diffstat (limited to 'libraries/edje/src/examples/edje-animations.c')
-rw-r--r--libraries/edje/src/examples/edje-animations.c125
1 files changed, 98 insertions, 27 deletions
diff --git a/libraries/edje/src/examples/edje-animations.c b/libraries/edje/src/examples/edje-animations.c
index 9363471..15f2ee0 100644
--- a/libraries/edje/src/examples/edje-animations.c
+++ b/libraries/edje/src/examples/edje-animations.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,34 +22,59 @@
23#define WIDTH (400) 22#define WIDTH (400)
24#define HEIGHT (300) 23#define HEIGHT (300)
25 24
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/animations.edj"; 25static const char commands[] = \
27static Ecore_Evas *ee; 26 "commands are:\n"
28static Evas_Object *bg, *edje_obj; 27 "\t+ - increase frametime\n"
29static double frametime = 1.0/30.0; /* default value */ 28 "\t- - decrease frametime\n"
29 "\t= - status of the animation\n"
30 "\ts - pause\n"
31 "\tp - play\n"
32 "\tf - freeze one object\n"
33 "\tF - freeze all objects\n"
34 "\tt - thaw one object\n"
35 "\tT - thaw all objects\n"
36 "\ta - start animation of one object\n"
37 "\tA - stop animation of one object\n"
38 "\tEsc - exit\n"
39 "\th - print help\n";
40
41static double frametime = 1.0 / 30.0; /* default value */
30 42
31static void 43static void
32_on_delete_cb(Ecore_Evas *ee) 44_on_delete_cb(Ecore_Evas *ee __UNUSED__)
33{ 45{
34 ecore_main_loop_quit(); 46 ecore_main_loop_quit();
35} 47}
36 48
37static void 49static void
38_canvas_resize_cb(Ecore_Evas *ee) 50_on_canvas_resize(Ecore_Evas *ee)
39{ 51{
40 int w, h; 52 Evas_Object *bg;
41 53 Evas_Object *edje_obj;
42 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 54 int w;
43 evas_object_resize(bg, w, h); 55 int h;
44 evas_object_resize(edje_obj, w, h); 56
57 bg = ecore_evas_data_get(ee, "background");
58 edje_obj = ecore_evas_data_get(ee, "edje_obj");
59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
60 evas_object_resize(bg, w, h);
61 evas_object_resize(edje_obj, w, h);
45} 62}
46 63
47static void 64static void
48_on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) 65_on_key_down(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
49{ 66{
50 Evas_Event_Key_Down *ev = event_info; 67 Evas_Event_Key_Down *ev;
51 double ft; 68 double ft;
69
70 ev = (Evas_Event_Key_Down *)event_info;
52 71
53 if (!strcmp(ev->key, "plus")) 72 if (!strcmp(ev->keyname, "h"))
73 {
74 fprintf(stdout, commands);
75 return;
76 }
77 else if (!strcmp(ev->key, "plus"))
54 { 78 {
55 frametime *= 2.0; 79 frametime *= 2.0;
56 fprintf(stdout, "Increasing frametime to: %f\n", frametime); 80 fprintf(stdout, "Increasing frametime to: %f\n", frametime);
@@ -109,24 +133,52 @@ _on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
109 edje_object_animation_set(obj, EINA_FALSE); 133 edje_object_animation_set(obj, EINA_FALSE);
110 fprintf(stdout, "Stopping the animation in the Edje object\n"); 134 fprintf(stdout, "Stopping the animation in the Edje object\n");
111 } 135 }
136 else if (!strcmp(ev->keyname, "Escape"))
137 ecore_main_loop_quit();
138 else
139 {
140 printf("unhandled key: %s\n", ev->keyname);
141 fprintf(stdout, commands);
142 }
112} 143}
113 144
114int 145int
115main(int argc, char *argv[]) 146main(int argc __UNUSED__, char *argv[])
116{ 147{
117 Evas *evas; 148 char edje_file_path[PATH_MAX];
118 149 const char *edje_file = "animations.edj";
119 ecore_evas_init(); 150 Ecore_Evas *ee;
120 edje_init(); 151 Evas *evas;
152 Evas_Object *bg;
153 Evas_Object *edje_obj;
154 Eina_Prefix *pfx;
155
156 if (!ecore_evas_init())
157 return EXIT_FAILURE;
158
159 if (!edje_init())
160 goto shutdown_ecore_evas;
161
162 pfx = eina_prefix_new(argv[0], main,
163 "EDJE_EXAMPLES",
164 "edje/examples",
165 edje_file,
166 PACKAGE_BIN_DIR,
167 PACKAGE_LIB_DIR,
168 PACKAGE_DATA_DIR,
169 PACKAGE_DATA_DIR);
170 if (!pfx)
171 goto shutdown_edje;
121 172
122 /* this will give you a window with an Evas canvas under the first 173 /* this will give you a window with an Evas canvas under the first
123 * engine available */ 174 * engine available */
124 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); 175 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
176 if (!ee)
177 goto free_prefix;
125 178
126 ecore_evas_callback_delete_request_set(ee, _on_delete_cb); 179 ecore_evas_callback_delete_request_set(ee, _on_delete_cb);
127 ecore_evas_callback_resize_set(ee, _canvas_resize_cb); 180 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
128 ecore_evas_title_set(ee, "Edje Animations Example"); 181 ecore_evas_title_set(ee, "Edje Animations Example");
129 ecore_evas_show(ee);
130 182
131 evas = ecore_evas_get(ee); 183 evas = ecore_evas_get(ee);
132 184
@@ -135,22 +187,41 @@ main(int argc, char *argv[])
135 evas_object_move(bg, 0, 0); /* at canvas' origin */ 187 evas_object_move(bg, 0, 0); /* at canvas' origin */
136 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ 188 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
137 evas_object_show(bg); 189 evas_object_show(bg);
190 ecore_evas_data_set(ee, "background", bg);
138 191
139 edje_obj = edje_object_add(evas); 192 edje_obj = edje_object_add(evas);
140 193
194 snprintf(edje_file_path, sizeof(edje_file_path),
195 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
141 edje_object_file_set(edje_obj, edje_file_path, "animations_group"); 196 edje_object_file_set(edje_obj, edje_file_path, "animations_group");
142 evas_object_move(edje_obj, 0, 0); 197 evas_object_move(edje_obj, 0, 0);
143 evas_object_resize(edje_obj, WIDTH, HEIGHT); 198 evas_object_resize(edje_obj, WIDTH, HEIGHT);
144 evas_object_show(edje_obj); 199 evas_object_show(edje_obj);
200 ecore_evas_data_set(ee, "edje_obj", edje_obj);
145 201
146 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN, 202 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN,
147 _on_key_down_cb, NULL); 203 _on_key_down, NULL);
148 evas_object_focus_set(edje_obj, EINA_TRUE); 204 evas_object_focus_set(edje_obj, EINA_TRUE);
149 205
206 fprintf(stdout, commands);
207
208 ecore_evas_show(ee);
209
150 ecore_main_loop_begin(); 210 ecore_main_loop_begin();
151 211
212 eina_prefix_free(pfx);
152 ecore_evas_free(ee); 213 ecore_evas_free(ee);
153 ecore_evas_shutdown(); 214 ecore_evas_shutdown();
154 edje_shutdown(); 215 edje_shutdown();
155 return 0; 216
217 return EXIT_SUCCESS;
218
219 free_prefix:
220 eina_prefix_free(pfx);
221 shutdown_edje:
222 edje_shutdown();
223 shutdown_ecore_evas:
224 ecore_evas_shutdown();
225
226 return EXIT_FAILURE;
156} 227}