summaryrefslogtreecommitdiff
path: root/legacy/edje/doc/examples/external_emotion_elm.edc
blob: 686e10f3e4f819d5bc66a1fcfd36e6fadacefbbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 Super-concise video player example using Edje/Emotion/Elementary.

 This is all in Edje by means of type:EXTERNAL, you don't need any C
 code other than emotion and edje installed with edje_external
 support enabled.

 Compile: edje_cc     external-emotion-elm.edc
 Run....: edje_player external-emotion-elm.edj

 */
collections {
   group { name: "main";
      min: 350 200; /* set a min window size */

      externals { /* declare the modules you want to load */
         external: "emotion"; /* video player engine */
         external: "elm"; /* toolkit/widgets */
      }

      parts {
         part { name: "bg"; /* dark gray rectangle as background */
            type: RECT;
            description { state: "default" 0.0;
               color: 64 64 64 255;
            }
         }

         part { name: "video"; /* video object */
            type: EXTERNAL;
            source: "emotion";
            description { state: "default" 0.0;
               params {
                  /* explicitly select the emotion engine
                   * ['xine', 'gstreamer' or 'vlc']
                   * or comment the line to autoselect the engine */
                  // choice: "engine" "gstreamer";
               }
            }
         }

         part { name: "title";
            type: TEXT;
            effect: SOFT_SHADOW;
            description { state: "default" 0.0;
               color: 255 255 255 0;
               color3: 0 0 0 0;
               align: 0.5 0.0;
               rel1 {
                  relative: 0.0 0.0;
                  offset: 10 2;
               }
               rel2 {
                  relative: 1.0 0.0;
                  offset: -11 10;
               }
               text {
                  font: "Sans:style=Bold";
                  align: 0.5 0.0;
                  size: 10;
                  min: 0 1;
                  text: "";
               }
            }
            description { state: "visible" 0.0;
               inherit: "default" 0.0;
               color: 255 255 255 255;
               color3: 0 0 0 255;
            }
         }

         part { name: "controls-clipper"; /* clipper to control visibility */
            type: RECT;
            description { state: "default" 0.0;
               color: 255 255 255 32;
            }
            description { state: "visible" 0.0;
               color: 255 255 255 255;
            }
         }

         part { name: "controls-bg"; /* controls background as
                                        semi-transparent black at bottom edge */
            type: RECT;
            clip_to: "controls-clipper";
            description { state: "default" 0.0;
               color: 0 0 0 128;
               rel1 {
                  relative: 0.0 1.0;
                  offset: 0 -40;
               }
               rel2 {
                  relative: 1.0 1.0;
                  offset: -1 -1;
               }
            }
         }

         part { name: "play"; /* play button at bottom-left (relative
                                to controls-bg) */
            type: EXTERNAL;
            source: "elm/button";
            clip_to: "controls-clipper";
            description { state: "default" 0.0;
               rel1 {
                  relative: 0.0 0.0;
                  offset: 0 0;
                  to: "controls-bg";
               }
               rel2 {
                  relative: 0.0 1.0;
                  offset: 50 -1;
                  to: "controls-bg";
               }
               params.string: "icon" "apps";
            }
         }

         part { name: "open"; /* open file button next to play button */
            type: EXTERNAL;
            source: "elm/fileselector_button";
            clip_to: "controls-clipper";
            description { state: "default" 0.0;
               rel1 {
                  relative: 0.0 0.0;
                  offset: 52 0;
                  to: "controls-bg";
               }
               rel2 {
                  relative: 0.0 1.0;
                  offset: 102 -1;
                  to: "controls-bg";
               }
               params.string: "icon" "folder";
            }
         }

         part { name: "time"; /* time/progress */
            type: EXTERNAL;
            source: "elm/slider";
            clip_to: "controls-clipper";
            description { state: "default" 0.0;
               rel1 {
                  relative: 0.0 0.0;
                  offset: 104 0;
                  to: "controls-bg";
               }
               rel2 {
                  relative: 1.0 1.0;
                  offset: -1 -1;
                  to: "controls-bg";
               }
            }
         }

         part { name: "controls-eventarea"; /* event area so we catch mouse in
                                               and out, repeat events so
                                               buttons get them */
            type: RECT;
            repeat_events: 1;
            description {
               state: "default" 0.0;
               color: 255 255 255 0; /* fully transparent as we don't
                                        need any visual feedback */
               rel1.to: "controls-bg";
               rel2.to: "controls-bg";
            }
         }

         programs {
            /* animated 0.2 linear fade in/out if mouse is over controls */
            program { signal: "mouse,in";
               source: "controls-eventarea";
               action: STATE_SET "visible" 0.0;
               transition: LINEAR 0.2;
               target: "controls-clipper";
               target: "title";
            }
            program { signal: "mouse,out";
               source: "controls-eventarea";
               action: STATE_SET "default" 0.0;
               transition: LINEAR 0.2;
               target: "controls-clipper";
               target: "title";
            }

            /* toggle video playing state when play is clicked */
            program { name: "toggle-play-video";
               signal: "clicked";
               source: "play";
               script {
                  new v = external_param_get_bool(PART:"video", "play");
                  external_param_set_bool(PART:"video", "play", !v);
               }
            }

            /* whenever file is chosen, set and play it */
            program { signal: "file,chosen";
               source: "open";
               action: PARAM_COPY "open" "path" "video" "file";
               after: "play-video";
               after: "set-title";
            }
            program { name: "play-video";
               action: PARAM_SET "video" "play" "1";
            }
            program { name: "set-title";
               action: PARAM_COPY "open" "path" "title" "text";
            }

            /* if position changes, set slider (time) */
            program { signal: "position_update";
               source: "video";
               script {
                  new Float:p, Float:len;

                  p = external_param_get_float(PART:"video", "position");
                  len = external_param_get_float(PART:"video", "play_length");
                  if (len > 0.0)
                     external_param_set_float(PART:"time", "value", p / len);
               }
            }

            /* if slider (time) changes, set the position (seek) */
            program { signal: "changed";
               source: "time";
               script {
                  new Float:v, Float:len;

                  v = external_param_get_float(PART:"time", "value");
                  len = external_param_get_float(PART:"video", "play_length");
                  if (len > 0.0)
                     external_param_set_float(PART:"video", "position", v * len);
               }
            }
         }
      }
   }
}