summaryrefslogtreecommitdiff
path: root/legacy/edje/doc/examples/external_elm_button.edc
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2010-10-08 09:48:38 +0000
committerDavide Andreoli <dave@gurumeditation.it>2010-10-08 09:48:38 +0000
commit994d9518eca48c26312fc0e574f748b9ac2e8d88 (patch)
treebbe5feb93599decf49614e5db966c6924c0ad31c /legacy/edje/doc/examples/external_elm_button.edc
parenta3b68b3e0e8179a53a9d4b9baa212ab28fddb224 (diff)
Add the first edje examples about the usage of EXTERNAL parts.
This example show 5 buttons that you can click to perform some simple actions, like changing the label or the icon of the buttons. The example also spot a bug: external buttons with label AND icon have layout issue. Standard icons are not visible at all while custom icons don't get the size calculated correctly. Buttons with only the icon work well instead. Can someone look at this? Thanks DaveMDS SVN revision: 53182
Diffstat (limited to '')
-rw-r--r--legacy/edje/doc/examples/external_elm_button.edc270
1 files changed, 270 insertions, 0 deletions
diff --git a/legacy/edje/doc/examples/external_elm_button.edc b/legacy/edje/doc/examples/external_elm_button.edc
new file mode 100644
index 0000000000..b7796d87ce
--- /dev/null
+++ b/legacy/edje/doc/examples/external_elm_button.edc
@@ -0,0 +1,270 @@
1collections {
2 /* those 2 groups are used as custom icons for the buttons */
3 group { name: "icon_green";
4 parts {
5 part { name: "icon_green";
6 type: RECT;
7 description { state: "default" 0.0;
8 color: 0 255 0 255;
9 aspect: 1 1;
10 aspect_preference: VERTICAL;
11 }
12 }
13 }
14 }
15 group { name: "icon_red";
16 parts {
17 part { name: "icon_red";
18 type: RECT;
19 description { state: "default" 0.0;
20 color: 255 0 0 255;
21 aspect: 1 1;
22 aspect_preference: VERTICAL;
23 }
24 }
25 }
26 }
27
28 group { name: "main";
29 /* set a min window size */
30 min: 250 250;
31
32 /* tell edje that we are going to use elementary external parts */
33 externals {
34 external: "elm";
35 }
36
37 /* define global variables */
38 script {
39 public counter, toggle1, toggle2, toggle3, toggle4;
40 }
41
42 parts {
43 part { name: "bg";
44 type: RECT;
45 description { state: "default" 0.0;
46 color: 255 255 255 255;
47 }
48 }
49
50 part { name: "title";
51 type: TEXT;
52 effect: SOFT_SHADOW;
53 description { state: "default" 0.0;
54 color: 255 255 255 255;
55 color3: 70 70 70 70;
56 text {
57 text: "Elementary buttons";
58 font: "Sans";
59 size: 16;
60 align: 0.5 0.0;
61 }
62 }
63 }
64
65 /* bottom label used for reporting */
66 part { name: "label";
67 type: TEXT;
68 description { state: "default" 0.0;
69 color: 0 0 0 255;
70 text {
71 text: "try every buttons";
72 font: "Sans";
73 size: 12;
74 align: 0.5 1.0;
75 }
76 }
77 }
78
79 /* EXTERNAL elementary button with a label */
80 part { name: "bt1";
81 type: EXTERNAL;
82 source: "elm/button";
83 description { state: "default" 0;
84 rel1 {
85 offset: 5 35;
86 }
87 rel2 {
88 relative: 1.0 0.0;
89 offset: -6 60;
90 }
91 params {
92 string: "label" "Label only";
93 }
94 }
95 }
96
97 /* EXTERNAL elementary button with label + standard icon */
98 part { name: "bt2";
99 type: EXTERNAL;
100 source: "elm/button";
101 description { state: "default" 0;
102 rel1 {
103 to: "bt1";
104 relative: 0.0 1.0;
105 offset: 0 5;
106 }
107 rel2 {
108 to: "bt1";
109 relative: 1.0 2.0;
110 offset: -1 5;
111 }
112 params {
113 string: "label" "Label + standard icon";
114 string: "icon" "home";
115 }
116 }
117 }
118
119 /* EXTERNAL elementary button with a label and a custom icon */
120 part { name: "bt3";
121 type: EXTERNAL;
122 source: "elm/button";
123 description { state: "default" 0;
124 rel1 {
125 to: "bt2";
126 relative: 0.0 1.0;
127 offset: 0 5;
128 }
129 rel2 {
130 to: "bt2";
131 relative: 1.0 2.0;
132 offset: -1 5;
133 }
134 params {
135 string: "label" "Label + custom icon";
136 string: "icon" "icon_green";
137 }
138 }
139 }
140
141 /* EXTERNAL elementary button with just a standard icon */
142 part { name: "bt4";
143 type: EXTERNAL;
144 source: "elm/button";
145 description { state: "default" 0;
146 rel1 {
147 to: "bt3";
148 relative: 0.0 1.0;
149 offset: 0 5;
150 }
151 rel2 {
152 to: "bt3";
153 relative: 0.5 2.0;
154 offset: -6 5;
155 }
156 params {
157 string: "icon" "folder";
158 }
159 }
160 }
161
162 /* EXTERNAL elementary button with just a custom icon */
163 part { name: "bt5";
164 type: EXTERNAL;
165 source: "elm/button";
166 description { state: "default" 0;
167 rel1 {
168 to: "bt3";
169 relative: 0.5 1.0;
170 offset: 5 5;
171 }
172 rel2 {
173 to: "bt3";
174 relative: 1.0 2.0;
175 offset: 0 5;
176 }
177 params {
178 string: "icon" "icon_green";
179 }
180 }
181 }
182 }
183
184 programs {
185 /* bt1 clicked, change it's label and count the clicks */
186 program { name: "bt1_click";
187 signal: "clicked";
188 source: "bt1";
189 script {
190 new buf[32];
191 /* increment the global counter*/
192 set_int(counter, get_int(counter) + 1);
193 /* set the button label */
194 snprintf(buf, sizeof(buf), "Clicked %d times", get_int(counter));
195 external_param_set_str(PART:"bt1", "label", buf);
196 /* set the bottom label */
197 set_text(PART:"label", "button 1 clicked: set label");
198 }
199 }
200
201 /* bt2 clicked, toggle it's standard icon */
202 program { name: "bt2_click";
203 signal: "clicked";
204 source: "bt2";
205 script {
206 if (get_int(toggle1) == 0) {
207 external_param_set_str(PART:"bt2", "icon", "home");
208 set_int(toggle1, 1);
209 }
210 else {
211 external_param_set_str(PART:"bt2", "icon", "folder");
212 set_int(toggle1, 0);
213 }
214 set_text(PART:"label", "button 2 clicked: toggle icon");
215 }
216 }
217
218 /* bt3 clicked, toggle it's custom icon */
219 program { name: "bt3_click";
220 signal: "clicked";
221 source: "bt3";
222 script {
223 if (get_int(toggle2) == 0) {
224 external_param_set_str(PART:"bt3", "icon", "icon_red");
225 set_int(toggle2, 1);
226 }
227 else {
228 external_param_set_str(PART:"bt3", "icon", "icon_green");
229 set_int(toggle2, 0);
230 }
231 set_text(PART:"label", "button 3 clicked: toggle icon");
232 }
233 }
234
235 /* bt4 clicked, toggle it's icon */
236 program { name: "bt4_click";
237 signal: "clicked";
238 source: "bt4";
239 script {
240 if (get_int(toggle3) == 0) {
241 external_param_set_str(PART:"bt4", "icon", "home");
242 set_int(toggle3, 1);
243 }
244 else {
245 external_param_set_str(PART:"bt4", "icon", "folder");
246 set_int(toggle3, 0);
247 }
248 set_text(PART:"label", "button 4 clicked: toggle icon");
249 }
250 }
251
252 /* bt5 clicked, toggle it's icon */
253 program { name: "bt5_click";
254 signal: "clicked";
255 source: "bt5";
256 script {
257 if (get_int(toggle4) == 0) {
258 external_param_set_str(PART:"bt5", "icon", "icon_red");
259 set_int(toggle4, 1);
260 }
261 else {
262 external_param_set_str(PART:"bt5", "icon", "icon_green");
263 set_int(toggle4, 0);
264 }
265 set_text(PART:"label", "button 5 clicked: toggle icon");
266 }
267 }
268 }
269 }
270}