diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/edje/src/examples/edje-animations.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/edje/src/examples/edje-animations.c')
-rw-r--r-- | libraries/edje/src/examples/edje-animations.c | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/libraries/edje/src/examples/edje-animations.c b/libraries/edje/src/examples/edje-animations.c new file mode 100644 index 0000000..9363471 --- /dev/null +++ b/libraries/edje/src/examples/edje-animations.c | |||
@@ -0,0 +1,156 @@ | |||
1 | /** | ||
2 | * Simple Edje example illustrating animations functions. | ||
3 | * | ||
4 | * You'll need at least one Evas engine built for it (excluding the | ||
5 | * buffer one). See stdout/stderr for output. | ||
6 | * | ||
7 | * @verbatim | ||
8 | * edje_cc animations.edc && gcc -o edje-animations edje-animations.c `pkg-config --libs --cflags evas ecore ecore-evas edje` | ||
9 | * @endverbatim | ||
10 | */ | ||
11 | |||
12 | #ifdef HAVE_CONFIG_H | ||
13 | #include "config.h" | ||
14 | #else | ||
15 | #define PACKAGE_EXAMPLES_DIR "." | ||
16 | #define __UNUSED__ | ||
17 | #endif | ||
18 | |||
19 | #include <Ecore.h> | ||
20 | #include <Ecore_Evas.h> | ||
21 | #include <Edje.h> | ||
22 | |||
23 | #define WIDTH (400) | ||
24 | #define HEIGHT (300) | ||
25 | |||
26 | static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/animations.edj"; | ||
27 | static Ecore_Evas *ee; | ||
28 | static Evas_Object *bg, *edje_obj; | ||
29 | static double frametime = 1.0/30.0; /* default value */ | ||
30 | |||
31 | static void | ||
32 | _on_delete_cb(Ecore_Evas *ee) | ||
33 | { | ||
34 | ecore_main_loop_quit(); | ||
35 | } | ||
36 | |||
37 | static void | ||
38 | _canvas_resize_cb(Ecore_Evas *ee) | ||
39 | { | ||
40 | int w, h; | ||
41 | |||
42 | ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); | ||
43 | evas_object_resize(bg, w, h); | ||
44 | evas_object_resize(edje_obj, w, h); | ||
45 | } | ||
46 | |||
47 | static void | ||
48 | _on_key_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
49 | { | ||
50 | Evas_Event_Key_Down *ev = event_info; | ||
51 | double ft; | ||
52 | |||
53 | if (!strcmp(ev->key, "plus")) | ||
54 | { | ||
55 | frametime *= 2.0; | ||
56 | fprintf(stdout, "Increasing frametime to: %f\n", frametime); | ||
57 | edje_frametime_set(frametime); | ||
58 | } | ||
59 | else if (!strcmp(ev->key, "minus")) | ||
60 | { | ||
61 | frametime /= 2.0; | ||
62 | fprintf(stdout, "Decreasing frametime to: %f\n", frametime); | ||
63 | edje_frametime_set(frametime); | ||
64 | } | ||
65 | else if (!strcmp(ev->key, "equal")) | ||
66 | { | ||
67 | ft = edje_frametime_get(); | ||
68 | fprintf(stdout, "Frametime: %f\n", ft); | ||
69 | if (edje_object_play_get(obj)) | ||
70 | fprintf(stdout, "Object is playing\n"); | ||
71 | else | ||
72 | fprintf(stdout, "Object was paused\n"); | ||
73 | if (edje_object_animation_get(obj)) | ||
74 | fprintf(stdout, "Animation is running\n"); | ||
75 | else | ||
76 | fprintf(stdout, "Animation was stopped\n"); | ||
77 | } | ||
78 | else if (!strcmp(ev->key, "s")) | ||
79 | { | ||
80 | edje_object_play_set(obj, EINA_FALSE); | ||
81 | fprintf(stdout, "Pausing the object\n"); | ||
82 | } | ||
83 | else if (!strcmp(ev->key, "p")) | ||
84 | { | ||
85 | edje_object_play_set(obj, EINA_TRUE); | ||
86 | fprintf(stdout, "Playing the object\n"); | ||
87 | } | ||
88 | else if (!strcmp(ev->key, "f")) | ||
89 | fprintf(stdout, "Freezing object. Count: %d\n", edje_object_freeze(obj)); | ||
90 | else if (!strcmp(ev->key, "t")) | ||
91 | fprintf(stdout, "Thawing object. Count: %d\n", edje_object_thaw(obj)); | ||
92 | else if (!strcmp(ev->key, "F")) | ||
93 | { | ||
94 | edje_freeze(); | ||
95 | fprintf(stdout, "Freezing all objects\n"); | ||
96 | } | ||
97 | else if (!strcmp(ev->key, "T")) | ||
98 | { | ||
99 | edje_thaw(); | ||
100 | fprintf(stdout, "Thawing all objects\n"); | ||
101 | } | ||
102 | else if (!strcmp(ev->key, "a")) | ||
103 | { | ||
104 | edje_object_animation_set(obj, EINA_TRUE); | ||
105 | fprintf(stdout, "Starting the animation in the Edje object\n"); | ||
106 | } | ||
107 | else if (!strcmp(ev->key, "A")) | ||
108 | { | ||
109 | edje_object_animation_set(obj, EINA_FALSE); | ||
110 | fprintf(stdout, "Stopping the animation in the Edje object\n"); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | int | ||
115 | main(int argc, char *argv[]) | ||
116 | { | ||
117 | Evas *evas; | ||
118 | |||
119 | ecore_evas_init(); | ||
120 | edje_init(); | ||
121 | |||
122 | /* this will give you a window with an Evas canvas under the first | ||
123 | * engine available */ | ||
124 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
125 | |||
126 | ecore_evas_callback_delete_request_set(ee, _on_delete_cb); | ||
127 | ecore_evas_callback_resize_set(ee, _canvas_resize_cb); | ||
128 | ecore_evas_title_set(ee, "Edje Animations Example"); | ||
129 | ecore_evas_show(ee); | ||
130 | |||
131 | evas = ecore_evas_get(ee); | ||
132 | |||
133 | bg = evas_object_rectangle_add(evas); | ||
134 | evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ | ||
135 | evas_object_move(bg, 0, 0); /* at canvas' origin */ | ||
136 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
137 | evas_object_show(bg); | ||
138 | |||
139 | edje_obj = edje_object_add(evas); | ||
140 | |||
141 | edje_object_file_set(edje_obj, edje_file_path, "animations_group"); | ||
142 | evas_object_move(edje_obj, 0, 0); | ||
143 | evas_object_resize(edje_obj, WIDTH, HEIGHT); | ||
144 | evas_object_show(edje_obj); | ||
145 | |||
146 | evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN, | ||
147 | _on_key_down_cb, NULL); | ||
148 | evas_object_focus_set(edje_obj, EINA_TRUE); | ||
149 | |||
150 | ecore_main_loop_begin(); | ||
151 | |||
152 | ecore_evas_free(ee); | ||
153 | ecore_evas_shutdown(); | ||
154 | edje_shutdown(); | ||
155 | return 0; | ||
156 | } | ||