efl
150 строк · 3.9 Кб
1#define MSG_ID_VEL (1)
2
3collections {
4group {
5name: "prefs_edje";
6max: 450 450;
7min: 50 50;
8
9parts {
10part {
11name: "bg";
12type: RECT;
13scale: 1;
14description {
15state: "default" 0.0;
16min: 450 450;
17max: 450 450;
18color: 255 255 255 0;
19align: 0.0 0.0;
20}
21}
22
23part {
24name: "square1";
25type: RECT;
26scale: 1;
27description {
28state: "default" 0.0;
29min: 50 50;
30max: 50 50;
31color: 0 0 255 255;
32align: 0.0 0.5;
33}
34description {
35state: "invert" 0.0;
36inherit: "default" 0.0;
37color: 0 255 0 255;
38align: 1 0.5;
39}
40}
41
42part {
43name: "square2";
44type: RECT;
45description {
46state: "default" 0.0;
47min: 50 50;
48max: 50 50;
49color: 0 255 0 255;
50align: 0.5 0.0;
51}
52description {
53state: "invert" 0.0;
54inherit: "default" 0.0;
55color: 0 0 255 255;
56align: 0.5 1.0;
57}
58}
59}
60
61program {
62name: "animation_start";
63signal: "start";
64source: "animation";
65after: "animation,clear";
66}
67
68program {
69name: "call_animation,state1";
70script {
71cancel_anim(anim_id);
72set_int(anim_id, anim(get_float(global_speed), "animation_1", 0));
73set_int(anim_n, 1);
74}
75}
76
77program {
78name: "call_animation,state2";
79script {
80cancel_anim(anim_id);
81set_int(anim_id, anim(get_float(global_speed), "animation_2", 0));
82set_int(anim_n, 2);
83}
84}
85
86program {
87name: "animation,stop";
88signal: "stop";
89source: "animation";
90script {
91cancel_anim(get_int(anim_id));
92}
93}
94
95program {
96name: "animation,clear";
97script {
98cancel_anim(get_int(anim_id));
99if (get_int(anim_n) == 2)
100set_float(anim_pos, (get_float(anim_pos) - 1) * ( -1));
101}
102after: "call_animation,state1";
103}
104
105script {
106public global_speed;
107public anim_id;
108public anim_pos;
109public anim_n;
110
111public message(Msg_Type:type, id, ...) {
112if ((type == MSG_FLOAT) && (id == MSG_ID_VEL))
113set_float(global_speed, Float:getarg(2));
114}
115
116public animation_1(val, Float:pos) {
117if (pos >= get_float(anim_pos) && get_int(anim_n) == 1)
118{
119set_tween_state(PART:"square1", pos, "default", 0.0,
120"invert", 0.0);
121set_tween_state(PART:"square2", pos, "default", 0.0,
122"invert", 0.0);
123set_float(anim_pos, pos);
124}
125if (pos >= 1)
126{
127run_program(PROGRAM:"call_animation,state2");
128set_float(anim_pos, 0.0);
129}
130}
131
132public animation_2(val, Float:pos) {
133if (pos >= get_float(anim_pos) && get_int(anim_n) == 2)
134{
135set_tween_state(PART:"square1", pos, "invert", 0.0,
136"default", 0.0);
137set_tween_state(PART:"square2", pos, "invert", 0.0,
138"default", 0.0);
139set_float(anim_pos, pos);
140}
141if (pos >= 1)
142{
143run_program(PROGRAM:"call_animation,state1");
144set_float(anim_pos, 0.0);
145}
146}
147}
148}
149
150#undef MSG_ID_VEL
151