summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/POTFILES.in2
-rw-r--r--src/Makefile_Elementary.am6
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_bg.c108
-rw-r--r--src/lib/elementary/efl_ui_bg.c (renamed from src/lib/elementary/elm_bg.c)182
-rw-r--r--src/lib/elementary/efl_ui_bg.eo17
-rw-r--r--src/lib/elementary/efl_ui_bg_eo.h1
-rw-r--r--src/lib/elementary/efl_ui_bg_private.h69
-rw-r--r--src/lib/elementary/efl_ui_win.c2
-rw-r--r--src/lib/elementary/elm_bg.eo101
-rw-r--r--src/lib/elementary/elm_bg.h2
-rw-r--r--src/lib/elementary/elm_bg_legacy.h72
12 files changed, 391 insertions, 173 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 187aaa3d07..5abceaabff 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -103,7 +103,7 @@ src/lib/elementary/elc_popup.c
103src/lib/elementary/elc_scrolled_entry.c 103src/lib/elementary/elc_scrolled_entry.c
104src/lib/elementary/elm_access.c 104src/lib/elementary/elm_access.c
105src/lib/elementary/elm_actionslider.c 105src/lib/elementary/elm_actionslider.c
106src/lib/elementary/elm_bg.c 106src/lib/elementary/efl_ui_bg.c
107src/lib/elementary/elm_box.c 107src/lib/elementary/elm_box.c
108src/lib/elementary/elm_bubble.c 108src/lib/elementary/elm_bubble.c
109src/lib/elementary/efl_ui_button.c 109src/lib/elementary/efl_ui_button.c
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 269b7104dc..60b2b7fac7 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -4,7 +4,7 @@
4elm_public_eolian_files = \ 4elm_public_eolian_files = \
5 lib/elementary/elm_atspi_bridge.eo \ 5 lib/elementary/elm_atspi_bridge.eo \
6 lib/elementary/elm_atspi_app_object.eo \ 6 lib/elementary/elm_atspi_app_object.eo \
7 lib/elementary/elm_bg.eo \ 7 lib/elementary/efl_ui_bg.eo \
8 lib/elementary/efl_ui_button.eo \ 8 lib/elementary/efl_ui_button.eo \
9 lib/elementary/elm_calendar.eo \ 9 lib/elementary/elm_calendar.eo \
10 lib/elementary/efl_ui_check.eo \ 10 lib/elementary/efl_ui_check.eo \
@@ -345,7 +345,7 @@ includesub_HEADERS = \
345 lib/elementary/elm_atspi_app_object.h \ 345 lib/elementary/elm_atspi_app_object.h \
346 lib/elementary/elm_authors.h \ 346 lib/elementary/elm_authors.h \
347 lib/elementary/elm_bg.h \ 347 lib/elementary/elm_bg.h \
348 lib/elementary/elm_bg_eo.h \ 348 lib/elementary/efl_ui_bg_eo.h \
349 lib/elementary/elm_bg_legacy.h \ 349 lib/elementary/elm_bg_legacy.h \
350 lib/elementary/elm_box.h \ 350 lib/elementary/elm_box.h \
351 lib/elementary/elm_box_legacy.h \ 351 lib/elementary/elm_box_legacy.h \
@@ -569,7 +569,7 @@ lib_elementary_libelementary_la_SOURCES = \
569 lib/elementary/elm_actionslider.c \ 569 lib/elementary/elm_actionslider.c \
570 lib/elementary/elm_atspi_app_object.c \ 570 lib/elementary/elm_atspi_app_object.c \
571 lib/elementary/elm_atspi_bridge.c \ 571 lib/elementary/elm_atspi_bridge.c \
572 lib/elementary/elm_bg.c \ 572 lib/elementary/efl_ui_bg.c \
573 lib/elementary/elm_box.c \ 573 lib/elementary/elm_box.c \
574 lib/elementary/elm_bubble.c \ 574 lib/elementary/elm_bubble.c \
575 lib/elementary/efl_ui_button.c \ 575 lib/elementary/efl_ui_button.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 8220261035..6652716eb3 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -17,6 +17,7 @@ void test_bg_plain(void *data, Evas_Object *obj, void *event_info);
17void test_bg_image(void *data, Evas_Object *obj, void *event_info); 17void test_bg_image(void *data, Evas_Object *obj, void *event_info);
18void test_bg_options(void *data, Evas_Object *obj, void *event_info); 18void test_bg_options(void *data, Evas_Object *obj, void *event_info);
19void test_bg_window(void *data, Evas_Object *obj, void *event_info); 19void test_bg_window(void *data, Evas_Object *obj, void *event_info);
20void test_bg_scale_type(void *data, Evas_Object *obj, void *event_info);
20void test_icon(void *data, Evas_Object *obj, void *event_info); 21void test_icon(void *data, Evas_Object *obj, void *event_info);
21void test_icon_transparent(void *data, Evas_Object *obj, void *event_info); 22void test_icon_transparent(void *data, Evas_Object *obj, void *event_info);
22void test_icon_standard(void *data, Evas_Object *obj, void *event_info); 23void test_icon_standard(void *data, Evas_Object *obj, void *event_info);
@@ -664,6 +665,7 @@ add_tests:
664 ADD_TEST(NULL, "Window / Background", "Bg Image", test_bg_image); 665 ADD_TEST(NULL, "Window / Background", "Bg Image", test_bg_image);
665 ADD_TEST(NULL, "Window / Background", "Bg Options", test_bg_options); 666 ADD_TEST(NULL, "Window / Background", "Bg Options", test_bg_options);
666 ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Win)", test_bg_window); 667 ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Win)", test_bg_window);
668 ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Bg)", test_bg_scale_type);
667 ADD_TEST(NULL, "Window / Background", "Window States", test_win_state); 669 ADD_TEST(NULL, "Window / Background", "Window States", test_win_state);
668 ADD_TEST(NULL, "Window / Background", "Window States 2", test_win_state2); 670 ADD_TEST(NULL, "Window / Background", "Window States 2", test_win_state2);
669 ADD_TEST(NULL, "Window / Background", "Inwin", test_inwin); 671 ADD_TEST(NULL, "Window / Background", "Inwin", test_inwin);
diff --git a/src/bin/elementary/test_bg.c b/src/bin/elementary/test_bg.c
index 8402a59509..ba64598505 100644
--- a/src/bin/elementary/test_bg.c
+++ b/src/bin/elementary/test_bg.c
@@ -366,3 +366,111 @@ test_bg_window(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
366 366
367 efl_gfx_size_set(win, EINA_SIZE2D(300, 200)); 367 efl_gfx_size_set(win, EINA_SIZE2D(300, 200));
368} 368}
369
370static void
371_cb_radio_changed_scale_type(void *data, const Efl_Event *ev)
372{
373 Evas_Object *o_bg = data;
374
375 efl_ui_image_scale_type_set(o_bg, efl_ui_radio_value_get(ev->object));
376}
377
378static void
379_cb_check_changed_scale_type(void *data, const Efl_Event *ev)
380{
381 Evas_Object *o_bg = data;
382
383 if (efl_ui_check_selected_get(ev->object))
384 efl_gfx_color_set(o_bg, 255, 128, 128, 255);
385 else
386 efl_gfx_color_set(o_bg, 0, 0, 0, 0);
387}
388
389void
390test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
391{
392 Evas_Object *win;
393 Evas_Object *box, *hbox, *o_bg;
394 Evas_Object *rd, *rdg;
395 char buf[PATH_MAX];
396
397 win = efl_add(EFL_UI_WIN_CLASS, NULL,
398 efl_text_set(efl_added, "Bg EOAPI (Efl.Ui.Bg)"),
399 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
400 efl_ui_win_alpha_set(efl_added, EINA_FALSE));
401
402 efl_add(EFL_UI_BG_CLASS, win,
403 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
404 efl_content_set(win, efl_added));
405
406 box = efl_add(EFL_UI_BOX_CLASS, win,
407 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
408 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
409 efl_content_set(win, efl_added));
410
411 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
412
413 o_bg = efl_add(EFL_UI_BG_CLASS, box,
414 efl_file_set(efl_added, buf, NULL),
415 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
416 efl_gfx_size_hint_align_set(efl_added, EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL),
417 efl_pack(box, efl_added));
418
419 hbox = efl_add(EFL_UI_BOX_CLASS, box,
420 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
421 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
422 efl_gfx_size_hint_align_set(efl_added, EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL),
423 efl_pack(box, efl_added));
424
425 rdg = rd = efl_add(EFL_UI_RADIO_CLASS, hbox,
426 efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FILL),
427 efl_text_set(efl_added, "Fill"),
428 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
429 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
430 efl_pack(hbox, efl_added));
431
432 rd = efl_add(EFL_UI_RADIO_CLASS, hbox,
433 efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE),
434 efl_ui_radio_group_add(efl_added, rdg),
435 efl_text_set(efl_added, "Fit Inside"),
436 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
437 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
438 efl_pack(hbox, efl_added));
439
440
441 rd = efl_add(EFL_UI_RADIO_CLASS, hbox,
442 efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE),
443 efl_ui_radio_group_add(efl_added, rdg),
444 efl_text_set(efl_added, "Fit Outside"),
445 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
446 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
447 efl_pack(hbox, efl_added));
448
449 rd = efl_add(EFL_UI_RADIO_CLASS, hbox,
450 efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_NONE),
451 efl_ui_radio_group_add(efl_added, rdg),
452 efl_text_set(efl_added, "None"),
453 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
454 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
455 efl_pack(hbox, efl_added));
456
457 rd = efl_add(EFL_UI_RADIO_CLASS, hbox,
458 efl_ui_radio_state_value_set(efl_added, EFL_UI_IMAGE_SCALE_TYPE_TILE),
459 efl_ui_radio_group_add(efl_added, rdg),
460 efl_text_set(efl_added, "Tile"),
461 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
462 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
463 efl_pack(hbox, efl_added));
464
465 efl_ui_radio_value_set(rdg, EFL_UI_IMAGE_SCALE_TYPE_FILL);
466
467 efl_add(EFL_UI_CHECK_CLASS, hbox,
468 efl_text_set(efl_added, "Bg Color"),
469 efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
470 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED, _cb_check_changed_scale_type, o_bg),
471 efl_pack(hbox, efl_added));
472
473 efl_gfx_size_set(win, EINA_SIZE2D(300, 200));
474}
475
476
diff --git a/src/lib/elementary/elm_bg.c b/src/lib/elementary/efl_ui_bg.c
index e0e2c48062..d12b5fd10b 100644
--- a/src/lib/elementary/elm_bg.c
+++ b/src/lib/elementary/efl_ui_bg.c
@@ -7,13 +7,13 @@
7 7
8#include <Elementary.h> 8#include <Elementary.h>
9#include "elm_priv.h" 9#include "elm_priv.h"
10#include "elm_widget_bg.h" 10#include "efl_ui_bg_private.h"
11#include "elm_widget_layout.h" 11#include "elm_widget_layout.h"
12 12
13#define MY_CLASS ELM_BG_CLASS 13#define MY_CLASS EFL_UI_BG_CLASS
14#define MY_CLASS_PFX elm_bg 14#define MY_CLASS_PFX efl_ui_bg
15 15
16#define MY_CLASS_NAME "Elm_Bg" 16#define MY_CLASS_NAME "Efl.Ui.Bg"
17#define MY_CLASS_NAME_LEGACY "elm_bg" 17#define MY_CLASS_NAME_LEGACY "elm_bg"
18 18
19static const Elm_Layout_Part_Alias_Description _content_aliases[] = 19static const Elm_Layout_Part_Alias_Description _content_aliases[] =
@@ -23,7 +23,7 @@ static const Elm_Layout_Part_Alias_Description _content_aliases[] =
23}; 23};
24 24
25EOLIAN static void 25EOLIAN static void
26_elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd) 26_efl_ui_bg_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Bg_Data *sd)
27{ 27{
28 Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1; 28 Evas_Coord iw = 0, ih = 0, mw = -1, mh = -1;
29 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0; 29 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
@@ -43,40 +43,44 @@ _elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd)
43 evas_object_geometry_get 43 evas_object_geometry_get
44 (wd->resize_obj, &bx, &by, &bw, &bh); 44 (wd->resize_obj, &bx, &by, &bw, &bh);
45 45
46 switch (sd->option) 46 switch (sd->scale_type)
47 { 47 {
48 case ELM_BG_OPTION_CENTER: 48 case EFL_UI_IMAGE_SCALE_TYPE_NONE:
49 fw = mw = iw; 49 fw = mw = iw;
50 fh = mh = ih; 50 fh = mh = ih;
51 break; 51 break;
52 52 case EFL_UI_IMAGE_SCALE_TYPE_FILL:
53 case ELM_BG_OPTION_SCALE: 53 fw = bw;
54 fw = bw; 54 fh = bh;
55 fh = ((ih * fw) / iw); 55 break;
56 if (fh < bh) 56 case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE:
57 { 57 mw = fw = bw;
58 fh = bh; 58 mh = fh = ((ih * fw) / iw);
59 fw = ((iw * fh) / ih); 59 if (fh > bh)
60 } 60 {
61 fx = ((bw - fw) / 2); 61 mh = fh = bh;
62 fy = ((bh - fh) / 2); 62 mw = fw = ((iw * fh) / ih);
63 break; 63 }
64 64 break;
65 case ELM_BG_OPTION_TILE: 65 case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
66 fw = iw; 66 fw = bw;
67 fh = ih; 67 fh = ((ih * fw) / iw);
68 break; 68 if (fh < bh)
69 69 {
70 case ELM_BG_OPTION_STRETCH: 70 fh = bh;
71 default: 71 fw = ((iw * fh) / ih);
72 fw = bw; 72 }
73 fh = bh; 73 fx = ((bw - fw) / 2);
74 break; 74 fy = ((bh - fh) / 2);
75 break;
76 case EFL_UI_IMAGE_SCALE_TYPE_TILE:
77 fw = iw;
78 fh = ih;
79 break;
75 } 80 }
76 81
77 evas_object_image_fill_set(sd->img, fx, fy, fw, fh); 82 evas_object_image_fill_set(sd->img, fx, fy, fw, fh);
78 83
79 evas_object_size_hint_min_set(sd->img, mw, mh);
80 evas_object_size_hint_max_set(sd->img, mw, mh); 84 evas_object_size_hint_max_set(sd->img, mw, mh);
81} 85}
82 86
@@ -90,14 +94,14 @@ _on_resize(void *data,
90} 94}
91 95
92EOLIAN static void 96EOLIAN static void
93_elm_bg_efl_canvas_group_group_add(Eo *obj, Elm_Bg_Data *priv) 97_efl_ui_bg_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Bg_Data *priv)
94{ 98{
95 99
96 efl_canvas_group_add(efl_super(obj, MY_CLASS)); 100 efl_canvas_group_add(efl_super(obj, MY_CLASS));
97 elm_widget_sub_object_parent_add(obj); 101 elm_widget_sub_object_parent_add(obj);
98 elm_widget_can_focus_set(obj, EINA_FALSE); 102 elm_widget_can_focus_set(obj, EINA_FALSE);
99 103
100 priv->option = ELM_BG_OPTION_SCALE; 104 priv->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
101 105
102 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj); 106 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
103 107
@@ -113,7 +117,7 @@ elm_bg_add(Evas_Object *parent)
113} 117}
114 118
115EOLIAN static Eo * 119EOLIAN static Eo *
116_elm_bg_efl_object_constructor(Eo *obj, Elm_Bg_Data *_pd EINA_UNUSED) 120_efl_ui_bg_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED)
117{ 121{
118 elm_interface_atspi_accessible_type_set(obj, ELM_ATSPI_TYPE_DISABLED); 122 elm_interface_atspi_accessible_type_set(obj, ELM_ATSPI_TYPE_DISABLED);
119 obj = efl_constructor(efl_super(obj, MY_CLASS)); 123 obj = efl_constructor(efl_super(obj, MY_CLASS));
@@ -123,7 +127,7 @@ _elm_bg_efl_object_constructor(Eo *obj, Elm_Bg_Data *_pd EINA_UNUSED)
123} 127}
124 128
125EOLIAN static Eina_Bool 129EOLIAN static Eina_Bool
126_elm_bg_efl_file_file_set(Eo *obj, Elm_Bg_Data *sd, const char *file, const char *group) 130_efl_ui_bg_efl_file_file_set(Eo *obj, Efl_Ui_Bg_Data *sd, const char *file, const char *group)
127{ 131{
128 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 132 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
129 133
@@ -178,24 +182,78 @@ _elm_bg_efl_file_file_set(Eo *obj, Elm_Bg_Data *sd, const char *file, const char
178} 182}
179 183
180EOLIAN static void 184EOLIAN static void
181_elm_bg_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, const char **file, const char **group) 185_efl_ui_bg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd, const char **file, const char **group)
182{ 186{
183 if (file) *file = sd->file; 187 if (file) *file = sd->file;
184 if (group) *group = sd->group; 188 if (group) *group = sd->group;
185} 189}
186 190
191EAPI void
192elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
193{
194 EFL_UI_BG_DATA_GET(obj, sd);
195 switch (option)
196 {
197 case ELM_BG_OPTION_CENTER:
198 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_NONE;
199 break;
200 case ELM_BG_OPTION_SCALE:
201 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
202 break;
203 case ELM_BG_OPTION_TILE:
204 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_TILE;
205 break;
206 case ELM_BG_OPTION_STRETCH:
207 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FILL;
208 break;
209 case ELM_BG_OPTION_LAST:
210 default:
211 sd->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
212 }
213
214 elm_layout_sizing_eval(obj);
215}
216
217EAPI Elm_Bg_Option
218elm_bg_option_get(const Evas_Object *obj)
219{
220 Elm_Bg_Option option = ELM_BG_OPTION_LAST;
221 EFL_UI_BG_DATA_GET(obj, sd);
222
223 switch (sd->scale_type)
224 {
225 case EFL_UI_IMAGE_SCALE_TYPE_NONE:
226 option = ELM_BG_OPTION_CENTER;
227 break;
228 case EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE:
229 option = ELM_BG_OPTION_SCALE;
230 break;
231 case EFL_UI_IMAGE_SCALE_TYPE_TILE:
232 option = ELM_BG_OPTION_TILE;
233 break;
234 case EFL_UI_IMAGE_SCALE_TYPE_FILL:
235 option = ELM_BG_OPTION_STRETCH;
236 break;
237 case EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE:
238 default:
239 ERR("Scale type %d cannot be converted to Elm_Bg_Option", sd->scale_type);
240 break;
241 }
242 return option;
243}
244
187EOLIAN static void 245EOLIAN static void
188_elm_bg_option_set(Eo *obj, Elm_Bg_Data *sd, Elm_Bg_Option option) 246_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)
189{ 247{
190 sd->option = option; 248 sd->scale_type = scale_type;
191 249
192 elm_layout_sizing_eval(obj); 250 elm_layout_sizing_eval(obj);
193} 251}
194 252
195EOLIAN static Elm_Bg_Option 253EOLIAN static Efl_Ui_Image_Scale_Type
196_elm_bg_option_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd) 254_efl_ui_bg_efl_ui_image_scale_type_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Data *sd)
197{ 255{
198 return sd->option; 256 return sd->scale_type;
199} 257}
200 258
201EAPI void 259EAPI void
@@ -204,12 +262,12 @@ elm_bg_color_set(Evas_Object *obj,
204 int g, 262 int g,
205 int b) 263 int b)
206{ 264{
207 ELM_BG_CHECK(obj); 265 EFL_UI_BG_CHECK(obj);
208 elm_obj_bg_color_set(obj, r, g, b, 255); 266 efl_gfx_color_set(obj, r, g, b, 255);
209} 267}
210 268
211EOLIAN static void 269EOLIAN static void
212_elm_bg_color_set(Eo *obj, Elm_Bg_Data *sd, int r, int g, int b, int a) 270_efl_ui_bg_efl_gfx_color_set(Eo *obj, Efl_Ui_Bg_Data *sd, int r, int g, int b, int a)
213{ 271{
214 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 272 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
215 273
@@ -224,9 +282,8 @@ _elm_bg_color_set(Eo *obj, Elm_Bg_Data *sd, int r, int g, int b, int a)
224 { 282 {
225 sd->rect = evas_object_rectangle_add 283 sd->rect = evas_object_rectangle_add
226 (evas_object_evas_get(wd->resize_obj)); 284 (evas_object_evas_get(wd->resize_obj));
227 285 efl_gfx_visible_set(sd->rect, EINA_TRUE);
228 elm_layout_content_set(obj, "elm.swallow.rectangle", sd->rect); 286 elm_layout_content_set(obj, "elm.swallow.rectangle", sd->rect);
229
230 elm_layout_sizing_eval(obj); 287 elm_layout_sizing_eval(obj);
231 } 288 }
232 289
@@ -239,20 +296,15 @@ elm_bg_color_get(const Evas_Object *obj,
239 int *g, 296 int *g,
240 int *b) 297 int *b)
241{ 298{
242 ELM_BG_CHECK(obj); 299 EFL_UI_BG_CHECK(obj);
243 elm_obj_bg_color_get((Eo *) obj, r, g, b, NULL); 300 efl_gfx_color_get((Eo *) obj, r, g, b, NULL);
244}
245
246EOLIAN static void
247_elm_bg_color_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, int *r, int *g, int *b, int *a)
248{
249 evas_object_color_get(sd->rect, r, g, b, a);
250} 301}
251 302
252EOLIAN static void 303EAPI void
253_elm_bg_load_size_set(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, Evas_Coord w, Evas_Coord h) 304elm_bg_load_size_set(Evas_Object *obj, int w, int h)
254{ 305{
255 const char *p; 306 const char *p;
307 EFL_UI_BG_DATA_GET(obj, sd);
256 308
257 sd->load_opts.w = w; 309 sd->load_opts.w = w;
258 sd->load_opts.h = h; 310 sd->load_opts.h = h;
@@ -263,7 +315,7 @@ _elm_bg_load_size_set(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, Evas_Coord w, Evas_C
263} 315}
264 316
265static void 317static void
266_elm_bg_class_constructor(Efl_Class *klass) 318_efl_ui_bg_class_constructor(Efl_Class *klass)
267{ 319{
268 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 320 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
269} 321}
@@ -284,9 +336,9 @@ elm_bg_file_get(const Eo *obj, const char **file, const char **group)
284 336
285ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX) 337ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
286 338
287#define ELM_BG_EXTRA_OPS \ 339#define EFL_UI_BG_EXTRA_OPS \
288 ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \ 340 ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
289 ELM_LAYOUT_SIZING_EVAL_OPS(elm_bg), \ 341 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg), \
290 EFL_CANVAS_GROUP_ADD_OPS(elm_bg) 342 EFL_CANVAS_GROUP_ADD_OPS(efl_ui_bg)
291 343
292#include "elm_bg.eo.c" 344#include "efl_ui_bg.eo.c"
diff --git a/src/lib/elementary/efl_ui_bg.eo b/src/lib/elementary/efl_ui_bg.eo
new file mode 100644
index 0000000000..280fe4d276
--- /dev/null
+++ b/src/lib/elementary/efl_ui_bg.eo
@@ -0,0 +1,17 @@
1class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image)
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.Gfx.color { set; }
15 Efl.Ui.Image.scale_type { get; set; }
16 }
17}
diff --git a/src/lib/elementary/efl_ui_bg_eo.h b/src/lib/elementary/efl_ui_bg_eo.h
new file mode 100644
index 0000000000..135630eeb4
--- /dev/null
+++ b/src/lib/elementary/efl_ui_bg_eo.h
@@ -0,0 +1 @@
#include "efl_ui_bg.eo.h" \ No newline at end of file
diff --git a/src/lib/elementary/efl_ui_bg_private.h b/src/lib/elementary/efl_ui_bg_private.h
new file mode 100644
index 0000000000..311fd44269
--- /dev/null
+++ b/src/lib/elementary/efl_ui_bg_private.h
@@ -0,0 +1,69 @@
1#ifndef ELM_WIDGET_BG_H
2#define ELM_WIDGET_BG_H
3
4#include "Elementary.h"
5
6/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
7 * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
8 * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
9 * IT AT RUNTIME.
10 */
11
12/**
13 * @addtogroup Widget
14 * @{
15 *
16 * @section elm-bg-class The Elementary Bg Class
17 *
18 * Elementary, besides having the @ref Bg widget, exposes its
19 * foundation -- the Elementary Bg Class -- in order to create other
20 * widgets which are a bg with some more logic on top.
21 */
22
23/**
24 * Base layout smart data extended with bg instance data.
25 */
26typedef struct _Efl_Ui_Bg_Data Efl_Ui_Bg_Data;
27struct _Efl_Ui_Bg_Data
28{
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 */
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;
33
34 struct
35 {
36 Evas_Coord w, h;
37 } load_opts;
38};
39
40/**
41 * @}
42 */
43
44#define EFL_UI_BG_DATA_GET(o, sd) \
45Efl_Ui_Bg_Data * sd = efl_data_scope_get(o, EFL_UI_BG_CLASS)
46
47#define EFL_UI_BG_DATA_GET_OR_RETURN(o, ptr) \
48 EFL_UI_BG_DATA_GET(o, ptr); \
49 if (EINA_UNLIKELY(!ptr)) \
50 { \
51 CRI("No widget data for object %p (%s)", \
52 o, evas_object_type_get(o)); \
53 return; \
54 }
55
56#define EFL_UI_BG_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
57 EFL_UI_BG_DATA_GET(o, ptr); \
58 if (EINA_UNLIKELY(!ptr)) \
59 { \
60 CRI("No widget data for object %p (%s)", \
61 o, evas_object_type_get(o)); \
62 return val; \
63 }
64
65#define EFL_UI_BG_CHECK(obj) \
66 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_CLASS))) \
67 return
68
69#endif
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index bdf94c1e36..0d6731c123 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -6911,7 +6911,7 @@ _elm_win_standard_init(Eo *obj)
6911 /* Legacy theme compatibility */ 6911 /* Legacy theme compatibility */
6912 DBG("Detected legacy theme used for elm_bg. Swallowing object."); 6912 DBG("Detected legacy theme used for elm_bg. Swallowing object.");
6913 sd->csd.need_bg_solid = EINA_FALSE; 6913 sd->csd.need_bg_solid = EINA_FALSE;
6914 _elm_win_bg_set(sd, efl_add(ELM_BG_CLASS, obj)); 6914 _elm_win_bg_set(sd, efl_add(EFL_UI_BG_CLASS, obj));
6915 } 6915 }
6916 6916
6917 _elm_win_frame_style_update(sd, 0, 1); 6917 _elm_win_frame_style_update(sd, 0, 1);
diff --git a/src/lib/elementary/elm_bg.eo b/src/lib/elementary/elm_bg.eo
deleted file mode 100644
index 0714299002..0000000000
--- a/src/lib/elementary/elm_bg.eo
+++ /dev/null
@@ -1,101 +0,0 @@
1enum Elm.Bg.Option
2{
3 [[Identifiers on how a background widget is to display its image
4
5 -- if it was set to use an image file.
6
7 See also @Elm.Bg.option.set, @Elm.Bg.option.get.
8 ]]
9 center, [[Center the background image.]]
10 scale, [[Scale the background image, retaining aspect ratio (default).]]
11 stretch, [[Stretch the background image to fill the widget's area.]]
12 tile, [[Tile background image at its original size.]]
13 last [[Sentinel value to indicate last enum field during iteration. Also used to indicate errors]]
14}
15
16class Elm.Bg (Efl.Ui.Layout, Efl.File)
17{
18 [[The bg (background) widget is used for setting (solid) background decorations
19
20 to a window (unless it has transparency enabled) or to any container object. It
21 works just like an image, but has some properties useful to a background, like
22 setting it to tiled, centered, scaled or stretched.
23 ]]
24 legacy_prefix: elm_bg;
25 eo_prefix: elm_obj_bg;
26 methods {
27 @property option {
28 [[The mode of display for a given background widget's image]]
29 set {
30 [[This sets how the background widget will display its image. This
31 will only work if the @Efl.File.file.set was previously called with
32 an image file on $obj. The image can be display tiled, scaled,
33 centered or stretched. @Elm.Bg.Option.scale by default.
34 ]]
35 }
36 get {
37 }
38 values {
39 option: Elm.Bg.Option; [[The desired background option(See @Elm.Bg.Option)]]
40 }
41 }
42 @property color {
43 [[The color on a given background widget]]
44 set {
45 [[This sets the color used for the background rectangle, in RGB
46 format. Each color component's range is from 0 to 255.
47
48 Note: You probably only want to use this function if you haven't
49 previously called @Efl.File.file.set, so that you just want a solid
50 color background.
51
52 Note: You can reset the color by setting $r, $g, $b as -1, -1, -1.
53 ]]
54 legacy: null; /* legacy doesn't have 'a' param */
55 }
56 get {
57 [[Note: Use $null pointers on the file components you're not
58 interested in: they'll be ignored by the function.
59 ]]
60 legacy: null; /* legacy doesn't have 'a' param */
61
62 }
63 values {
64 r: int; [[The red color component's value]]
65 g: int; [[The green color component's value]]
66 b: int; [[The blue color component's value]]
67 a: int; [[The alpha color component's value]]
68 }
69 }
70 @property load_size {
71 set {
72 [[Set the size of the pixmap representation of the image set on a
73 given background widget.
74
75 Warning: This function just makes sense if an image file was set on
76 $obj, with @Efl.File.file.set
77
78 This function sets a new size for pixmap representation of the
79 given bg image. It allows for the image to be loaded already in the
80 specified size, reducing the memory usage and load time (for
81 example, when loading a big image file with its load size set to a
82 smaller size)
83
84 Note: This is just a hint for the underlying system. The real size
85 of the pixmap may differ depending on the type of image being
86 loaded, being bigger than requested.
87
88 ]]
89 }
90 values {
91 w: int; [[The new width of the image pixmap representation.]]
92 h: int; [[The new height of the image pixmap representation.]]
93 }
94 }
95 }
96 implements {
97 class.constructor;
98 Efl.Object.constructor;
99 Efl.File.file { get; set; }
100 }
101}
diff --git a/src/lib/elementary/elm_bg.h b/src/lib/elementary/elm_bg.h
index 0a93268f77..c11c342d90 100644
--- a/src/lib/elementary/elm_bg.h
+++ b/src/lib/elementary/elm_bg.h
@@ -30,7 +30,7 @@
30 */ 30 */
31 31
32#ifdef EFL_EO_API_SUPPORT 32#ifdef EFL_EO_API_SUPPORT
33#include "elm_bg_eo.h" 33#include "efl_ui_bg_eo.h"
34#endif 34#endif
35#ifndef EFL_NOLEGACY_API_SUPPORT 35#ifndef EFL_NOLEGACY_API_SUPPORT
36#include "elm_bg_legacy.h" 36#include "elm_bg_legacy.h"
diff --git a/src/lib/elementary/elm_bg_legacy.h b/src/lib/elementary/elm_bg_legacy.h
index a46cc7bcd8..33a1a5211d 100644
--- a/src/lib/elementary/elm_bg_legacy.h
+++ b/src/lib/elementary/elm_bg_legacy.h
@@ -1,4 +1,23 @@
1/** 1/**
2 * @brief Identifiers on how a background widget is to display its image
3 *
4 * -- if it was set to use an image file.
5 *
6 * @ingroup Elm_Bg
7 */
8 typedef enum
9 {
10 ELM_BG_OPTION_CENTER = 0, /**< Center the background image. */
11 ELM_BG_OPTION_SCALE, /**< Scale the background image, retaining aspect ratio
12 * (default). */
13 ELM_BG_OPTION_STRETCH, /**< Stretch the background image to fill the widget's
14 * area. */
15 ELM_BG_OPTION_TILE, /**< Tile background image at its original size. */
16 ELM_BG_OPTION_LAST /**< Sentinel value to indicate last enum field during
17 * iteration. Also used to indicate errors */
18 } Elm_Bg_Option;
19
20/**
2 * Add a new background to the parent 21 * Add a new background to the parent
3 * 22 *
4 * @param parent The parent object 23 * @param parent The parent object
@@ -91,4 +110,55 @@ EAPI Eina_Bool elm_bg_file_set(Eo *obj, const char *file, const char *group);
91 */ 110 */
92EAPI void elm_bg_file_get(const Eo *obj, const char **file, const char **group); 111EAPI void elm_bg_file_get(const Eo *obj, const char **file, const char **group);
93 112
94#include "elm_bg.eo.legacy.h" 113/**
114 * Set the mode of display for a given background widget's image
115 *
116 * This sets how the background widget will display its image. This
117 * will only work if the elm_bg_file_set() was previously called with
118 * an image file on $obj. The image can be display tiled, scaled,
119 * centered or stretched. #ELM_BG_OPTION_SCALE by default.
120 *
121 * @param[in] option The desired background option(See Elm.Bg.Option).
122 *
123 * @see elm_bg_option_get()
124 *
125 * @ingroup Elm_Bg
126 */
127EAPI void elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option);
128
129/**
130 * Get the mode of display of a given background widget's image
131 *
132 * @return The background option Elm.Bg.Option Default is #Elm_Bg_SCALE.
133 *
134 * @see elm_bg_option_set()
135 *
136 * @ingroup Elm_Bg
137 */
138EAPI Elm_Bg_Option elm_bg_option_get(const Evas_Object *obj);
139
140/**
141 * Set the size of the pixmap representation of the image set on a
142 * given background widget.
143 *
144 * @warning: This function just makes sense if an image file was set on
145 * @p obj, with elm_bg_file_set().
146 *
147 * This function sets a new size for pixmap representation of the
148 * given bg image. It allows for the image to be loaded already in the
149 * specified size, reducing the memory usage and load time (for
150 * example, when loading a big image file with its load size set to a
151 * smaller size)
152 *
153 * @note: This is just a hint for the underlying system. The real size
154 * of the pixmap may differ depending on the type of image being
155 * loaded, being bigger than requested.
156 *
157 * @ingroup Elm_Bg
158 *
159 * @param[in] w The new width of the image pixmap representation
160 * @param[in] h The new height of the image pixmap representation
161 */
162EAPI void elm_bg_load_size_set(Evas_Object *obj, int w, int h);
163
164#include "efl_ui_bg.eo.legacy.h"