forked from enlightenment/efl
[Elm] Elm bg now happily inherits from elm
layout. SVN revision: 70632
This commit is contained in:
parent
e6ab50005c
commit
837c6d2354
|
@ -1,75 +1,90 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#include "elm_priv.h"
|
#include "elm_priv.h"
|
||||||
|
#include "elm_widget_layout.h"
|
||||||
|
|
||||||
typedef struct _Widget_Data Widget_Data;
|
static const char BG_SMART_NAME[] = "elm_bg";
|
||||||
|
|
||||||
struct _Widget_Data
|
typedef struct _Elm_Bg_Smart_Data Elm_Bg_Smart_Data;
|
||||||
|
|
||||||
|
struct _Elm_Bg_Smart_Data
|
||||||
{
|
{
|
||||||
Evas_Object *base, *rect, *img, *overlay;
|
Elm_Layout_Smart_Data base;
|
||||||
const char *file, *group;
|
|
||||||
Elm_Bg_Option option;
|
/* the basic background's edje object has three swallow spots, namely:
|
||||||
|
* - "elm.swallow.rectangle" (elm_bg_color_set),
|
||||||
|
* - "elm.swallow.background" (elm_bg_file_set) and
|
||||||
|
* - "elm.swallow.content" (elm_bg_overlay_set).
|
||||||
|
* the following three variables hold possible content to fit in each
|
||||||
|
* of them, respectively. */
|
||||||
|
|
||||||
|
Evas_Object *rect, *img;
|
||||||
|
const char *file, *group; /* path to file and group name
|
||||||
|
* to give life to "img" */
|
||||||
|
Elm_Bg_Option option;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Evas_Coord w, h;
|
Evas_Coord w, h;
|
||||||
} load_opts;
|
} load_opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *widtype = NULL;
|
#define ELM_BG_DATA_GET(o, sd) \
|
||||||
|
Elm_Bg_Smart_Data * sd = evas_object_smart_data_get(o)
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
#define ELM_BG_DATA_GET_OR_RETURN(o, ptr) \
|
||||||
static void _theme_hook(Evas_Object *obj);
|
ELM_BG_DATA_GET(o, ptr); \
|
||||||
static void _custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info);
|
if (!ptr) \
|
||||||
static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
|
{ \
|
||||||
static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
|
CRITICAL("No widget data for object %p (%s)", \
|
||||||
static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
|
o, evas_object_type_get(o)); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ELM_BG_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
||||||
|
ELM_BG_DATA_GET(o, ptr); \
|
||||||
|
if (!ptr) \
|
||||||
|
{ \
|
||||||
|
CRITICAL("No widget data for object %p (%s)", \
|
||||||
|
o, evas_object_type_get(o)); \
|
||||||
|
return val; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ELM_BG_CHECK(obj) \
|
||||||
|
if (!obj || !elm_widget_type_check((obj), BG_SMART_NAME, __func__)) \
|
||||||
|
return
|
||||||
|
|
||||||
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
||||||
|
{
|
||||||
|
{"overlay", "elm.swallow.content"},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Inheriting from elm_layout. Besides, we need no more than what is
|
||||||
|
* there */
|
||||||
|
EVAS_SMART_SUBCLASS_NEW
|
||||||
|
(BG_SMART_NAME, _elm_bg, Elm_Layout_Smart_Class, Elm_Layout_Smart_Class,
|
||||||
|
elm_layout_smart_class_get, NULL);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_elm_bg_smart_sizing_eval(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
|
||||||
free(wd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_theme_hook(Evas_Object *obj)
|
|
||||||
{
|
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
|
||||||
Evas_Coord w, h;
|
|
||||||
|
|
||||||
_elm_theme_object_set(obj, wd->base, "bg", "base",
|
|
||||||
elm_widget_style_get(obj));
|
|
||||||
|
|
||||||
if (wd->rect)
|
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.rectangle", wd->rect);
|
|
||||||
if (wd->img)
|
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.background", wd->img);
|
|
||||||
if (wd->overlay)
|
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.content", wd->overlay);
|
|
||||||
|
|
||||||
// FIXME: if i don't do this, bg doesnt calc correctly. why?
|
|
||||||
evas_object_geometry_get(wd->base, NULL, NULL, &w, &h);
|
|
||||||
evas_object_resize(wd->base, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_custom_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
Widget_Data *wd = data;
|
|
||||||
Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
|
|
||||||
Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
|
Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
|
||||||
|
Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
|
||||||
Evas_Coord fx = 0, fy = 0, fw = 0, fh = 0;
|
Evas_Coord fx = 0, fy = 0, fw = 0, fh = 0;
|
||||||
Evas_Coord nx = 0, ny = 0, nw = 0, nh = 0;
|
Evas_Coord nx = 0, ny = 0, nw = 0, nh = 0;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
if ((!wd->img) || (!wd->file)) return;
|
ELM_BG_DATA_GET(obj, sd);
|
||||||
if (((p = strrchr(wd->file, '.'))) && (!strcasecmp(p, ".edj"))) return;
|
|
||||||
|
if ((!sd->img) || (!sd->file)) return;
|
||||||
|
if (((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))) return;
|
||||||
|
|
||||||
/* grab image size */
|
/* grab image size */
|
||||||
evas_object_image_size_get(wd->img, &iw, &ih);
|
evas_object_image_size_get(sd->img, &iw, &ih);
|
||||||
if ((iw < 1) || (ih < 1)) return;
|
if ((iw < 1) || (ih < 1)) return;
|
||||||
|
|
||||||
/* grab base object dimensions */
|
/* grab base object dimensions */
|
||||||
evas_object_geometry_get(wd->base, &bx, &by, &bw, &bh);
|
evas_object_geometry_get
|
||||||
|
(ELM_WIDGET_DATA(sd)->resize_obj, &bx, &by, &bw, &bh);
|
||||||
|
|
||||||
/* set some defaults */
|
/* set some defaults */
|
||||||
nx = bx;
|
nx = bx;
|
||||||
|
@ -77,248 +92,246 @@ _custom_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void
|
||||||
nw = bw;
|
nw = bw;
|
||||||
nh = bh;
|
nh = bh;
|
||||||
|
|
||||||
switch (wd->option)
|
switch (sd->option)
|
||||||
{
|
{
|
||||||
case ELM_BG_OPTION_CENTER:
|
case ELM_BG_OPTION_CENTER:
|
||||||
fw = nw = iw;
|
fw = nw = iw;
|
||||||
fh = nh = ih;
|
fh = nh = ih;
|
||||||
nx = ((bw - fw) / 2);
|
nx = ((bw - fw) / 2);
|
||||||
ny = ((bh - fh) / 2);
|
ny = ((bh - fh) / 2);
|
||||||
mw = iw;
|
mw = iw;
|
||||||
mh = ih;
|
mh = ih;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELM_BG_OPTION_SCALE:
|
case ELM_BG_OPTION_SCALE:
|
||||||
fw = bw;
|
fw = bw;
|
||||||
fh = ((ih * fw) / iw);
|
fh = ((ih * fw) / iw);
|
||||||
if (fh < bh)
|
if (fh < bh)
|
||||||
{
|
{
|
||||||
fh = bh;
|
fh = bh;
|
||||||
fw = ((iw * fh) / ih);
|
fw = ((iw * fh) / ih);
|
||||||
}
|
}
|
||||||
fx = ((bw - fw) / 2);
|
fx = ((bw - fw) / 2);
|
||||||
fy = ((bh - fh) / 2);
|
fy = ((bh - fh) / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELM_BG_OPTION_TILE:
|
case ELM_BG_OPTION_TILE:
|
||||||
fw = iw;
|
fw = iw;
|
||||||
fh = ih;
|
fh = ih;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELM_BG_OPTION_STRETCH:
|
case ELM_BG_OPTION_STRETCH:
|
||||||
default:
|
default:
|
||||||
fw = bw;
|
fw = bw;
|
||||||
fh = bh;
|
fh = bh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_object_move(wd->img, nx, ny);
|
evas_object_move(sd->img, nx, ny);
|
||||||
evas_object_resize(wd->img, nw, nh);
|
evas_object_resize(sd->img, nw, nh);
|
||||||
evas_object_image_fill_set(wd->img, fx, fy, fw, fh);
|
evas_object_image_fill_set(sd->img, fx, fy, fw, fh);
|
||||||
|
|
||||||
evas_object_size_hint_min_set(wd->img, mw, mh);
|
evas_object_size_hint_min_set(sd->img, mw, mh);
|
||||||
evas_object_size_hint_max_set(wd->img, mw, mh);
|
evas_object_size_hint_max_set(sd->img, mw, mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
|
_on_resize(void *data,
|
||||||
|
Evas *e __UNUSED__,
|
||||||
|
Evas_Object *obj __UNUSED__,
|
||||||
|
void *event_info __UNUSED__)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
elm_layout_sizing_eval(data);
|
||||||
Widget_Data *wd;
|
|
||||||
if (part && strcmp(part, "overlay")) return;
|
|
||||||
wd = elm_widget_data_get(obj);
|
|
||||||
if (!wd) return;
|
|
||||||
|
|
||||||
if (content == wd->overlay) return;
|
|
||||||
if (wd->overlay) evas_object_del(wd->overlay);
|
|
||||||
|
|
||||||
wd->overlay = content;
|
|
||||||
if (content)
|
|
||||||
{
|
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
|
|
||||||
elm_widget_sub_object_add(obj, content);
|
|
||||||
}
|
|
||||||
|
|
||||||
_custom_resize(wd, NULL, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static void
|
||||||
_content_get_hook(const Evas_Object *obj, const char *part)
|
_elm_bg_smart_add(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
EVAS_SMART_DATA_ALLOC(obj, Elm_Bg_Smart_Data);
|
||||||
Widget_Data *wd;
|
|
||||||
if (part && strcmp(part, "overlay")) return NULL;
|
ELM_WIDGET_CLASS(_elm_bg_parent_sc)->base.add(obj);
|
||||||
wd = elm_widget_data_get(obj);
|
|
||||||
if (!wd) return NULL;
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||||
return wd->overlay;
|
|
||||||
|
priv->option = ELM_BG_OPTION_SCALE;
|
||||||
|
|
||||||
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
|
||||||
|
|
||||||
|
elm_layout_theme_set(obj, "bg", "base", elm_widget_style_get(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static void
|
||||||
_content_unset_hook(Evas_Object *obj, const char *part)
|
_elm_bg_smart_set_user(Elm_Layout_Smart_Class *sc)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
ELM_WIDGET_CLASS(sc)->base.add = _elm_bg_smart_add;
|
||||||
Widget_Data *wd;
|
|
||||||
Evas_Object *overlay;
|
sc->sizing_eval = _elm_bg_smart_sizing_eval;
|
||||||
if (part && strcmp(part, "overlay")) return NULL;
|
|
||||||
wd = elm_widget_data_get(obj);
|
sc->content_aliases = _content_aliases;
|
||||||
if (!wd || !wd->overlay) return NULL;
|
|
||||||
overlay = wd->overlay;
|
|
||||||
elm_widget_sub_object_del(obj, wd->overlay);
|
|
||||||
edje_object_part_unswallow(wd->base, wd->overlay);
|
|
||||||
wd->overlay = NULL;
|
|
||||||
_custom_resize(wd, NULL, NULL, NULL);
|
|
||||||
return overlay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_bg_add(Evas_Object *parent)
|
elm_bg_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Evas_Object *obj;
|
|
||||||
Evas *e;
|
Evas *e;
|
||||||
Widget_Data *wd;
|
Evas_Object *obj;
|
||||||
|
|
||||||
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
||||||
|
|
||||||
ELM_SET_WIDTYPE(widtype, "bg");
|
e = evas_object_evas_get(parent);
|
||||||
elm_widget_type_set(obj, "bg");
|
if (!e) return NULL;
|
||||||
elm_widget_sub_object_add(parent, obj);
|
|
||||||
elm_widget_data_set(obj, wd);
|
|
||||||
elm_widget_del_hook_set(obj, _del_hook);
|
|
||||||
elm_widget_theme_hook_set(obj, _theme_hook);
|
|
||||||
elm_widget_content_set_hook_set(obj, _content_set_hook);
|
|
||||||
elm_widget_content_get_hook_set(obj, _content_get_hook);
|
|
||||||
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
|
|
||||||
|
|
||||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
obj = evas_object_smart_add(e, _elm_bg_smart_class_new());
|
||||||
|
|
||||||
wd->base = edje_object_add(e);
|
if (!elm_widget_sub_object_add(parent, obj))
|
||||||
_elm_theme_object_set(obj, wd->base, "bg", "base", "default");
|
ERR("could not add %p as sub object of %p", obj, parent);
|
||||||
elm_widget_resize_object_set(obj, wd->base);
|
|
||||||
|
|
||||||
evas_object_event_callback_add(wd->base, EVAS_CALLBACK_RESIZE,
|
|
||||||
_custom_resize, wd);
|
|
||||||
|
|
||||||
wd->option = ELM_BG_OPTION_SCALE;
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
elm_bg_file_set(Evas_Object *obj, const char *file, const char *group)
|
elm_bg_file_set(Evas_Object *obj,
|
||||||
|
const char *file,
|
||||||
|
const char *group)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
ELM_BG_CHECK(obj) EINA_FALSE;
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
ELM_BG_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
|
||||||
const char *p;
|
|
||||||
|
|
||||||
if (wd->img)
|
const char *p;
|
||||||
|
Eina_Bool ret;
|
||||||
|
|
||||||
|
if (sd->img)
|
||||||
{
|
{
|
||||||
evas_object_del(wd->img);
|
evas_object_del(sd->img);
|
||||||
wd->img = NULL;
|
sd->img = NULL;
|
||||||
}
|
}
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(wd->file);
|
eina_stringshare_del(sd->file);
|
||||||
wd->file = NULL;
|
sd->file = NULL;
|
||||||
eina_stringshare_del(wd->group);
|
eina_stringshare_del(sd->group);
|
||||||
wd->group = NULL;
|
sd->group = NULL;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
eina_stringshare_replace(&wd->file, file);
|
eina_stringshare_replace(&sd->file, file);
|
||||||
eina_stringshare_replace(&wd->group, group);
|
eina_stringshare_replace(&sd->group, group);
|
||||||
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
|
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
|
||||||
{
|
{
|
||||||
wd->img = edje_object_add(evas_object_evas_get(wd->base));
|
sd->img = edje_object_add
|
||||||
edje_object_file_set(wd->img, file, group);
|
(evas_object_evas_get(ELM_WIDGET_DATA(sd)->resize_obj));
|
||||||
|
ret = edje_object_file_set(sd->img, file, group);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wd->img = evas_object_image_add(evas_object_evas_get(wd->base));
|
int err;
|
||||||
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);
|
sd->img = evas_object_image_add
|
||||||
evas_object_image_file_set(wd->img, file, group);
|
(evas_object_evas_get(ELM_WIDGET_DATA(sd)->resize_obj));
|
||||||
|
if ((sd->load_opts.w > 0) && (sd->load_opts.h > 0))
|
||||||
|
evas_object_image_load_size_set
|
||||||
|
(sd->img, sd->load_opts.w, sd->load_opts.h);
|
||||||
|
evas_object_image_file_set(sd->img, file, group);
|
||||||
|
|
||||||
|
err = evas_object_image_load_error_get(sd->img);
|
||||||
|
if (err != EVAS_LOAD_ERROR_NONE)
|
||||||
|
{
|
||||||
|
ERR("Could not load image '%s': %s\n",
|
||||||
|
file, evas_load_error_str(err));
|
||||||
|
ret = EINA_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = EINA_TRUE;
|
||||||
}
|
}
|
||||||
evas_object_repeat_events_set(wd->img, EINA_TRUE);
|
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.background", wd->img);
|
|
||||||
elm_widget_sub_object_add(obj, wd->img);
|
|
||||||
_custom_resize(wd, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
return EINA_TRUE;
|
evas_object_repeat_events_set(sd->img, EINA_TRUE);
|
||||||
|
|
||||||
|
ret &= elm_layout_content_set(obj, "elm.swallow.background", sd->img);
|
||||||
|
|
||||||
|
elm_layout_sizing_eval(obj);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_bg_file_get(const Evas_Object *obj, const char **file, const char **group)
|
elm_bg_file_get(const Evas_Object *obj,
|
||||||
|
const char **file,
|
||||||
|
const char **group)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
ELM_BG_CHECK(obj);
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
ELM_BG_DATA_GET_OR_RETURN(obj, sd);
|
||||||
if (file) *file = wd->file;
|
|
||||||
if (group) *group = wd->group;
|
|
||||||
|
|
||||||
return;
|
if (file) *file = sd->file;
|
||||||
|
if (group) *group = sd->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
|
elm_bg_option_set(Evas_Object *obj,
|
||||||
|
Elm_Bg_Option option)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
ELM_BG_CHECK(obj);
|
||||||
Widget_Data *wd;
|
ELM_BG_DATA_GET_OR_RETURN(obj, sd);
|
||||||
|
|
||||||
wd = elm_widget_data_get(obj);
|
sd->option = option;
|
||||||
wd->option = option;
|
|
||||||
_custom_resize(wd, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
return;
|
elm_layout_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Elm_Bg_Option
|
EAPI Elm_Bg_Option
|
||||||
elm_bg_option_get(const Evas_Object *obj)
|
elm_bg_option_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype) ELM_BG_OPTION_LAST;
|
ELM_BG_CHECK(obj) EINA_FALSE;
|
||||||
Widget_Data *wd;
|
ELM_BG_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_BG_OPTION_LAST);
|
||||||
|
|
||||||
wd = elm_widget_data_get(obj);
|
return sd->option;
|
||||||
return wd->option;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_bg_color_set(Evas_Object *obj, int r, int g, int b)
|
elm_bg_color_set(Evas_Object *obj,
|
||||||
|
int r,
|
||||||
|
int g,
|
||||||
|
int b)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
ELM_BG_CHECK(obj);
|
||||||
Widget_Data *wd;
|
ELM_BG_DATA_GET_OR_RETURN(obj, sd);
|
||||||
|
|
||||||
wd = elm_widget_data_get(obj);
|
if (!sd->rect)
|
||||||
if (!wd->rect)
|
|
||||||
{
|
{
|
||||||
wd->rect = evas_object_rectangle_add(evas_object_evas_get(wd->base));
|
sd->rect = evas_object_rectangle_add
|
||||||
edje_object_part_swallow(wd->base, "elm.swallow.rectangle", wd->rect);
|
(evas_object_evas_get(ELM_WIDGET_DATA(sd)->resize_obj));
|
||||||
elm_widget_sub_object_add(obj, wd->rect);
|
|
||||||
_custom_resize(wd, NULL, NULL, NULL);
|
elm_layout_content_set(obj, "elm.swallow.rectangle", sd->rect);
|
||||||
|
|
||||||
|
elm_layout_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
evas_object_color_set(wd->rect, r, g, b, 255);
|
|
||||||
|
|
||||||
return;
|
evas_object_color_set(sd->rect, r, g, b, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b)
|
elm_bg_color_get(const Evas_Object *obj,
|
||||||
|
int *r,
|
||||||
|
int *g,
|
||||||
|
int *b)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
ELM_BG_CHECK(obj);
|
||||||
Widget_Data *wd;
|
ELM_BG_DATA_GET_OR_RETURN(obj, sd);
|
||||||
|
|
||||||
wd = elm_widget_data_get(obj);
|
evas_object_color_get(sd->rect, r, g, b, NULL);
|
||||||
evas_object_color_get(wd->rect, r, g, b, NULL);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_bg_load_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
elm_bg_load_size_set(Evas_Object *obj,
|
||||||
|
Evas_Coord w,
|
||||||
|
Evas_Coord h)
|
||||||
{
|
{
|
||||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
ELM_BG_CHECK(obj);
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
ELM_BG_DATA_GET_OR_RETURN(obj, sd);
|
||||||
const char *p;
|
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);
|
|
||||||
|
|
||||||
return;
|
sd->load_opts.w = w;
|
||||||
|
sd->load_opts.h = h;
|
||||||
|
if (!sd->img) return;
|
||||||
|
|
||||||
|
if (!(((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))))
|
||||||
|
evas_object_image_load_size_set(sd->img, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* @defgroup Bg Bg
|
* @defgroup Bg Background
|
||||||
* @ingroup Elementary
|
* @ingroup Elementary
|
||||||
*
|
*
|
||||||
* @image html img/widget/bg/preview-00.png
|
* @image html img/widget/bg/preview-00.png
|
||||||
|
@ -14,8 +14,11 @@
|
||||||
* properties useful to a background, like setting it to tiled,
|
* properties useful to a background, like setting it to tiled,
|
||||||
* centered, scaled or stretched.
|
* centered, scaled or stretched.
|
||||||
*
|
*
|
||||||
|
* This widget inherits from the @ref Layout one, so that all the
|
||||||
|
* functions acting on it also work for background objects.
|
||||||
|
*
|
||||||
* Default content parts of the bg widget that you can use for are:
|
* Default content parts of the bg widget that you can use for are:
|
||||||
* @li "overlay" - overlay of the bg
|
* @li @c "overlay" - overlay of the bg
|
||||||
*
|
*
|
||||||
* Supported elm_object common APIs.
|
* Supported elm_object common APIs.
|
||||||
* @li @ref elm_object_part_content_set
|
* @li @ref elm_object_part_content_set
|
||||||
|
|
Loading…
Reference in New Issue