summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-09-21 17:21:18 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commit1c5452bda194f0b828669b3b70f4bcf1a476e653 (patch)
tree4495c160eb56f0be536c3ef73d99e521f62c65cb
parent45694f20761668da7b57ada7af3103613a030c04 (diff)
efl_ui_popup: add timeout property
Summary: add timeout property Test Plan: 1. run elementary_test -to efluipopup 2. after 3 seconds, popup will be delete Reviewers: Jaehyun_Cho, jpeg, woohyun, thiepha, Blackmole, cedric Reviewed By: Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5205
-rw-r--r--src/bin/elementary/test_popup.c17
-rw-r--r--src/lib/elementary/efl_ui_popup.c61
-rw-r--r--src/lib/elementary/efl_ui_popup.eo14
-rw-r--r--src/lib/elementary/efl_ui_popup_private.h2
4 files changed, 93 insertions, 1 deletions
diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c
index 701cd178b5..960cbab8a8 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -1011,6 +1011,14 @@ _position_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
1011 evas_object_move(data, 0, 0); 1011 evas_object_move(data, 0, 0);
1012} 1012}
1013 1013
1014static void
1015_timeout_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
1016 void *event_info EINA_UNUSED)
1017{
1018 efl_ui_popup_timeout_set(data, 3);
1019 printf("timemout is set to 3 seconds\n");
1020}
1021
1014void 1022void
1015test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1023test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1016{ 1024{
@@ -1031,7 +1039,6 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
1031 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win); 1039 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win);
1032 1040
1033 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL); 1041 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
1034
1035 evas_object_resize(efl_ui_popup, 160, 160); 1042 evas_object_resize(efl_ui_popup, 160, 160);
1036 evas_object_show(efl_ui_popup); 1043 evas_object_show(efl_ui_popup);
1037 1044
@@ -1092,6 +1099,14 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
1092 evas_object_show(position_btn); 1099 evas_object_show(position_btn);
1093 evas_object_smart_callback_add(position_btn, "clicked", _position_set_cb, efl_ui_popup); 1100 evas_object_smart_callback_add(position_btn, "clicked", _position_set_cb, efl_ui_popup);
1094 1101
1102 Evas_Object *timeout_btn;
1103 timeout_btn = elm_button_add(win);
1104 elm_object_text_set(timeout_btn, "Timeout Set");
1105 evas_object_move(timeout_btn, 0, 400);
1106 evas_object_resize(timeout_btn, 100, 50);
1107 evas_object_show(timeout_btn);
1108 evas_object_smart_callback_add(timeout_btn, "clicked", _timeout_set_cb, efl_ui_popup);
1109
1095 efl_content_set(efl_ui_popup, btn); 1110 efl_content_set(efl_ui_popup, btn);
1096} 1111}
1097 1112
diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c
index 2deb6a29f4..344105436a 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -131,6 +131,67 @@ _efl_ui_popup_align_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
131 return pd->align; 131 return pd->align;
132} 132}
133 133
134static Eina_Bool
135_timer_cb(void *data)
136{
137 Evas_Object *popup = data;
138 evas_object_del(popup);
139
140 return ECORE_CALLBACK_CANCEL;
141}
142
143static void
144_timer_del(Efl_Ui_Popup_Data *pd)
145{
146 if (pd->timer)
147 {
148 ecore_timer_del(pd->timer);
149 pd->timer = NULL;
150 }
151}
152
153static void
154_timer_init(Eo *obj, Efl_Ui_Popup_Data *pd)
155{
156 if (pd->timeout > 0.0)
157 pd->timer = ecore_timer_add(pd->timeout, _timer_cb, obj);
158}
159
160EOLIAN static void
161_efl_ui_popup_efl_gfx_visible_set(Eo *obj, Efl_Ui_Popup_Data *pd, Eina_Bool v)
162{
163 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, v))
164 return;
165
166 efl_gfx_visible_set(efl_super(obj, MY_CLASS), v);
167
168 if (v)
169 {
170 _timer_del(pd);
171 _timer_init(obj, pd);
172 }
173}
174
175EOLIAN static void
176_efl_ui_popup_timeout_set(Eo *obj, Efl_Ui_Popup_Data *pd, double time)
177{
178 if (time < 0.0)
179 time = 0.0;
180
181 pd->timeout = time;
182
183 _timer_del(pd);
184
185 if (efl_gfx_visible_get(obj))
186 _timer_init(obj, pd);
187}
188
189EOLIAN static double
190_efl_ui_popup_timeout_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
191{
192 return pd->timeout;
193}
194
134EOLIAN static void 195EOLIAN static void
135_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd) 196_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
136{ 197{
diff --git a/src/lib/elementary/efl_ui_popup.eo b/src/lib/elementary/efl_ui_popup.eo
index a1a16644d3..06aefd019c 100644
--- a/src/lib/elementary/efl_ui_popup.eo
+++ b/src/lib/elementary/efl_ui_popup.eo
@@ -50,10 +50,24 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
50 type: Efl.Ui.Popup.Align; 50 type: Efl.Ui.Popup.Align;
51 } 51 }
52 } 52 }
53 @property timeout {
54 set {
55 [[ Set the timeout seconds.
56 After timeout seconds, popup will be deleted automatically.
57 ]]
58 }
59 get {
60 [[ Get the currently set timeout seconds.]]
61 }
62 values {
63 time: double;
64 }
65 }
53 } 66 }
54 implements { 67 implements {
55 class.constructor; 68 class.constructor;
56 Efl.Gfx.position { set; } 69 Efl.Gfx.position { set; }
70 Efl.Gfx.visible { set; }
57 Elm.Widget.widget_parent { set; } 71 Elm.Widget.widget_parent { set; }
58 Efl.Container.content { get; set; } 72 Efl.Container.content { get; set; }
59 Efl.Container.content_unset; 73 Efl.Container.content_unset;
diff --git a/src/lib/elementary/efl_ui_popup_private.h b/src/lib/elementary/efl_ui_popup_private.h
index e87151edd1..8256ec5fce 100644
--- a/src/lib/elementary/efl_ui_popup_private.h
+++ b/src/lib/elementary/efl_ui_popup_private.h
@@ -7,6 +7,8 @@ struct _Efl_Ui_Popup_Data
7 Evas_Object *win_parent; 7 Evas_Object *win_parent;
8 Evas_Object *event_bg; 8 Evas_Object *event_bg;
9 Efl_Ui_Popup_Align align; 9 Efl_Ui_Popup_Align align;
10 Ecore_Timer *timer;
11 double timeout;
10 Eina_Bool bg_repeat_events : 1; 12 Eina_Bool bg_repeat_events : 1;
11}; 13};
12 14