Imported Upstream version 1.7.1
[platform/upstream/edje.git] / src / examples / external_emotion_elm.edc
1 /*
2  Super-concise video player example using Edje/Emotion/Elementary.
3
4  This is all in Edje by means of type:EXTERNAL, you don't need any C
5  code other than emotion and edje installed with edje_external
6  support enabled.
7
8  Compile: edje_cc     external-emotion-elm.edc
9  Run....: edje_player external-emotion-elm.edj
10
11  */
12 collections {
13    group { name: "main";
14       min: 350 200; /* set a min window size */
15
16       externals { /* declare the modules you want to load */
17          external: "emotion"; /* video player engine */
18          external: "elm"; /* toolkit/widgets */
19       }
20
21       parts {
22          part { name: "bg"; /* dark gray rectangle as background */
23             type: RECT;
24             description { state: "default" 0.0;
25                color: 64 64 64 255;
26             }
27          }
28
29          part { name: "video"; /* video object */
30             type: EXTERNAL;
31             source: "emotion";
32             description { state: "default" 0.0;
33                params {
34                   /* explicitly select the emotion engine
35                    * ['xine', 'gstreamer' or 'vlc']
36                    * or comment the line to autoselect the engine */
37                   // choice: "engine" "gstreamer";
38                }
39             }
40          }
41
42          part { name: "title";
43             type: TEXT;
44             effect: SOFT_SHADOW;
45             description { state: "default" 0.0;
46                color: 255 255 255 0;
47                color3: 0 0 0 0;
48                align: 0.5 0.0;
49                rel1 {
50                   relative: 0.0 0.0;
51                   offset: 10 2;
52                }
53                rel2 {
54                   relative: 1.0 0.0;
55                   offset: -11 10;
56                }
57                text {
58                   font: "Sans:style=Bold";
59                   align: 0.5 0.0;
60                   size: 10;
61                   min: 0 1;
62                   text: "";
63                }
64             }
65             description { state: "visible" 0.0;
66                inherit: "default" 0.0;
67                color: 255 255 255 255;
68                color3: 0 0 0 255;
69             }
70          }
71
72          part { name: "controls-clipper"; /* clipper to control visibility */
73             type: RECT;
74             description { state: "default" 0.0;
75                color: 255 255 255 32;
76             }
77             description { state: "visible" 0.0;
78                color: 255 255 255 255;
79             }
80          }
81
82          part { name: "controls-bg"; /* controls background as
83                                         semi-transparent black at bottom edge */
84             type: RECT;
85             clip_to: "controls-clipper";
86             description { state: "default" 0.0;
87                color: 0 0 0 128;
88                rel1 {
89                   relative: 0.0 1.0;
90                   offset: 0 -40;
91                }
92                rel2 {
93                   relative: 1.0 1.0;
94                   offset: -1 -1;
95                }
96             }
97          }
98
99          part { name: "play"; /* play button at bottom-left (relative
100                                 to controls-bg) */
101             type: EXTERNAL;
102             source: "elm/button";
103             clip_to: "controls-clipper";
104             description { state: "default" 0.0;
105                rel1 {
106                   relative: 0.0 0.0;
107                   offset: 0 0;
108                   to: "controls-bg";
109                }
110                rel2 {
111                   relative: 0.0 1.0;
112                   offset: 50 -1;
113                   to: "controls-bg";
114                }
115                params.string: "icon" "apps";
116             }
117          }
118
119          part { name: "open"; /* open file button next to play button */
120             type: EXTERNAL;
121             source: "elm/fileselector_button";
122             clip_to: "controls-clipper";
123             description { state: "default" 0.0;
124                rel1 {
125                   relative: 0.0 0.0;
126                   offset: 52 0;
127                   to: "controls-bg";
128                }
129                rel2 {
130                   relative: 0.0 1.0;
131                   offset: 102 -1;
132                   to: "controls-bg";
133                }
134                params.string: "icon" "folder";
135             }
136          }
137
138          part { name: "time"; /* time/progress */
139             type: EXTERNAL;
140             source: "elm/slider";
141             clip_to: "controls-clipper";
142             description { state: "default" 0.0;
143                rel1 {
144                   relative: 0.0 0.0;
145                   offset: 104 0;
146                   to: "controls-bg";
147                }
148                rel2 {
149                   relative: 1.0 1.0;
150                   offset: -1 -1;
151                   to: "controls-bg";
152                }
153             }
154          }
155
156          part { name: "controls-eventarea"; /* event area so we catch mouse in
157                                                and out, repeat events so
158                                                buttons get them */
159             type: RECT;
160             repeat_events: 1;
161             description {
162                state: "default" 0.0;
163                color: 255 255 255 0; /* fully transparent as we don't
164                                         need any visual feedback */
165                rel1.to: "controls-bg";
166                rel2.to: "controls-bg";
167             }
168          }
169
170          programs {
171             /* animated 0.2 linear fade in/out if mouse is over controls */
172             program { signal: "mouse,in";
173                source: "controls-eventarea";
174                action: STATE_SET "visible" 0.0;
175                transition: LINEAR 0.2;
176                target: "controls-clipper";
177                target: "title";
178             }
179             program { signal: "mouse,out";
180                source: "controls-eventarea";
181                action: STATE_SET "default" 0.0;
182                transition: LINEAR 0.2;
183                target: "controls-clipper";
184                target: "title";
185             }
186
187             /* toggle video playing state when play is clicked */
188             program { name: "toggle-play-video";
189                signal: "clicked";
190                source: "play";
191                script {
192                   new v = external_param_get_bool(PART:"video", "play");
193                   external_param_set_bool(PART:"video", "play", !v);
194                }
195             }
196
197             /* whenever file is chosen, set and play it */
198             program { signal: "file,chosen";
199                source: "open";
200                action: PARAM_COPY "open" "path" "video" "file";
201                after: "play-video";
202                after: "set-title";
203             }
204             program { name: "play-video";
205                action: PARAM_SET "video" "play" "1";
206             }
207             program { name: "set-title";
208                action: PARAM_COPY "open" "path" "title" "text";
209             }
210
211             /* if position changes, set slider (time) */
212             program { signal: "position_update";
213                source: "video";
214                script {
215                   new Float:p, Float:len;
216
217                   p = external_param_get_float(PART:"video", "position");
218                   len = external_param_get_float(PART:"video", "play_length");
219                   if (len > 0.0)
220                      external_param_set_float(PART:"time", "value", p / len);
221                }
222             }
223
224             /* if slider (time) changes, set the position (seek) */
225             program { signal: "changed";
226                source: "time";
227                script {
228                   new Float:v, Float:len;
229
230                   v = external_param_get_float(PART:"time", "value");
231                   len = external_param_get_float(PART:"video", "play_length");
232                   if (len > 0.0)
233                      external_param_set_float(PART:"video", "position", v * len);
234                }
235             }
236          }
237       }
238    }
239 }