prefs_example_03.edc
#define MSG_ID_VEL (1)
collections {
group {
name: "prefs_edje";
max: 450 450;
min: 50 50;
parts {
part {
name: "bg";
type: RECT;
scale: 1;
description {
state: "default" 0.0;
min: 450 450;
max: 450 450;
color: 255 255 255 0;
align: 0.0 0.0;
}
}
part {
name: "square1";
type: RECT;
scale: 1;
description {
state: "default" 0.0;
min: 50 50;
max: 50 50;
color: 0 0 255 255;
align: 0.0 0.5;
}
description {
state: "invert" 0.0;
inherit: "default" 0.0;
color: 0 255 0 255;
align: 1 0.5;
}
}
part {
name: "square2";
type: RECT;
description {
state: "default" 0.0;
min: 50 50;
max: 50 50;
color: 0 255 0 255;
align: 0.5 0.0;
}
description {
state: "invert" 0.0;
inherit: "default" 0.0;
color: 0 0 255 255;
align: 0.5 1.0;
}
}
}
program {
name: "animation_start";
signal: "start";
source: "animation";
after: "animation,clear";
}
program {
name: "call_animation,state1";
script {
cancel_anim(anim_id);
set_int(anim_id, anim(get_float(global_speed), "animation_1", 0));
set_int(anim_n, 1);
}
}
program {
name: "call_animation,state2";
script {
cancel_anim(anim_id);
set_int(anim_id, anim(get_float(global_speed), "animation_2", 0));
set_int(anim_n, 2);
}
}
program {
name: "animation,stop";
signal: "stop";
source: "animation";
script {
cancel_anim(get_int(anim_id));
}
}
program {
name: "animation,clear";
script {
cancel_anim(get_int(anim_id));
if (get_int(anim_n) == 2)
set_float(anim_pos, (get_float(anim_pos) - 1) * ( -1));
}
after: "call_animation,state1";
}
script {
public global_speed;
public anim_id;
public anim_pos;
public anim_n;
public message(Msg_Type:type, id, ...) {
if ((type == MSG_FLOAT) && (id == MSG_ID_VEL))
set_float(global_speed, Float:getarg(2));
}
public animation_1(val, Float:pos) {
if (pos >= get_float(anim_pos) && get_int(anim_n) == 1)
{
set_tween_state(PART:"square1", pos, "default", 0.0,
"invert", 0.0);
set_tween_state(PART:"square2", pos, "default", 0.0,
"invert", 0.0);
set_float(anim_pos, pos);
}
if (pos >= 1)
{
run_program(PROGRAM:"call_animation,state2");
set_float(anim_pos, 0.0);
}
}
public animation_2(val, Float:pos) {
if (pos >= get_float(anim_pos) && get_int(anim_n) == 2)
{
set_tween_state(PART:"square1", pos, "invert", 0.0,
"default", 0.0);
set_tween_state(PART:"square2", pos, "invert", 0.0,
"default", 0.0);
set_float(anim_pos, pos);
}
if (pos >= 1)
{
run_program(PROGRAM:"call_animation,state1");
set_float(anim_pos, 0.0);
}
}
}
}
#undef MSG_ID_VEL