forked from enlightenment/efl
elm_bg: rename elm_bg to Efl.Ui.Bg
Summary: elm_bg was supposed to be used only in legacy, but since we need a common object to be used as a background of widgets, it is now renamed as efl_ui_bg and supports EO APIs. Reviewers: cedric, jpeg, woohyun Differential Revision: https://phab.enlightenment.org/D5147
This commit is contained in:
parent
8557fe818f
commit
ebff5e8639
|
@ -103,7 +103,7 @@ src/lib/elementary/elc_popup.c
|
||||||
src/lib/elementary/elc_scrolled_entry.c
|
src/lib/elementary/elc_scrolled_entry.c
|
||||||
src/lib/elementary/elm_access.c
|
src/lib/elementary/elm_access.c
|
||||||
src/lib/elementary/elm_actionslider.c
|
src/lib/elementary/elm_actionslider.c
|
||||||
src/lib/elementary/elm_bg.c
|
src/lib/elementary/efl_ui_bg.c
|
||||||
src/lib/elementary/elm_box.c
|
src/lib/elementary/elm_box.c
|
||||||
src/lib/elementary/elm_bubble.c
|
src/lib/elementary/elm_bubble.c
|
||||||
src/lib/elementary/efl_ui_button.c
|
src/lib/elementary/efl_ui_button.c
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
elm_public_eolian_files = \
|
elm_public_eolian_files = \
|
||||||
lib/elementary/elm_atspi_bridge.eo \
|
lib/elementary/elm_atspi_bridge.eo \
|
||||||
lib/elementary/elm_atspi_app_object.eo \
|
lib/elementary/elm_atspi_app_object.eo \
|
||||||
lib/elementary/elm_bg.eo \
|
lib/elementary/efl_ui_bg.eo \
|
||||||
lib/elementary/efl_ui_button.eo \
|
lib/elementary/efl_ui_button.eo \
|
||||||
lib/elementary/elm_calendar.eo \
|
lib/elementary/elm_calendar.eo \
|
||||||
lib/elementary/efl_ui_check.eo \
|
lib/elementary/efl_ui_check.eo \
|
||||||
|
@ -345,7 +345,7 @@ includesub_HEADERS = \
|
||||||
lib/elementary/elm_atspi_app_object.h \
|
lib/elementary/elm_atspi_app_object.h \
|
||||||
lib/elementary/elm_authors.h \
|
lib/elementary/elm_authors.h \
|
||||||
lib/elementary/elm_bg.h \
|
lib/elementary/elm_bg.h \
|
||||||
lib/elementary/elm_bg_eo.h \
|
lib/elementary/efl_ui_bg_eo.h \
|
||||||
lib/elementary/elm_bg_legacy.h \
|
lib/elementary/elm_bg_legacy.h \
|
||||||
lib/elementary/elm_box.h \
|
lib/elementary/elm_box.h \
|
||||||
lib/elementary/elm_box_legacy.h \
|
lib/elementary/elm_box_legacy.h \
|
||||||
|
@ -569,7 +569,7 @@ lib_elementary_libelementary_la_SOURCES = \
|
||||||
lib/elementary/elm_actionslider.c \
|
lib/elementary/elm_actionslider.c \
|
||||||
lib/elementary/elm_atspi_app_object.c \
|
lib/elementary/elm_atspi_app_object.c \
|
||||||
lib/elementary/elm_atspi_bridge.c \
|
lib/elementary/elm_atspi_bridge.c \
|
||||||
lib/elementary/elm_bg.c \
|
lib/elementary/efl_ui_bg.c \
|
||||||
lib/elementary/elm_box.c \
|
lib/elementary/elm_box.c \
|
||||||
lib/elementary/elm_bubble.c \
|
lib/elementary/elm_bubble.c \
|
||||||
lib/elementary/efl_ui_button.c \
|
lib/elementary/efl_ui_button.c \
|
||||||
|
|
|
@ -17,6 +17,7 @@ void test_bg_plain(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_bg_image(void *data, Evas_Object *obj, void *event_info);
|
void test_bg_image(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_bg_options(void *data, Evas_Object *obj, void *event_info);
|
void test_bg_options(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_bg_window(void *data, Evas_Object *obj, void *event_info);
|
void test_bg_window(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
void test_bg_scale_type(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_icon(void *data, Evas_Object *obj, void *event_info);
|
void test_icon(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_icon_transparent(void *data, Evas_Object *obj, void *event_info);
|
void test_icon_transparent(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_icon_standard(void *data, Evas_Object *obj, void *event_info);
|
void test_icon_standard(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -664,6 +665,7 @@ add_tests:
|
||||||
ADD_TEST(NULL, "Window / Background", "Bg Image", test_bg_image);
|
ADD_TEST(NULL, "Window / Background", "Bg Image", test_bg_image);
|
||||||
ADD_TEST(NULL, "Window / Background", "Bg Options", test_bg_options);
|
ADD_TEST(NULL, "Window / Background", "Bg Options", test_bg_options);
|
||||||
ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Win)", test_bg_window);
|
ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Win)", test_bg_window);
|
||||||
|
ADD_TEST(NULL, "Window / Background", "Bg EOAPI (Efl.Ui.Bg)", test_bg_scale_type);
|
||||||
ADD_TEST(NULL, "Window / Background", "Window States", test_win_state);
|
ADD_TEST(NULL, "Window / Background", "Window States", test_win_state);
|
||||||
ADD_TEST(NULL, "Window / Background", "Window States 2", test_win_state2);
|
ADD_TEST(NULL, "Window / Background", "Window States 2", test_win_state2);
|
||||||
ADD_TEST(NULL, "Window / Background", "Inwin", test_inwin);
|
ADD_TEST(NULL, "Window / Background", "Inwin", test_inwin);
|
||||||
|
|
|
@ -366,3 +366,111 @@ test_bg_window(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
|
||||||
|
|
||||||
efl_gfx_size_set(win, EINA_SIZE2D(300, 200));
|
efl_gfx_size_set(win, EINA_SIZE2D(300, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_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_radio_value_get(ev->object));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cb_check_changed_scale_type(void *data, const Efl_Event *ev)
|
||||||
|
{
|
||||||
|
Evas_Object *o_bg = data;
|
||||||
|
|
||||||
|
if (efl_ui_check_selected_get(ev->object))
|
||||||
|
efl_gfx_color_set(o_bg, 255, 128, 128, 255);
|
||||||
|
else
|
||||||
|
efl_gfx_color_set(o_bg, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *win;
|
||||||
|
Evas_Object *box, *hbox, *o_bg;
|
||||||
|
Evas_Object *rd, *rdg;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
||||||
|
efl_text_set(efl_added, "Bg EOAPI (Efl.Ui.Bg)"),
|
||||||
|
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_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
|
||||||
|
efl_content_set(win, efl_added));
|
||||||
|
|
||||||
|
box = efl_add(EFL_UI_BOX_CLASS, win,
|
||||||
|
efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
|
||||||
|
efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
|
||||||
|
efl_content_set(win, efl_added));
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
|
||||||
|
|
||||||
|
o_bg = efl_add(EFL_UI_BG_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),
|
||||||
|
efl_pack(box, efl_added));
|
||||||
|
|
||||||
|
hbox = efl_add(EFL_UI_BOX_CLASS, box,
|
||||||
|
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
|
||||||
|
efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
|
||||||
|
efl_gfx_size_hint_align_set(efl_added, EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL),
|
||||||
|
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_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_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),
|
||||||
|
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_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),
|
||||||
|
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_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),
|
||||||
|
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_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_radio_value_set(rdg, EFL_UI_IMAGE_SCALE_TYPE_FILL);
|
||||||
|
|
||||||
|
efl_add(EFL_UI_CHECK_CLASS, hbox,
|
||||||
|
efl_text_set(efl_added, "Bg Color"),
|
||||||
|
efl_gfx_size_hint_weight_set(efl_added, EFL_GFX_SIZE_HINT_EXPAND, 0.0),
|
||||||
|
efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED, _cb_check_changed_scale_type, o_bg),
|
||||||
|
efl_pack(hbox, efl_added));
|
||||||
|
|
||||||
|
efl_gfx_size_set(win, EINA_SIZE2D(300, 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#include "elm_priv.h"
|
#include "elm_priv.h"
|
||||||
#include "elm_widget_bg.h"
|
#include "efl_ui_bg_private.h"
|
||||||
#include "elm_widget_layout.h"
|
#include "elm_widget_layout.h"
|
||||||
|
|
||||||
#define MY_CLASS ELM_BG_CLASS
|
#define MY_CLASS EFL_UI_BG_CLASS
|
||||||
#define MY_CLASS_PFX elm_bg
|
#define MY_CLASS_PFX efl_ui_bg
|
||||||
|
|
||||||
#define MY_CLASS_NAME "Elm_Bg"
|
#define MY_CLASS_NAME "Efl.Ui.Bg"
|
||||||
#define MY_CLASS_NAME_LEGACY "elm_bg"
|
#define MY_CLASS_NAME_LEGACY "elm_bg"
|
||||||
|
|
||||||
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
||||||
|
@ -23,7 +23,7 @@ static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd)
|
_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 iw = 0, ih = 0, mw = -1, mh = -1;
|
||||||
Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
|
Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
|
||||||
|
@ -43,14 +43,26 @@ _elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd)
|
||||||
evas_object_geometry_get
|
evas_object_geometry_get
|
||||||
(wd->resize_obj, &bx, &by, &bw, &bh);
|
(wd->resize_obj, &bx, &by, &bw, &bh);
|
||||||
|
|
||||||
switch (sd->option)
|
switch (sd->scale_type)
|
||||||
{
|
{
|
||||||
case ELM_BG_OPTION_CENTER:
|
case EFL_UI_IMAGE_SCALE_TYPE_NONE:
|
||||||
fw = mw = iw;
|
fw = mw = iw;
|
||||||
fh = mh = ih;
|
fh = mh = ih;
|
||||||
break;
|
break;
|
||||||
|
case EFL_UI_IMAGE_SCALE_TYPE_FILL:
|
||||||
case ELM_BG_OPTION_SCALE:
|
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;
|
fw = bw;
|
||||||
fh = ((ih * fw) / iw);
|
fh = ((ih * fw) / iw);
|
||||||
if (fh < bh)
|
if (fh < bh)
|
||||||
|
@ -61,22 +73,14 @@ _elm_bg_elm_layout_sizing_eval(Eo *obj, Elm_Bg_Data *sd)
|
||||||
fx = ((bw - fw) / 2);
|
fx = ((bw - fw) / 2);
|
||||||
fy = ((bh - fh) / 2);
|
fy = ((bh - fh) / 2);
|
||||||
break;
|
break;
|
||||||
|
case EFL_UI_IMAGE_SCALE_TYPE_TILE:
|
||||||
case ELM_BG_OPTION_TILE:
|
|
||||||
fw = iw;
|
fw = iw;
|
||||||
fh = ih;
|
fh = ih;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELM_BG_OPTION_STRETCH:
|
|
||||||
default:
|
|
||||||
fw = bw;
|
|
||||||
fh = bh;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_object_image_fill_set(sd->img, fx, fy, fw, fh);
|
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);
|
evas_object_size_hint_max_set(sd->img, mw, mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,14 +94,14 @@ _on_resize(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_bg_efl_canvas_group_group_add(Eo *obj, Elm_Bg_Data *priv)
|
_efl_ui_bg_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Bg_Data *priv)
|
||||||
{
|
{
|
||||||
|
|
||||||
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
||||||
elm_widget_sub_object_parent_add(obj);
|
elm_widget_sub_object_parent_add(obj);
|
||||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||||
|
|
||||||
priv->option = ELM_BG_OPTION_SCALE;
|
priv->scale_type = EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE;
|
||||||
|
|
||||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_resize, obj);
|
||||||
|
|
||||||
|
@ -113,7 +117,7 @@ elm_bg_add(Evas_Object *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eo *
|
EOLIAN static Eo *
|
||||||
_elm_bg_efl_object_constructor(Eo *obj, Elm_Bg_Data *_pd EINA_UNUSED)
|
_efl_ui_bg_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Data *_pd EINA_UNUSED)
|
||||||
{
|
{
|
||||||
elm_interface_atspi_accessible_type_set(obj, ELM_ATSPI_TYPE_DISABLED);
|
elm_interface_atspi_accessible_type_set(obj, ELM_ATSPI_TYPE_DISABLED);
|
||||||
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_elm_bg_efl_file_file_set(Eo *obj, Elm_Bg_Data *sd, const char *file, const char *group)
|
_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);
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
||||||
|
|
||||||
|
@ -178,24 +182,78 @@ _elm_bg_efl_file_file_set(Eo *obj, Elm_Bg_Data *sd, const char *file, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_bg_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, const char **file, const char **group)
|
_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 (file) *file = sd->file;
|
||||||
if (group) *group = sd->group;
|
if (group) *group = sd->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EAPI void
|
||||||
_elm_bg_option_set(Eo *obj, Elm_Bg_Data *sd, Elm_Bg_Option option)
|
elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
|
||||||
{
|
{
|
||||||
sd->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);
|
elm_layout_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Elm_Bg_Option
|
EAPI Elm_Bg_Option
|
||||||
_elm_bg_option_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd)
|
elm_bg_option_get(const Evas_Object *obj)
|
||||||
{
|
{
|
||||||
return sd->option;
|
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
|
EAPI void
|
||||||
|
@ -204,12 +262,12 @@ elm_bg_color_set(Evas_Object *obj,
|
||||||
int g,
|
int g,
|
||||||
int b)
|
int b)
|
||||||
{
|
{
|
||||||
ELM_BG_CHECK(obj);
|
EFL_UI_BG_CHECK(obj);
|
||||||
elm_obj_bg_color_set(obj, r, g, b, 255);
|
efl_gfx_color_set(obj, r, g, b, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_bg_color_set(Eo *obj, Elm_Bg_Data *sd, int r, int g, int b, int a)
|
_efl_ui_bg_efl_gfx_color_set(Eo *obj, Efl_Ui_Bg_Data *sd, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
|
|
||||||
|
@ -224,9 +282,8 @@ _elm_bg_color_set(Eo *obj, Elm_Bg_Data *sd, int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
sd->rect = evas_object_rectangle_add
|
sd->rect = evas_object_rectangle_add
|
||||||
(evas_object_evas_get(wd->resize_obj));
|
(evas_object_evas_get(wd->resize_obj));
|
||||||
|
efl_gfx_visible_set(sd->rect, EINA_TRUE);
|
||||||
elm_layout_content_set(obj, "elm.swallow.rectangle", sd->rect);
|
elm_layout_content_set(obj, "elm.swallow.rectangle", sd->rect);
|
||||||
|
|
||||||
elm_layout_sizing_eval(obj);
|
elm_layout_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,20 +296,15 @@ elm_bg_color_get(const Evas_Object *obj,
|
||||||
int *g,
|
int *g,
|
||||||
int *b)
|
int *b)
|
||||||
{
|
{
|
||||||
ELM_BG_CHECK(obj);
|
EFL_UI_BG_CHECK(obj);
|
||||||
elm_obj_bg_color_get((Eo *) obj, r, g, b, NULL);
|
efl_gfx_color_get((Eo *) obj, r, g, b, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EAPI void
|
||||||
_elm_bg_color_get(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, int *r, int *g, int *b, int *a)
|
elm_bg_load_size_set(Evas_Object *obj, int w, int h)
|
||||||
{
|
|
||||||
evas_object_color_get(sd->rect, r, g, b, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
EOLIAN static void
|
|
||||||
_elm_bg_load_size_set(Eo *obj EINA_UNUSED, Elm_Bg_Data *sd, Evas_Coord w, Evas_Coord h)
|
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
|
EFL_UI_BG_DATA_GET(obj, sd);
|
||||||
|
|
||||||
sd->load_opts.w = w;
|
sd->load_opts.w = w;
|
||||||
sd->load_opts.h = h;
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_elm_bg_class_constructor(Efl_Class *klass)
|
_efl_ui_bg_class_constructor(Efl_Class *klass)
|
||||||
{
|
{
|
||||||
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
||||||
}
|
}
|
||||||
|
@ -284,9 +336,9 @@ elm_bg_file_get(const Eo *obj, const char **file, const char **group)
|
||||||
|
|
||||||
ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
||||||
|
|
||||||
#define ELM_BG_EXTRA_OPS \
|
#define EFL_UI_BG_EXTRA_OPS \
|
||||||
ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
|
ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
|
||||||
ELM_LAYOUT_SIZING_EVAL_OPS(elm_bg), \
|
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_bg), \
|
||||||
EFL_CANVAS_GROUP_ADD_OPS(elm_bg)
|
EFL_CANVAS_GROUP_ADD_OPS(efl_ui_bg)
|
||||||
|
|
||||||
#include "elm_bg.eo.c"
|
#include "efl_ui_bg.eo.c"
|
|
@ -0,0 +1,17 @@
|
||||||
|
class Efl.Ui.Bg (Efl.Ui.Layout, Efl.Ui.Image)
|
||||||
|
{
|
||||||
|
[[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.Gfx.color { set; }
|
||||||
|
Efl.Ui.Image.scale_type { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
#include "efl_ui_bg.eo.h"
|
|
@ -0,0 +1,69 @@
|
||||||
|
#ifndef ELM_WIDGET_BG_H
|
||||||
|
#define ELM_WIDGET_BG_H
|
||||||
|
|
||||||
|
#include "Elementary.h"
|
||||||
|
|
||||||
|
/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
|
||||||
|
* CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
|
||||||
|
* FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
|
||||||
|
* IT AT RUNTIME.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup Widget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @section elm-bg-class The Elementary Bg Class
|
||||||
|
*
|
||||||
|
* Elementary, besides having the @ref Bg widget, exposes its
|
||||||
|
* foundation -- the Elementary Bg Class -- in order to create other
|
||||||
|
* widgets which are a bg with some more logic on top.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base layout smart data extended with bg instance data.
|
||||||
|
*/
|
||||||
|
typedef struct _Efl_Ui_Bg_Data Efl_Ui_Bg_Data;
|
||||||
|
struct _Efl_Ui_Bg_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;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
Evas_Coord w, h;
|
||||||
|
} load_opts;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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_DATA_GET_OR_RETURN(o, ptr) \
|
||||||
|
EFL_UI_BG_DATA_GET(o, ptr); \
|
||||||
|
if (EINA_UNLIKELY(!ptr)) \
|
||||||
|
{ \
|
||||||
|
CRI("No widget data for object %p (%s)", \
|
||||||
|
o, evas_object_type_get(o)); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EFL_UI_BG_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
||||||
|
EFL_UI_BG_DATA_GET(o, ptr); \
|
||||||
|
if (EINA_UNLIKELY(!ptr)) \
|
||||||
|
{ \
|
||||||
|
CRI("No widget data for object %p (%s)", \
|
||||||
|
o, evas_object_type_get(o)); \
|
||||||
|
return val; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EFL_UI_BG_CHECK(obj) \
|
||||||
|
if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_BG_CLASS))) \
|
||||||
|
return
|
||||||
|
|
||||||
|
#endif
|
|
@ -6911,7 +6911,7 @@ _elm_win_standard_init(Eo *obj)
|
||||||
/* Legacy theme compatibility */
|
/* Legacy theme compatibility */
|
||||||
DBG("Detected legacy theme used for elm_bg. Swallowing object.");
|
DBG("Detected legacy theme used for elm_bg. Swallowing object.");
|
||||||
sd->csd.need_bg_solid = EINA_FALSE;
|
sd->csd.need_bg_solid = EINA_FALSE;
|
||||||
_elm_win_bg_set(sd, efl_add(ELM_BG_CLASS, obj));
|
_elm_win_bg_set(sd, efl_add(EFL_UI_BG_CLASS, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
_elm_win_frame_style_update(sd, 0, 1);
|
_elm_win_frame_style_update(sd, 0, 1);
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
enum Elm.Bg.Option
|
|
||||||
{
|
|
||||||
[[Identifiers on how a background widget is to display its image
|
|
||||||
|
|
||||||
-- if it was set to use an image file.
|
|
||||||
|
|
||||||
See also @Elm.Bg.option.set, @Elm.Bg.option.get.
|
|
||||||
]]
|
|
||||||
center, [[Center the background image.]]
|
|
||||||
scale, [[Scale the background image, retaining aspect ratio (default).]]
|
|
||||||
stretch, [[Stretch the background image to fill the widget's area.]]
|
|
||||||
tile, [[Tile background image at its original size.]]
|
|
||||||
last [[Sentinel value to indicate last enum field during iteration. Also used to indicate errors]]
|
|
||||||
}
|
|
||||||
|
|
||||||
class Elm.Bg (Efl.Ui.Layout, Efl.File)
|
|
||||||
{
|
|
||||||
[[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;
|
|
||||||
eo_prefix: elm_obj_bg;
|
|
||||||
methods {
|
|
||||||
@property option {
|
|
||||||
[[The mode of display for a given background widget's image]]
|
|
||||||
set {
|
|
||||||
[[This sets how the background widget will display its image. This
|
|
||||||
will only work if the @Efl.File.file.set was previously called with
|
|
||||||
an image file on $obj. The image can be display tiled, scaled,
|
|
||||||
centered or stretched. @Elm.Bg.Option.scale by default.
|
|
||||||
]]
|
|
||||||
}
|
|
||||||
get {
|
|
||||||
}
|
|
||||||
values {
|
|
||||||
option: Elm.Bg.Option; [[The desired background option(See @Elm.Bg.Option)]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@property color {
|
|
||||||
[[The color on a given background widget]]
|
|
||||||
set {
|
|
||||||
[[This sets the color used for the background rectangle, in RGB
|
|
||||||
format. Each color component's range is from 0 to 255.
|
|
||||||
|
|
||||||
Note: You probably only want to use this function if you haven't
|
|
||||||
previously called @Efl.File.file.set, so that you just want a solid
|
|
||||||
color background.
|
|
||||||
|
|
||||||
Note: You can reset the color by setting $r, $g, $b as -1, -1, -1.
|
|
||||||
]]
|
|
||||||
legacy: null; /* legacy doesn't have 'a' param */
|
|
||||||
}
|
|
||||||
get {
|
|
||||||
[[Note: Use $null pointers on the file components you're not
|
|
||||||
interested in: they'll be ignored by the function.
|
|
||||||
]]
|
|
||||||
legacy: null; /* legacy doesn't have 'a' param */
|
|
||||||
|
|
||||||
}
|
|
||||||
values {
|
|
||||||
r: int; [[The red color component's value]]
|
|
||||||
g: int; [[The green color component's value]]
|
|
||||||
b: int; [[The blue color component's value]]
|
|
||||||
a: int; [[The alpha color component's value]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@property load_size {
|
|
||||||
set {
|
|
||||||
[[Set the size of the pixmap representation of the image set on a
|
|
||||||
given background widget.
|
|
||||||
|
|
||||||
Warning: This function just makes sense if an image file was set on
|
|
||||||
$obj, with @Efl.File.file.set
|
|
||||||
|
|
||||||
This function sets a new size for pixmap representation of the
|
|
||||||
given bg image. It allows for the image to be loaded already in the
|
|
||||||
specified size, reducing the memory usage and load time (for
|
|
||||||
example, when loading a big image file with its load size set to a
|
|
||||||
smaller size)
|
|
||||||
|
|
||||||
Note: This is just a hint for the underlying system. The real size
|
|
||||||
of the pixmap may differ depending on the type of image being
|
|
||||||
loaded, being bigger than requested.
|
|
||||||
|
|
||||||
]]
|
|
||||||
}
|
|
||||||
values {
|
|
||||||
w: int; [[The new width of the image pixmap representation.]]
|
|
||||||
h: int; [[The new height of the image pixmap representation.]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
implements {
|
|
||||||
class.constructor;
|
|
||||||
Efl.Object.constructor;
|
|
||||||
Efl.File.file { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef EFL_EO_API_SUPPORT
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
#include "elm_bg_eo.h"
|
#include "efl_ui_bg_eo.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef EFL_NOLEGACY_API_SUPPORT
|
#ifndef EFL_NOLEGACY_API_SUPPORT
|
||||||
#include "elm_bg_legacy.h"
|
#include "elm_bg_legacy.h"
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/**
|
||||||
|
* @brief Identifiers on how a background widget is to display its image
|
||||||
|
*
|
||||||
|
* -- if it was set to use an image file.
|
||||||
|
*
|
||||||
|
* @ingroup Elm_Bg
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ELM_BG_OPTION_CENTER = 0, /**< Center the background image. */
|
||||||
|
ELM_BG_OPTION_SCALE, /**< Scale the background image, retaining aspect ratio
|
||||||
|
* (default). */
|
||||||
|
ELM_BG_OPTION_STRETCH, /**< Stretch the background image to fill the widget's
|
||||||
|
* area. */
|
||||||
|
ELM_BG_OPTION_TILE, /**< Tile background image at its original size. */
|
||||||
|
ELM_BG_OPTION_LAST /**< Sentinel value to indicate last enum field during
|
||||||
|
* iteration. Also used to indicate errors */
|
||||||
|
} Elm_Bg_Option;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new background to the parent
|
* Add a new background to the parent
|
||||||
*
|
*
|
||||||
|
@ -91,4 +110,55 @@ EAPI Eina_Bool elm_bg_file_set(Eo *obj, const char *file, const char *group);
|
||||||
*/
|
*/
|
||||||
EAPI void elm_bg_file_get(const Eo *obj, const char **file, const char **group);
|
EAPI void elm_bg_file_get(const Eo *obj, const char **file, const char **group);
|
||||||
|
|
||||||
#include "elm_bg.eo.legacy.h"
|
/**
|
||||||
|
* Set the mode of display for a given background widget's image
|
||||||
|
*
|
||||||
|
* This sets how the background widget will display its image. This
|
||||||
|
* will only work if the elm_bg_file_set() was previously called with
|
||||||
|
* an image file on $obj. The image can be display tiled, scaled,
|
||||||
|
* centered or stretched. #ELM_BG_OPTION_SCALE by default.
|
||||||
|
*
|
||||||
|
* @param[in] option The desired background option(See Elm.Bg.Option).
|
||||||
|
*
|
||||||
|
* @see elm_bg_option_get()
|
||||||
|
*
|
||||||
|
* @ingroup Elm_Bg
|
||||||
|
*/
|
||||||
|
EAPI void elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mode of display of a given background widget's image
|
||||||
|
*
|
||||||
|
* @return The background option Elm.Bg.Option Default is #Elm_Bg_SCALE.
|
||||||
|
*
|
||||||
|
* @see elm_bg_option_set()
|
||||||
|
*
|
||||||
|
* @ingroup Elm_Bg
|
||||||
|
*/
|
||||||
|
EAPI Elm_Bg_Option elm_bg_option_get(const Evas_Object *obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the pixmap representation of the image set on a
|
||||||
|
* given background widget.
|
||||||
|
*
|
||||||
|
* @warning: This function just makes sense if an image file was set on
|
||||||
|
* @p obj, with elm_bg_file_set().
|
||||||
|
*
|
||||||
|
* This function sets a new size for pixmap representation of the
|
||||||
|
* given bg image. It allows for the image to be loaded already in the
|
||||||
|
* specified size, reducing the memory usage and load time (for
|
||||||
|
* example, when loading a big image file with its load size set to a
|
||||||
|
* smaller size)
|
||||||
|
*
|
||||||
|
* @note: This is just a hint for the underlying system. The real size
|
||||||
|
* of the pixmap may differ depending on the type of image being
|
||||||
|
* loaded, being bigger than requested.
|
||||||
|
*
|
||||||
|
* @ingroup Elm_Bg
|
||||||
|
*
|
||||||
|
* @param[in] w The new width of the image pixmap representation
|
||||||
|
* @param[in] h The new height of the image pixmap representation
|
||||||
|
*/
|
||||||
|
EAPI void elm_bg_load_size_set(Evas_Object *obj, int w, int h);
|
||||||
|
|
||||||
|
#include "efl_ui_bg.eo.legacy.h"
|
||||||
|
|
Loading…
Reference in New Issue