From: Enlightenment S. <no-...@en...> - 2011-02-14 16:38:25
|
Log: elementary/elm_bg - added new api elm_bg_load_size_set Author: hermet Date: 2011-02-14 08:38:18 -0800 (Mon, 14 Feb 2011) New Revision: 57029 Trac: http://trac.enlightenment.org/e/changeset/57029 Modified: trunk/elementary/src/lib/Elementary.h.in trunk/elementary/src/lib/elm_bg.c Modified: trunk/elementary/src/lib/Elementary.h.in =================================================================== --- trunk/elementary/src/lib/Elementary.h.in 2011-02-14 16:22:31 UTC (rev 57028) +++ trunk/elementary/src/lib/Elementary.h.in 2011-02-14 16:38:18 UTC (rev 57029) @@ -590,6 +590,7 @@ 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: */ Modified: trunk/elementary/src/lib/elm_bg.c =================================================================== --- trunk/elementary/src/lib/elm_bg.c 2011-02-14 16:22:31 UTC (rev 57028) +++ trunk/elementary/src/lib/elm_bg.c 2011-02-14 16:38:18 UTC (rev 57029) @@ -15,6 +15,9 @@ 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 @@ 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 @@ 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 @@ _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); +} + |