[Radio] Fixed radio missing if we tap radio quickly.
[platform/core/uifw/efl-theme-tizen.git] / themes / widgets / radio.edc
1 /*
2  * efl-theme-tizen
3  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #define RADIO_STATE_DEFAULT 0 // radio is off
19 #define RADIO_STATE_VISIBLE 1 // radio is on
20
21    styles {
22       style { name: "radio_label_textblock_style";
23          base: "font=Tizen:style=Medium font_size="RADIO_STYLE_DEFAULT_FONT_SIZE_INC" color=#ffffff wrap=char text_class=tizen";
24          tag: "br" "\n";
25          tag: "ps" "ps";
26          tag: "hilight" "+ font=Tizen:style=Bold";
27          tag: "b" "+ font=Tizen:style=Bold";
28          tag: "whitecolor" "+ color=#ffffff";
29          tag: "tab" "\t";
30       }
31    }
32 ////////////////////////////////////////////////////////////////////////////////////////
33
34 #define RADIO_STYLE_DEFAULT(style_name, min_width, min_height) \
35    group { name: "elm/radio/base/"style_name; \
36       images { \
37          image: "00_button_radio_activated_dim.png" COMP; \
38          image: "00_button_radio_activated.png" COMP; \
39          image: "00_button_radio_bg.png" COMP; \
40          image: "00_button_radio_dim_bg.png" COMP; \
41          image: "00_button_radio_press_bg.png" COMP; \
42          image: "00_button_radio_press.png" COMP; \
43       } \
44       script { \
45          public radio_state = RADIO_STATE_DEFAULT; \
46       } \
47       parts { \
48          part { name: "back_bg"; \
49             type: RECT; \
50             scale: 1; \
51             description { state: "default" 0.0; \
52                rel2.relative: 0.0 1.0; \
53                align: 0 0.5; \
54                min: min_width min_height; \
55                fixed: 1 0; \
56                color: 0 0 0 0; \
57             } \
58          } \
59          part { name: "bg"; \
60             mouse_events: 0; \
61             scale: 1; \
62             description { state: "default" 0.0; \
63                min: RADIO_STYLE_DEFAULT_BG_MIN_MAX_INC; \
64                max: RADIO_STYLE_DEFAULT_BG_MIN_MAX_INC; \
65                fixed: 1 1; \
66                rel1.to: "back_bg"; \
67                rel2.to: "back_bg"; \
68                image.normal: "00_button_radio_bg.png"; \
69             } \
70             description { state: "disabled" 0.0; \
71                inherit: "default" 0.0; \
72                image.normal: "00_button_radio_dim_bg.png"; \
73             } \
74             description { state: "pressed" 0.0; \
75                inherit: "default" 0.0; \
76                image.normal: "00_button_radio_press_bg.png"; \
77             } \
78          } \
79          part { name: "radio"; \
80             clip_to: "opacity_clip"; \
81             mouse_events: 0; \
82             scale: 1; \
83             description { state: "default" 0.0; \
84                rel1.to: "bg"; \
85                rel2.to: "bg"; \
86                max: 0 0; \
87                image.normal: "00_button_radio_activated.png"; \
88                visible: 0; \
89             } \
90             description { state: "visible" 0.0; \
91                inherit: "default" 0.0; \
92                visible: 1; \
93                max: RADIO_STYLE_DEFAULT_BG_MIN_MAX_INC; \
94             } \
95             description { state: "disabled" 0.0; \
96                inherit: "default" 0.0; \
97             } \
98             description { state: "disabled_visible" 0.0; \
99                inherit: "visible" 0.0; \
100                image.normal: "00_button_radio_activated_dim.png"; \
101             } \
102             description { state: "pressed" 0.0; \
103                inherit: "visible" 0.0; \
104                image.normal: "00_button_radio_press.png"; \
105             } \
106          } \
107          part { name: "opacity_clip"; \
108             type: RECT; \
109             mouse_events: 0; \
110             description { state: "default" 0.0; \
111                color: 255 255 255 0; \
112             } \
113             description { state: "visible" 0.0; \
114                inherit: "default" 0.0; \
115                color: 255 255 255 255; \
116             } \
117          } \
118          part { name: "elm.swallow.content"; \
119             type: SWALLOW; \
120             clip_to: "disclip"; \
121             description { state: "default" 0.0; \
122                fixed: 1 0; \
123                visible: 0; \
124                align: 0.0 0.5; \
125                rel1 { \
126                   to_x: "bg"; \
127                   relative: 1.0 0.0; \
128                   offset: 1 1; \
129                } \
130                rel2 { \
131                   to_x: "bg"; \
132                   offset: 2 -2; \
133                } \
134             } \
135             description { state: "visible" 0.0; \
136                inherit: "default" 0.0; \
137                fixed: 1 1; \
138                visible: 1; \
139                aspect: 1.0 1.0; \
140                aspect_preference: VERTICAL; \
141             } \
142             description { state: "disabled" 0.0; \
143                inherit: "default" 0.0; \
144             } \
145             description { state: "disabled_visible" 0.0; \
146                inherit: "default" 0.0; \
147                fixed: 1 1; \
148                visible: 1; \
149                aspect: 1.0 1.0; \
150             } \
151          } \
152          part { name: "elm.text"; \
153             type: TEXTBLOCK; \
154             mouse_events: 0; \
155             clip_to: "disclip"; \
156             scale: 1; \
157             description { state: "default" 0.0; \
158                visible: 0; \
159                fixed: 0 1; \
160                rel1 { \
161                   relative: 1.0 0.5; \
162                   offset: 1 1; \
163                   to_x: "elm.swallow.content"; \
164                } \
165                rel2 { \
166                   relative: 1.0 0.5; \
167                   offset: -2 -2; \
168                } \
169                align: 0.0 0.5; \
170                text { \
171                   style: "radio_label_textblock_style"; \
172                   min: 0 0; \
173                } \
174                color: RADIO_DEFAULT_TEXT_NORMAL_COLOR_INC; \
175             } \
176             description { state: "visible" 0.0; \
177                inherit: "default" 0.0; \
178                visible: 1; \
179                text.min: 1 1; \
180             } \
181             description { state: "disabled" 0.0; \
182                inherit: "default" 0.0; \
183             } \
184             description { state: "disabled_visible" 0.0; \
185                inherit: "default" 0.0; \
186                visible: 1; \
187                text.min: 1 1; \
188                color: RADIO_DEFAULT_TEXT_DISABLED_COLOR_INC; \
189             } \
190          } \
191          part { name: "over1"; \
192             type: RECT; \
193             ignore_flags: ON_HOLD; \
194             description { state: "default" 0.0; \
195                color: 0 0 0 0; \
196             } \
197          } \
198          part { name: "over2"; \
199             type: RECT; \
200             repeat_events:1; \
201             description { state: "default" 0.0; \
202                color: 0 0 0 0; \
203             } \
204          } \
205          part { name: "disclip"; \
206             type: RECT; \
207             mouse_events: 0; \
208             description { state: "default" 0.0; \
209                color: RADIO_DISCLIP_NORMAL_COLOR_INC; \
210             } \
211             description { state: "disabled" 0.0; \
212                color: RADIO_DISCLIP_DISABLED_COLOR_INC; \
213             } \
214          } \
215          part { name: "disabler"; \
216             type: RECT; \
217             description { state: "default" 0.0; \
218                visible: 0; \
219             } \
220             description { state: "disabled" 0.0; \
221                inherit: "default" 0.0; \
222                visible: 1; \
223                color: 0 0 0 0; \
224             } \
225          } \
226       } \
227       programs { \
228          program { name: "click"; \
229             signal: "mouse,clicked,1"; \
230             source: "over1"; \
231             action: SIGNAL_EMIT "elm,action,radio,toggle" ""; \
232          } \
233          program { name: "touch_sound"; \
234             signal: "mouse,clicked,1"; \
235             source: "over2"; \
236             action: PLAY_SAMPLE "touch_sound" 1.0; \
237          } \
238          program { name: "bg_normal"; \
239             signal: "mouse,up,1"; \
240             source: "over2"; \
241             script { \
242                if (get_int(radio_state) == RADIO_STATE_VISIBLE) \
243                   set_state(PART:"radio", "visible", 0.0); \
244                else \
245                   set_state(PART:"radio", "default", 0.0); \
246                set_state(PART:"bg", "default", 0.0); \
247             } \
248          } \
249          program { name: "pressed"; \
250             signal: "mouse,down,1"; \
251             source: "over2"; \
252             script { \
253                if (get_int(radio_state) == RADIO_STATE_VISIBLE) \
254                   set_state(PART:"radio", "pressed", 0.0); \
255                else \
256                   set_state(PART:"radio", "default", 0.0); \
257                set_state(PART:"bg", "pressed", 0.0); \
258             } \
259          } \
260          program { name: "mouse,out"; \
261             signal: "mouse,out"; \
262             source: "over2"; \
263             script { \
264                if (get_int(radio_state) == RADIO_STATE_VISIBLE) \
265                   set_state(PART:"radio", "visible", 0.0); \
266                else \
267                   set_state(PART:"radio", "default", 0.0); \
268                set_state(PART:"bg", "default", 0.0); \
269             } \
270          } \
271          program { name: "radio_on"; \
272             signal: "elm,state,radio,on"; \
273             source: "elm"; \
274             script { \
275                set_int(radio_state, RADIO_STATE_VISIBLE); \
276                run_program(PROGRAM:"radio_show_effect"); \
277                run_program(PROGRAM:"radio_draw_effect"); \
278             } \
279          } \
280          program { name: "radio_off"; \
281             signal: "elm,state,radio,off"; \
282             source: "elm"; \
283             script { \
284                set_int(radio_state, RADIO_STATE_DEFAULT); \
285                set_state(PART:"opacity_clip", "default", 0.0); \
286                set_state(PART:"radio", "default", 0.0); \
287             } \
288          } \
289          program { name: "radio_show_effect"; \
290             action: STATE_SET "visible" 0.0; \
291             transition: LINEAR 0.233; \
292             target: "opacity_clip"; \
293          } \
294          program { name: "radio_draw_effect"; \
295             action: STATE_SET "visible" 0.0; \
296             transition: LINEAR 0.267; \
297             target: "radio"; \
298          } \
299          program { name: "text_show"; \
300             signal: "elm,state,text,visible"; \
301             source: "elm"; \
302             action: STATE_SET "visible" 0.0; \
303             target: "elm.text"; \
304          } \
305          program { name: "text_hide"; \
306             signal: "elm,state,text,hidden"; \
307             source: "elm"; \
308             action: STATE_SET "default" 0.0; \
309             target: "elm.text"; \
310          } \
311          program { name: "icon_show"; \
312             signal: "elm,state,icon,visible"; \
313             source: "elm"; \
314             action: STATE_SET "visible" 0.0; \
315             target: "elm.swallow.content"; \
316          } \
317          program { name: "icon_hide"; \
318             signal: "elm,state,icon,hidden"; \
319             source: "elm"; \
320             action: STATE_SET "default" 0.0; \
321             target: "elm.swallow.content"; \
322          } \
323          program { name: "disable"; \
324             signal: "elm,state,disabled"; \
325             source: "elm"; \
326             action: STATE_SET "disabled" 0.0; \
327             target: "disclip"; \
328             target: "bg"; \
329             target: "disabler"; \
330             after: "disable_text"; \
331          } \
332          program { name: "disable_text"; \
333             script { \
334                new st[31]; \
335                new Float:vl; \
336                get_state(PART:"elm.text", st, 30, vl); \
337                if (!strcmp(st, "visible")) \
338                  set_state(PART:"elm.text", "disabled_visible", 0.0); \
339                else \
340                  set_state(PART:"elm.text", "disabled", 0.0); \
341                get_state(PART:"elm.swallow.content", st, 30, vl); \
342                if (!strcmp(st, "visible")) \
343                  set_state(PART:"elm.swallow.content", "disabled_visible", 0.0); \
344                else \
345                  set_state(PART:"elm.swallow.content", "disabled", 0.0); \
346                get_state(PART:"radio", st, 30, vl); \
347                if (!strcmp(st, "visible")) \
348                  set_state(PART:"radio", "disabled_visible", 0.0); \
349                else \
350                  set_state(PART:"radio", "disabled", 0.0); \
351             } \
352          } \
353          program { name: "enable"; \
354             signal: "elm,state,enabled"; \
355             source: "elm"; \
356             action: STATE_SET "default" 0.0; \
357             target: "disabler"; \
358             target: "disclip"; \
359             target: "bg"; \
360             after: "enable_text"; \
361          } \
362          program { name: "enable_text"; \
363             script { \
364                new st[31]; \
365                new Float:vl; \
366                get_state(PART:"elm.text", st, 30, vl); \
367                if (!strcmp(st, "disabled_visible")) \
368                  set_state(PART:"elm.text", "visible", 0.0); \
369                else \
370                  set_state(PART:"elm.text", "default", 0.0); \
371                get_state(PART:"elm.swallow.content", st, 30, vl); \
372                if (!strcmp(st, "disabled_visible")) \
373                  set_state(PART:"elm.swallow.content", "visible", 0.0); \
374                else \
375                  set_state(PART:"elm.swallow.content", "default", 0.0); \
376                get_state(PART:"radio", st, 30, vl); \
377                if (!strcmp(st, "disabled_visible")) \
378                  { \
379                     set_state(PART:"opacity_clip", "visible", 0.0); \
380                     set_state(PART:"radio", "visible", 0.0); \
381                  } \
382                else \
383                  { \
384                     set_state(PART:"opacity_clip", "default", 0.0); \
385                     set_state(PART:"radio", "default", 0.0); \
386                  } \
387             } \
388          } \
389       } \
390    }
391
392 ///////////////////////////////////////////////////////////////////////////////////////
393 RADIO_STYLE_DEFAULT("default", RADIO_STYLE_DEFAULT_BG_IMAGE_MIN_WIDTH_INC, RADIO_STYLE_DEFAULT_BG_IMAGE_MIN_HEIGHT_INC)
394
395 ///////////////////////////////////////////////////////////////////////////////////////
396 RADIO_STYLE_DEFAULT("default/extended", RADIO_STYLE_DEFAULT_EXTENDED_BG_IMAGE_MIN_WIDTH_INC, RADIO_STYLE_DEFAULT_EXTENDED_BG_IMAGE_MIN_WIDTH_INC)
397
398 ///////////////////////////////////////////////////////////////////////////////////////
399
400 #undef RADIO_STATE_DEFAULT
401 #undef RADIO_STATE_VISIBLE