summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorSungtaek Hong <sth253.hong@samsung.com>2017-12-18 13:55:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-12-18 20:49:45 +0900
commit25136ddf8ccbf384b21d89a7ce3939c1d4db00a6 (patch)
tree4d467b7a2abcfc727e5dbb288c77218178530e9f /src/lib
parent147ef4f91deb99d44c67cbb37fa737d42d8a1792 (diff)
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/efl/interfaces/efl_image.eo28
-rw-r--r--src/lib/elementary/Efl_Ui.h3
-rw-r--r--src/lib/elementary/Elementary.h2
-rw-r--r--src/lib/elementary/efl_ui_bg.c358
-rw-r--r--src/lib/elementary/efl_ui_bg.eo11
-rw-r--r--src/lib/elementary/efl_ui_bg_eo.h1
-rw-r--r--src/lib/elementary/efl_ui_bg_widget.c347
-rw-r--r--src/lib/elementary/efl_ui_bg_widget.eo18
-rw-r--r--src/lib/elementary/efl_ui_bg_widget_private.h (renamed from src/lib/elementary/efl_ui_bg_private.h)22
-rw-r--r--src/lib/elementary/efl_ui_image.c30
-rw-r--r--src/lib/elementary/efl_ui_image.eo34
-rw-r--r--src/lib/elementary/efl_ui_widget_image.h2
-rw-r--r--src/lib/elementary/efl_ui_widget_part_bg.eo2
-rw-r--r--src/lib/elementary/efl_ui_win.c4
-rw-r--r--src/lib/elementary/elm_bg.h3
-rw-r--r--src/lib/elementary/elm_bg_legacy.h2
-rw-r--r--src/lib/elementary/elm_widget.c12
17 files changed, 436 insertions, 443 deletions
diff --git a/src/lib/efl/interfaces/efl_image.eo b/src/lib/efl/interfaces/efl_image.eo
index 9cf3391e4d..1e46b70769 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
18 static = 2 [[Image will not be re-scaled over time, thus turning scaling cache ON for its data.]] 18 static = 2 [[Image will not be re-scaled over time, thus turning scaling cache ON for its data.]]
19} 19}
20 20
21enum Efl.Image.Scale_Type
22{
23 [[Enumeration that defines scale types of an image.]]
24 fill, [[Scale the image so that it matches
25 the object's area exactly.
26 The image's aspect ratio might be changed.]]
27 fit_inside, [[Scale the image
28 so that it fits inside the object's area
29 while maintaining the aspect ratio.
30 At least one of the dimensions of the image
31 should be equal to the corresponding dimension
32 of the object.]]
33 fit_outside, [[Scale the image
34 so that it covers the entire object area
35 while maintaining the aspect ratio.
36 At least one of the dimensions of the image
37 should be equal to the corresponding
38 dimension of the object.]]
39 tile, [[Tile image at its original size.]]
40 none [[Not scale the image]]
41}
42
21interface Efl.Image () 43interface Efl.Image ()
22{ 44{
23 [[Common APIs for all 2D images that can be rendered on the canvas.]] 45 [[Common APIs for all 2D images that can be rendered on the canvas.]]
@@ -39,6 +61,12 @@ interface Efl.Image ()
39 smooth_scale: bool; [[Whether to use smooth scale or not.]] 61 smooth_scale: bool; [[Whether to use smooth scale or not.]]
40 } 62 }
41 } 63 }
64 @property scale_type {
65 [[Control how the image is scaled.]]
66 values {
67 scale_type: Efl.Image.Scale_Type; [[Image scale type]]
68 }
69 }
42 @property ratio { 70 @property ratio {
43 [[The native width/height ratio of the image.]] 71 [[The native width/height ratio of the image.]]
44 get { 72 get {
diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h
index 96a7b65259..e575d9195f 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;
160# include <efl_ui_layout_part_text.eo.h> 160# include <efl_ui_layout_part_text.eo.h>
161# include <efl_ui_layout_part_table.eo.h> 161# include <efl_ui_layout_part_table.eo.h>
162# include <efl_ui_win_part.eo.h> 162# include <efl_ui_win_part.eo.h>
163# include <efl_ui_bg.eo.h>
164# include <efl_ui_bg_widget.eo.h>
163# include <efl_ui_box.eo.h> 165# include <efl_ui_box.eo.h>
164# include <efl_ui_box_flow.eo.h> 166# include <efl_ui_box_flow.eo.h>
165# include <efl_ui_box_stack.eo.h> 167# include <efl_ui_box_stack.eo.h>
@@ -187,7 +189,6 @@ extern EAPI double _efl_startup_time;
187# include <efl_ui_image_zoomable_eo.h> 189# include <efl_ui_image_zoomable_eo.h>
188# include <efl_ui_progressbar_eo.h> 190# include <efl_ui_progressbar_eo.h>
189# include <efl_ui_radio_eo.h> 191# include <efl_ui_radio_eo.h>
190# include <efl_ui_bg_eo.h>
191# include <efl_ui_panes_eo.h> 192# include <efl_ui_panes_eo.h>
192 193
193/** 194/**
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index e404d6b3ab..1fc4f5419a 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -293,6 +293,8 @@ EAPI extern Elm_Version *elm_version;
293# include <efl_ui_layout_part_text.eo.h> 293# include <efl_ui_layout_part_text.eo.h>
294# include <efl_ui_layout_part_table.eo.h> 294# include <efl_ui_layout_part_table.eo.h>
295# include <efl_ui_win_part.eo.h> 295# include <efl_ui_win_part.eo.h>
296# include <efl_ui_bg.eo.h>
297# include <efl_ui_bg_widget.eo.h>
296# include <efl_ui_box.eo.h> 298# include <efl_ui_box.eo.h>
297# include <efl_ui_box_flow.eo.h> 299# include <efl_ui_box_flow.eo.h>
298# include <efl_ui_box_stack.eo.h> 300# include <efl_ui_box_stack.eo.h>
diff --git a/src/lib/elementary/efl_ui_bg.c b/src/lib/elementary/efl_ui_bg.c
index 79991a2179..cdf4efa2f5 100644
--- a/src/lib/elementary/efl_ui_bg.c
+++ b/src/lib/elementary/efl_ui_bg.c
@@ -2,365 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#define EFL_ACCESS_PROTECTED
6#define ELM_LAYOUT_PROTECTED
7
8#include <Elementary.h> 5#include <Elementary.h>
9#include "elm_priv.h" 6#include "elm_priv.h"
10#include "efl_ui_bg_private.h"
11#include "elm_widget_layout.h"
12
13#define MY_CLASS EFL_UI_BG_CLASS
14#define MY_CLASS_PFX efl_ui_bg
15
16#define MY_CLASS_NAME "Efl.Ui.Bg"
17#define MY_CLASS_NAME_LEGACY "elm_bg"
18
19static const Elm_Layout_Part_Alias_Description _content_aliases[] =
20{
21 {"overlay", "elm.swallow.content"},
22 {NULL, NULL}
23};
24
25EOLIAN static void
26_efl_ui_bg_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Bg_Data *sd)
27{
28 Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
29 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
30 Evas_Coord fx = 0, fy = 0, fw = 0, fh = 0;
31 const char *p;
32
33 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
34
35 if ((!sd->img) || (!sd->file)) return;
36 if (((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))) return;
37
38 /* grab image size */
39 evas_object_image_size_get(sd->img, &iw, &ih);
40 if ((iw < 1) || (ih < 1)) return;
41
42 /* grab base object dimensions */
43 evas_object_geometry_get
44 (wd->resize_obj, &bx, &by, &bw, &bh);
45
46 switch (sd->scale_type)
47 {
48 case EFL_UI_IMAGE_SCALE_TYPE_NONE:
49 fw = mw = iw;
50 fh = mh = ih;
51 break;
52 case EFL_UI_IMAGE_SCALE_TYPE_FILL:
53 fw = bw;
54 fh = bh;
55 break;
56 case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE:
57 mw = fw = bw;
58 mh = fh = ((ih * fw) / iw);
59 if (fh > bh)
60 {
61 mh = fh = bh;
62 mw = fw = ((iw * fh) / ih);
63 }
64 break;
65 case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
66 fw = bw;
67 fh = ((ih * fw) / iw);
68 if (fh < bh)
69 {
70 fh = bh;
71 fw = ((iw * fh) / ih);
72 }
73 fx = ((bw - fw) / 2);
74 fy = ((bh - fh) / 2);
75 break;
76 case EFL_UI_IMAGE_SCALE_TYPE_TILE:
77 fw = iw;
78 fh = ih;
79 break;
80 }
81
82 evas_object_image_fill_set(sd->img, fx, fy, fw, fh);
83
84 evas_object_size_hint_min_set(sd->img, mw, mh);
85 evas_object_size_hint_max_set(sd->img, mw, mh);
86}
87
88static void
89_on_resize(void *data,
90 Evas *e EINA_UNUSED,
91 Evas_Object *obj EINA_UNUSED,
92 void *event_info EINA_UNUSED)
93{
94 elm_layout_sizing_eval(data);
95}
96
97EOLIAN static void
98_efl_ui_bg_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Bg_Data *priv)
99{
100 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
101
102 priv->rect = evas_object_rectangle_add(evas_object_evas_get(obj));
103 evas_object_color_set(priv->rect, 0, 0, 0, 0);
104
105 if (!elm_widget_theme_klass_get(obj))
106 elm_widget_theme_klass_set(obj, "bg");
107 efl_canvas_group_add(efl_super(obj, MY_CLASS));
108 elm_widget_sub_object_parent_add(obj);
109 elm_widget_can_focus_set(obj, EINA_FALSE);
110
111 priv->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
112
113 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
114
115 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
116 elm_widget_theme_klass_get(obj),
117 elm_widget_theme_element_get(obj),
118 elm_widget_theme_style_get(obj)))
119 CRI("Failed to set layout!");
120 elm_layout_content_set(obj, "elm.swallow.rectangle", priv->rect);
121}
122
123EAPI Evas_Object *
124elm_bg_add(Evas_Object *parent)
125{
126 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
127 return elm_legacy_add(MY_CLASS, parent);
128}
129
130EOLIAN static Eo *
131_efl_ui_bg_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED)
132{
133 obj = efl_constructor(efl_super(obj, MY_CLASS));
134 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
135 efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED);
136
137 efl_ui_widget_focus_allow_set(obj, EINA_FALSE);
138
139 return obj;
140}
141
142/* FIXME: Efl.Canvas.group_member_add in Elm.Widget sets child's colors as the same
143 * with that of obj. The color of resize_obj of Bg should not be changed
144 * because actual color is the color of rectangle in resize_obj.
145 */
146EOLIAN static void
147_efl_ui_bg_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED, Evas_Object *child)
148{
149 efl_canvas_group_member_add(efl_super(obj, MY_CLASS), child);
150 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
151
152 if (wd->resize_obj == child)
153 evas_object_color_set(child, 255, 255, 255, 255);
154}
155
156EOLIAN static Eina_Bool
157_efl_ui_bg_efl_file_file_set(Eo *obj, Efl_Ui_Bg_Data *sd, const char *file, const char *group)
158{
159 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
160
161 const char *p;
162 Eina_Bool int_ret;
163
164 ELM_SAFE_FREE(sd->img, evas_object_del);
165 if (!file)
166 {
167 ELM_SAFE_FREE(sd->file, eina_stringshare_del);
168 ELM_SAFE_FREE(sd->group, eina_stringshare_del);
169 return EINA_TRUE;
170 }
171 eina_stringshare_replace(&sd->file, file);
172 eina_stringshare_replace(&sd->group, group);
173 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
174 {
175 sd->img = edje_object_add
176 (evas_object_evas_get(wd->resize_obj));
177 int_ret = edje_object_file_set(sd->img, file, group);
178 }
179 else
180 {
181 int err;
182
183 sd->img = evas_object_image_add
184 (evas_object_evas_get(wd->resize_obj));
185 evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
186 if ((sd->load_opts.w > 0) && (sd->load_opts.h > 0))
187 evas_object_image_load_size_set
188 (sd->img, sd->load_opts.w, sd->load_opts.h);
189 evas_object_image_file_set(sd->img, file, group);
190
191 err = evas_object_image_load_error_get(sd->img);
192 if (err != EVAS_LOAD_ERROR_NONE)
193 {
194 ERR("Could not load image '%s': %s",
195 file, evas_load_error_str(err));
196 int_ret = EINA_FALSE;
197 }
198 else
199 int_ret = EINA_TRUE;
200 }
201
202 evas_object_repeat_events_set(sd->img, EINA_TRUE);
203
204 int_ret &= elm_layout_content_set(obj, "elm.swallow.background", sd->img);
205
206 elm_layout_sizing_eval(obj);
207
208 return int_ret;
209}
210
211EOLIAN static void
212_efl_ui_bg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, const char **file, const char **group)
213{
214 if (file) *file = sd->file;
215 if (group) *group = sd->group;
216}
217
218EAPI void
219elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
220{
221 EFL_UI_BG_DATA_GET(obj, sd);
222 switch (option)
223 {
224 case ELM_BG_OPTION_CENTER:
225 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_NONE;
226 break;
227 case ELM_BG_OPTION_SCALE:
228 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
229 break;
230 case ELM_BG_OPTION_TILE:
231 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_TILE;
232 break;
233 case ELM_BG_OPTION_STRETCH:
234 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL;
235 break;
236 case ELM_BG_OPTION_LAST:
237 default:
238 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
239 }
240
241 elm_layout_sizing_eval(obj);
242}
243
244EAPI Elm_Bg_Option
245elm_bg_option_get(const Evas_Object *obj)
246{
247 Elm_Bg_Option option = ELM_BG_OPTION_LAST;
248 EFL_UI_BG_DATA_GET(obj, sd);
249
250 switch (sd->scale_type)
251 {
252 case EFL_UI_IMAGE_SCALE_TYPE_NONE:
253 option = ELM_BG_OPTION_CENTER;
254 break;
255 case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
256 option = ELM_BG_OPTION_SCALE;
257 break;
258 case EFL_UI_IMAGE_SCALE_TYPE_TILE:
259 option = ELM_BG_OPTION_TILE;
260 break;
261 case EFL_UI_IMAGE_SCALE_TYPE_FILL:
262 option = ELM_BG_OPTION_STRETCH;
263 break;
264 case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE:
265 default:
266 ERR("Scale type %d cannot be converted to Elm_Bg_Option", sd->scale_type);
267 break;
268 }
269 return option;
270}
271
272EOLIAN static void
273_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)
274{
275 sd->scale_type = scale_type;
276
277 elm_layout_sizing_eval(obj);
278}
279
280EOLIAN static Efl_Ui_Image_Scale_Type
281_efl_ui_bg_efl_ui_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd)
282{
283 return sd->scale_type;
284}
285
286EAPI void
287elm_bg_color_set(Evas_Object *obj,
288 int r,
289 int g,
290 int b)
291{
292 int a = 255;
293 EFL_UI_BG_CHECK(obj);
294
295 // reset color
296 if ((r == -1) && (g == -1) && (b == -1))
297 {
298 r = g = b = a = 0;
299 }
300 efl_gfx_color_set(obj, r, g, b, a);
301}
302
303EOLIAN static void
304_efl_ui_bg_efl_gfx_color_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, int r, int g, int b, int a)
305{
306 evas_object_color_set(sd->rect, r, g, b, a);
307}
308
309EAPI void
310elm_bg_color_get(const Evas_Object *obj,
311 int *r,
312 int *g,
313 int *b)
314{
315 EFL_UI_BG_CHECK(obj);
316 efl_gfx_color_get((Eo *) obj, r, g, b, NULL);
317}
318
319EOLIAN static void
320_efl_ui_bg_efl_gfx_color_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, int *r, int *g, int *b, int *a)
321{
322 evas_object_color_get(sd->rect, r, g, b, a);
323}
324
325EAPI void
326elm_bg_load_size_set(Evas_Object *obj, int w, int h)
327{
328 const char *p;
329 EFL_UI_BG_DATA_GET(obj, sd);
330
331 sd->load_opts.w = w;
332 sd->load_opts.h = h;
333 if (!sd->img) return;
334
335 if (!(((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))))
336 evas_object_image_load_size_set(sd->img, w, h);
337}
338
339static void
340_efl_ui_bg_class_constructor(Efl_Class *klass)
341{
342 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
343}
344
345EAPI Eina_Bool
346elm_bg_file_set(Eo *obj, const char *file, const char *group)
347{
348 return efl_file_set((Eo *) obj, file, group);
349}
350
351EAPI void
352elm_bg_file_get(const Eo *obj, const char **file, const char **group)
353{
354 efl_file_get((Eo *) obj, file, group);
355}
356
357/* Internal EO APIs and hidden overrides */
358
359ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
360
361#define EFL_UI_BG_EXTRA_OPS \
362 ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
363 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg), \
364 EFL_CANVAS_GROUP_ADD_OPS(efl_ui_bg)
365 7
366#include "efl_ui_bg.eo.c" 8#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 d6976da340..23583bf83c 100644
--- a/src/lib/elementary/efl_ui_bg.eo
+++ b/src/lib/elementary/efl_ui_bg.eo
@@ -1,4 +1,4 @@
1class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image) 1interface Efl.Ui.Bg (Efl.Interface, Efl.Gfx, Efl.Image, Efl.File)
2{ 2{
3 [[The bg (background) widget is used for setting (solid) background decorations 3 [[The bg (background) widget is used for setting (solid) background decorations
4 4
@@ -6,13 +6,4 @@ class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image)
6 works just like an image, but has some properties useful to a background, like 6 works just like an image, but has some properties useful to a background, like
7 setting it to tiled, centered, scaled or stretched. 7 setting it to tiled, centered, scaled or stretched.
8 ]] 8 ]]
9 legacy_prefix: elm_bg;
10 implements {
11 class.constructor;
12 Efl.Object.constructor;
13 Efl.Canvas.Group.group_member_add;
14 Efl.File.file { get; set; }
15 Efl.Gfx.color { get; set; }
16 Efl.Ui.Image.scale_type { get; set; }
17 }
18} 9}
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 135630eeb4..0000000000
--- a/src/lib/elementary/efl_ui_bg_eo.h
+++ /dev/null
@@ -1 +0,0 @@
1#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 0000000000..d1e1c73044
--- /dev/null
+++ b/src/lib/elementary/efl_ui_bg_widget.c
@@ -0,0 +1,347 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_ACCESS_PROTECTED
6#define ELM_LAYOUT_PROTECTED
7
8#include <Elementary.h>
9#include "elm_priv.h"
10#include "efl_ui_bg_widget_private.h"
11
12#define MY_CLASS EFL_UI_BG_WIDGET_CLASS
13#define MY_CLASS_PFX efl_ui_bg_widget
14
15#define MY_CLASS_NAME "Efl.Ui.Bg_Widget"
16#define MY_CLASS_NAME_LEGACY "elm_bg"
17
18static const Elm_Layout_Part_Alias_Description _content_aliases[] =
19{
20 {"overlay", "elm.swallow.content"},
21 {NULL, NULL}
22};
23
24EOLIAN static void
25_efl_ui_bg_widget_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Bg_Widget_Data *sd)
26{
27 Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
28 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
29 Evas_Coord fx = 0, fy = 0, fw = 0, fh = 0;
30 const char *p;
31
32 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
33
34 if ((!sd->img) || (!sd->file)) return;
35 if (((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))) return;
36
37 /* grab image size */
38 evas_object_image_size_get(sd->img, &iw, &ih);
39 if ((iw < 1) || (ih < 1)) return;
40
41 /* grab base object dimensions */
42 evas_object_geometry_get
43 (wd->resize_obj, &bx, &by, &bw, &bh);
44
45 switch (sd->scale_type)
46 {
47 case EFL_IMAGE_SCALE_TYPE_NONE:
48 fw = mw = iw;
49 fh = mh = ih;
50 break;
51 case EFL_IMAGE_SCALE_TYPE_FILL:
52 fw = bw;
53 fh = bh;
54 break;
55 case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE:
56 mw = fw = bw;
57 mh = fh = ((ih * fw) / iw);
58 if (fh > bh)
59 {
60 mh = fh = bh;
61 mw = fw = ((iw * fh) / ih);
62 }
63 break;
64 case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
65 fw = bw;
66 fh = ((ih * fw) / iw);
67 if (fh < bh)
68 {
69 fh = bh;
70 fw = ((iw * fh) / ih);
71 }
72 fx = ((bw - fw) / 2);
73 fy = ((bh - fh) / 2);
74 break;
75 case EFL_IMAGE_SCALE_TYPE_TILE:
76 fw = iw;
77 fh = ih;
78 break;
79 }
80
81 evas_object_image_fill_set(sd->img, fx, fy, fw, fh);
82
83 evas_object_size_hint_min_set(sd->img, mw, mh);
84 evas_object_size_hint_max_set(sd->img, mw, mh);
85}
86
87static void
88_on_resize(void *data,
89 Evas *e EINA_UNUSED,
90 Evas_Object *obj EINA_UNUSED,
91 void *event_info EINA_UNUSED)
92{
93 elm_layout_sizing_eval(data);
94}
95
96EAPI Evas_Object *
97elm_bg_add(Evas_Object *parent)
98{
99 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
100 return elm_legacy_add(MY_CLASS, parent);
101}
102
103EOLIAN static Eo *
104_efl_ui_bg_widget_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Widget_Data *pd)
105{
106 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
107
108 if (!elm_widget_theme_klass_get(obj))
109 elm_widget_theme_klass_set(obj, "bg");
110
111 obj = efl_constructor(efl_super(obj, MY_CLASS));
112 elm_widget_sub_object_parent_add(obj);
113 elm_widget_can_focus_set(obj, EINA_FALSE);
114 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
115
116 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
117 elm_widget_theme_klass_get(obj),
118 elm_widget_theme_element_get(obj),
119 elm_widget_theme_style_get(obj)))
120 CRI("Failed to set layout!");
121
122 pd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
123 pd->rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, obj,
124 efl_gfx_color_set(efl_added, 0, 0, 0, 0),
125 efl_content_set(efl_part(obj, "elm.swallow.rectangle"), efl_added));
126
127 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
128 efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED);
129
130 efl_ui_widget_focus_allow_set(obj, EINA_FALSE);
131
132 return obj;
133}
134
135EOLIAN static Eina_Bool
136_efl_ui_bg_widget_efl_file_file_set(Eo *obj, Efl_Ui_Bg_Widget_Data *sd, const char *file, const char *group)
137{
138 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
139
140 const char *p;
141 Eina_Bool int_ret;
142
143 ELM_SAFE_FREE(sd->img, evas_object_del);
144 if (!file)
145 {
146 ELM_SAFE_FREE(sd->file, eina_stringshare_del);
147 ELM_SAFE_FREE(sd->group, eina_stringshare_del);
148 return EINA_TRUE;
149 }
150 eina_stringshare_replace(&sd->file, file);
151 eina_stringshare_replace(&sd->group, group);
152 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
153 {
154 sd->img = edje_object_add
155 (evas_object_evas_get(wd->resize_obj));
156 int_ret = edje_object_file_set(sd->img, file, group);
157 }
158 else
159 {
160 int err;
161
162 sd->img = evas_object_image_add
163 (evas_object_evas_get(wd->resize_obj));
164 evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
165 if ((sd->load_opts.w > 0) && (sd->load_opts.h > 0))
166 evas_object_image_load_size_set
167 (sd->img, sd->load_opts.w, sd->load_opts.h);
168 evas_object_image_file_set(sd->img, file, group);
169
170 err = evas_object_image_load_error_get(sd->img);
171 if (err != EVAS_LOAD_ERROR_NONE)
172 {
173 ERR("Could not load image '%s': %s",
174 file, evas_load_error_str(err));
175 int_ret = EINA_FALSE;
176 }
177 else
178 int_ret = EINA_TRUE;
179 }
180
181 evas_object_repeat_events_set(sd->img, EINA_TRUE);
182
183 int_ret &= elm_layout_content_set(obj, "elm.swallow.background", sd->img);
184
185 elm_layout_sizing_eval(obj);
186
187 return int_ret;
188}
189
190EOLIAN static void
191_efl_ui_bg_widget_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, const char **file, const char **group)
192{
193 if (file) *file = sd->file;
194 if (group) *group = sd->group;
195}
196
197EAPI void
198elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
199{
200 EFL_UI_BG_WIDGET_DATA_GET(obj, sd);
201 switch (option)
202 {
203 case ELM_BG_OPTION_CENTER:
204 sd->scale_type = EFL_IMAGE_SCALE_TYPE_NONE;
205 break;
206 case ELM_BG_OPTION_SCALE:
207 sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
208 break;
209 case ELM_BG_OPTION_TILE:
210 sd->scale_type = EFL_IMAGE_SCALE_TYPE_TILE;
211 break;
212 case ELM_BG_OPTION_STRETCH:
213 sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL;
214 break;
215 case ELM_BG_OPTION_LAST:
216 default:
217 sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
218 }
219
220 elm_layout_sizing_eval(obj);
221}
222
223EAPI Elm_Bg_Option
224elm_bg_option_get(const Evas_Object *obj)
225{
226 Elm_Bg_Option option = ELM_BG_OPTION_LAST;
227 EFL_UI_BG_WIDGET_DATA_GET(obj, sd);
228
229 switch (sd->scale_type)
230 {
231 case EFL_IMAGE_SCALE_TYPE_NONE:
232 option = ELM_BG_OPTION_CENTER;
233 break;
234 case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
235 option = ELM_BG_OPTION_SCALE;
236 break;
237 case EFL_IMAGE_SCALE_TYPE_TILE:
238 option = ELM_BG_OPTION_TILE;
239 break;
240 case EFL_IMAGE_SCALE_TYPE_FILL:
241 option = ELM_BG_OPTION_STRETCH;
242 break;
243 case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE:
244 default:
245 ERR("Scale type %d cannot be converted to Elm_Bg_Option", sd->scale_type);
246 break;
247 }
248 return option;
249}
250
251EOLIAN static void
252_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)
253{
254 sd->scale_type = scale_type;
255
256 elm_layout_sizing_eval(obj);
257}
258
259EOLIAN static Efl_Image_Scale_Type
260_efl_ui_bg_widget_efl_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd)
261{
262 return sd->scale_type;
263}
264
265EAPI void
266elm_bg_color_set(Evas_Object *obj,
267 int r,
268 int g,
269 int b)
270{
271 int a = 255;
272 EFL_UI_BG_WIDGET_CHECK(obj);
273
274 // reset color
275 if ((r == -1) && (g == -1) && (b == -1))
276 {
277 r = g = b = a = 0;
278 }
279 efl_gfx_color_set(obj, r, g, b, a);
280}
281
282EOLIAN static void
283_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)
284{
285 efl_gfx_color_set(sd->rect, r, g, b, a);
286}
287
288EAPI void
289elm_bg_color_get(const Evas_Object *obj,
290 int *r,
291 int *g,
292 int *b)
293{
294 EFL_UI_BG_WIDGET_CHECK(obj);
295 efl_gfx_color_get((Eo *) obj, r, g, b, NULL);
296}
297
298EOLIAN static void
299_efl_ui_bg_widget_efl_gfx_color_get(Eo *obj, Efl_Ui_Bg_Widget_Data *sd, int *r, int *g, int *b, int *a)
300{
301 if (!sd->rect)
302 efl_gfx_color_get(efl_super(obj, MY_CLASS), r, g, b, a);
303 else
304 efl_gfx_color_get(sd->rect, r, g, b, a);
305}
306
307EAPI void
308elm_bg_load_size_set(Evas_Object *obj, int w, int h)
309{
310 const char *p;
311 EFL_UI_BG_WIDGET_DATA_GET(obj, sd);
312
313 sd->load_opts.w = w;
314 sd->load_opts.h = h;
315 if (!sd->img) return;
316
317 if (!(((p = strrchr(sd->file, '.'))) && (!strcasecmp(p, ".edj"))))
318 evas_object_image_load_size_set(sd->img, w, h);
319}
320
321static void
322_efl_ui_bg_widget_class_constructor(Efl_Class *klass)
323{
324 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
325}
326
327EAPI Eina_Bool
328elm_bg_file_set(Eo *obj, const char *file, const char *group)
329{
330 return efl_file_set((Eo *) obj, file, group);
331}
332
333EAPI void
334elm_bg_file_get(const Eo *obj, const char **file, const char **group)
335{
336 efl_file_get((Eo *) obj, file, group);
337}
338
339/* Internal EO APIs and hidden overrides */
340
341ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
342
343#define EFL_UI_BG_WIDGET_EXTRA_OPS \
344 ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
345 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg_widget)
346
347#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 0000000000..837126daa3
--- /dev/null
+++ b/src/lib/elementary/efl_ui_bg_widget.eo
@@ -0,0 +1,18 @@
1class Efl.Ui.Bg_Widget (Efl.Ui.Layout, Efl.Ui.Bg)
2{
3 [[The bg (background) widget is used for setting (solid) background decorations
4
5 to a window (unless it has transparency enabled) or to any container object. It
6 works just like an image, but has some properties useful to a background, like
7 setting it to tiled, centered, scaled or stretched.
8 ]]
9 legacy_prefix: elm_bg;
10 implements {
11 class.constructor;
12 Efl.Object.constructor;
13 Efl.File.file { get; set; }
14 //Efl.File.mmap { get; set; }
15 Efl.Gfx.color { get; set; }
16 Efl.Image.scale_type { get; set; }
17 }
18}
diff --git a/src/lib/elementary/efl_ui_bg_private.h b/src/lib/elementary/efl_ui_bg_widget_private.h
index 311fd44269..d95095e249 100644
--- a/src/lib/elementary/efl_ui_bg_private.h
+++ b/src/lib/elementary/efl_ui_bg_widget_private.h
@@ -23,13 +23,13 @@
23/** 23/**
24 * Base layout smart data extended with bg instance data. 24 * Base layout smart data extended with bg instance data.
25 */ 25 */
26typedef struct _Efl_Ui_Bg_Data Efl_Ui_Bg_Data; 26typedef struct _Efl_Ui_Bg_Widget_Data Efl_Ui_Bg_Widget_Data;
27struct _Efl_Ui_Bg_Data 27struct _Efl_Ui_Bg_Widget_Data
28{ 28{
29 Evas_Object *rect; /*<< Used for elm_bg_color_set(): elm.swallow.rectangle */ 29 Evas_Object *rect; /*<< Used for elm_bg_color_set(): elm.swallow.rectangle */
30 Evas_Object *img; /*<< Used for elm_bg_file_set(): elm.swallow.content */ 30 Evas_Object *img; /*<< Used for elm_bg_file_set(): elm.swallow.content */
31 const char *file, *group; /*<< path to file and group name to give life to "img": elm.swallow.background */ 31 const char *file, *group; /*<< path to file and group name to give life to "img": elm.swallow.background */
32 Efl_Ui_Image_Scale_Type scale_type; 32 Efl_Image_Scale_Type scale_type;
33 33
34 struct 34 struct
35 { 35 {
@@ -41,11 +41,11 @@ struct _Efl_Ui_Bg_Data
41 * @} 41 * @}
42 */ 42 */
43 43
44#define EFL_UI_BG_DATA_GET(o, sd) \ 44#define EFL_UI_BG_WIDGET_DATA_GET(o, sd) \
45Efl_Ui_Bg_Data * sd = efl_data_scope_get(o, EFL_UI_BG_CLASS) 45Efl_Ui_Bg_Widget_Data * sd = efl_data_scope_get(o, EFL_UI_BG_WIDGET_CLASS)
46 46
47#define EFL_UI_BG_DATA_GET_OR_RETURN(o, ptr) \ 47#define EFL_UI_BG_WIDGET_DATA_GET_OR_RETURN(o, ptr) \
48 EFL_UI_BG_DATA_GET(o, ptr); \ 48 EFL_UI_BG_WIDGET_DATA_GET(o, ptr); \
49 if (EINA_UNLIKELY(!ptr)) \ 49 if (EINA_UNLIKELY(!ptr)) \
50 { \ 50 { \
51 CRI("No widget data for object %p (%s)", \ 51 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)
53 return; \ 53 return; \
54 } 54 }
55 55
56#define EFL_UI_BG_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ 56#define EFL_UI_BG_WIDGET_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
57 EFL_UI_BG_DATA_GET(o, ptr); \ 57 EFL_UI_BG_WIDGET_DATA_GET(o, ptr); \
58 if (EINA_UNLIKELY(!ptr)) \ 58 if (EINA_UNLIKELY(!ptr)) \
59 { \ 59 { \
60 CRI("No widget data for object %p (%s)", \ 60 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)
62 return val; \ 62 return val; \
63 } 63 }
64 64
65#define EFL_UI_BG_CHECK(obj) \ 65#define EFL_UI_BG_WIDGET_CHECK(obj) \
66 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_CLASS))) \ 66 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_WIDGET_CLASS))) \
67 return 67 return
68 68
69#endif 69#endif
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index a9f0157af0..696413df8e 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)
181 // according to (iw x ih), (sd->img_w x sd->img_h), and scale_type 181 // according to (iw x ih), (sd->img_w x sd->img_h), and scale_type
182 switch (sd->scale_type) 182 switch (sd->scale_type)
183 { 183 {
184 case EFL_UI_IMAGE_SCALE_TYPE_NONE: 184 case EFL_IMAGE_SCALE_TYPE_NONE:
185 w = iw; 185 w = iw;
186 h = ih; 186 h = ih;
187 break; 187 break;
188 case EFL_UI_IMAGE_SCALE_TYPE_FILL: 188 case EFL_IMAGE_SCALE_TYPE_FILL:
189 w = sd->img_w; 189 w = sd->img_w;
190 h = sd->img_h; 190 h = sd->img_h;
191 break; 191 break;
192 case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE: 192 case EFL_IMAGE_SCALE_TYPE_FIT_INSIDE:
193 w = sd->img_w; 193 w = sd->img_w;
194 h = ((double)ih * w) / (double)iw; 194 h = ((double)ih * w) / (double)iw;
195 195
@@ -206,7 +206,7 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
206 h = ih; 206 h = ih;
207 } 207 }
208 break; 208 break;
209 case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE: 209 case EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
210 w = sd->img_w; 210 w = sd->img_w;
211 h = ((double)ih * w) / (double)iw; 211 h = ((double)ih * w) / (double)iw;
212 if (h < sd->img_h) 212 if (h < sd->img_h)
@@ -222,7 +222,7 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
222 h = ih; 222 h = ih;
223 } 223 }
224 break; 224 break;
225 case EFL_UI_IMAGE_SCALE_TYPE_TILE: 225 case EFL_IMAGE_SCALE_TYPE_TILE:
226 x = sd->img_x; 226 x = sd->img_x;
227 y = sd->img_y; 227 y = sd->img_y;
228 w = sd->img_w; 228 w = sd->img_w;
@@ -866,7 +866,7 @@ _efl_ui_image_efl_object_constructor(Eo *obj, Efl_Ui_Image_Data *pd)
866 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 866 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
867 efl_access_role_set(obj, EFL_ACCESS_ROLE_IMAGE); 867 efl_access_role_set(obj, EFL_ACCESS_ROLE_IMAGE);
868 868
869 pd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; 869 pd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE;
870 pd->self = obj; 870 pd->self = obj;
871 871
872 return obj; 872 return obj;
@@ -1524,7 +1524,7 @@ _efl_ui_image_class_constructor(Efl_Class *klass)
1524} 1524}
1525 1525
1526EOLIAN static void 1526EOLIAN static void
1527_efl_ui_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNUSED, Efl_Ui_Image_Scale_Type scale_type) 1527_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)
1528{ 1528{
1529 if (scale_type == sd->scale_type) return; 1529 if (scale_type == sd->scale_type) return;
1530 1530
@@ -1533,8 +1533,8 @@ _efl_ui_image_scale_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNU
1533 _efl_ui_image_internal_sizing_eval(obj, sd); 1533 _efl_ui_image_internal_sizing_eval(obj, sd);
1534} 1534}
1535 1535
1536EOLIAN static Efl_Ui_Image_Scale_Type 1536EOLIAN static Efl_Image_Scale_Type
1537_efl_ui_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd) 1537_efl_ui_image_efl_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
1538{ 1538{
1539 return sd->scale_type; 1539 return sd->scale_type;
1540} 1540}
@@ -2077,11 +2077,11 @@ elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
2077 2077
2078 if (sd->aspect_fixed) 2078 if (sd->aspect_fixed)
2079 { 2079 {
2080 if (sd->fill_inside) sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; 2080 if (sd->fill_inside) sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE;
2081 else sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; 2081 else sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
2082 } 2082 }
2083 else 2083 else
2084 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL; 2084 sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL;
2085 2085
2086 _efl_ui_image_internal_sizing_eval(obj, sd); 2086 _efl_ui_image_internal_sizing_eval(obj, sd);
2087} 2087}
@@ -2250,11 +2250,11 @@ elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
2250 2250
2251 if (sd->aspect_fixed) 2251 if (sd->aspect_fixed)
2252 { 2252 {
2253 if (sd->fill_inside) sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE; 2253 if (sd->fill_inside) sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_INSIDE;
2254 else sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE; 2254 else sd->scale_type = EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
2255 } 2255 }
2256 else 2256 else
2257 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL; 2257 sd->scale_type = EFL_IMAGE_SCALE_TYPE_FILL;
2258 2258
2259 _efl_ui_image_sizing_eval(obj); 2259 _efl_ui_image_sizing_eval(obj);
2260} 2260}
diff --git a/src/lib/elementary/efl_ui_image.eo b/src/lib/elementary/efl_ui_image.eo
index 91a601c036..9a568aed53 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -1,28 +1,3 @@
1enum Efl.Ui.Image.Scale_Type
2{
3 [[Enumeration that defines scale types for the object's internal image.
4
5 @since 1.18
6 ]]
7 fill, [[Scale the internal image so that it matches
8 the object's area exactly.
9 The image's aspect ratio might be changed.]]
10 fit_inside, [[Scale the internal image
11 so that it fits inside the object's area
12 while maintaining the aspect ratio.
13 At least one of the dimensions of the image
14 should be equal to the corresponding dimension
15 of the object.]]
16 fit_outside, [[Scale the internal image
17 so that it covers the entire object area
18 while maintaining the aspect ratio.
19 At least one of the dimensions of the image
20 should be equal to the corresponding
21 dimension of the object.]]
22 tile, [[Tile image at its original size.]]
23 none [[Not scale the internal image]]
24}
25
26struct Efl.Ui.Image.Progress 1struct Efl.Ui.Image.Progress
27{ 2{
28 [[ 3 [[
@@ -53,14 +28,6 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable,
53 [[ Efl UI image class]] 28 [[ Efl UI image class]]
54 event_prefix: efl_ui_image; 29 event_prefix: efl_ui_image;
55 methods { 30 methods {
56 @property scale_type {
57 [[Control how the internal image is scaled.
58
59 @since 1.18]]
60 values {
61 scale_type: Efl.Ui.Image.Scale_Type; [[Image scale type]]
62 }
63 }
64 @property scalable { 31 @property scalable {
65 [[Enable or disable scaling up or down the internal image. 32 [[Enable or disable scaling up or down the internal image.
66 33
@@ -133,6 +100,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable,
133 Efl.Image.image_size { get; } 100 Efl.Image.image_size { get; }
134 Efl.Image.Load.load_size { get; set; } 101 Efl.Image.Load.load_size { get; set; }
135 Efl.Image.smooth_scale { get; set; } 102 Efl.Image.smooth_scale { get; set; }
103 Efl.Image.scale_type { get; set; }
136 Efl.Orientation.orientation { get; set; } 104 Efl.Orientation.orientation { get; set; }
137 Efl.Flipable.flip { get; set; } 105 Efl.Flipable.flip { get; set; }
138 Efl.Player.playable { get; } 106 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 4c91f8faa3..88759c4a13 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
76 } async; 76 } async;
77 77
78 Efl_Ui_Image_Preload_Status preload_status; 78 Efl_Ui_Image_Preload_Status preload_status;
79 Efl_Ui_Image_Scale_Type scale_type; 79 Efl_Image_Scale_Type scale_type;
80 80
81 const char *stdicon; 81 const char *stdicon;
82 82
diff --git a/src/lib/elementary/efl_ui_widget_part_bg.eo b/src/lib/elementary/efl_ui_widget_part_bg.eo
index f35d4f66e4..d624ffcbc9 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)
6 Efl.File.file { get; set; } 6 Efl.File.file { get; set; }
7 //Efl.File.mmap { get; set; } 7 //Efl.File.mmap { get; set; }
8 Efl.Gfx.color { set; get; } 8 Efl.Gfx.color { set; get; }
9 Efl.Ui.Image.scale_type { get; set; } 9 Efl.Image.scale_type { get; set; }
10 } 10 }
11} 11}
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 54945cb699..926e4249b8 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -7142,7 +7142,7 @@ _elm_win_standard_init(Eo *obj)
7142 /* Legacy theme compatibility */ 7142 /* Legacy theme compatibility */
7143 DBG("Detected legacy theme used for elm_bg. Swallowing object."); 7143 DBG("Detected legacy theme used for elm_bg. Swallowing object.");
7144 sd->csd.need_bg_solid = EINA_FALSE; 7144 sd->csd.need_bg_solid = EINA_FALSE;
7145 _elm_win_bg_set(sd, efl_add(EFL_UI_BG_CLASS, obj)); 7145 _elm_win_bg_set(sd, efl_add(EFL_UI_BG_WIDGET_CLASS, obj));
7146 } 7146 }
7147 7147
7148 _elm_win_frame_style_update(sd, 0, 1); 7148 _elm_win_frame_style_update(sd, 0, 1);
@@ -7252,7 +7252,7 @@ _efl_ui_win_part_file_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *part, const
7252 if (file) 7252 if (file)
7253 { 7253 {
7254 bg = efl_add(EFL_UI_IMAGE_CLASS, obj); 7254 bg = efl_add(EFL_UI_IMAGE_CLASS, obj);
7255 efl_ui_image_scale_type_set(bg, EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE); 7255 efl_image_scale_type_set(bg, EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE);
7256 ok = efl_file_set(bg, file, key); 7256 ok = efl_file_set(bg, file, key);
7257 if (!ok) ELM_SAFE_DEL(bg); 7257 if (!ok) ELM_SAFE_DEL(bg);
7258 _elm_win_bg_set(sd, bg); 7258 _elm_win_bg_set(sd, bg);
diff --git a/src/lib/elementary/elm_bg.h b/src/lib/elementary/elm_bg.h
index c11c342d90..030f83e53a 100644
--- a/src/lib/elementary/elm_bg.h
+++ b/src/lib/elementary/elm_bg.h
@@ -29,9 +29,6 @@
29 * @li @ref bg_03_example_page 29 * @li @ref bg_03_example_page
30 */ 30 */
31 31
32#ifdef EFL_EO_API_SUPPORT
33#include "efl_ui_bg_eo.h"
34#endif
35#ifndef EFL_NOLEGACY_API_SUPPORT 32#ifndef EFL_NOLEGACY_API_SUPPORT
36#include "elm_bg_legacy.h" 33#include "elm_bg_legacy.h"
37#endif 34#endif
diff --git a/src/lib/elementary/elm_bg_legacy.h b/src/lib/elementary/elm_bg_legacy.h
index 545c5d46c8..8110c80d0f 100644
--- a/src/lib/elementary/elm_bg_legacy.h
+++ b/src/lib/elementary/elm_bg_legacy.h
@@ -163,4 +163,4 @@ EAPI Elm_Bg_Option elm_bg_option_get(const Evas_Object *obj);
163 */ 163 */
164EAPI void elm_bg_load_size_set(Evas_Object *obj, int w, int h); 164EAPI void elm_bg_load_size_set(Evas_Object *obj, int w, int h);
165 165
166#include "efl_ui_bg.eo.legacy.h" 166#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 bf983bc8d9..33a6845484 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -5921,7 +5921,7 @@ _efl_ui_widget_bg_get(Elm_Widget *obj)
5921 5921
5922 if (!bg_obj) 5922 if (!bg_obj)
5923 { 5923 {
5924 bg_obj = efl_add(EFL_UI_BG_CLASS, obj); 5924 bg_obj = efl_add(EFL_UI_BG_WIDGET_CLASS, obj);
5925 EINA_SAFETY_ON_NULL_RETURN_VAL(bg_obj, NULL); 5925 EINA_SAFETY_ON_NULL_RETURN_VAL(bg_obj, NULL);
5926 sd->bg = bg_obj; 5926 sd->bg = bg_obj;
5927 efl_canvas_group_member_add(obj, sd->bg); 5927 efl_canvas_group_member_add(obj, sd->bg);
@@ -5972,19 +5972,19 @@ _efl_ui_widget_part_bg_efl_gfx_color_get(Eo *obj, void *pd EINA_UNUSED, int *r,
5972} 5972}
5973 5973
5974EOLIAN static void 5974EOLIAN static void
5975_efl_ui_widget_part_bg_efl_ui_image_scale_type_set(Eo *obj, void *pd EINA_UNUSED, Efl_Ui_Image_Scale_Type scale_type) 5975_efl_ui_widget_part_bg_efl_image_scale_type_set(Eo *obj, void *pd EINA_UNUSED, Efl_Image_Scale_Type scale_type)
5976{ 5976{
5977 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); 5977 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
5978 5978
5979 efl_ui_image_scale_type_set(bg_obj, scale_type); 5979 efl_image_scale_type_set(bg_obj, scale_type);
5980} 5980}
5981 5981
5982EOLIAN static Efl_Ui_Image_Scale_Type 5982EOLIAN static Efl_Image_Scale_Type
5983_efl_ui_widget_part_bg_efl_ui_image_scale_type_get(Eo *obj, void *pd EINA_UNUSED) 5983_efl_ui_widget_part_bg_efl_image_scale_type_get(Eo *obj, void *pd EINA_UNUSED)
5984{ 5984{
5985 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); 5985 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
5986 5986
5987 return efl_ui_image_scale_type_get(bg_obj); 5987 return efl_image_scale_type_get(bg_obj);
5988} 5988}
5989 5989
5990#include "efl_ui_widget_part_bg.eo.c" 5990#include "efl_ui_widget_part_bg.eo.c"