elementary: try to find the best icon size to display.

This patch need review. The goal is to always find the best
quality for the output. Sadly in our theme we don't provide
multiple size for icon (we could, as edje provide this feature).
So to test it, better switch to FreeDesktop first before
trying the theme.


SVN revision: 60636
This commit is contained in:
Cedric BAIL 2011-06-23 14:54:29 +00:00
parent 2a31563c8f
commit 61f1bc4329
2 changed files with 35 additions and 7 deletions

View File

@ -654,16 +654,12 @@ _icon_size_min_get(Evas_Object *icon)
*
* @ingroup Icon
*/
EAPI Eina_Bool
elm_icon_standard_set(Evas_Object *obj, const char *name)
static Eina_Bool
_elm_icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
char *tmp;
Eina_Bool ret;
if ((!wd) || (!name)) return EINA_FALSE;
/* try locating the icon using the specified lookup order */
switch (wd->lookup_order)
{
@ -699,11 +695,39 @@ elm_icon_standard_set(Evas_Object *obj, const char *name)
if (!(tmp = strchr(name, '/'))) return EINA_FALSE;
++tmp;
if (*tmp) return elm_icon_standard_set(obj, tmp);
/* give up */
return EINA_FALSE;
}
static void
_elm_icon_standard_resize(void *data,
Evas *e __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
Widget_Data *wd = data;
if (!_elm_icon_standard_set(wd, obj, wd->stdicon))
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
_elm_icon_standard_resize, wd);
}
EAPI Eina_Bool
elm_icon_standard_set(Evas_Object *obj, const char *name)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!name)) return EINA_FALSE;
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
_elm_icon_standard_resize, wd);
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
_elm_icon_standard_resize, wd);
return _elm_icon_standard_set(wd, obj, name);
}
/**
* Get the theme, as standard, for an icon
*

View File

@ -161,6 +161,7 @@ _els_smart_icon_size_get(const Evas_Object *obj, int *w, int *h)
{
Smart_Data *sd;
int tw, th;
int cw, ch;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
@ -168,6 +169,9 @@ _els_smart_icon_size_get(const Evas_Object *obj, int *w, int *h)
edje_object_size_min_get(sd->obj, &tw, &th);
else
evas_object_image_size_get(sd->obj, &tw, &th);
evas_object_geometry_get(sd->obj, NULL, NULL, &cw, &ch);
tw = tw > cw ? tw : cw;
th = th > ch ? th : ch;
tw = ((double)tw) * sd->scale;
th = ((double)th) * sd->scale;
if (w) *w = tw;