From: Sungtaek Hong Date: Mon, 18 Dec 2017 04:55:25 +0000 (+0900) Subject: efl_ui_bg: add Efl.Ui.Bg interface X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~594 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16e1d697e112b9e1f42b7a3486a717f9c50d6c27;p=platform%2Fupstream%2Fefl.git efl_ui_bg: add Efl.Ui.Bg interface Summary: - Previous class efl_ui_bg moved to efl_ui_bg_widget. - Scale_type moved to efl_image from efl_ui_image. - Previous enum Efl_Ui_Image_Scale_Type moved to Efl_Image_Scale_Type. Test Plan: Run elementary_test 1.Image Scale Type 2.Efl.Ui.Bg 3.Efl.Ui.Win 4.Part Background Reviewers: jpeg, woohyun, cedric Differential Revision: https://phab.enlightenment.org/D5616 --- diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index ccf6a2f..111d977 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -4,6 +4,7 @@ elm_public_eolian_files = \ lib/elementary/elm_widget.eo \ lib/elementary/efl_ui_bg.eo \ + lib/elementary/efl_ui_bg_widget.eo \ lib/elementary/efl_ui_button.eo \ lib/elementary/efl_ui_calendar.eo \ lib/elementary/efl_ui_calendar_item.eo \ @@ -279,7 +280,7 @@ includesunstable_HEADERS = \ lib/elementary/elm_widget_box.h \ lib/elementary/elm_widget_bubble.h \ lib/elementary/efl_ui_button_private.h \ - lib/elementary/efl_ui_bg_private.h \ + lib/elementary/efl_ui_bg_widget_private.h \ lib/elementary/elm_widget_calendar.h \ lib/elementary/efl_ui_calendar_private.h \ lib/elementary/efl_ui_check_private.h \ @@ -399,7 +400,6 @@ includesub_HEADERS = \ lib/elementary/elm_atspi_proxy.h \ lib/elementary/elm_authors.h \ lib/elementary/elm_bg.h \ - lib/elementary/efl_ui_bg_eo.h \ lib/elementary/elm_bg_legacy.h \ lib/elementary/elm_box.h \ lib/elementary/elm_box_legacy.h \ @@ -605,6 +605,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/elm_atspi_ewk_wrapper.c \ lib/elementary/elm_atspi_proxy.c \ lib/elementary/efl_ui_bg.c \ + lib/elementary/efl_ui_bg_widget.c \ lib/elementary/elm_box.c \ lib/elementary/elm_bubble.c \ lib/elementary/efl_ui_button.c \ diff --git a/src/bin/elementary/test_bg.c b/src/bin/elementary/test_bg.c index 7ec6fe6..a0e2399 100644 --- a/src/bin/elementary/test_bg.c +++ b/src/bin/elementary/test_bg.c @@ -317,7 +317,7 @@ _image_cb(void *data, const Efl_Event *ev) { efl_file_get(ev->object, &f, &k); o = efl_add(EFL_UI_IMAGE_CLASS, win, - efl_ui_image_scale_type_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE), + efl_image_scale_type_set(efl_added, EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE), efl_file_set(efl_added, f, k) ); efl_content_set(efl_part(win, "background"), o); @@ -375,7 +375,7 @@ _cb_radio_changed_scale_type(void *data, const Efl_Event *ev) { Evas_Object *o_bg = data; - efl_ui_image_scale_type_set(o_bg, efl_ui_nstate_value_get(ev->object)); + efl_image_scale_type_set(o_bg, efl_ui_nstate_value_get(ev->object)); } static void @@ -407,7 +407,7 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_ui_win_autodel_set(efl_added, EINA_TRUE), efl_ui_win_alpha_set(efl_added, EINA_FALSE)); - efl_add(EFL_UI_BG_CLASS, win, + efl_add(EFL_UI_BG_WIDGET_CLASS, win, efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND), efl_content_set(win, efl_added)); @@ -418,7 +418,7 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); - o_bg = efl_add(EFL_UI_BG_CLASS, box, + o_bg = efl_add(EFL_UI_BG_WIDGET_CLASS, box, efl_file_set(efl_added, buf, NULL), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND), efl_gfx_size_hint_align_set(efl_added, EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL), @@ -431,14 +431,14 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_pack(box, efl_added)); rdg = rd = efl_add(EFL_UI_RADIO_CLASS, hbox, - efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FILL), + efl_ui_radio_state_value_set(efl_added, EFL_IMAGE_SCALE_TYPE_FILL), efl_text_set(efl_added, "Fill"), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0), efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg), efl_pack(hbox, efl_added)); rd = efl_add(EFL_UI_RADIO_CLASS, hbox, - efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE), + efl_ui_radio_state_value_set(efl_added, EFL_IMAGE_SCALE_TYPE_FIT_INSIDE), efl_ui_radio_group_add(efl_added, rdg), efl_text_set(efl_added, "Fit Inside"), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0), @@ -447,7 +447,7 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e rd = efl_add(EFL_UI_RADIO_CLASS, hbox, - efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE), + efl_ui_radio_state_value_set(efl_added, EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE), efl_ui_radio_group_add(efl_added, rdg), efl_text_set(efl_added, "Fit Outside"), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0), @@ -455,7 +455,7 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_pack(hbox, efl_added)); rd = efl_add(EFL_UI_RADIO_CLASS, hbox, - efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_NONE), + efl_ui_radio_state_value_set(efl_added, EFL_IMAGE_SCALE_TYPE_NONE), efl_ui_radio_group_add(efl_added, rdg), efl_text_set(efl_added, "None"), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0), @@ -463,14 +463,14 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e efl_pack(hbox, efl_added)); rd = efl_add(EFL_UI_RADIO_CLASS, hbox, - efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_TILE), + efl_ui_radio_state_value_set(efl_added, EFL_IMAGE_SCALE_TYPE_TILE), efl_ui_radio_group_add(efl_added, rdg), efl_text_set(efl_added, "Tile"), efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0), efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg), efl_pack(hbox, efl_added)); - efl_ui_nstate_value_set(rdg, EFL_UI_IMAGE_SCALE_TYPE_FILL); + efl_ui_nstate_value_set(rdg, EFL_IMAGE_SCALE_TYPE_FILL); efl_add(EFL_UI_CHECK_CLASS, hbox, efl_text_set(efl_added, "Bg Color"), diff --git a/src/bin/elementary/test_efl_gfx_map.c b/src/bin/elementary/test_efl_gfx_map.c index a05b277..1f06daf 100644 --- a/src/bin/elementary/test_efl_gfx_map.c +++ b/src/bin/elementary/test_efl_gfx_map.c @@ -54,7 +54,7 @@ test_efl_gfx_map(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, img = efl_add(EFL_UI_IMAGE_CLASS, win, efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(64, 64)), efl_file_set(efl_added, buf, NULL)); - efl_ui_image_scale_type_set(img, EFL_UI_IMAGE_SCALE_TYPE_FILL); + efl_image_scale_type_set(img, EFL_IMAGE_SCALE_TYPE_FILL); evas_object_event_callback_add(img, EVAS_CALLBACK_RESIZE, _image_resize_cb, NULL); diff --git a/src/bin/elementary/test_evas_map.c b/src/bin/elementary/test_evas_map.c index 6a7c38d..6f026cb 100644 --- a/src/bin/elementary/test_evas_map.c +++ b/src/bin/elementary/test_evas_map.c @@ -62,7 +62,7 @@ test_evas_map(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, img = efl_add(EFL_UI_IMAGE_CLASS, win, efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(64, 64)), efl_file_set(efl_added, buf, NULL)); - efl_ui_image_scale_type_set(img, EFL_UI_IMAGE_SCALE_TYPE_FILL); + efl_image_scale_type_set(img, EFL_IMAGE_SCALE_TYPE_FILL); evas_object_event_callback_add(img, EVAS_CALLBACK_RESIZE, _image_resize_cb, NULL); diff --git a/src/bin/elementary/test_image.c b/src/bin/elementary/test_image.c index 8f4f2e9..08232df 100644 --- a/src/bin/elementary/test_image.c +++ b/src/bin/elementary/test_image.c @@ -99,14 +99,14 @@ im_align_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS } static const struct { - Efl_Ui_Image_Scale_Type scale_type; + Efl_Image_Scale_Type scale_type; const char *name; } images_scale_type[] = { - { EFL_UI_IMAGE_SCALE_TYPE_NONE, "None" }, - { EFL_UI_IMAGE_SCALE_TYPE_FILL, "Fill" }, - { EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE, "Fit Inside" }, - { EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE, "Fit Outside" }, - { EFL_UI_IMAGE_SCALE_TYPE_TILE, "Tile" }, + { EFL_IMAGE_SCALE_TYPE_NONE, "None" }, + { EFL_IMAGE_SCALE_TYPE_FILL, "Fill" }, + { EFL_IMAGE_SCALE_TYPE_FIT_INSIDE, "Fit Inside" }, + { EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE, "Fit Outside" }, + { EFL_IMAGE_SCALE_TYPE_TILE, "Tile" }, { 0, NULL } }; @@ -118,9 +118,9 @@ my_im_scale_ch(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_U Evas_Object *rdg = evas_object_data_get(win, "rdg"); int v = elm_radio_value_get(rdg); - efl_ui_image_scale_type_set(im, images_scale_type[v].scale_type); + efl_image_scale_type_set(im, images_scale_type[v].scale_type); fprintf(stderr, "Set %d[%s] and got %d\n", - images_scale_type[v].scale_type, images_scale_type[v].name, efl_ui_image_scale_type_get(im)); + images_scale_type[v].scale_type, images_scale_type[v].name, efl_image_scale_type_get(im)); } void diff --git a/src/bin/elementary/test_part_bg.c b/src/bin/elementary/test_part_bg.c index c3b391b..5a68e33 100644 --- a/src/bin/elementary/test_part_bg.c +++ b/src/bin/elementary/test_part_bg.c @@ -39,7 +39,7 @@ _scale_type_cb(void *data, const Efl_Event *ev EINA_UNUSED) { Evas_Object *radio = data; Evas_Object *target; - Efl_Ui_Image_Scale_Type type; + Efl_Image_Scale_Type type; char buf[PATH_MAX]; radio = efl_ui_radio_selected_object_get(radio); @@ -47,9 +47,9 @@ _scale_type_cb(void *data, const Efl_Event *ev EINA_UNUSED) snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); efl_file_set(efl_part(target, "background"), buf, NULL); - type = efl_ui_image_scale_type_get(efl_part(target, "background")); + type = efl_image_scale_type_get(efl_part(target, "background")); type = (type + 1) % 5; - efl_ui_image_scale_type_set(efl_part(target, "background"), type); + efl_image_scale_type_set(efl_part(target, "background"), type); } static Evas_Object * @@ -136,7 +136,7 @@ test_part_background(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void content_class[10] = EFL_UI_FLIP_CLASS; content_class[11] = EFL_UI_PANES_CLASS; content_class[12] = EFL_UI_VIDEO_CLASS; - content_class[13] = EFL_UI_BG_CLASS; + content_class[13] = EFL_UI_BG_WIDGET_CLASS; content_class[14] = EFL_UI_IMAGE_CLASS; content_class[15] = EFL_UI_IMAGE_ZOOMABLE_CLASS; content_class[16] = EFL_UI_NSTATE_CLASS; diff --git a/src/examples/elementary/bg_cxx_example_02.cc b/src/examples/elementary/bg_cxx_example_02.cc index 775b8bb..96dd491 100644 --- a/src/examples/elementary/bg_cxx_example_02.cc +++ b/src/examples/elementary/bg_cxx_example_02.cc @@ -30,7 +30,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev) path = "performance/background.png"; efl::ui::Bg bg(instantiate, win); - bg.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_FILL); + bg.scale_type_set(EFL_IMAGE_SCALE_TYPE_FILL); bg.file_set(path, nullptr); win.content_set(bg); diff --git a/src/examples/elementary/icon_cxx_example_01.cc b/src/examples/elementary/icon_cxx_example_01.cc index 8ca0f2f..d7171d5 100644 --- a/src/examples/elementary/icon_cxx_example_01.cc +++ b/src/examples/elementary/icon_cxx_example_01.cc @@ -20,7 +20,7 @@ elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED) std::cout << ", name = " << icon.icon_get() << std::endl; - icon.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_NONE); + icon.scale_type_set(EFL_IMAGE_SCALE_TYPE_NONE); //icon.resizable_set(false, true); //icon.smooth_set(false); //icon.fill_outside_set(true); diff --git a/src/lib/efl/interfaces/efl_image.eo b/src/lib/efl/interfaces/efl_image.eo index 9cf3391..1e46b70 100644 --- a/src/lib/efl/interfaces/efl_image.eo +++ b/src/lib/efl/interfaces/efl_image.eo @@ -18,6 +18,28 @@ enum Efl.Image.Scale_Hint static = 2 [[Image will not be re-scaled over time, thus turning scaling cache ON for its data.]] } +enum Efl.Image.Scale_Type +{ + [[Enumeration that defines scale types of an image.]] + fill, [[Scale the image so that it matches + the object's area exactly. + The image's aspect ratio might be changed.]] + fit_inside, [[Scale the image + so that it fits inside the object's area + while maintaining the aspect ratio. + At least one of the dimensions of the image + should be equal to the corresponding dimension + of the object.]] + fit_outside, [[Scale the image + so that it covers the entire object area + while maintaining the aspect ratio. + At least one of the dimensions of the image + should be equal to the corresponding + dimension of the object.]] + tile, [[Tile image at its original size.]] + none [[Not scale the image]] +} + interface Efl.Image () { [[Common APIs for all 2D images that can be rendered on the canvas.]] @@ -39,6 +61,12 @@ interface Efl.Image () smooth_scale: bool; [[Whether to use smooth scale or not.]] } } + @property scale_type { + [[Control how the image is scaled.]] + values { + scale_type: Efl.Image.Scale_Type; [[Image scale type]] + } + } @property ratio { [[The native width/height ratio of the image.]] get { diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h index 96a7b65..e575d91 100644 --- a/src/lib/elementary/Efl_Ui.h +++ b/src/lib/elementary/Efl_Ui.h @@ -160,6 +160,8 @@ extern EAPI double _efl_startup_time; # include # include # include +# include +# include # include # include # include @@ -187,7 +189,6 @@ extern EAPI double _efl_startup_time; # include # include # include -# include # include /** diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 78eb198..361b2cd 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -297,6 +297,8 @@ EAPI extern Elm_Version *elm_version; # include # include # include +# include +# include # include # include # include diff --git a/src/lib/elementary/efl_ui_bg.c b/src/lib/elementary/efl_ui_bg.c index 4e3347b..cdf4efa 100644 --- a/src/lib/elementary/efl_ui_bg.c +++ b/src/lib/elementary/efl_ui_bg.c @@ -2,389 +2,7 @@ # include "elementary_config.h" #endif -#define EFL_ACCESS_PROTECTED -#define ELM_LAYOUT_PROTECTED - #include #include "elm_priv.h" -#include "efl_ui_bg_private.h" -#include "elm_widget_layout.h" - -#define MY_CLASS EFL_UI_BG_CLASS -#define MY_CLASS_PFX efl_ui_bg - -#define MY_CLASS_NAME "Efl.Ui.Bg" -#define MY_CLASS_NAME_LEGACY "elm_bg" - -static const Elm_Layout_Part_Alias_Description _content_aliases[] = -{ - {"overlay", "elm.swallow.content"}, - {NULL, NULL} -}; - -// TIZEN_ONLY(20160218): Improve launching performance. -static Evas_Object *_precreated_bg_obj = NULL; -// - -EOLIAN static void -_efl_ui_bg_elm_layout_sizing_eval(Eo *obj, Efl_Ui_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 fx = 0, fy = 0, fw = 0, fh = 0; - const char *p; - - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - if ((!sd->img) || (!sd->file)) return; - if (((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))) return; - - /* grab image size */ - evas_object_image_size_get(sd->img, &iw, &ih); - if ((iw < 1) || (ih < 1)) return; - - /* grab base object dimensions */ - evas_object_geometry_get - (wd->resize_obj, &bx, &by, &bw, &bh); - - switch (sd->scale_type) - { - case EFL_UI_IMAGE_SCALE_TYPE_NONE: - fw = mw = iw; - fh = mh = ih; - break; - case EFL_UI_IMAGE_SCALE_TYPE_FILL: - fw = bw; - fh = bh; - break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE: - mw = fw = bw; - mh = fh = ((ih * fw) / iw); - if (fh > bh) - { - mh = fh = bh; - mw = fw = ((iw * fh) / ih); - } - break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE: - fw = bw; - fh = ((ih * fw) / iw); - if (fh < bh) - { - fh = bh; - fw = ((iw * fh) / ih); - } - fx = ((bw - fw) / 2); - fy = ((bh - fh) / 2); - break; - case EFL_UI_IMAGE_SCALE_TYPE_TILE: - fw = iw; - fh = ih; - break; - } - - evas_object_image_fill_set(sd->img, fx, fy, fw, fh); - - evas_object_size_hint_min_set(sd->img, mw, mh); - evas_object_size_hint_max_set(sd->img, mw, mh); -} - -static void -_on_resize(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - elm_layout_sizing_eval(data); -} - -EOLIAN static void -_efl_ui_bg_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Bg_Data *priv) -{ - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - priv->rect = evas_object_rectangle_add(evas_object_evas_get(obj)); - evas_object_color_set(priv->rect, 0, 0, 0, 0); - - if (!elm_widget_theme_klass_get(obj)) - elm_widget_theme_klass_set(obj, "bg"); - efl_canvas_group_add(efl_super(obj, MY_CLASS)); - elm_widget_sub_object_parent_add(obj); - elm_widget_can_focus_set(obj, EINA_FALSE); - - priv->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; - - evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj); - - if (!elm_widget_theme_object_set(obj, wd->resize_obj, - elm_widget_theme_klass_get(obj), - elm_widget_theme_element_get(obj), - elm_widget_theme_style_get(obj))) - CRI("Failed to set layout!"); - elm_layout_content_set(obj, "elm.swallow.rectangle", priv->rect); -} - -// TIZEN_ONLY(20160218): Improve launching performance. -EAPI void -elm_bg_precreated_object_set(Evas_Object *obj) -{ - INF("Set precreated obj(%p).", obj); - _precreated_bg_obj = obj; -} - -EAPI Evas_Object * -elm_bg_precreated_object_get(void) -{ - INF("Get precreated obj(%p).", _precreated_bg_obj); - return _precreated_bg_obj; -} -// - -EAPI Evas_Object * -elm_bg_add(Evas_Object *parent) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - return elm_legacy_add(MY_CLASS, parent); -} - -EOLIAN static Eo * -_efl_ui_bg_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED) -{ - obj = efl_constructor(efl_super(obj, MY_CLASS)); - efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); - efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED); - - //TIZEN_ONLY (20171114) imporove object at xy get function - efl_access_role_set(obj, EFL_ACCESS_ROLE_REDUNDANT_OBJECT); - // - - efl_ui_widget_focus_allow_set(obj, EINA_FALSE); - - return obj; -} - -/* FIXME: Efl.Canvas.group_member_add in Elm.Widget sets child's colors as the same - * with that of obj. The color of resize_obj of Bg should not be changed - * because actual color is the color of rectangle in resize_obj. - */ -EOLIAN static void -_efl_ui_bg_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED, Evas_Object *child) -{ - efl_canvas_group_member_add(efl_super(obj, MY_CLASS), child); - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - - if (wd->resize_obj == child) - evas_object_color_set(child, 255, 255, 255, 255); -} - -EOLIAN static Eina_Bool -_efl_ui_bg_efl_file_file_set(Eo *obj, Efl_Ui_Bg_Data *sd, const char *file, const char *group) -{ - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); - - const char *p; - Eina_Bool int_ret; - - ELM_SAFE_FREE(sd->img, evas_object_del); - if (!file) - { - ELM_SAFE_FREE(sd->file, eina_stringshare_del); - ELM_SAFE_FREE(sd->group, eina_stringshare_del); - return EINA_TRUE; - } - eina_stringshare_replace(&sd->file, file); - eina_stringshare_replace(&sd->group, group); - if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj"))) - { - sd->img = edje_object_add - (evas_object_evas_get(wd->resize_obj)); - int_ret = edje_object_file_set(sd->img, file, group); - } - else - { - int err; - - sd->img = evas_object_image_add - (evas_object_evas_get(wd->resize_obj)); - evas_object_image_load_orientation_set(sd->img, EINA_TRUE); - 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", - file, evas_load_error_str(err)); - int_ret = EINA_FALSE; - } - else - int_ret = EINA_TRUE; - } - - evas_object_repeat_events_set(sd->img, EINA_TRUE); - - int_ret &= elm_layout_content_set(obj, "elm.swallow.background", sd->img); - - elm_layout_sizing_eval(obj); - - return int_ret; -} - -EOLIAN static void -_efl_ui_bg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, const char **file, const char **group) -{ - if (file) *file = sd->file; - if (group) *group = sd->group; -} - -EAPI void -elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option) -{ - EFL_UI_BG_DATA_GET(obj, sd); - switch (option) - { - case ELM_BG_OPTION_CENTER: - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_NONE; - break; - case ELM_BG_OPTION_SCALE: - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; - break; - case ELM_BG_OPTION_TILE: - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_TILE; - break; - case ELM_BG_OPTION_STRETCH: - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL; - break; - case ELM_BG_OPTION_LAST: - default: - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; - } - - elm_layout_sizing_eval(obj); -} - -EAPI Elm_Bg_Option -elm_bg_option_get(const Evas_Object *obj) -{ - Elm_Bg_Option option = ELM_BG_OPTION_LAST; - EFL_UI_BG_DATA_GET(obj, sd); - - switch (sd->scale_type) - { - case EFL_UI_IMAGE_SCALE_TYPE_NONE: - option = ELM_BG_OPTION_CENTER; - break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE: - option = ELM_BG_OPTION_SCALE; - break; - case EFL_UI_IMAGE_SCALE_TYPE_TILE: - option = ELM_BG_OPTION_TILE; - break; - case EFL_UI_IMAGE_SCALE_TYPE_FILL: - option = ELM_BG_OPTION_STRETCH; - break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE: - default: - ERR("Scale type %d cannot be converted to Elm_Bg_Option", sd->scale_type); - break; - } - return option; -} - -EOLIAN static void -_efl_ui_bg_efl_ui_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, Efl_Ui_Image_Scale_Type scale_type) -{ - sd->scale_type = scale_type; - - elm_layout_sizing_eval(obj); -} - -EOLIAN static Efl_Ui_Image_Scale_Type -_efl_ui_bg_efl_ui_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd) -{ - return sd->scale_type; -} - -EAPI void -elm_bg_color_set(Evas_Object *obj, - int r, - int g, - int b) -{ - int a = 255; - EFL_UI_BG_CHECK(obj); - - // reset color - if ((r == -1) && (g == -1) && (b == -1)) - { - r = g = b = a = 0; - } - efl_gfx_color_set(obj, r, g, b, a); -} - -EOLIAN static void -_efl_ui_bg_efl_gfx_color_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, int r, int g, int b, int a) -{ - evas_object_color_set(sd->rect, r, g, b, a); -} - -EAPI void -elm_bg_color_get(const Evas_Object *obj, - int *r, - int *g, - int *b) -{ - EFL_UI_BG_CHECK(obj); - efl_gfx_color_get((Eo *) obj, r, g, b, NULL); -} - -EOLIAN static void -_efl_ui_bg_efl_gfx_color_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, int *r, int *g, int *b, int *a) -{ - evas_object_color_get(sd->rect, r, g, b, a); -} - -EAPI void -elm_bg_load_size_set(Evas_Object *obj, int w, int h) -{ - const char *p; - EFL_UI_BG_DATA_GET(obj, sd); - - 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); -} - -static void -_efl_ui_bg_class_constructor(Efl_Class *klass) -{ - evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); -} - -EAPI Eina_Bool -elm_bg_file_set(Eo *obj, const char *file, const char *group) -{ - return efl_file_set((Eo *) obj, file, group); -} - -EAPI void -elm_bg_file_get(const Eo *obj, const char **file, const char **group) -{ - efl_file_get((Eo *) obj, file, group); -} - -/* Internal EO APIs and hidden overrides */ - -ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX) - -#define EFL_UI_BG_EXTRA_OPS \ - ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \ - ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg), \ - EFL_CANVAS_GROUP_ADD_OPS(efl_ui_bg) #include "efl_ui_bg.eo.c" diff --git a/src/lib/elementary/efl_ui_bg.eo b/src/lib/elementary/efl_ui_bg.eo index d6976da..23583bf 100644 --- a/src/lib/elementary/efl_ui_bg.eo +++ b/src/lib/elementary/efl_ui_bg.eo @@ -1,4 +1,4 @@ -class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image) +interface Efl.Ui.Bg (Efl.Interface, Efl.Gfx, Efl.Image, Efl.File) { [[The bg (background) widget is used for setting (solid) background decorations @@ -6,13 +6,4 @@ class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image) works just like an image, but has some properties useful to a background, like setting it to tiled, centered, scaled or stretched. ]] - legacy_prefix: elm_bg; - implements { - class.constructor; - Efl.Object.constructor; - Efl.Canvas.Group.group_member_add; - Efl.File.file { get; set; } - Efl.Gfx.color { get; set; } - Efl.Ui.Image.scale_type { get; set; } - } } diff --git a/src/lib/elementary/efl_ui_bg_eo.h b/src/lib/elementary/efl_ui_bg_eo.h deleted file mode 100644 index 135630e..0000000 --- a/src/lib/elementary/efl_ui_bg_eo.h +++ /dev/null @@ -1 +0,0 @@ -#include "efl_ui_bg.eo.h" \ No newline at end of file diff --git a/src/lib/elementary/efl_ui_bg_widget.c b/src/lib/elementary/efl_ui_bg_widget.c new file mode 100644 index 0000000..d1e1c73 --- /dev/null +++ b/src/lib/elementary/efl_ui_bg_widget.c @@ -0,0 +1,347 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define EFL_ACCESS_PROTECTED +#define ELM_LAYOUT_PROTECTED + +#include +#include "elm_priv.h" +#include "efl_ui_bg_widget_private.h" + +#define MY_CLASS EFL_UI_BG_WIDGET_CLASS +#define MY_CLASS_PFX efl_ui_bg_widget + +#define MY_CLASS_NAME "Efl.Ui.Bg_Widget" +#define MY_CLASS_NAME_LEGACY "elm_bg" + +static const Elm_Layout_Part_Alias_Description _content_aliases[] = +{ + {"overlay", "elm.swallow.content"}, + {NULL, NULL} +}; + +EOLIAN static void +_efl_ui_bg_widget_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Bg_Widget_Data *sd) +{ + 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; + const char *p; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + if ((!sd->img) || (!sd->file)) return; + if (((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))) return; + + /* grab image size */ + evas_object_image_size_get(sd->img, &iw, &ih); + if ((iw < 1) || (ih < 1)) return; + + /* grab base object dimensions */ + evas_object_geometry_get + (wd->resize_obj, &bx, &by, &bw, &bh); + + switch (sd->scale_type) + { + case EFL_IMAGE_SCALE_TYPE_NONE: + fw = mw = iw; + fh = mh = ih; + break; + case EFL_IMAGE_SCALE_TYPE_FILL: + fw = bw; + fh = bh; + break; + case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE: + mw = fw = bw; + mh = fh = ((ih * fw) / iw); + if (fh > bh) + { + mh = fh = bh; + mw = fw = ((iw * fh) / ih); + } + break; + case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE: + fw = bw; + fh = ((ih * fw) / iw); + if (fh < bh) + { + fh = bh; + fw = ((iw * fh) / ih); + } + fx = ((bw - fw) / 2); + fy = ((bh - fh) / 2); + break; + case EFL_IMAGE_SCALE_TYPE_TILE: + fw = iw; + fh = ih; + break; + } + + evas_object_image_fill_set(sd->img, fx, fy, fw, fh); + + evas_object_size_hint_min_set(sd->img, mw, mh); + evas_object_size_hint_max_set(sd->img, mw, mh); +} + +static void +_on_resize(void *data, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + elm_layout_sizing_eval(data); +} + +EAPI Evas_Object * +elm_bg_add(Evas_Object *parent) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); + return elm_legacy_add(MY_CLASS, parent); +} + +EOLIAN static Eo * +_efl_ui_bg_widget_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Widget_Data *pd) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + + if (!elm_widget_theme_klass_get(obj)) + elm_widget_theme_klass_set(obj, "bg"); + + obj = efl_constructor(efl_super(obj, MY_CLASS)); + elm_widget_sub_object_parent_add(obj); + elm_widget_can_focus_set(obj, EINA_FALSE); + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj); + + if (!elm_widget_theme_object_set(obj, wd->resize_obj, + elm_widget_theme_klass_get(obj), + elm_widget_theme_element_get(obj), + elm_widget_theme_style_get(obj))) + CRI("Failed to set layout!"); + + pd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE; + pd->rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, obj, + efl_gfx_color_set(efl_added, 0, 0, 0, 0), + efl_content_set(efl_part(obj, "elm.swallow.rectangle"), efl_added)); + + efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); + efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED); + + efl_ui_widget_focus_allow_set(obj, EINA_FALSE); + + return obj; +} + +EOLIAN static Eina_Bool +_efl_ui_bg_widget_efl_file_file_set(Eo *obj, Efl_Ui_Bg_Widget_Data *sd, const char *file, const char *group) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + const char *p; + Eina_Bool int_ret; + + ELM_SAFE_FREE(sd->img, evas_object_del); + if (!file) + { + ELM_SAFE_FREE(sd->file, eina_stringshare_del); + ELM_SAFE_FREE(sd->group, eina_stringshare_del); + return EINA_TRUE; + } + eina_stringshare_replace(&sd->file, file); + eina_stringshare_replace(&sd->group, group); + if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj"))) + { + sd->img = edje_object_add + (evas_object_evas_get(wd->resize_obj)); + int_ret = edje_object_file_set(sd->img, file, group); + } + else + { + int err; + + sd->img = evas_object_image_add + (evas_object_evas_get(wd->resize_obj)); + evas_object_image_load_orientation_set(sd->img, EINA_TRUE); + 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", + file, evas_load_error_str(err)); + int_ret = EINA_FALSE; + } + else + int_ret = EINA_TRUE; + } + + evas_object_repeat_events_set(sd->img, EINA_TRUE); + + int_ret &= elm_layout_content_set(obj, "elm.swallow.background", sd->img); + + elm_layout_sizing_eval(obj); + + return int_ret; +} + +EOLIAN static void +_efl_ui_bg_widget_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, const char **file, const char **group) +{ + if (file) *file = sd->file; + if (group) *group = sd->group; +} + +EAPI void +elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option) +{ + EFL_UI_BG_WIDGET_DATA_GET(obj, sd); + switch (option) + { + case ELM_BG_OPTION_CENTER: + sd->scale_type = EFL_IMAGE_SCALE_TYPE_NONE; + break; + case ELM_BG_OPTION_SCALE: + sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE; + break; + case ELM_BG_OPTION_TILE: + sd->scale_type = EFL_IMAGE_SCALE_TYPE_TILE; + break; + case ELM_BG_OPTION_STRETCH: + sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL; + break; + case ELM_BG_OPTION_LAST: + default: + sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE; + } + + elm_layout_sizing_eval(obj); +} + +EAPI Elm_Bg_Option +elm_bg_option_get(const Evas_Object *obj) +{ + Elm_Bg_Option option = ELM_BG_OPTION_LAST; + EFL_UI_BG_WIDGET_DATA_GET(obj, sd); + + switch (sd->scale_type) + { + case EFL_IMAGE_SCALE_TYPE_NONE: + option = ELM_BG_OPTION_CENTER; + break; + case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE: + option = ELM_BG_OPTION_SCALE; + break; + case EFL_IMAGE_SCALE_TYPE_TILE: + option = ELM_BG_OPTION_TILE; + break; + case EFL_IMAGE_SCALE_TYPE_FILL: + option = ELM_BG_OPTION_STRETCH; + break; + case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE: + default: + ERR("Scale type %d cannot be converted to Elm_Bg_Option", sd->scale_type); + break; + } + return option; +} + +EOLIAN static void +_efl_ui_bg_widget_efl_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, Efl_Image_Scale_Type scale_type) +{ + sd->scale_type = scale_type; + + elm_layout_sizing_eval(obj); +} + +EOLIAN static Efl_Image_Scale_Type +_efl_ui_bg_widget_efl_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd) +{ + return sd->scale_type; +} + +EAPI void +elm_bg_color_set(Evas_Object *obj, + int r, + int g, + int b) +{ + int a = 255; + EFL_UI_BG_WIDGET_CHECK(obj); + + // reset color + if ((r == -1) && (g == -1) && (b == -1)) + { + r = g = b = a = 0; + } + efl_gfx_color_set(obj, r, g, b, a); +} + +EOLIAN static void +_efl_ui_bg_widget_efl_gfx_color_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, int r, int g, int b, int a) +{ + efl_gfx_color_set(sd->rect, r, g, b, a); +} + +EAPI void +elm_bg_color_get(const Evas_Object *obj, + int *r, + int *g, + int *b) +{ + EFL_UI_BG_WIDGET_CHECK(obj); + efl_gfx_color_get((Eo *) obj, r, g, b, NULL); +} + +EOLIAN static void +_efl_ui_bg_widget_efl_gfx_color_get(Eo *obj, Efl_Ui_Bg_Widget_Data *sd, int *r, int *g, int *b, int *a) +{ + if (!sd->rect) + efl_gfx_color_get(efl_super(obj, MY_CLASS), r, g, b, a); + else + efl_gfx_color_get(sd->rect, r, g, b, a); +} + +EAPI void +elm_bg_load_size_set(Evas_Object *obj, int w, int h) +{ + const char *p; + EFL_UI_BG_WIDGET_DATA_GET(obj, sd); + + 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); +} + +static void +_efl_ui_bg_widget_class_constructor(Efl_Class *klass) +{ + evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); +} + +EAPI Eina_Bool +elm_bg_file_set(Eo *obj, const char *file, const char *group) +{ + return efl_file_set((Eo *) obj, file, group); +} + +EAPI void +elm_bg_file_get(const Eo *obj, const char **file, const char **group) +{ + efl_file_get((Eo *) obj, file, group); +} + +/* Internal EO APIs and hidden overrides */ + +ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX) + +#define EFL_UI_BG_WIDGET_EXTRA_OPS \ + ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \ + ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg_widget) + +#include "efl_ui_bg_widget.eo.c" diff --git a/src/lib/elementary/efl_ui_bg_widget.eo b/src/lib/elementary/efl_ui_bg_widget.eo new file mode 100644 index 0000000..837126d --- /dev/null +++ b/src/lib/elementary/efl_ui_bg_widget.eo @@ -0,0 +1,18 @@ +class Efl.Ui.Bg_Widget (Efl.Ui.Layout, Efl.Ui.Bg) +{ + [[The bg (background) widget is used for setting (solid) background decorations + + to a window (unless it has transparency enabled) or to any container object. It + works just like an image, but has some properties useful to a background, like + setting it to tiled, centered, scaled or stretched. + ]] + legacy_prefix: elm_bg; + implements { + class.constructor; + Efl.Object.constructor; + Efl.File.file { get; set; } + //Efl.File.mmap { get; set; } + Efl.Gfx.color { get; set; } + Efl.Image.scale_type { get; set; } + } +} diff --git a/src/lib/elementary/efl_ui_bg_private.h b/src/lib/elementary/efl_ui_bg_widget_private.h similarity index 71% rename from src/lib/elementary/efl_ui_bg_private.h rename to src/lib/elementary/efl_ui_bg_widget_private.h index 311fd44..d95095e 100644 --- a/src/lib/elementary/efl_ui_bg_private.h +++ b/src/lib/elementary/efl_ui_bg_widget_private.h @@ -23,13 +23,13 @@ /** * Base layout smart data extended with bg instance data. */ -typedef struct _Efl_Ui_Bg_Data Efl_Ui_Bg_Data; -struct _Efl_Ui_Bg_Data +typedef struct _Efl_Ui_Bg_Widget_Data Efl_Ui_Bg_Widget_Data; +struct _Efl_Ui_Bg_Widget_Data { Evas_Object *rect; /*<< Used for elm_bg_color_set(): elm.swallow.rectangle */ Evas_Object *img; /*<< Used for elm_bg_file_set(): elm.swallow.content */ const char *file, *group; /*<< path to file and group name to give life to "img": elm.swallow.background */ - Efl_Ui_Image_Scale_Type scale_type; + Efl_Image_Scale_Type scale_type; struct { @@ -41,11 +41,11 @@ struct _Efl_Ui_Bg_Data * @} */ -#define EFL_UI_BG_DATA_GET(o, sd) \ -Efl_Ui_Bg_Data * sd = efl_data_scope_get(o, EFL_UI_BG_CLASS) +#define EFL_UI_BG_WIDGET_DATA_GET(o, sd) \ +Efl_Ui_Bg_Widget_Data * sd = efl_data_scope_get(o, EFL_UI_BG_WIDGET_CLASS) -#define EFL_UI_BG_DATA_GET_OR_RETURN(o, ptr) \ - EFL_UI_BG_DATA_GET(o, ptr); \ +#define EFL_UI_BG_WIDGET_DATA_GET_OR_RETURN(o, ptr) \ + EFL_UI_BG_WIDGET_DATA_GET(o, ptr); \ if (EINA_UNLIKELY(!ptr)) \ { \ CRI("No widget data for object %p (%s)", \ @@ -53,8 +53,8 @@ Efl_Ui_Bg_Data * sd = efl_data_scope_get(o, EFL_UI_BG_CLASS) return; \ } -#define EFL_UI_BG_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ - EFL_UI_BG_DATA_GET(o, ptr); \ +#define EFL_UI_BG_WIDGET_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ + EFL_UI_BG_WIDGET_DATA_GET(o, ptr); \ if (EINA_UNLIKELY(!ptr)) \ { \ CRI("No widget data for object %p (%s)", \ @@ -62,8 +62,8 @@ Efl_Ui_Bg_Data * sd = efl_data_scope_get(o, EFL_UI_BG_CLASS) return val; \ } -#define EFL_UI_BG_CHECK(obj) \ - if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_CLASS))) \ +#define EFL_UI_BG_WIDGET_CHECK(obj) \ + if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_WIDGET_CLASS))) \ return #endif diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c index a9f0157..696413d 100644 --- a/src/lib/elementary/efl_ui_image.c +++ b/src/lib/elementary/efl_ui_image.c @@ -181,15 +181,15 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img) // according to (iw x ih), (sd->img_w x sd->img_h), and scale_type switch (sd->scale_type) { - case EFL_UI_IMAGE_SCALE_TYPE_NONE: + case EFL_IMAGE_SCALE_TYPE_NONE: w = iw; h = ih; break; - case EFL_UI_IMAGE_SCALE_TYPE_FILL: + case EFL_IMAGE_SCALE_TYPE_FILL: w = sd->img_w; h = sd->img_h; break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE: + case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE: w = sd->img_w; h = ((double)ih * w) / (double)iw; @@ -206,7 +206,7 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img) h = ih; } break; - case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE: + case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE: w = sd->img_w; h = ((double)ih * w) / (double)iw; if (h < sd->img_h) @@ -222,7 +222,7 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img) h = ih; } break; - case EFL_UI_IMAGE_SCALE_TYPE_TILE: + case EFL_IMAGE_SCALE_TYPE_TILE: x = sd->img_x; y = sd->img_y; w = sd->img_w; @@ -866,7 +866,7 @@ _efl_ui_image_efl_object_constructor(Eo *obj, Efl_Ui_Image_Data *pd) evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); efl_access_role_set(obj, EFL_ACCESS_ROLE_IMAGE); - pd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; + pd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE; pd->self = obj; return obj; @@ -1524,7 +1524,7 @@ _efl_ui_image_class_constructor(Efl_Class *klass) } EOLIAN static void -_efl_ui_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNUSED, Efl_Ui_Image_Scale_Type scale_type) +_efl_ui_image_efl_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNUSED, Efl_Image_Scale_Type scale_type) { if (scale_type == sd->scale_type) return; @@ -1533,8 +1533,8 @@ _efl_ui_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNU _efl_ui_image_internal_sizing_eval(obj, sd); } -EOLIAN static Efl_Ui_Image_Scale_Type -_efl_ui_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd) +EOLIAN static Efl_Image_Scale_Type +_efl_ui_image_efl_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd) { return sd->scale_type; } @@ -2077,11 +2077,11 @@ elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside) if (sd->aspect_fixed) { - if (sd->fill_inside) sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; - else sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; + if (sd->fill_inside) sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE; + else sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE; } else - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL; + sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL; _efl_ui_image_internal_sizing_eval(obj, sd); } @@ -2250,11 +2250,11 @@ elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed) if (sd->aspect_fixed) { - if (sd->fill_inside) sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; - else sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; + if (sd->fill_inside) sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE; + else sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE; } else - sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL; + sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL; _efl_ui_image_sizing_eval(obj); } diff --git a/src/lib/elementary/efl_ui_image.eo b/src/lib/elementary/efl_ui_image.eo index 91a601c..9a568ae 100644 --- a/src/lib/elementary/efl_ui_image.eo +++ b/src/lib/elementary/efl_ui_image.eo @@ -1,28 +1,3 @@ -enum Efl.Ui.Image.Scale_Type -{ - [[Enumeration that defines scale types for the object's internal image. - - @since 1.18 - ]] - fill, [[Scale the internal image so that it matches - the object's area exactly. - The image's aspect ratio might be changed.]] - fit_inside, [[Scale the internal image - so that it fits inside the object's area - while maintaining the aspect ratio. - At least one of the dimensions of the image - should be equal to the corresponding dimension - of the object.]] - fit_outside, [[Scale the internal image - so that it covers the entire object area - while maintaining the aspect ratio. - At least one of the dimensions of the image - should be equal to the corresponding - dimension of the object.]] - tile, [[Tile image at its original size.]] - none [[Not scale the internal image]] -} - struct Efl.Ui.Image.Progress { [[ @@ -53,14 +28,6 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable, [[ Efl UI image class]] event_prefix: efl_ui_image; methods { - @property scale_type { - [[Control how the internal image is scaled. - - @since 1.18]] - values { - scale_type: Efl.Ui.Image.Scale_Type; [[Image scale type]] - } - } @property scalable { [[Enable or disable scaling up or down the internal image. @@ -133,6 +100,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable, Efl.Image.image_size { get; } Efl.Image.Load.load_size { get; set; } Efl.Image.smooth_scale { get; set; } + Efl.Image.scale_type { get; set; } Efl.Orientation.orientation { get; set; } Efl.Flipable.flip { get; set; } Efl.Player.playable { get; } diff --git a/src/lib/elementary/efl_ui_widget_image.h b/src/lib/elementary/efl_ui_widget_image.h index 4c91f8f..88759c4 100644 --- a/src/lib/elementary/efl_ui_widget_image.h +++ b/src/lib/elementary/efl_ui_widget_image.h @@ -76,7 +76,7 @@ struct _Efl_Ui_Image_Data } async; Efl_Ui_Image_Preload_Status preload_status; - Efl_Ui_Image_Scale_Type scale_type; + Efl_Image_Scale_Type scale_type; const char *stdicon; diff --git a/src/lib/elementary/efl_ui_widget_part_bg.eo b/src/lib/elementary/efl_ui_widget_part_bg.eo index f35d4f6..d624ffc 100644 --- a/src/lib/elementary/efl_ui_widget_part_bg.eo +++ b/src/lib/elementary/efl_ui_widget_part_bg.eo @@ -6,6 +6,6 @@ class Efl.Ui.Widget.Part_Bg (Efl.Ui.Widget.Part, Efl.Ui.Bg) Efl.File.file { get; set; } //Efl.File.mmap { get; set; } Efl.Gfx.color { set; get; } - Efl.Ui.Image.scale_type { get; set; } + Efl.Image.scale_type { get; set; } } } diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 99eea62..82dbd1a 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -7812,7 +7812,7 @@ _elm_win_standard_init(Eo *obj) /* Legacy theme compatibility */ DBG("Detected legacy theme used for elm_bg. Swallowing object."); sd->csd.need_bg_solid = EINA_FALSE; - _elm_win_bg_set(sd, efl_add(EFL_UI_BG_CLASS, obj)); + _elm_win_bg_set(sd, efl_add(EFL_UI_BG_WIDGET_CLASS, obj)); } _elm_win_frame_style_update(sd, 0, 1); @@ -7922,7 +7922,7 @@ _efl_ui_win_part_file_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *part, const if (file) { bg = efl_add(EFL_UI_IMAGE_CLASS, obj); - efl_ui_image_scale_type_set(bg, EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE); + efl_image_scale_type_set(bg, EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE); ok = efl_file_set(bg, file, key); if (!ok) ELM_SAFE_DEL(bg); _elm_win_bg_set(sd, bg); diff --git a/src/lib/elementary/elm_bg.h b/src/lib/elementary/elm_bg.h index c11c342..030f83e 100644 --- a/src/lib/elementary/elm_bg.h +++ b/src/lib/elementary/elm_bg.h @@ -29,9 +29,6 @@ * @li @ref bg_03_example_page */ -#ifdef EFL_EO_API_SUPPORT -#include "efl_ui_bg_eo.h" -#endif #ifndef EFL_NOLEGACY_API_SUPPORT #include "elm_bg_legacy.h" #endif diff --git a/src/lib/elementary/elm_bg_legacy.h b/src/lib/elementary/elm_bg_legacy.h index 0ed5848..ed2c455 100644 --- a/src/lib/elementary/elm_bg_legacy.h +++ b/src/lib/elementary/elm_bg_legacy.h @@ -193,4 +193,4 @@ EAPI void elm_bg_precreated_object_set(Evas_Object *obj); EAPI Evas_Object *elm_bg_precreated_object_get(void); // -#include "efl_ui_bg.eo.legacy.h" +#include "efl_ui_bg_widget.eo.legacy.h" diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index 3130556..60644b4 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -6408,7 +6408,7 @@ _efl_ui_widget_bg_get(Elm_Widget *obj) if (!bg_obj) { - bg_obj = efl_add(EFL_UI_BG_CLASS, obj); + bg_obj = efl_add(EFL_UI_BG_WIDGET_CLASS, obj); EINA_SAFETY_ON_NULL_RETURN_VAL(bg_obj, NULL); sd->bg = bg_obj; efl_canvas_group_member_add(obj, sd->bg); @@ -6459,19 +6459,19 @@ _efl_ui_widget_part_bg_efl_gfx_color_get(Eo *obj, void *pd EINA_UNUSED, int *r, } EOLIAN static void -_efl_ui_widget_part_bg_efl_ui_image_scale_type_set(Eo *obj, void *pd EINA_UNUSED, Efl_Ui_Image_Scale_Type scale_type) +_efl_ui_widget_part_bg_efl_image_scale_type_set(Eo *obj, void *pd EINA_UNUSED, Efl_Image_Scale_Type scale_type) { Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); - efl_ui_image_scale_type_set(bg_obj, scale_type); + efl_image_scale_type_set(bg_obj, scale_type); } -EOLIAN static Efl_Ui_Image_Scale_Type -_efl_ui_widget_part_bg_efl_ui_image_scale_type_get(Eo *obj, void *pd EINA_UNUSED) +EOLIAN static Efl_Image_Scale_Type +_efl_ui_widget_part_bg_efl_image_scale_type_get(Eo *obj, void *pd EINA_UNUSED) { Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); - return efl_ui_image_scale_type_get(bg_obj); + return efl_image_scale_type_get(bg_obj); } #include "efl_ui_widget_part_bg.eo.c"