summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-01-25 18:31:59 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-01-25 18:31:59 +0100
commita28d94b34e4e13e2fcdd46e156178cd6cc76275f (patch)
tree461ae5331a93b807bd325c957d117c1266f8c888
parentdfa3dfdb1abd083510f285bb4b12190dd7eddc65 (diff)
Icon: choose the fdo icon size using the evas obj geometry
Use the min between w and h of the evas object to request the size in the icon theme. Fdo icon are always square (1:1) so min seems correct. Also improved the test to include a test that do not relay on the size_hint_min of the icon. Now in all the test I have done always the correct fdo icon are used.
-rw-r--r--src/bin/test_icon.c47
-rw-r--r--src/lib/elm_icon.c6
2 files changed, 49 insertions, 4 deletions
diff --git a/src/bin/test_icon.c b/src/bin/test_icon.c
index 3938ea701..e84d075c8 100644
--- a/src/bin/test_icon.c
+++ b/src/bin/test_icon.c
@@ -213,11 +213,47 @@ _list_selected_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
213 elm_icon_standard_set(icon, elm_object_item_text_get(list_it)); 213 elm_icon_standard_set(icon, elm_object_item_text_get(list_it));
214} 214}
215 215
216static void
217_std_btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
218 void *event_info EINA_UNUSED)
219{
220 Evas_Object *win, *panes, *icon;
221
222 win = elm_win_util_standard_add("icon-test-std-auto", "Icon Standard");
223 elm_win_autodel_set(win, EINA_TRUE);
224
225 panes = elm_panes_add(win);
226 evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
227 elm_panes_content_left_min_size_set(panes, 16);
228 elm_panes_content_right_min_size_set(panes, 16);
229 elm_win_resize_object_add(win, panes);
230 evas_object_show(panes);
231
232 icon = elm_icon_add(panes);
233 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
234 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
235 elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME);
236 elm_icon_standard_set(icon, "folder");
237 elm_object_part_content_set(panes, "left", icon);
238 evas_object_show(icon);
239
240 icon = elm_icon_add(panes);
241 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME);
244 elm_icon_standard_set(icon, "user-home");
245 elm_object_part_content_set(panes, "right", icon);
246 evas_object_show(icon);
247
248 evas_object_resize(win, 300, 200);
249 evas_object_show(win);
250}
251
216void 252void
217test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 253test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
218 void *event_info EINA_UNUSED) 254 void *event_info EINA_UNUSED)
219{ 255{
220 Evas_Object *win, *li, *box, *hbox, *fr, *rd, *rdg, *icon, *sl; 256 Evas_Object *win, *li, *box, *hbox, *fr, *rd, *rdg, *icon, *sl, *bt;
221 257
222 win = elm_win_util_standard_add("icon-test-std", "Icon Standard"); 258 win = elm_win_util_standard_add("icon-test-std", "Icon Standard");
223 elm_win_autodel_set(win, EINA_TRUE); 259 elm_win_autodel_set(win, EINA_TRUE);
@@ -377,6 +413,7 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
377 evas_object_data_set(li, "resize_icon", icon); 413 evas_object_data_set(li, "resize_icon", icon);
378 414
379 sl = elm_slider_add(hbox); 415 sl = elm_slider_add(hbox);
416 elm_object_text_set(sl, "min_size");
380 elm_slider_min_max_set(sl, 16, 256); 417 elm_slider_min_max_set(sl, 16, 256);
381 elm_slider_value_set(sl, 16); 418 elm_slider_value_set(sl, 16);
382 elm_slider_unit_format_set(sl, "%.0f px"); 419 elm_slider_unit_format_set(sl, "%.0f px");
@@ -386,6 +423,14 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
386 elm_box_pack_end(hbox, sl); 423 elm_box_pack_end(hbox, sl);
387 evas_object_show(sl); 424 evas_object_show(sl);
388 425
426 bt = elm_button_add(box);
427 elm_object_text_set(bt, "Another size test, without using min_size");
428 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
429 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.0);
430 evas_object_smart_callback_add(bt, "clicked", _std_btn_clicked_cb, NULL);
431 elm_box_pack_end(box, bt);
432 evas_object_show(bt);
433
389 // show the win 434 // show the win
390 evas_object_resize(win, 300, 400); 435 evas_object_resize(win, 300, 400);
391 evas_object_show(win); 436 evas_object_show(win);
diff --git a/src/lib/elm_icon.c b/src/lib/elm_icon.c
index 0b79a4222..efbdc5d58 100644
--- a/src/lib/elm_icon.c
+++ b/src/lib/elm_icon.c
@@ -50,11 +50,11 @@ _path_is_absolute(const char *path)
50static inline int 50static inline int
51_icon_size_min_get(Evas_Object *icon) 51_icon_size_min_get(Evas_Object *icon)
52{ 52{
53 int size; 53 int w, h;
54 54
55 elm_image_object_size_get(icon, &size, NULL); 55 evas_object_geometry_get(icon, NULL, NULL, &w, &h);
56 56
57 return (size < 16) ? 16 : size; 57 return MAX(16, MIN(w, h));
58} 58}
59 59
60static void 60static void