elementary: try to find the best icon size to display.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 23 Jun 2011 14:54:29 +0000 (14:54 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 23 Jun 2011 14:54:29 +0000 (14:54 +0000)
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.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@60636 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_icon.c
src/lib/els_icon.c

index ef62875..f4173fa 100644 (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
  *
index 0bbfc38..cf7a848 100644 (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;