elementary/elm_bg - added new api elm_bg_load_size_set
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 14 Feb 2011 16:38:18 +0000 (16:38 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 14 Feb 2011 16:38:18 +0000 (16:38 +0000)
git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@57029 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Elementary.h.in
src/lib/elm_bg.c

index 90ffd56..64ac1b1 100644 (file)
@@ -590,6 +590,7 @@ extern "C" {
    EAPI void          elm_bg_overlay_set(Evas_Object *obj, Evas_Object *overlay) EINA_ARG_NONNULL(1);
    EAPI Evas_Object  *elm_bg_overlay_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
    EAPI Evas_Object  *elm_bg_overlay_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
+   EAPI void          elm_bg_load_size_set(Evas_Object *obj, int w, int h);
    /* smart callbacks called:
     */
 
index 50dd1e0..9ad7a3d 100644 (file)
@@ -15,6 +15,9 @@ struct _Widget_Data
    Evas_Object *base, *rect, *img, *overlay;
    const char  *file, *group;
    Elm_Bg_Option option;
+   struct {
+      int w, h;
+   } load_opts;
 };
 
 static const char *widtype = NULL;
@@ -182,8 +185,8 @@ elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
 
    if (wd->img)
      {
-       evas_object_del(wd->img);
-       wd->img = NULL;
+        evas_object_del(wd->img);
+        wd->img = NULL;
      }
    if (!file)
      {
@@ -197,13 +200,15 @@ elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
    eina_stringshare_replace(&wd->group, group);
    if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
      {
-       wd->img = edje_object_add(evas_object_evas_get(wd->base));
-       edje_object_file_set(wd->img, file, group);
+        wd->img = edje_object_add(evas_object_evas_get(wd->base));
+        edje_object_file_set(wd->img, file, group);
      }
    else
      {
-       wd->img = evas_object_image_add(evas_object_evas_get(wd->base));
-       evas_object_image_file_set(wd->img, file, group);
+        wd->img = evas_object_image_add(evas_object_evas_get(wd->base));
+        if ((wd->load_opts.w > 0) && (wd->load_opts.h > 0))
+           evas_object_image_load_size_set(wd->img, wd->load_opts.w, wd->load_opts.h);
+        evas_object_image_file_set(wd->img, file, group);
      }
    evas_object_repeat_events_set(wd->img, EINA_TRUE);
    edje_object_part_swallow(wd->base, "elm.swallow.background", wd->img);
@@ -396,3 +401,28 @@ elm_bg_overlay_unset(Evas_Object *obj)
    _custom_resize(wd, NULL, NULL, NULL);
    return overlay;
 }
+
+/**
+ * Set the size of a loaded image of the canvas of the bg.
+ *
+ * @param obj The bg object
+ * @param w The new width of the canvas image given.
+ * @param h The new height of the canvas image given.
+ *
+ * This function sets a new size for the canvas image of the given the bg.
+ *
+ */
+EAPI void
+elm_bg_load_size_set(Evas_Object *obj, int w, int h)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);   
+   Widget_Data *wd = elm_widget_data_get(obj);
+   const char *p;
+   if (!wd) return;
+   wd->load_opts.w = w;
+   wd->load_opts.h = h;
+   if (!wd->img) return;
+   if (!(((p = strrchr(wd->file, '.'))) && (!strcasecmp(p, ".edj"))))
+      evas_object_image_load_size_set(wd->img, w, h);
+}
+