summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-08-17 17:37:54 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commit21c3254a0dbfa7a8670ab6041e5299ee8cb6dba6 (patch)
treedd121f5628c740c242cd8237bd9c4feb0038b5f8
parent0cd862ef88ceee71b79a4f52faff527e02789720 (diff)
efl_ui_popup: add align and position properties
Summary: add align feature and position properties (center, left, right, top, bottom) efl_ui_popup_position_set should be seperated from evas_object_move since evas_object_move can be called internally. Test Plan: 1. run elementary_test -to efluipopup Reviewers: Jaehyun_Cho, jpeg, cedric, thiepha, Blackmole, woohyun Reviewed By: Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5105
-rw-r--r--src/bin/elementary/test_popup.c93
-rw-r--r--src/lib/elementary/efl_ui_popup.c79
-rw-r--r--src/lib/elementary/efl_ui_popup.eo30
-rw-r--r--src/lib/elementary/efl_ui_popup_private.h2
4 files changed, 189 insertions, 15 deletions
diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c
index cc9de42f82..e42b7dc4a9 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -967,6 +967,48 @@ _image_change_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
967 k = !k; 967 k = !k;
968} 968}
969 969
970static void
971_center_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
972 void *event_info EINA_UNUSED)
973{
974 efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_CENTER);
975}
976
977static void
978_left_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
979 void *event_info EINA_UNUSED)
980{
981 efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_LEFT);
982}
983
984static void
985_right_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
986 void *event_info EINA_UNUSED)
987{
988 efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_RIGHT);
989}
990
991static void
992_top_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
993 void *event_info EINA_UNUSED)
994{
995 efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_TOP);
996}
997
998static void
999_bottom_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
1000 void *event_info EINA_UNUSED)
1001{
1002 efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_BOTTOM);
1003}
1004
1005static void
1006_position_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
1007 void *event_info EINA_UNUSED)
1008{
1009 efl_ui_popup_position_set(data, 0, 0);
1010}
1011
970void 1012void
971test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1013test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
972{ 1014{
@@ -975,7 +1017,7 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
975 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup"); 1017 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
976 elm_win_autodel_set(win, EINA_TRUE); 1018 elm_win_autodel_set(win, EINA_TRUE);
977 1019
978 evas_object_resize(win, 320, 320); 1020 evas_object_resize(win, 500, 500);
979 evas_object_show(win); 1021 evas_object_show(win);
980 1022
981 btn = elm_button_add(win); 1023 btn = elm_button_add(win);
@@ -988,7 +1030,6 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
988 1030
989 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL); 1031 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
990 1032
991 evas_object_move(efl_ui_popup, 80, 80);
992 evas_object_resize(efl_ui_popup, 160, 160); 1033 evas_object_resize(efl_ui_popup, 160, 160);
993 evas_object_show(efl_ui_popup); 1034 evas_object_show(efl_ui_popup);
994 1035
@@ -1001,5 +1042,53 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
1001 evas_object_smart_callback_add(btn, "clicked", _image_change_btn_cb, efl_ui_popup); 1042 evas_object_smart_callback_add(btn, "clicked", _image_change_btn_cb, efl_ui_popup);
1002 evas_object_show(btn); 1043 evas_object_show(btn);
1003 1044
1045 Evas_Object *center_btn;
1046 center_btn = elm_button_add(win);
1047 elm_object_text_set(center_btn, "Center Align");
1048 evas_object_move(center_btn, 0, 300);
1049 evas_object_resize(center_btn, 100, 50);
1050 evas_object_show(center_btn);
1051 evas_object_smart_callback_add(center_btn, "clicked", _center_align_cb, efl_ui_popup);
1052
1053 Evas_Object *left_btn;
1054 left_btn = elm_button_add(win);
1055 elm_object_text_set(left_btn, "Left Align");
1056 evas_object_move(left_btn, 100, 300);
1057 evas_object_resize(left_btn, 100, 50);
1058 evas_object_show(left_btn);
1059 evas_object_smart_callback_add(left_btn, "clicked", _left_align_cb, efl_ui_popup);
1060
1061 Evas_Object *right_btn;
1062 right_btn = elm_button_add(win);
1063 elm_object_text_set(right_btn, "Right Align");
1064 evas_object_move(right_btn, 200, 300);
1065 evas_object_resize(right_btn, 100, 50);
1066 evas_object_show(right_btn);
1067 evas_object_smart_callback_add(right_btn, "clicked", _right_align_cb, efl_ui_popup);
1068
1069 Evas_Object *top_btn;
1070 top_btn = elm_button_add(win);
1071 elm_object_text_set(top_btn, "Top Align");
1072 evas_object_move(top_btn, 0, 350);
1073 evas_object_resize(top_btn, 100, 50);
1074 evas_object_show(top_btn);
1075 evas_object_smart_callback_add(top_btn, "clicked", _top_align_cb, efl_ui_popup);
1076
1077 Evas_Object *bottom_btn;
1078 bottom_btn = elm_button_add(win);
1079 elm_object_text_set(bottom_btn, "Bottom Align");
1080 evas_object_move(bottom_btn, 100, 350);
1081 evas_object_resize(bottom_btn, 100, 50);
1082 evas_object_show(bottom_btn);
1083 evas_object_smart_callback_add(bottom_btn, "clicked", _bottom_align_cb, efl_ui_popup);
1084
1085 Evas_Object *position_btn;
1086 position_btn = elm_button_add(win);
1087 elm_object_text_set(position_btn, "Position Set");
1088 evas_object_move(position_btn, 200, 350);
1089 evas_object_resize(position_btn, 100, 50);
1090 evas_object_show(position_btn);
1091 evas_object_smart_callback_add(position_btn, "clicked", _position_set_cb, efl_ui_popup);
1092
1004 efl_content_set(efl_ui_popup, btn); 1093 efl_content_set(efl_ui_popup, btn);
1005} 1094}
diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c
index 972342b5ca..a8404cb89f 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -30,20 +30,51 @@ _efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, E
30} 30}
31 31
32static void 32static void
33_parent_geom_cb(void *data, const Efl_Event *ev) 33_calc_align(Efl_Ui_Popup_Data *pd)
34{ 34{
35 Evas_Object *event_bg = data;
36 Evas_Coord x, y, w, h; 35 Evas_Coord x, y, w, h;
37 evas_object_geometry_get(ev->object, &x, &y, &w, &h); 36 evas_object_geometry_get(pd->win_parent, &x, &y, &w, &h);
37
38 x = 0;
39 y = 0;
40
41 evas_object_move(pd->event_bg, x, y);
42 evas_object_resize(pd->event_bg, w, h);
43
44 Evas_Coord pw, ph;
45 evas_object_geometry_get(pd->self, NULL, NULL, &pw, &ph);
38 46
39 if (efl_isa(ev->object, EFL_UI_WIN_CLASS)) 47 Efl_Ui_Popup_Align align;
48 align = efl_ui_popup_align_get(pd->self);
49
50 switch (align)
40 { 51 {
41 x = 0; 52 case EFL_UI_POPUP_ALIGN_CENTER:
42 y = 0; 53 evas_object_move(pd->self, x + ((w - pw ) / 2), y + ((h - ph) / 2));
54 break;
55 case EFL_UI_POPUP_ALIGN_LEFT:
56 evas_object_move(pd->self, x, y + ((h - ph) / 2));
57 break;
58 case EFL_UI_POPUP_ALIGN_RIGHT:
59 evas_object_move(pd->self, x + (w - pw), ((h - ph) / 2));
60 break;
61 case EFL_UI_POPUP_ALIGN_TOP:
62 evas_object_move(pd->self, x + ((w - pw) / 2), y);
63 break;
64 case EFL_UI_POPUP_ALIGN_BOTTOM:
65 evas_object_move(pd->self, x + ((w - pw) / 2), y + (h - ph));
66 break;
67 default:
68 break;
43 } 69 }
70}
71
44 72
45 evas_object_move(event_bg, x, y); 73static void
46 evas_object_resize(event_bg, w, h); 74_parent_geom_cb(void *data, const Efl_Event *ev EINA_UNUSED)
75{
76 Efl_Ui_Popup_Data *pd = data;
77 _calc_align(pd);
47} 78}
48 79
49EOLIAN static void 80EOLIAN static void
@@ -61,8 +92,8 @@ _efl_ui_popup_elm_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_U
61 evas_object_move(pd->event_bg, x, y); 92 evas_object_move(pd->event_bg, x, y);
62 evas_object_resize(pd->event_bg, w, h); 93 evas_object_resize(pd->event_bg, w, h);
63 94
64 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg); 95 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd);
65 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg); 96 efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd);
66} 97}
67 98
68EOLIAN static Eina_Bool 99EOLIAN static Eina_Bool
@@ -89,6 +120,26 @@ _efl_ui_popup_parent_window_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
89 return pd->win_parent; 120 return pd->win_parent;
90} 121}
91 122
123EOLIAN void
124_efl_ui_popup_position_set(Eo *obj, Efl_Ui_Popup_Data *pd, int x, int y)
125{
126 evas_object_move(obj, x, y);
127 pd->align = EFL_UI_POPUP_ALIGN_NONE;
128}
129
130EOLIAN static void
131_efl_ui_popup_align_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd, Efl_Ui_Popup_Align type)
132{
133 pd->align = type;
134 _calc_align(pd);
135}
136
137EOLIAN static Efl_Ui_Popup_Align
138_efl_ui_popup_align_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
139{
140 return pd->align;
141}
142
92EOLIAN static void 143EOLIAN static void
93_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd) 144_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
94{ 145{
@@ -97,6 +148,8 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
97 efl_canvas_group_add(efl_super(obj, MY_CLASS)); 148 efl_canvas_group_add(efl_super(obj, MY_CLASS));
98 elm_widget_sub_object_parent_add(obj); 149 elm_widget_sub_object_parent_add(obj);
99 150
151 pd->self = obj;
152
100 elm_widget_can_focus_set(obj, EINA_TRUE); 153 elm_widget_can_focus_set(obj, EINA_TRUE);
101 elm_layout_theme_set(obj, "popup", "base", "view"); 154 elm_layout_theme_set(obj, "popup", "base", "view");
102 155
@@ -106,14 +159,16 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
106 evas_object_stack_below(pd->event_bg, wd->resize_obj); 159 evas_object_stack_below(pd->event_bg, wd->resize_obj);
107 160
108 edje_object_signal_callback_add(pd->event_bg, "elm,action,clicked", "*", _bg_clicked_cb, obj); 161 edje_object_signal_callback_add(pd->event_bg, "elm,action,clicked", "*", _bg_clicked_cb, obj);
162
163 pd->align = EFL_UI_POPUP_ALIGN_CENTER;
109} 164}
110 165
111EOLIAN static void 166EOLIAN static void
112_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd) 167_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd)
113{ 168{
114 ELM_SAFE_FREE(pd->event_bg, evas_object_del); 169 ELM_SAFE_FREE(pd->event_bg, evas_object_del);
115 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd->event_bg); 170 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd);
116 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd->event_bg); 171 efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd);
117 172
118 efl_canvas_group_del(efl_super(obj, MY_CLASS)); 173 efl_canvas_group_del(efl_super(obj, MY_CLASS));
119} 174}
diff --git a/src/lib/elementary/efl_ui_popup.eo b/src/lib/elementary/efl_ui_popup.eo
index 07b415955e..14a30ca14e 100644
--- a/src/lib/elementary/efl_ui_popup.eo
+++ b/src/lib/elementary/efl_ui_popup.eo
@@ -1,6 +1,14 @@
1enum Efl.Ui.Popup.Align {
2 none = 0,
3 center,
4 left,
5 right,
6 top,
7 bottom
8}
9
1class Efl.Ui.Popup(Efl.Ui.Layout) 10class Efl.Ui.Popup(Efl.Ui.Layout)
2{ 11{
3 legacy_prefix: elm_popup;
4 methods { 12 methods {
5 @property parent_window @protected { 13 @property parent_window @protected {
6 get { 14 get {
@@ -31,6 +39,26 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
31 repeat: bool; [[If $true, events are passed to lower objects.]] 39 repeat: bool; [[If $true, events are passed to lower objects.]]
32 } 40 }
33 } 41 }
42 @property position {
43 set {
44 [[Set the current popup position.]]
45 }
46 values {
47 x: int;
48 y: int;
49 }
50 }
51 @property align {
52 set {
53 [[ Set the popup alignment.]]
54 }
55 get {
56 [[ Get the current popup alignment.]]
57 }
58 values {
59 type: Efl.Ui.Popup.Align;
60 }
61 }
34 } 62 }
35 implements { 63 implements {
36 class.constructor; 64 class.constructor;
diff --git a/src/lib/elementary/efl_ui_popup_private.h b/src/lib/elementary/efl_ui_popup_private.h
index 191a5544de..dd979b318e 100644
--- a/src/lib/elementary/efl_ui_popup_private.h
+++ b/src/lib/elementary/efl_ui_popup_private.h
@@ -4,8 +4,10 @@
4typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data; 4typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data;
5struct _Efl_Ui_Popup_Data 5struct _Efl_Ui_Popup_Data
6{ 6{
7 Evas_Object *self;
7 Evas_Object *win_parent; 8 Evas_Object *win_parent;
8 Evas_Object *event_bg; 9 Evas_Object *event_bg;
10 Efl_Ui_Popup_Align align;
9 Eina_Bool bg_repeat_events : 1; 11 Eina_Bool bg_repeat_events : 1;
10}; 12};
11 13