summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--data/edje/include/edje.inc25
-rw-r--r--src/examples/edje/Makefile.am3
-rw-r--r--src/examples/edje/embryo_tween_anim.edc169
-rw-r--r--src/lib/edje/edje_embryo.c109
5 files changed, 306 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index fa10193..956468e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -226,6 +226,7 @@ Embryo
226 226
227The Rasterman (Carsten Haitzler) <raster@rasterman.com> 227The Rasterman (Carsten Haitzler) <raster@rasterman.com>
228Jérôme Pinot <ngc891@gmail.com> 228Jérôme Pinot <ngc891@gmail.com>
229kumar Navneet <k.navneet@samsung.com>
229 230
230Eio 231Eio
231--- 232---
diff --git a/data/edje/include/edje.inc b/data/edje/include/edje.inc
index 5758cc3..6842db5 100644
--- a/data/edje/include/edje.inc
+++ b/data/edje/include/edje.inc
@@ -290,3 +290,28 @@ native physics_stop (part_id);
290 290
291native physics_set_rotation (part_id, Float:w, Float:x, Float:y, Float:z); 291native physics_set_rotation (part_id, Float:w, Float:x, Float:y, Float:z);
292native physics_get_rotation (part_id, &Float:w, &Float:x, &Float:y, &Float:z); 292native physics_get_rotation (part_id, &Float:w, &Float:x, &Float:y, &Float:z);
293
294enum Anim_Param
295{
296 LIN = 1,
297 LINEAR = 1,
298 SIN = 2,
299 SINUSOIDAL = 2,
300 ACCEL = 3,
301 ACCELERATE = 3,
302 DECEL = 4,
303 DECELERATE = 4,
304 ACCEL_FAC = 5,
305 ACCELERATE_FACTOR = 5,
306 DECEL_FAC = 6,
307 DECELERATE_FACTOR = 6,
308 SIN_FAC = 7,
309 SINUSOIDAL_FACTOR = 7,
310 DIVIS = 8,
311 DIVISOR_INTERP = 8,
312 BOUNCE = 9,
313 SPRING = 10,
314 CUBIC_BEZIER = 11,
315};
316
317native set_tween_state_anim (part_id, state1[], Float:state1_val, state2[], Float:state2_val, Anim_Param:p, Float:tween, ...);
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am
index a311c5b..4ef72fd 100644
--- a/src/examples/edje/Makefile.am
+++ b/src/examples/edje/Makefile.am
@@ -46,7 +46,8 @@ swallow.edc \
46table.edc \ 46table.edc \
47text.edc \ 47text.edc \
48toggle_using_filter.edc \ 48toggle_using_filter.edc \
49box_example.edc 49box_example.edc \
50embryo_tween_anim.edc \
50 51
51DIST_EDCS = $(EDCS) 52DIST_EDCS = $(EDCS)
52 53
diff --git a/src/examples/edje/embryo_tween_anim.edc b/src/examples/edje/embryo_tween_anim.edc
new file mode 100644
index 0000000..79577fd
--- /dev/null
+++ b/src/examples/edje/embryo_tween_anim.edc
@@ -0,0 +1,169 @@
1collections {
2 group { name: "main";
3 script {
4 public g_duration = 0, g_stopslide, g_timer_id, g_anim_id, toggle=0;
5
6 public slide_to_end_anim(val, Float:pos) {
7 new stopflag;
8 new id;
9 new Float:duration;
10 stopflag = get_int(g_stopslide);
11 duration = get_float(g_duration);
12 if (stopflag == 1) return;
13 set_tween_state_anim(PART:"move","slide_end", 0.0, "slide_begin", 0.0, ACCEL , pos);
14 if (pos >= 1.0) {
15 id = anim(duration, "slide_to_start_anim", 1);
16 set_int(g_timer_id, id);
17 }
18 }
19 public slide_to_start_anim(val, Float:pos) {
20 new stopflag;
21 new id;
22 new Float:duration;
23 stopflag = get_int(g_stopslide);
24 duration = get_float(g_duration);
25 if (stopflag == 1) return;
26 set_tween_state_anim(PART:"move","slide_begin", 0.0, "slide_end", 0.0, DECEL , pos);
27 if (pos >= 1.0) {
28 id = anim(duration, "slide_to_end_anim", 1);
29 set_int(g_timer_id, id);
30 }
31 }
32 public slide_to_end() {
33 new stopflag;
34 new id;
35 new Float:duration;
36 stopflag = get_int(g_stopslide);
37 if (stopflag == 1) return;
38 duration = get_float(g_duration);
39 id = anim(duration, "slide_to_end_anim", 1);
40 set_int(g_anim_id, id);
41 }
42 public slide_to_begin() {
43 new stopflag;
44 new id;
45 stopflag = get_int(g_stopslide);
46 if (stopflag == 1) return;
47 set_state(PART:"move", "slide_begin", 0.0);
48 id = timer(0.5, "slide_to_end", 1);
49 set_int(g_timer_id, id);
50 }
51 public start_slide() {
52 set_int(g_stopslide, 0);
53 set_float(g_duration, 1.3);
54 set_state(PART:"move", "slide_begin", 0.0);
55 slide_to_end();
56 }
57 public stop_slide() {
58 new id;
59 set_int(g_stopslide, 1);
60 id = get_int(g_anim_id);
61 cancel_anim(id);
62 id = get_int(g_timer_id);
63 cancel_timer(id);
64 set_state(PART:"move", "default", 0.0);
65 }
66 }
67 parts {
68 part { name: "bg";
69 type: RECT;
70 description { state: "default" 0.0;
71 color: 255 255 255 255;
72 }
73 }
74 part { name: "label";
75 type: TEXT;
76 description { state: "default" 0.0;
77 color: 255 0 0 255;
78 text {
79 text: "Click me.";
80 font: "Sans";
81 size: 12;
82 align: 0.5 0.8;
83 }
84 }
85 }
86 part { name: "rect1";
87 type: RECT;
88 description { state: "default" 0.0;
89 color: 255 0 0 255;
90 min: 30 30;
91 max: 30 30;
92 fixed: 1 1;
93 align: 0.1 0.2;
94 }
95 }
96 part { name: "rect2";
97 type: RECT;
98 description { state: "default" 0.0;
99 color: 0 255 0 255;
100 min: 30 30;
101 max: 30 30;
102 fixed: 1 1;
103 align: 0.9 0.2;
104 }
105 }
106 part { name: "rect";
107 type: RECT;
108 description { state: "default" 0.0;
109 rel1 {
110 to: "rect1";
111 relative: 1.0 0.0;
112 }
113 rel2 {
114 to:"rect2";
115 relative: 0.0 1.0;
116 }
117 }
118 }
119 part {
120 name: "move";
121 type: RECT;
122 description {
123 state: "default" 0.0;
124 align: 0.0 0.0;
125 min: 30 30;
126 max: 30 30;
127 fixed: 1 1;
128 color: 0 0 255 255;
129 rel1 {
130 to: "rect1";
131 relative: 1.0 0.0;
132 }
133 rel2 {
134 to:"rect1";
135 relative: 1.0 1.0;
136 }
137 }
138 description {
139 state: "slide_end" 0.0;
140 inherit: "default" 0.0;
141 }
142 description {state: "slide_begin" 0.0;
143 inherit: "default" 0.0;
144 align: 1.0 1.0;
145 rel1 {
146 to: "rect2";
147 relative: 0.0 0.0;
148 }
149 rel2 {
150 to:"rect2";
151 relative: 0.0 1.0;
152 }
153 }
154 }
155 }
156 programs {
157 program {signal: "mouse,down,1";
158 source: "label";
159 script{
160 start_slide();
161 }
162 }
163 program { name: "go_left";
164 script{
165 stop_slide();
166 }
167 }
168 }
169 }
diff --git a/src/lib/edje/edje_embryo.c b/src/lib/edje/edje_embryo.c
index b4207ea..e82b567 100644
--- a/src/lib/edje/edje_embryo.c
+++ b/src/lib/edje/edje_embryo.c
@@ -1148,6 +1148,114 @@ _edje_embryo_fn_set_tween_state(Embryo_Program *ep, Embryo_Cell *params)
1148 return 0; 1148 return 0;
1149} 1149}
1150 1150
1151static Embryo_Cell
1152_edje_embryo_fn_set_tween_state_anim(Embryo_Program *ep, Embryo_Cell *params)
1153{
1154 Edje *ed;
1155 char *tmp = NULL;
1156 char *state1 = NULL, *state2 = NULL;
1157 int part_id = 0;
1158 int anim_type = 0;
1159 float f = 0.0;
1160 double tween = 0.0, value1 = 0.0, value2 = 0.0, v1 = 0.0, v2 = 0.0, v3 = 0.0, v4 = 0.0;
1161 Edje_Real_Part *rp;
1162
1163 if ((HASNPARAMS(6))) return -1;
1164 ed = embryo_program_data_get(ep);
1165 GETSTR(state1, params[2]);
1166 GETSTR(state2, params[4]);
1167 if ((!state1) || (!state2)) return 0;
1168 part_id = params[1];
1169 anim_type = params[6];
1170 if (part_id < 0) return 0;
1171 f = EMBRYO_CELL_TO_FLOAT(params[3]);
1172 value1 = (double)f;
1173 f = EMBRYO_CELL_TO_FLOAT(params[5]);
1174 value2 = (double)f;
1175 f = EMBRYO_CELL_TO_FLOAT(params[7]);
1176 tween = (double)f;
1177 if ((anim_type >= EDJE_TWEEN_MODE_LINEAR) &&
1178 (anim_type <= EDJE_TWEEN_MODE_DECELERATE))
1179 {
1180 if (HASNPARAMS(8))
1181 {
1182 GETSTR(tmp, params[8]);
1183 if (!strcmp(tmp, "CURRENT"))
1184 anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
1185 }
1186 }
1187 else if ((anim_type >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
1188 (anim_type <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR))
1189 {
1190 if (HASNPARAMS(9))
1191 {
1192 GETSTR(tmp, params[9]);
1193 if (!strcmp(tmp, "CURRENT"))
1194 anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
1195 }
1196 else if (HASNPARAMS(7))
1197 {
1198 ERR("parse error. Need 8th parameter to set factor");
1199 return -1;
1200 }
1201 GETFLOAT_T(v1, params[8]);
1202 }
1203 else if ((anim_type >= EDJE_TWEEN_MODE_DIVISOR_INTERP) &&
1204 (anim_type <= EDJE_TWEEN_MODE_SPRING))
1205 {
1206 if (HASNPARAMS(10))
1207 {
1208 GETSTR(tmp, params[10]);
1209 if (!strcmp(tmp, "CURRENT"))
1210 anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
1211 }
1212 else if (HASNPARAMS(7))
1213 {
1214 ERR("parse error.Need 8th and 9th parameters to set factor and counts");
1215 return -1;
1216 }
1217 GETFLOAT_T(v1, params[8]);
1218 GETFLOAT_T(v2, params[9]);
1219 }
1220 else if (anim_type == EDJE_TWEEN_MODE_CUBIC_BEZIER)
1221 {
1222 if (HASNPARAMS(12))
1223 {
1224 GETSTR(tmp, params[10]);
1225 if (!strcmp(tmp, "CURRENT"))
1226 anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
1227 }
1228 else if (HASNPARAMS(7))
1229 {
1230 ERR("parse error.Need 8th, 9th, 10th and 11th parameters to set x1, y1, x2 and y2");
1231 return -1;
1232 }
1233 if (HASNPARAMS(12))
1234 {
1235 GETFLOAT_T(v1, params[8]);
1236 GETFLOAT_T(v2, params[9]);
1237 GETFLOAT_T(v3, params[11]);
1238 GETFLOAT_T(v4, params[12]);
1239 }
1240 else
1241 {
1242 GETFLOAT_T(v1, params[8]);
1243 GETFLOAT_T(v2, params[9]);
1244 GETFLOAT_T(v3, params[10]);
1245 GETFLOAT_T(v4, params[11]);
1246 }
1247 }
1248 rp = ed->table_parts[part_id % ed->table_parts_size];
1249 if (!rp) return 0;
1250
1251 if (rp->program) _edje_program_end(ed, rp->program);
1252 _edje_part_description_apply(ed, rp, state1, value1, state2, value2);
1253 _edje_part_pos_set(ed, rp, anim_type, FROM_DOUBLE(tween),
1254 v1, v2, v3, v4);
1255 _edje_recalc(ed);
1256 return 0;
1257}
1258
1151/* run_program(program_id) */ 1259/* run_program(program_id) */
1152static Embryo_Cell 1260static Embryo_Cell
1153_edje_embryo_fn_run_program(Embryo_Program *ep, Embryo_Cell *params) 1261_edje_embryo_fn_run_program(Embryo_Program *ep, Embryo_Cell *params)
@@ -3808,6 +3916,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
3808 embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state); 3916 embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state);
3809 embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state); 3917 embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state);
3810 embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state); 3918 embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);
3919 embryo_program_native_call_add(ep, "set_tween_state_anim", _edje_embryo_fn_set_tween_state_anim);
3811 embryo_program_native_call_add(ep, "run_program", _edje_embryo_fn_run_program); 3920 embryo_program_native_call_add(ep, "run_program", _edje_embryo_fn_run_program);
3812 embryo_program_native_call_add(ep, "get_drag_dir", _edje_embryo_fn_get_drag_dir); 3921 embryo_program_native_call_add(ep, "get_drag_dir", _edje_embryo_fn_get_drag_dir);
3813 embryo_program_native_call_add(ep, "get_drag", _edje_embryo_fn_get_drag); 3922 embryo_program_native_call_add(ep, "get_drag", _edje_embryo_fn_get_drag);