Imported Upstream version 1.7.1
[platform/upstream/edje.git] / src / examples / embryo_custom_state.edc
1 collections {
2    group { name: "main";
3       script {
4          /* define 3 global vars to hold the rotation values */
5          public rotx;
6          public roty;
7          public rotz;
8       }
9       parts {
10          part { name: "bg";
11             type: RECT;
12             description { state: "default" 0.0;
13                color: 255 255 255 255;
14             }
15          }
16          part { name: "title";
17             type: TEXT;
18             description { state: "default" 0.0;
19                color: 0 0 0 255;
20                text {
21                   text: "Click labels to rotate";
22                   font: "Sans";
23                   size: 12;
24                   align: 0.5 0.0;
25                }
26             }
27          }
28          part { name: "X";
29             type: TEXT;
30             description { state: "default" 0.0;
31                color: 0 0 0 255;
32                text {
33                   text: "Rot X (0)";
34                   font: "Sans";
35                   size: 12;
36                   align: 0.1 0.5;
37                }
38             }
39          }
40          part { name: "Y";
41             type: TEXT;
42             description { state: "default" 0.0;
43                color: 0 0 0 255;
44                text {
45                   text: "Rot Y (0)";
46                   font: "Sans";
47                   size: 12;
48                   align: 0.5 0.9;
49                }
50             }
51          }
52          part { name: "Z";
53             type: TEXT;
54             description { state: "default" 0.0;
55                color: 0 0 0 255;
56                text {
57                   text: "Rot Z (0)";
58                   font: "Sans";
59                   size: 12;
60                   align: 0.9 0.5;
61                }
62             }
63          }
64          part { name: "rect";
65             type: RECT;
66             mouse_events: 0;
67             description { state: "default" 0.0;
68                color: 255 0 0 150;
69                max: 150 150;
70                align: 0.5 0.5;
71                map {
72                   on: 1;
73                   perspective_on: 1;
74                   smooth: 1;
75                   alpha: 1;
76                }
77             }
78          }
79       }
80       programs {
81          program {
82             signal: "mouse,down,1";
83             source: "X";
84             script {
85                /* define local vars */
86                new buf[32];
87                new Float:x;
88
89                /* get global var (and increment) */
90                x = get_int(rotx) + 10;
91                /* set global var */
92                set_int(rotx, round(x));
93                /* crete a new custom state (inherit from default 0.0) */
94                custom_state(PART:"rect", "default", 0.0);
95                /* change the rotation in the custom state */
96                set_state_val(PART:"rect", STATE_MAP_ROT_X, x);
97                /* apply the custom state */
98                set_state(PART:"rect", "custom", 0.0);
99                /* update the label to show the current value */
100                snprintf(buf, sizeof(buf), "Rot X (%d)", round(x));
101                set_text(PART:"X", buf);
102             }
103          }
104          program {
105             signal: "mouse,down,1";
106             source: "Y";
107             script {
108                new buf[32];
109                new Float:y = get_int(roty) + 10;
110                set_int(roty, round(y));
111                custom_state(PART:"rect", "default", 0.0);
112                set_state_val(PART:"rect", STATE_MAP_ROT_Y, y);
113                set_state(PART:"rect", "custom", 0.0);
114                snprintf(buf, sizeof(buf), "Rot Y (%d)", round(y));
115                set_text(PART:"Y", buf);
116             }
117          }
118          program {
119             signal: "mouse,down,1";
120             source: "Z";
121             script {
122                new buf[32];
123                new Float:z = get_int(rotz) + 10;
124                set_int(rotz, round(z));
125                custom_state(PART:"rect", "default", 0.0);
126                set_state_val(PART:"rect", STATE_MAP_ROT_Z, z);
127                set_state(PART:"rect", "custom", 0.0);
128                snprintf(buf, sizeof(buf), "Rot Z (%d)", round(z));
129                set_text(PART:"Z", buf);
130             }
131          }
132       }
133    }
134 }