forked from enlightenment/efl
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.
This commit is contained in:
parent
38daa7553f
commit
3662d3c601
|
@ -213,11 +213,47 @@ _list_selected_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
|
|||
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;
|
||||
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);
|
||||
|
@ -377,6 +413,7 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
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");
|
||||
|
@ -386,6 +423,14 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
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);
|
||||
|
|
|
@ -50,11 +50,11 @@ _path_is_absolute(const char *path)
|
|||
static inline int
|
||||
_icon_size_min_get(Evas_Object *icon)
|
||||
{
|
||||
int size;
|
||||
int w, h;
|
||||
|
||||
elm_image_object_size_get(icon, &size, NULL);
|
||||
evas_object_geometry_get(icon, NULL, NULL, &w, &h);
|
||||
|
||||
return (size < 16) ? 16 : size;
|
||||
return MAX(16, MIN(w, h));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue