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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
static void
aspect_fixed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *ic = (Evas_Object *)data;
elm_image_aspect_fixed_set(ic, elm_check_state_get(obj));
}
static void
fill_outside_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *ic = (Evas_Object *)data;
elm_image_fill_outside_set(ic, elm_check_state_get(obj));
}
static void
smooth_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *ic = (Evas_Object *)data;
elm_image_smooth_set(ic, elm_check_state_get(obj));
}
static void
bt_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *ic;
char buf[PATH_MAX];
win = elm_win_util_standard_add("preload-prescale", "Preload & Prescale");
elm_win_autodel_set(win, EINA_TRUE);
ic = elm_icon_add(win);
evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, ic);
snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg",
elm_app_data_dir_get());
elm_image_file_set(ic, buf, NULL);
elm_image_aspect_fixed_set(ic, EINA_FALSE);
elm_image_preload_disabled_set(ic, EINA_TRUE);
elm_image_prescale_set(ic, EINA_TRUE);
evas_object_show(ic);
evas_object_resize(win, 350, 350);
evas_object_show(win);
}
void
test_icon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *box, *ic, *hbox, *tg, *bt;
char buf[PATH_MAX];
win = elm_win_util_standard_add("icon-test", "Icon Test");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
ic = elm_icon_add(box);
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
elm_image_file_set(ic, buf, NULL);
evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, ic);
evas_object_show(ic);
hbox = elm_box_add(box);
elm_box_horizontal_set(hbox, EINA_TRUE);
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
elm_box_pack_end(box, hbox);
evas_object_show(hbox);
/* Test Aspect Fixed */
tg = elm_check_add(hbox);
elm_object_text_set(tg, "Aspect Fixed");
elm_check_state_set(tg, EINA_TRUE);
evas_object_smart_callback_add(tg, "changed", aspect_fixed_cb, ic);
elm_box_pack_end(hbox, tg);
evas_object_show(tg);
/* Test Fill Outside */
tg = elm_check_add(hbox);
elm_object_text_set(tg, "Fill Outside");
evas_object_smart_callback_add(tg, "changed", fill_outside_cb, ic);
elm_box_pack_end(hbox, tg);
evas_object_show(tg);
/* Test Smooth */
tg = elm_check_add(hbox);
elm_object_text_set(tg, "Smooth");
elm_check_state_set(tg, EINA_TRUE);
evas_object_smart_callback_add(tg, "changed", smooth_cb, ic);
elm_box_pack_end(hbox, tg);
evas_object_show(tg);
/* Test Preload, Prescale */
bt = elm_button_add(hbox);
elm_object_text_set(bt, "Preload & Prescale");
evas_object_smart_callback_add(bt, "clicked", bt_clicked, NULL);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
/* Test: Icon Transparent */
static void
icon_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("clicked!\n");
}
void
test_icon_transparent(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *ic;
char buf[PATH_MAX];
win = elm_win_add(NULL, "icon-transparent", ELM_WIN_BASIC);
elm_win_title_set(win, "Icon Transparent");
elm_win_autodel_set(win, EINA_TRUE);
elm_win_alpha_set(win, EINA_TRUE);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
elm_image_file_set(ic, buf, NULL);
elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
elm_image_no_scale_set(ic, EINA_TRUE);
evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(ic, 0.5, 0.5);
elm_win_resize_object_add(win, ic);
evas_object_show(ic);
evas_object_smart_callback_add(ic, "clicked", icon_clicked, NULL);
evas_object_show(win);
}
/* Test: Icon Standard */
static void
_standard_list_populate(Evas_Object *list, Elm_Icon_Lookup_Order order, int size)
{
Evas_Object *ic;
Eina_List *l;
const char *group;
char name[128], *p;
elm_list_clear(list);
l = elm_theme_group_base_list(NULL, "elm/icon/");
EINA_LIST_FREE(l, group)
{
// group = "/elm/icon/standard-name/style/maybe_another_style??"
snprintf(name, sizeof(name), "%s", group + 9);
if ((p = strrchr(name, '/')))
*p = '\0';
// printf("Found group:%s Name:%s\n", group, name);
// quick hack to show only standard-compliant icons
// apart from the "folder" one, all the others have "-" in the name
if ((strrchr(name, '-') != NULL) || !strcmp(name, "folder"))
{
ic = elm_icon_add(list);
elm_icon_order_lookup_set(ic, order);
elm_icon_standard_set(ic, name);
if (size)
evas_object_size_hint_min_set(ic, size, size);
elm_list_item_append(list, name, ic, NULL, NULL, NULL);
}
eina_stringshare_del(group);
}
elm_list_go(list);
}
static void
_rdg_changed_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *li = data;
Evas_Object *icon = evas_object_data_get(li, "resize_icon");
Evas_Object *order_rdg = evas_object_data_get(li, "order_rdg");
Evas_Object *size_rdg = evas_object_data_get(li, "size_rdg");
_standard_list_populate(li, elm_radio_value_get(order_rdg),
elm_radio_value_get(size_rdg));
elm_icon_order_lookup_set(icon, elm_radio_value_get(order_rdg));
}
static void
_slider_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *icon = data;
int size = (int)elm_slider_value_get(obj);
evas_object_size_hint_min_set(icon, size, size);
}
static void
_list_selected_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *list_it = event_info;
Evas_Object *icon = evas_object_data_get(obj, "resize_icon");
elm_icon_standard_set(icon, elm_object_item_text_get(list_it));
}
static void
_std_btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *panes, *icon;
win = elm_win_util_standard_add("icon-test-std-auto", "Icon Standard");
elm_win_autodel_set(win, EINA_TRUE);
panes = elm_panes_add(win);
evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_panes_content_left_min_size_set(panes, 16);
elm_panes_content_right_min_size_set(panes, 16);
elm_win_resize_object_add(win, panes);
evas_object_show(panes);
icon = elm_icon_add(panes);
evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME);
elm_icon_standard_set(icon, "folder");
elm_object_part_content_set(panes, "left", icon);
evas_object_show(icon);
icon = elm_icon_add(panes);
evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME);
elm_icon_standard_set(icon, "user-home");
elm_object_part_content_set(panes, "right", icon);
evas_object_show(icon);
evas_object_resize(win, 300, 200);
evas_object_show(win);
}
void
test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *li, *box, *hbox, *fr, *rd, *rdg, *icon, *sl, *bt;
win = elm_win_util_standard_add("icon-test-std", "Icon Standard");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
li = elm_list_add(box);
evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(li, "selected", _list_selected_cb, NULL);
_standard_list_populate(li, ELM_ICON_LOOKUP_FDO_THEME, 0);
evas_object_show(li);
// lookup order
fr = elm_frame_add(box);
elm_object_text_set(fr, "standard icon order lookup");
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.0);
elm_box_pack_end(box, fr);
evas_object_show(fr);
hbox = elm_box_add(fr);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_object_content_set(fr, hbox);
evas_object_show(hbox);
rdg = elm_radio_add(hbox);
elm_radio_state_value_set(rdg, ELM_ICON_LOOKUP_FDO_THEME);
elm_object_text_set(rdg, "fdo, theme");
elm_box_pack_end(hbox, rdg);
evas_object_show(rdg);
evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, li);
evas_object_data_set(li, "order_rdg", rdg);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_THEME_FDO);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "theme, fdo");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_FDO);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "fdo only");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_THEME);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "theme only");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
// size
fr = elm_frame_add(box);
elm_object_text_set(fr, "standard icon size");
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.0);
elm_box_pack_end(box, fr);
evas_object_show(fr);
hbox = elm_box_add(fr);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_object_content_set(fr, hbox);
evas_object_show(hbox);
rdg = elm_radio_add(hbox);
elm_radio_state_value_set(rdg, 0);
elm_object_text_set(rdg, "Free");
elm_box_pack_end(hbox, rdg);
evas_object_show(rdg);
evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, li);
evas_object_data_set(li, "size_rdg", rdg);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 16);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "16");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 22);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "22");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 24);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "24");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 32);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "32");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 48);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "48");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 64);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "64");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
rd = elm_radio_add(hbox);
elm_radio_state_value_set(rd, 128);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "128");
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li);
// pack the list
elm_box_pack_end(box, li);
// live resize
fr = elm_frame_add(box);
elm_object_text_set(fr, "live resize");
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.0);
elm_box_pack_end(box, fr);
evas_object_show(fr);
hbox = elm_box_add(fr);
elm_object_content_set(fr, hbox);
evas_object_show(hbox);
icon = elm_icon_add(hbox);
elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME);
elm_icon_standard_set(icon, "folder");
evas_object_size_hint_min_set(icon, 16, 16);
elm_box_pack_end(hbox, icon);
evas_object_show(icon);
evas_object_data_set(li, "resize_icon", icon);
sl = elm_slider_add(hbox);
elm_object_text_set(sl, "min_size");
elm_slider_min_max_set(sl, 16, 256);
elm_slider_value_set(sl, 16);
elm_slider_unit_format_set(sl, "%.0f px");
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.0);
evas_object_smart_callback_add(sl, "changed", _slider_changed_cb, icon);
elm_box_pack_end(hbox, sl);
evas_object_show(sl);
bt = elm_button_add(box);
elm_object_text_set(bt, "Another size test, without using min_size");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.0);
evas_object_smart_callback_add(bt, "clicked", _std_btn_clicked_cb, NULL);
elm_box_pack_end(box, bt);
evas_object_show(bt);
// show the win
evas_object_resize(win, 300, 400);
evas_object_show(win);
}
|