forked from enlightenment/efl
set_tween_state_anim API added.
Summary: Issue: Current embryo script do not provide any mechanism to set transition type in animation, by default supports only linear e.g: set_tween_state API Solution: To not break backward compatibility, a new API set_tween_state_anim is added in which we can even specify type of transition required. Signed-Off by: Kumar Navneet <k.navneet@samsung.com> Signed-Off by: Shilpa Singh <shilpa.singh@samsung.com> Test Plan: A test edc (embryo_tween_anim.edc) is added to edje examples to test set_tween_state_anim API. Reviewers: raster, cedric, shilpasingh, Hermet Reviewed By: shilpasingh Subscribers: poornima.srinivasan, SubodhKumar, rajeshps, cedric, govi Differential Revision: https://phab.enlightenment.org/D2344
This commit is contained in:
parent
f3c78cd69e
commit
c38e477364
1
AUTHORS
1
AUTHORS
|
@ -226,6 +226,7 @@ Embryo
|
|||
|
||||
The Rasterman (Carsten Haitzler) <raster@rasterman.com>
|
||||
Jérôme Pinot <ngc891@gmail.com>
|
||||
kumar Navneet <k.navneet@samsung.com>
|
||||
|
||||
Eio
|
||||
---
|
||||
|
|
|
@ -290,3 +290,28 @@ native physics_stop (part_id);
|
|||
|
||||
native physics_set_rotation (part_id, Float:w, Float:x, Float:y, Float:z);
|
||||
native physics_get_rotation (part_id, &Float:w, &Float:x, &Float:y, &Float:z);
|
||||
|
||||
enum Anim_Param
|
||||
{
|
||||
LIN = 1,
|
||||
LINEAR = 1,
|
||||
SIN = 2,
|
||||
SINUSOIDAL = 2,
|
||||
ACCEL = 3,
|
||||
ACCELERATE = 3,
|
||||
DECEL = 4,
|
||||
DECELERATE = 4,
|
||||
ACCEL_FAC = 5,
|
||||
ACCELERATE_FACTOR = 5,
|
||||
DECEL_FAC = 6,
|
||||
DECELERATE_FACTOR = 6,
|
||||
SIN_FAC = 7,
|
||||
SINUSOIDAL_FACTOR = 7,
|
||||
DIVIS = 8,
|
||||
DIVISOR_INTERP = 8,
|
||||
BOUNCE = 9,
|
||||
SPRING = 10,
|
||||
CUBIC_BEZIER = 11,
|
||||
};
|
||||
|
||||
native set_tween_state_anim (part_id, state1[], Float:state1_val, state2[], Float:state2_val, Anim_Param:p, Float:tween, ...);
|
||||
|
|
|
@ -46,7 +46,8 @@ swallow.edc \
|
|||
table.edc \
|
||||
text.edc \
|
||||
toggle_using_filter.edc \
|
||||
box_example.edc
|
||||
box_example.edc \
|
||||
embryo_tween_anim.edc \
|
||||
|
||||
DIST_EDCS = $(EDCS)
|
||||
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
collections {
|
||||
group { name: "main";
|
||||
script {
|
||||
public g_duration = 0, g_stopslide, g_timer_id, g_anim_id, toggle=0;
|
||||
|
||||
public slide_to_end_anim(val, Float:pos) {
|
||||
new stopflag;
|
||||
new id;
|
||||
new Float:duration;
|
||||
stopflag = get_int(g_stopslide);
|
||||
duration = get_float(g_duration);
|
||||
if (stopflag == 1) return;
|
||||
set_tween_state_anim(PART:"move","slide_end", 0.0, "slide_begin", 0.0, ACCEL , pos);
|
||||
if (pos >= 1.0) {
|
||||
id = anim(duration, "slide_to_start_anim", 1);
|
||||
set_int(g_timer_id, id);
|
||||
}
|
||||
}
|
||||
public slide_to_start_anim(val, Float:pos) {
|
||||
new stopflag;
|
||||
new id;
|
||||
new Float:duration;
|
||||
stopflag = get_int(g_stopslide);
|
||||
duration = get_float(g_duration);
|
||||
if (stopflag == 1) return;
|
||||
set_tween_state_anim(PART:"move","slide_begin", 0.0, "slide_end", 0.0, DECEL , pos);
|
||||
if (pos >= 1.0) {
|
||||
id = anim(duration, "slide_to_end_anim", 1);
|
||||
set_int(g_timer_id, id);
|
||||
}
|
||||
}
|
||||
public slide_to_end() {
|
||||
new stopflag;
|
||||
new id;
|
||||
new Float:duration;
|
||||
stopflag = get_int(g_stopslide);
|
||||
if (stopflag == 1) return;
|
||||
duration = get_float(g_duration);
|
||||
id = anim(duration, "slide_to_end_anim", 1);
|
||||
set_int(g_anim_id, id);
|
||||
}
|
||||
public slide_to_begin() {
|
||||
new stopflag;
|
||||
new id;
|
||||
stopflag = get_int(g_stopslide);
|
||||
if (stopflag == 1) return;
|
||||
set_state(PART:"move", "slide_begin", 0.0);
|
||||
id = timer(0.5, "slide_to_end", 1);
|
||||
set_int(g_timer_id, id);
|
||||
}
|
||||
public start_slide() {
|
||||
set_int(g_stopslide, 0);
|
||||
set_float(g_duration, 1.3);
|
||||
set_state(PART:"move", "slide_begin", 0.0);
|
||||
slide_to_end();
|
||||
}
|
||||
public stop_slide() {
|
||||
new id;
|
||||
set_int(g_stopslide, 1);
|
||||
id = get_int(g_anim_id);
|
||||
cancel_anim(id);
|
||||
id = get_int(g_timer_id);
|
||||
cancel_timer(id);
|
||||
set_state(PART:"move", "default", 0.0);
|
||||
}
|
||||
}
|
||||
parts {
|
||||
part { name: "bg";
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
color: 255 255 255 255;
|
||||
}
|
||||
}
|
||||
part { name: "label";
|
||||
type: TEXT;
|
||||
description { state: "default" 0.0;
|
||||
color: 255 0 0 255;
|
||||
text {
|
||||
text: "Click me.";
|
||||
font: "Sans";
|
||||
size: 12;
|
||||
align: 0.5 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "rect1";
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
color: 255 0 0 255;
|
||||
min: 30 30;
|
||||
max: 30 30;
|
||||
fixed: 1 1;
|
||||
align: 0.1 0.2;
|
||||
}
|
||||
}
|
||||
part { name: "rect2";
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
color: 0 255 0 255;
|
||||
min: 30 30;
|
||||
max: 30 30;
|
||||
fixed: 1 1;
|
||||
align: 0.9 0.2;
|
||||
}
|
||||
}
|
||||
part { name: "rect";
|
||||
type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
rel1 {
|
||||
to: "rect1";
|
||||
relative: 1.0 0.0;
|
||||
}
|
||||
rel2 {
|
||||
to:"rect2";
|
||||
relative: 0.0 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "move";
|
||||
type: RECT;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
align: 0.0 0.0;
|
||||
min: 30 30;
|
||||
max: 30 30;
|
||||
fixed: 1 1;
|
||||
color: 0 0 255 255;
|
||||
rel1 {
|
||||
to: "rect1";
|
||||
relative: 1.0 0.0;
|
||||
}
|
||||
rel2 {
|
||||
to:"rect1";
|
||||
relative: 1.0 1.0;
|
||||
}
|
||||
}
|
||||
description {
|
||||
state: "slide_end" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
}
|
||||
description {state: "slide_begin" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
align: 1.0 1.0;
|
||||
rel1 {
|
||||
to: "rect2";
|
||||
relative: 0.0 0.0;
|
||||
}
|
||||
rel2 {
|
||||
to:"rect2";
|
||||
relative: 0.0 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program {signal: "mouse,down,1";
|
||||
source: "label";
|
||||
script{
|
||||
start_slide();
|
||||
}
|
||||
}
|
||||
program { name: "go_left";
|
||||
script{
|
||||
stop_slide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1148,6 +1148,114 @@ _edje_embryo_fn_set_tween_state(Embryo_Program *ep, Embryo_Cell *params)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Embryo_Cell
|
||||
_edje_embryo_fn_set_tween_state_anim(Embryo_Program *ep, Embryo_Cell *params)
|
||||
{
|
||||
Edje *ed;
|
||||
char *tmp = NULL;
|
||||
char *state1 = NULL, *state2 = NULL;
|
||||
int part_id = 0;
|
||||
int anim_type = 0;
|
||||
float f = 0.0;
|
||||
double tween = 0.0, value1 = 0.0, value2 = 0.0, v1 = 0.0, v2 = 0.0, v3 = 0.0, v4 = 0.0;
|
||||
Edje_Real_Part *rp;
|
||||
|
||||
if ((HASNPARAMS(6))) return -1;
|
||||
ed = embryo_program_data_get(ep);
|
||||
GETSTR(state1, params[2]);
|
||||
GETSTR(state2, params[4]);
|
||||
if ((!state1) || (!state2)) return 0;
|
||||
part_id = params[1];
|
||||
anim_type = params[6];
|
||||
if (part_id < 0) return 0;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[3]);
|
||||
value1 = (double)f;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[5]);
|
||||
value2 = (double)f;
|
||||
f = EMBRYO_CELL_TO_FLOAT(params[7]);
|
||||
tween = (double)f;
|
||||
if ((anim_type >= EDJE_TWEEN_MODE_LINEAR) &&
|
||||
(anim_type <= EDJE_TWEEN_MODE_DECELERATE))
|
||||
{
|
||||
if (HASNPARAMS(8))
|
||||
{
|
||||
GETSTR(tmp, params[8]);
|
||||
if (!strcmp(tmp, "CURRENT"))
|
||||
anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
|
||||
}
|
||||
}
|
||||
else if ((anim_type >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
|
||||
(anim_type <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR))
|
||||
{
|
||||
if (HASNPARAMS(9))
|
||||
{
|
||||
GETSTR(tmp, params[9]);
|
||||
if (!strcmp(tmp, "CURRENT"))
|
||||
anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
|
||||
}
|
||||
else if (HASNPARAMS(7))
|
||||
{
|
||||
ERR("parse error. Need 8th parameter to set factor");
|
||||
return -1;
|
||||
}
|
||||
GETFLOAT_T(v1, params[8]);
|
||||
}
|
||||
else if ((anim_type >= EDJE_TWEEN_MODE_DIVISOR_INTERP) &&
|
||||
(anim_type <= EDJE_TWEEN_MODE_SPRING))
|
||||
{
|
||||
if (HASNPARAMS(10))
|
||||
{
|
||||
GETSTR(tmp, params[10]);
|
||||
if (!strcmp(tmp, "CURRENT"))
|
||||
anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
|
||||
}
|
||||
else if (HASNPARAMS(7))
|
||||
{
|
||||
ERR("parse error.Need 8th and 9th parameters to set factor and counts");
|
||||
return -1;
|
||||
}
|
||||
GETFLOAT_T(v1, params[8]);
|
||||
GETFLOAT_T(v2, params[9]);
|
||||
}
|
||||
else if (anim_type == EDJE_TWEEN_MODE_CUBIC_BEZIER)
|
||||
{
|
||||
if (HASNPARAMS(12))
|
||||
{
|
||||
GETSTR(tmp, params[10]);
|
||||
if (!strcmp(tmp, "CURRENT"))
|
||||
anim_type |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
|
||||
}
|
||||
else if (HASNPARAMS(7))
|
||||
{
|
||||
ERR("parse error.Need 8th, 9th, 10th and 11th parameters to set x1, y1, x2 and y2");
|
||||
return -1;
|
||||
}
|
||||
if (HASNPARAMS(12))
|
||||
{
|
||||
GETFLOAT_T(v1, params[8]);
|
||||
GETFLOAT_T(v2, params[9]);
|
||||
GETFLOAT_T(v3, params[11]);
|
||||
GETFLOAT_T(v4, params[12]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GETFLOAT_T(v1, params[8]);
|
||||
GETFLOAT_T(v2, params[9]);
|
||||
GETFLOAT_T(v3, params[10]);
|
||||
GETFLOAT_T(v4, params[11]);
|
||||
}
|
||||
}
|
||||
rp = ed->table_parts[part_id % ed->table_parts_size];
|
||||
if (!rp) return 0;
|
||||
|
||||
if (rp->program) _edje_program_end(ed, rp->program);
|
||||
_edje_part_description_apply(ed, rp, state1, value1, state2, value2);
|
||||
_edje_part_pos_set(ed, rp, anim_type, FROM_DOUBLE(tween),
|
||||
v1, v2, v3, v4);
|
||||
_edje_recalc(ed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* run_program(program_id) */
|
||||
static Embryo_Cell
|
||||
_edje_embryo_fn_run_program(Embryo_Program *ep, Embryo_Cell *params)
|
||||
|
@ -3808,6 +3916,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
|
|||
embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state);
|
||||
embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state);
|
||||
embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);
|
||||
embryo_program_native_call_add(ep, "set_tween_state_anim", _edje_embryo_fn_set_tween_state_anim);
|
||||
embryo_program_native_call_add(ep, "run_program", _edje_embryo_fn_run_program);
|
||||
embryo_program_native_call_add(ep, "get_drag_dir", _edje_embryo_fn_get_drag_dir);
|
||||
embryo_program_native_call_add(ep, "get_drag", _edje_embryo_fn_get_drag);
|
||||
|
|
Loading…
Reference in New Issue