diff --git a/data/elementary/themes/edc/elm/popup.edc b/data/elementary/themes/edc/elm/popup.edc index a551d4c602..ec79630716 100644 --- a/data/elementary/themes/edc/elm/popup.edc +++ b/data/elementary/themes/edc/elm/popup.edc @@ -507,3 +507,39 @@ group { name: "elm/popup/base/subpopup"; } } } + +//Efl.Ui.Popup Themes +group { "elm/popup/base/view"; + images.image: "rounded_square.png" COMP; + parts { + spacer { "base"; + desc { "default"; + rel1.offset: 10 10; + rel2.offset: -11 -11; + } + } + image { "bg"; + desc { "default"; + min: 100 100; + image.border: 15 15 15 15; + image.normal: "rounded_square.png"; + } + } + swallow { "elm.swallow.content"; + desc { "default"; + rel.to: "base"; + } + } + } +} + +group { "elm/popup/base/event_bg"; + parts { + rect { "base"; + repeat; + desc { "default"; + color: 0 255 0 128; + } + } + } +} diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 3950d11e7d..d825df3d6c 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -33,6 +33,7 @@ elm_public_eolian_files = \ lib/elementary/efl_ui_grid_static.eo \ lib/elementary/efl_ui_text_interactive.eo \ lib/elementary/efl_ui_text.eo \ + lib/elementary/efl_ui_popup.eo \ lib/elementary/efl_ui_text_editable.eo \ lib/elementary/efl_ui_text_async.eo \ lib/elementary/efl_ui_textpath.eo \ @@ -285,6 +286,7 @@ includesunstable_HEADERS = \ lib/elementary/elm_widget_hoversel.h \ lib/elementary/elm_widget_icon.h \ lib/elementary/efl_ui_widget_image.h \ + lib/elementary/efl_ui_popup_private.h \ lib/elementary/elm_widget_index.h \ lib/elementary/elm_widget_inwin.h \ lib/elementary/elm_widget_label.h \ @@ -694,6 +696,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_box_stack.c \ lib/elementary/efl_ui_box_layout.c \ lib/elementary/efl_ui_box_private.h \ + lib/elementary/efl_ui_popup.c \ lib/elementary/efl_ui_grid.c \ lib/elementary/efl_ui_grid_static.c \ lib/elementary/efl_ui_grid_private.h \ diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c index c643b8a4e1..63e902e902 100644 --- a/src/bin/elementary/test.c +++ b/src/bin/elementary/test.c @@ -274,6 +274,7 @@ void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info); void test_datetime(void *data, Evas_Object *obj, void *event_info); void test_ui_clock(void *data, Evas_Object *obj, void *event_info); void test_popup(void *data, Evas_Object *obj, void *event_info); +void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info); void test_dayselector(void *data, Evas_Object *obj, void *event_info); void test_image(void *data, Evas_Object *obj, void *event_info); void test_image_scale_type(void *data, Evas_Object *obj, void *event_info); @@ -1042,6 +1043,7 @@ add_tests: ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3); ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4); ADD_TEST(NULL, "Popups", "Popup", test_popup); + ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup); //------------------------------// ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar); diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c index 173b1bf555..dbbb1a8891 100644 --- a/src/bin/elementary/test_popup.c +++ b/src/bin/elementary/test_popup.c @@ -938,3 +938,31 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, evas_object_resize(win, 480, 400); evas_object_show(win); } + +void +test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *win; + + win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup"); + elm_win_autodel_set(win, EINA_TRUE); + + evas_object_resize(win, 320, 320); + evas_object_show(win); + + Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win); + + evas_object_move(efl_ui_popup, 80, 80); + evas_object_resize(efl_ui_popup, 160, 160); + evas_object_show(efl_ui_popup); + + int x, y, w, h; + evas_object_geometry_get(efl_ui_popup, &x, &y, &w, &h); + printf("efl_ui_popup: %d %d %d %d\n", x, y, w, h); + + Evas_Object *btn = elm_button_add(efl_ui_popup); + elm_object_text_set(btn, "Efl.Ui.Popup content"); + evas_object_show(btn); + + efl_content_set(efl_ui_popup, btn); +} diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 64367cadc8..e2e221c29f 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -301,6 +301,7 @@ EAPI extern Elm_Version *elm_version; # include # include # include +# include # include # include # include diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c new file mode 100644 index 0000000000..4b938a7016 --- /dev/null +++ b/src/lib/elementary/efl_ui_popup.c @@ -0,0 +1,133 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define EFL_UI_POPUP_PROTECTED + +#include + +#include "elm_priv.h" +#include "efl_ui_popup_private.h" + +#define MY_CLASS EFL_UI_POPUP_CLASS +#define MY_CLASS_NAME "Efl.Ui.Popup" +#define MY_CLASS_NAME_LEGACY "elm_popup" + +EOLIAN static void +_efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Position2D pos) +{ + efl_gfx_position_set(efl_super(obj, MY_CLASS), pos); +} + +static void +_parent_geom_cb(void *data, const Efl_Event *ev) +{ + Evas_Object *event_bg = data; + Evas_Coord x, y, w, h; + evas_object_geometry_get(ev->object, &x, &y, &w, &h); + + if (efl_isa(ev->object, EFL_UI_WIN_CLASS)) + { + x = 0; + y = 0; + } + + evas_object_move(event_bg, x, y); + evas_object_resize(event_bg, w, h); +} + +EOLIAN static void +_efl_ui_popup_elm_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED) +{ + Evas_Coord x, y, w, h; + pd->win_parent = efl_provider_find(obj, EFL_UI_WIN_CLASS); + if (!pd->win_parent) + { + ERR("Cannot find window parent"); + return; + } + + evas_object_geometry_get(pd->win_parent, &x, &y, &w, &h); + evas_object_move(pd->event_bg, x, y); + evas_object_resize(pd->event_bg, w, h); + + efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg); + efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg); +} + +EOLIAN static Eina_Bool +_efl_ui_popup_efl_container_content_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Evas_Object *content) +{ + return efl_content_set(efl_part(obj, "elm.swallow.content"), content); +} + +EOLIAN static Evas_Object* +_efl_ui_popup_efl_container_content_get(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED) +{ + return efl_content_get(efl_part(obj, "elm.swallow.content")); +} + +EOLIAN static Evas_Object* +_efl_ui_popup_efl_container_content_unset(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED) +{ + return efl_content_unset(efl_part(obj, "elm.swallow.content")); +} + +EOLIAN static Efl_Canvas_Object * +_efl_ui_popup_parent_window_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd) +{ + return pd->win_parent; +} + +EOLIAN static void +_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + efl_canvas_group_add(efl_super(obj, MY_CLASS)); + elm_widget_sub_object_parent_add(obj); + + elm_widget_can_focus_set(obj, EINA_TRUE); + elm_layout_theme_set(obj, "popup", "base", "view"); + + pd->event_bg = edje_object_add(evas_object_evas_get(obj)); + elm_widget_theme_object_set(obj, pd->event_bg, "popup", "base", "event_bg"); + evas_object_smart_member_add(pd->event_bg, obj); + evas_object_stack_below(pd->event_bg, wd->resize_obj); +} + +EOLIAN static void +_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd) +{ + ELM_SAFE_FREE(pd->event_bg, evas_object_del); + efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg); + efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg); + + efl_canvas_group_del(efl_super(obj, MY_CLASS)); +} + +EOLIAN static void +_efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + Evas_Coord minw = -1, minh = -1; + + elm_coords_finger_size_adjust(1, &minw, 1, &minh); + edje_object_size_min_restricted_calc + (wd->resize_obj, &minw, &minh, minw, minh); + evas_object_size_hint_min_set(obj, minw, minh); +} + +EOLIAN static void +_efl_ui_popup_class_constructor(Efl_Class *klass) +{ + evas_smart_legacy_type_register(MY_CLASS_NAME, klass); +} + +/* Internal EO APIs and hidden overrides */ + +#define EFL_UI_POPUP_EXTRA_OPS \ + EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup), \ + ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup) + +#include "efl_ui_popup.eo.c" diff --git a/src/lib/elementary/efl_ui_popup.eo b/src/lib/elementary/efl_ui_popup.eo new file mode 100644 index 0000000000..8383e7c269 --- /dev/null +++ b/src/lib/elementary/efl_ui_popup.eo @@ -0,0 +1,21 @@ +class Efl.Ui.Popup(Efl.Ui.Layout) +{ + legacy_prefix: elm_popup; + methods { + @property parent_window @protected { + get { + [[Get the parent window of Popup.]] + } + values { + window: Efl.Canvas.Object; + } + } + } + implements { + class.constructor; + Efl.Gfx.position { set; } + Elm.Widget.widget_parent { set; } + Efl.Container.content { get; set; } + Efl.Container.content_unset; + } +} diff --git a/src/lib/elementary/efl_ui_popup_private.h b/src/lib/elementary/efl_ui_popup_private.h new file mode 100644 index 0000000000..d0b979ba05 --- /dev/null +++ b/src/lib/elementary/efl_ui_popup_private.h @@ -0,0 +1,11 @@ +#ifndef EFL_UI_WIDGET_POPUP_H +#define EFL_UI_WIDGET_POPUP_H + +typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data; +struct _Efl_Ui_Popup_Data +{ + Evas_Object *win_parent; + Evas_Object *event_bg; +}; + +#endif