jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=6ba6a0faa5b72e5202d5c1cb4a804c3b5b9c00dd
commit 6ba6a0faa5b72e5202d5c1cb4a804c3b5b9c00dd Author: Daniel Zaoui <[email protected]> Date: Wed Mar 19 15:27:27 2014 +0200 Eolian: Integration of Bg --- src/lib/Makefile.am | 10 ++- src/lib/elm_bg.c | 177 ++++++++---------------------------------------- src/lib/elm_bg.eo | 149 ++++++++++++++++++++++++++++++++++++++++ src/lib/elm_bg_eo.h | 4 ++ src/lib/elm_widget_bg.h | 6 +- 5 files changed, 192 insertions(+), 154 deletions(-) diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index e9159e8..91804c5 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -555,7 +555,9 @@ BUILT_SOURCES = \ elm_interface_atspi_window.eo.c \ elm_interface_atspi_window.eo.h \ elm_atspi_object.eo.c \ - elm_atspi_object.eo.h + elm_atspi_object.eo.h \ + elm_bg.eo.c \ + elm_bg.eo.h EXTRA_DIST += \ elm_widget.eo \ @@ -573,7 +575,8 @@ EXTRA_DIST += \ elm_app_server_view.eo \ elm_interface_atspi_component.eo \ elm_interface_atspi_window.eo \ - elm_atspi_object.eo + elm_atspi_object.eo \ + elm_bg.eo nodist_includesunstable_HEADERS = \ elm_widget.eo.h \ @@ -591,5 +594,6 @@ nodist_includesunstable_HEADERS = \ elm_app_server_view.eo.h \ elm_interface_atspi_component.eo.h \ elm_interface_atspi_window.eo.h \ - elm_atspi_object.eo.h + elm_atspi_object.eo.h \ + elm_bg.eo.h diff --git a/src/lib/elm_bg.c b/src/lib/elm_bg.c index ef8792d..3a24d9d 100644 --- a/src/lib/elm_bg.c +++ b/src/lib/elm_bg.c @@ -7,8 +7,6 @@ #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" @@ -20,8 +18,8 @@ static const Elm_Layout_Part_Alias_Description _content_aliases[] = {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; @@ -29,7 +27,6 @@ _elm_bg_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 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; @@ -101,10 +98,9 @@ _on_resize(void *data, 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); @@ -118,11 +114,10 @@ _elm_bg_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 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 * @@ -134,8 +129,8 @@ elm_bg_add(Evas_Object *parent) 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)); @@ -154,25 +149,10 @@ _elm_bg_file_reload(void *data, Evas_Object *obj, 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; @@ -182,8 +162,7 @@ _file_set(Eo *obj, void *_pd, va_list *list) { 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); @@ -225,64 +204,28 @@ _file_set(Eo *obj, void *_pd, va_list *list) 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 @@ -295,14 +238,9 @@ elm_bg_color_set(Evas_Object *obj, 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 @@ -335,33 +273,15 @@ elm_bg_color_get(const Evas_Object *obj, 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; @@ -373,48 +293,9 @@ _load_size_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list) } 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" diff --git a/src/lib/elm_bg.eo b/src/lib/elm_bg.eo new file mode 100644 index 0000000..67beaa5 --- /dev/null +++ b/src/lib/elm_bg.eo @@ -0,0 +1,149 @@ +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; + } + +} diff --git a/src/lib/elm_bg_eo.h b/src/lib/elm_bg_eo.h index ca0ebd4..e449526 100644 --- a/src/lib/elm_bg_eo.h +++ b/src/lib/elm_bg_eo.h @@ -1,3 +1,6 @@ +#include "elm_bg.eo.h" + +#if 0 #define ELM_OBJ_BG_CLASS elm_obj_bg_class_get() const Eo_Class *elm_obj_bg_class_get(void) EINA_CONST; @@ -128,3 +131,4 @@ enum * @ingroup Bg */ #define elm_obj_bg_load_size_set(w, h) ELM_OBJ_BG_ID(ELM_OBJ_BG_SUB_ID_LOAD_SIZE_SET), EO_TYPECHECK(Evas_Coord, w), EO_TYPECHECK(Evas_Coord, h) +#endif diff --git a/src/lib/elm_widget_bg.h b/src/lib/elm_widget_bg.h index dbf427b..e878a3f 100644 --- a/src/lib/elm_widget_bg.h +++ b/src/lib/elm_widget_bg.h @@ -17,8 +17,8 @@ /** * Base layout smart data extended with bg instance data. */ -typedef struct _Elm_Bg_Smart_Data Elm_Bg_Smart_Data; -struct _Elm_Bg_Smart_Data +typedef struct _Elm_Bg_Data Elm_Bg_Data; +struct _Elm_Bg_Data { /* the basic background's edje object has three swallow spots, namely: * - "elm.swallow.rectangle" (elm_bg_color_set), @@ -42,7 +42,7 @@ struct _Elm_Bg_Smart_Data */ #define ELM_BG_DATA_GET(o, sd) \ - Elm_Bg_Smart_Data * sd = eo_data_scope_get(o, ELM_OBJ_BG_CLASS) + Elm_Bg_Data * sd = eo_data_scope_get(o, ELM_OBJ_BG_CLASS) #define ELM_BG_DATA_GET_OR_RETURN(o, ptr) \ ELM_BG_DATA_GET(o, ptr); \ --
