#include "elm_widget_bg.h"
#include "elm_widget_layout.h"
-EAPI Eo_Op ELM_OBJ_BG_BASE_ID = EO_NOOP;
-
#define MY_CLASS ELM_OBJ_BG_CLASS
#define MY_CLASS_NAME "Elm_Bg"
{NULL, NULL}
};
-static void
-_elm_bg_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd)
{
Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
Evas_Coord nx = 0, ny = 0, nw = 0, nh = 0;
const char *p;
- Elm_Bg_Smart_Data *sd = _pd;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
if ((!sd->img) || (!sd->file)) return;
elm_layout_sizing_eval(data);
}
-static void
-_elm_bg_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_bg_evas_smart_add(Eo *obj, Elm_Bg_Data *priv)
{
- Elm_Bg_Smart_Data *priv = _pd;
eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
elm_widget_sub_object_parent_add(obj);
CRI("Failed to set layout!");
}
-static void
-_elm_bg_smart_content_aliases_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
+EOLIAN static const Elm_Layout_Part_Alias_Description*
+_elm_bg_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *_pd EINA_UNUSED)
{
- const Elm_Layout_Part_Alias_Description **aliases = va_arg(*list, const Elm_Layout_Part_Alias_Description **);
- *aliases = _content_aliases;
+ return _content_aliases;
}
EAPI Evas_Object *
return obj;
}
-static void
-_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
+EOLIAN static void
+_elm_bg_eo_base_constructor(Eo *obj, Elm_Bg_Data *_pd EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, evas_obj_type_set(MY_CLASS_NAME_LEGACY));
elm_bg_file_set(bg, file, group);
}
-EAPI Eina_Bool
-elm_bg_file_set(Evas_Object *obj,
- const char *file,
- const char *group)
+EOLIAN static Eina_Bool
+_elm_bg_file_set(Eo *obj, Elm_Bg_Data *sd, const char *file, const char *group)
{
- ELM_BG_CHECK(obj) EINA_FALSE;
- Eina_Bool ret = EINA_FALSE;
- eo_do(obj, elm_obj_bg_file_set(file, group, &ret));
- return ret;
-}
-
-static void
-_file_set(Eo *obj, void *_pd, va_list *list)
-{
- const char *file = va_arg(*list, const char *);
- const char *group = va_arg(*list, const char *);
- Eina_Bool *ret = va_arg(*list, Eina_Bool *);
- Elm_Bg_Smart_Data *sd = _pd;
- ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
const char *p;
Eina_Bool int_ret;
{
ELM_SAFE_FREE(sd->file, eina_stringshare_del);
ELM_SAFE_FREE(sd->group, eina_stringshare_del);
- if (ret) *ret = EINA_TRUE;
- return;
+ return EINA_TRUE;
}
eina_stringshare_replace(&sd->file, file);
eina_stringshare_replace(&sd->group, group);
elm_layout_sizing_eval(obj);
- if (ret) *ret = int_ret;
+ return int_ret;
}
-EAPI void
-elm_bg_file_get(const Evas_Object *obj,
- const char **file,
- const char **group)
-{
- ELM_BG_CHECK(obj);
- eo_do((Eo *) obj, elm_obj_bg_file_get(file, group));
-}
-
-static void
-_file_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_bg_file_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, const char **file, const char **group)
{
- const char **file = va_arg(*list, const char **);
- const char **group = va_arg(*list, const char **);
- Elm_Bg_Smart_Data *sd = _pd;
-
if (file) *file = sd->file;
if (group) *group = sd->group;
}
-EAPI void
-elm_bg_option_set(Evas_Object *obj,
- Elm_Bg_Option option)
+EOLIAN static void
+_elm_bg_option_set(Eo *obj, Elm_Bg_Data *sd, Elm_Bg_Option option)
{
- ELM_BG_CHECK(obj);
- eo_do(obj, elm_obj_bg_option_set(option));
-}
-
-static void
-_option_set(Eo *obj, void *_pd, va_list *list)
-{
- Elm_Bg_Option option = va_arg(*list, Elm_Bg_Option);
- Elm_Bg_Smart_Data *sd = _pd;
-
sd->option = option;
elm_layout_sizing_eval(obj);
}
-EAPI Elm_Bg_Option
-elm_bg_option_get(const Evas_Object *obj)
+EOLIAN static Elm_Bg_Option
+_elm_bg_option_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd)
{
- ELM_BG_CHECK(obj) ELM_BG_OPTION_LAST;
- Elm_Bg_Option ret = ELM_BG_OPTION_LAST;
- eo_do((Eo *) obj, elm_obj_bg_option_get(&ret));
- return ret;
-}
-
-static void
-_option_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
-{
- Elm_Bg_Option *ret = va_arg(*list, Elm_Bg_Option *);
- Elm_Bg_Smart_Data *sd = _pd;
-
- *ret = sd->option;
+ return sd->option;
}
EAPI void
eo_do(obj, elm_obj_bg_color_set(r, g, b, 255));
}
-static void
-_color_set(Eo *obj, void *_pd, va_list *list)
+EOLIAN static void
+_elm_bg_color_set(Eo *obj, Elm_Bg_Data *sd, int r, int g, int b, int a)
{
- int r = va_arg(*list, int);
- int g = va_arg(*list, int);
- int b = va_arg(*list, int);
- int a = va_arg(*list, int);
- Elm_Bg_Smart_Data *sd = _pd;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
// reset color
eo_do((Eo *) obj, elm_obj_bg_color_get(r, g, b, NULL));
}
-static void
-_color_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_bg_color_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, int *r, int *g, int *b, int *a)
{
- int *r = va_arg(*list, int *);
- int *g = va_arg(*list, int *);
- int *b = va_arg(*list, int *);
- int *a = va_arg(*list, int *);
- Elm_Bg_Smart_Data *sd = _pd;
-
evas_object_color_get(sd->rect, r, g, b, a);
}
-EAPI void
-elm_bg_load_size_set(Evas_Object *obj,
- Evas_Coord w,
- Evas_Coord h)
-{
- ELM_BG_CHECK(obj);
- eo_do(obj, elm_obj_bg_load_size_set(w, h));
-}
-
-static void
-_load_size_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+EOLIAN static void
+_elm_bg_load_size_set(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, Evas_Coord w, Evas_Coord h)
{
- Evas_Coord w = va_arg(*list, Evas_Coord);
- Evas_Coord h = va_arg(*list, Evas_Coord);
- Elm_Bg_Smart_Data *sd = _pd;
const char *p;
sd->load_opts.w = w;
}
static void
-_class_constructor(Eo_Class *klass)
+_elm_bg_class_constructor(Eo_Class *klass)
{
- const Eo_Op_Func_Description func_desc[] = {
- EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
- EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_bg_smart_add),
-
- EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_bg_smart_sizing_eval),
- EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_CONTENT_ALIASES_GET), _elm_bg_smart_content_aliases_get),
-
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_FILE_SET), _file_set),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_FILE_GET), _file_get),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_OPTION_SET), _option_set),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_OPTION_GET), _option_get),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_COLOR_SET), _color_set),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_COLOR_GET), _color_get),
- EO_OP_FUNC(ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_LOAD_SIZE_SET), _load_size_set),
- EO_OP_FUNC_SENTINEL
- };
- eo_class_funcs_set(klass, func_desc);
-
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}
-static const Eo_Op_Description op_desc[] = {
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_FILE_SET, "Set the file (image or edje collection) to give life for the background."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_FILE_GET, "Get the file (image or edje collection) set on a given background."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_OPTION_SET, "Set the mode of display for a given background widget's image."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_OPTION_GET, "Get the mode of display for a given background widget's image."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_COLOR_SET, "Set the color on a given background widget."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_COLOR_GET, "Get the color set on a given background widget."),
- EO_OP_DESCRIPTION(ELM_OBJ_BG_SUB_ID_LOAD_SIZE_SET, "Set the size of the pixmap representation of the image set on a given background widget."),
- EO_OP_DESCRIPTION_SENTINEL
-};
-
-static const Eo_Class_Description class_desc = {
- EO_VERSION,
- MY_CLASS_NAME,
- EO_CLASS_TYPE_REGULAR,
- EO_CLASS_DESCRIPTION_OPS(&ELM_OBJ_BG_BASE_ID, op_desc, ELM_OBJ_BG_SUB_ID_LAST),
- NULL,
- sizeof(Elm_Bg_Smart_Data),
- _class_constructor,
- NULL
-};
-EO_DEFINE_CLASS(elm_obj_bg_class_get, &class_desc, ELM_OBJ_LAYOUT_CLASS, NULL);
+#include "elm_bg.eo.c"
--- /dev/null
+class Elm_Bg (Elm_Layout)
+{
+ eo_prefix: elm_obj_bg;
+ properties {
+ option {
+ set {
+ /*@
+ Set the mode of display for a given background widget's image
+
+ This sets how the background widget will display its image. This
+ will only work if the elm_bg_file_set() was previously called with
+ an image file on @a obj. The image can be display tiled, scaled,
+ centered or stretched.
+
+ @see elm_bg_option_get()
+
+ @ingroup Bg */
+ }
+ get {
+ /*@
+ Get the mode of display for a given background widget's image
+
+ @return The image displaying mode in use for @a obj or #ELM_BG_OPTION_LAST,
+ on errors.
+
+ @see elm_bg_option_set() for more details
+
+ @ingroup Bg */
+ }
+ values {
+ Elm_Bg_Option option; /*@ The desired background option (see #Elm_Bg_Option) */
+ }
+ }
+ color {
+ set {
+ /*@
+ Set the color on a given background widget
+
+ This sets the color used for the background rectangle, in RGB
+ format. Each color component's range is from 0 to 255.
+
+ @note You probably only want to use this function if you haven't
+ previously called elm_bg_file_set(), so that you just want a solid
+ color background.
+
+ @note You can reset the color by setting @p r, @p g, @p b as -1, -1, -1.
+
+ @see elm_bg_color_get()
+
+ @ingroup Bg */
+ legacy null; /* legacy doesn't have 'a' param */
+ }
+ get {
+ /*@
+ Get the color set on a given background widget
+
+ @note Use @c NULL pointers on the file components you're not
+ interested in: they'll be ignored by the function.
+
+ @see elm_bg_color_get() for more details
+
+ @ingroup Bg */
+ legacy null; /* legacy doesn't have 'a' param */
+ }
+ values {
+ int r; /*@ The red color component's value */
+ int g; /*@ The green color component's value */
+ int b; /*@ The blue color component's value */
+ int a; /*@ The blue color component's value */
+ }
+ }
+ file {
+ set {
+ /*@
+ Set the file (image or edje collection) to give life for the
+ background
+
+ @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
+
+ This sets the image file used in the background object. If the
+ image comes from an Edje group, it will be stretched to completely
+ fill the background object. If it comes from a traditional image file, it
+ will by default be centered in this widget's are (thus retaining
+ its aspect), what could lead to some parts being not visible. You
+ may change the mode of exhibition for a real image file with
+ elm_bg_option_set().
+
+ @note Once the image of @p obj is set, a previously set one will be
+ deleted, even if @p file is @c NULL.
+
+ @note This will only affect the contents of one of the background's
+ swallow spots, namely @c "elm.swallow.background". If you want to
+ achieve the @c Layout's file setting behavior, you'll have to call
+ that method on this object.
+
+ @ingroup Bg */
+ return Eina_Bool;
+ }
+ get {
+ /*@
+ Get the file (image or edje collection) set on a given background
+ widget
+
+ @note Use @c NULL pointers on the file components you're not
+ interested in: they'll be ignored by the function.
+
+ @ingroup Bg */
+ }
+ values {
+ const char *file; /*@ The file path */
+ const char *group; /*@ Optional key (group in Edje) within the file */
+ }
+ }
+ load_size {
+ set {
+ /*@
+ Set the size of the pixmap representation of the image set on a
+ given background widget.
+
+ @warning This function just makes sense if an image file was set on
+ @p obj, with elm_bg_file_set().
+
+ This function sets a new size for pixmap representation of the
+ given bg image. It allows for the image to be loaded already in the
+ specified size, reducing the memory usage and load time (for
+ example, when loading a big image file with its load size set to a
+ smaller size)
+
+ @note This is just a hint for the underlying system. The real size
+ of the pixmap may differ depending on the type of image being
+ loaded, being bigger than requested.
+
+ @ingroup Bg */
+ }
+ values {
+ Evas_Coord w; /*@ The new width of the image pixmap representation. */
+ Evas_Coord h; /*@ The new height of the image pixmap representation. */
+ }
+ }
+ }
+ implements {
+ class::constructor;
+ Eo_Base::constructor;
+ Evas_Smart::add;
+ Elm_Layout::content_aliases::get;
+ Elm_Layout::sizing_eval;
+ }
+
+}