summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-07-28 14:48:48 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commitcdda66fb56530520b4008ff0b15953ff297820f6 (patch)
treea6d26ab906d4db413d37b87244abb1c90d4c410a
parent61b2368d88c8e0eee42e4cbe2714f8ff3202470b (diff)
efl_ui_popup: add Efl.Ui.Popup class
Summary: add initial code for Efl.Ui.Popup class Test Plan: 1. run elementary_test -to efluipopup Reviewers: Jaehyun_Cho, Blackmole, thiepha, woohyun, cedric Reviewed By: Jaehyun_Cho Subscribers: bu5hm4n, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5037
-rw-r--r--data/elementary/themes/edc/elm/popup.edc36
-rw-r--r--src/Makefile_Elementary.am3
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_popup.c28
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_popup.c133
-rw-r--r--src/lib/elementary/efl_ui_popup.eo21
-rw-r--r--src/lib/elementary/efl_ui_popup_private.h11
8 files changed, 235 insertions, 0 deletions
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";
507 } 507 }
508 } 508 }
509} 509}
510
511//Efl.Ui.Popup Themes
512group { "elm/popup/base/view";
513 images.image: "rounded_square.png" COMP;
514 parts {
515 spacer { "base";
516 desc { "default";
517 rel1.offset: 10 10;
518 rel2.offset: -11 -11;
519 }
520 }
521 image { "bg";
522 desc { "default";
523 min: 100 100;
524 image.border: 15 15 15 15;
525 image.normal: "rounded_square.png";
526 }
527 }
528 swallow { "elm.swallow.content";
529 desc { "default";
530 rel.to: "base";
531 }
532 }
533 }
534}
535
536group { "elm/popup/base/event_bg";
537 parts {
538 rect { "base";
539 repeat;
540 desc { "default";
541 color: 0 255 0 128;
542 }
543 }
544 }
545}
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index d777fd5f73..934aec43d5 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -31,6 +31,7 @@ elm_public_eolian_files = \
31 lib/elementary/efl_ui_grid_static.eo \ 31 lib/elementary/efl_ui_grid_static.eo \
32 lib/elementary/efl_ui_text_interactive.eo \ 32 lib/elementary/efl_ui_text_interactive.eo \
33 lib/elementary/efl_ui_text.eo \ 33 lib/elementary/efl_ui_text.eo \
34 lib/elementary/efl_ui_popup.eo \
34 lib/elementary/efl_ui_text_editable.eo \ 35 lib/elementary/efl_ui_text_editable.eo \
35 lib/elementary/efl_ui_text_async.eo \ 36 lib/elementary/efl_ui_text_async.eo \
36 lib/elementary/efl_ui_textpath.eo \ 37 lib/elementary/efl_ui_textpath.eo \
@@ -290,6 +291,7 @@ includesunstable_HEADERS = \
290 lib/elementary/elm_widget_hoversel.h \ 291 lib/elementary/elm_widget_hoversel.h \
291 lib/elementary/elm_widget_icon.h \ 292 lib/elementary/elm_widget_icon.h \
292 lib/elementary/efl_ui_widget_image.h \ 293 lib/elementary/efl_ui_widget_image.h \
294 lib/elementary/efl_ui_popup_private.h \
293 lib/elementary/elm_widget_index.h \ 295 lib/elementary/elm_widget_index.h \
294 lib/elementary/elm_widget_inwin.h \ 296 lib/elementary/elm_widget_inwin.h \
295 lib/elementary/elm_widget_label.h \ 297 lib/elementary/elm_widget_label.h \
@@ -700,6 +702,7 @@ lib_elementary_libelementary_la_SOURCES = \
700 lib/elementary/efl_ui_box_stack.c \ 702 lib/elementary/efl_ui_box_stack.c \
701 lib/elementary/efl_ui_box_layout.c \ 703 lib/elementary/efl_ui_box_layout.c \
702 lib/elementary/efl_ui_box_private.h \ 704 lib/elementary/efl_ui_box_private.h \
705 lib/elementary/efl_ui_popup.c \
703 lib/elementary/efl_ui_grid.c \ 706 lib/elementary/efl_ui_grid.c \
704 lib/elementary/efl_ui_grid_static.c \ 707 lib/elementary/efl_ui_grid_static.c \
705 lib/elementary/efl_ui_grid_private.h \ 708 lib/elementary/efl_ui_grid_private.h \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 081edbf074..9e936d96e4 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);
274void test_datetime(void *data, Evas_Object *obj, void *event_info); 274void test_datetime(void *data, Evas_Object *obj, void *event_info);
275void test_ui_clock(void *data, Evas_Object *obj, void *event_info); 275void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
276void test_popup(void *data, Evas_Object *obj, void *event_info); 276void test_popup(void *data, Evas_Object *obj, void *event_info);
277void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info);
277void test_dayselector(void *data, Evas_Object *obj, void *event_info); 278void test_dayselector(void *data, Evas_Object *obj, void *event_info);
278void test_image(void *data, Evas_Object *obj, void *event_info); 279void test_image(void *data, Evas_Object *obj, void *event_info);
279void test_image_scale_type(void *data, Evas_Object *obj, void *event_info); 280void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
@@ -1006,6 +1007,7 @@ add_tests:
1006 ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3); 1007 ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3);
1007 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4); 1008 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
1008 ADD_TEST(NULL, "Popups", "Popup", test_popup); 1009 ADD_TEST(NULL, "Popups", "Popup", test_popup);
1010 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup);
1009 1011
1010 //------------------------------// 1012 //------------------------------//
1011 ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar); 1013 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,
938 evas_object_resize(win, 480, 400); 938 evas_object_resize(win, 480, 400);
939 evas_object_show(win); 939 evas_object_show(win);
940} 940}
941
942void
943test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
944{
945 Evas_Object *win;
946
947 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
948 elm_win_autodel_set(win, EINA_TRUE);
949
950 evas_object_resize(win, 320, 320);
951 evas_object_show(win);
952
953 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win);
954
955 evas_object_move(efl_ui_popup, 80, 80);
956 evas_object_resize(efl_ui_popup, 160, 160);
957 evas_object_show(efl_ui_popup);
958
959 int x, y, w, h;
960 evas_object_geometry_get(efl_ui_popup, &x, &y, &w, &h);
961 printf("efl_ui_popup: %d %d %d %d\n", x, y, w, h);
962
963 Evas_Object *btn = elm_button_add(efl_ui_popup);
964 elm_object_text_set(btn, "Efl.Ui.Popup content");
965 evas_object_show(btn);
966
967 efl_content_set(efl_ui_popup, btn);
968}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index f5ae473f5d..c8b1e90ce7 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -281,6 +281,7 @@ EAPI extern Elm_Version *elm_version;
281# include <efl_ui_win_socket.eo.h> 281# include <efl_ui_win_socket.eo.h>
282# include <efl_ui_text_interactive.eo.h> 282# include <efl_ui_text_interactive.eo.h>
283# include <efl_ui_text.eo.h> 283# include <efl_ui_text.eo.h>
284# include <efl_ui_popup.eo.h>
284# include <efl_ui_text_editable.eo.h> 285# include <efl_ui_text_editable.eo.h>
285# include <efl_ui_text_async.eo.h> 286# include <efl_ui_text_async.eo.h>
286# include <efl_ui_clock.eo.h> 287# include <efl_ui_clock.eo.h>
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 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_UI_POPUP_PROTECTED
6
7#include <Elementary.h>
8
9#include "elm_priv.h"
10#include "efl_ui_popup_private.h"
11
12#define MY_CLASS EFL_UI_POPUP_CLASS
13#define MY_CLASS_NAME "Efl.Ui.Popup"
14#define MY_CLASS_NAME_LEGACY "elm_popup"
15
16EOLIAN static void
17_efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Position2D pos)
18{
19 efl_gfx_position_set(efl_super(obj, MY_CLASS), pos);
20}
21
22static void
23_parent_geom_cb(void *data, const Efl_Event *ev)
24{
25 Evas_Object *event_bg = data;
26 Evas_Coord x, y, w, h;
27 evas_object_geometry_get(ev->object, &x, &y, &w, &h);
28
29 if (efl_isa(ev->object, EFL_UI_WIN_CLASS))
30 {
31 x = 0;
32 y = 0;
33 }
34
35 evas_object_move(event_bg, x, y);
36 evas_object_resize(event_bg, w, h);
37}
38
39EOLIAN static void
40_efl_ui_popup_elm_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED)
41{
42 Evas_Coord x, y, w, h;
43 pd->win_parent = efl_provider_find(obj, EFL_UI_WIN_CLASS);
44 if (!pd->win_parent)
45 {
46 ERR("Cannot find window parent");
47 return;
48 }
49
50 evas_object_geometry_get(pd->win_parent, &x, &y, &w, &h);
51 evas_object_move(pd->event_bg, x, y);
52 evas_object_resize(pd->event_bg, w, h);
53
54 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg);
55 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg);
56}
57
58EOLIAN static Eina_Bool
59_efl_ui_popup_efl_container_content_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Evas_Object *content)
60{
61 return efl_content_set(efl_part(obj, "elm.swallow.content"), content);
62}
63
64EOLIAN static Evas_Object*
65_efl_ui_popup_efl_container_content_get(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
66{
67 return efl_content_get(efl_part(obj, "elm.swallow.content"));
68}
69
70EOLIAN static Evas_Object*
71_efl_ui_popup_efl_container_content_unset(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
72{
73 return efl_content_unset(efl_part(obj, "elm.swallow.content"));
74}
75
76EOLIAN static Efl_Canvas_Object *
77_efl_ui_popup_parent_window_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
78{
79 return pd->win_parent;
80}
81
82EOLIAN static void
83_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
84{
85 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
86
87 efl_canvas_group_add(efl_super(obj, MY_CLASS));
88 elm_widget_sub_object_parent_add(obj);
89
90 elm_widget_can_focus_set(obj, EINA_TRUE);
91 elm_layout_theme_set(obj, "popup", "base", "view");
92
93 pd->event_bg = edje_object_add(evas_object_evas_get(obj));
94 elm_widget_theme_object_set(obj, pd->event_bg, "popup", "base", "event_bg");
95 evas_object_smart_member_add(pd->event_bg, obj);
96 evas_object_stack_below(pd->event_bg, wd->resize_obj);
97}
98
99EOLIAN static void
100_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd)
101{
102 ELM_SAFE_FREE(pd->event_bg, evas_object_del);
103 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg);
104 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg);
105
106 efl_canvas_group_del(efl_super(obj, MY_CLASS));
107}
108
109EOLIAN static void
110_efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
111{
112 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
113 Evas_Coord minw = -1, minh = -1;
114
115 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
116 edje_object_size_min_restricted_calc
117 (wd->resize_obj, &minw, &minh, minw, minh);
118 evas_object_size_hint_min_set(obj, minw, minh);
119}
120
121EOLIAN static void
122_efl_ui_popup_class_constructor(Efl_Class *klass)
123{
124 evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
125}
126
127/* Internal EO APIs and hidden overrides */
128
129#define EFL_UI_POPUP_EXTRA_OPS \
130 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup), \
131 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup)
132
133#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 @@
1class Efl.Ui.Popup(Efl.Ui.Layout)
2{
3 legacy_prefix: elm_popup;
4 methods {
5 @property parent_window @protected {
6 get {
7 [[Get the parent window of Popup.]]
8 }
9 values {
10 window: Efl.Canvas.Object;
11 }
12 }
13 }
14 implements {
15 class.constructor;
16 Efl.Gfx.position { set; }
17 Elm.Widget.widget_parent { set; }
18 Efl.Container.content { get; set; }
19 Efl.Container.content_unset;
20 }
21}
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 @@
1#ifndef EFL_UI_WIDGET_POPUP_H
2#define EFL_UI_WIDGET_POPUP_H
3
4typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data;
5struct _Efl_Ui_Popup_Data
6{
7 Evas_Object *win_parent;
8 Evas_Object *event_bg;
9};
10
11#endif