aboutsummaryrefslogtreecommitdiffstats
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-28 17:15:42 +0900
commit8d315ce7aad54c16ad0d7dd0b675846618209028 (patch)
tree1d50b944cc912e3eea4164dc88f59adec723a45d
parentefl_ui_popup_anchor: add Efl.Ui.Popup.Anchor class (diff)
downloadefl-8d315ce7aad54c16ad0d7dd0b675846618209028.tar.gz
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,
evas_object_move(data, 0, 0);
}
+static void
+_timeout_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_timeout_set(data, 3);
+ printf("timemout is set to 3 seconds\n");
+}
+
void
test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -1031,7 +1039,6 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win);
evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
-
evas_object_resize(efl_ui_popup, 160, 160);
evas_object_show(efl_ui_popup);
@@ -1092,6 +1099,14 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
evas_object_show(position_btn);
evas_object_smart_callback_add(position_btn, "clicked", _position_set_cb, efl_ui_popup);
+ Evas_Object *timeout_btn;
+ timeout_btn = elm_button_add(win);
+ elm_object_text_set(timeout_btn, "Timeout Set");
+ evas_object_move(timeout_btn, 0, 400);
+ evas_object_resize(timeout_btn, 100, 50);
+ evas_object_show(timeout_btn);
+ evas_object_smart_callback_add(timeout_btn, "clicked", _timeout_set_cb, efl_ui_popup);
+
efl_content_set(efl_ui_popup, btn);
}
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)
return pd->align;
}
+static Eina_Bool
+_timer_cb(void *data)
+{
+ Evas_Object *popup = data;
+ evas_object_del(popup);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_timer_del(Efl_Ui_Popup_Data *pd)
+{
+ if (pd->timer)
+ {
+ ecore_timer_del(pd->timer);
+ pd->timer = NULL;
+ }
+}
+
+static void
+_timer_init(Eo *obj, Efl_Ui_Popup_Data *pd)
+{
+ if (pd->timeout > 0.0)
+ pd->timer = ecore_timer_add(pd->timeout, _timer_cb, obj);
+}
+
+EOLIAN static void
+_efl_ui_popup_efl_gfx_visible_set(Eo *obj, Efl_Ui_Popup_Data *pd, Eina_Bool v)
+{
+ if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, v))
+ return;
+
+ efl_gfx_visible_set(efl_super(obj, MY_CLASS), v);
+
+ if (v)
+ {
+ _timer_del(pd);
+ _timer_init(obj, pd);
+ }
+}
+
+EOLIAN static void
+_efl_ui_popup_timeout_set(Eo *obj, Efl_Ui_Popup_Data *pd, double time)
+{
+ if (time < 0.0)
+ time = 0.0;
+
+ pd->timeout = time;
+
+ _timer_del(pd);
+
+ if (efl_gfx_visible_get(obj))
+ _timer_init(obj, pd);
+}
+
+EOLIAN static double
+_efl_ui_popup_timeout_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
+{
+ return pd->timeout;
+}
+
EOLIAN static void
_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
{
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)
type: Efl.Ui.Popup.Align;
}
}
+ @property timeout {
+ set {
+ [[ Set the timeout seconds.
+ After timeout seconds, popup will be deleted automatically.
+ ]]
+ }
+ get {
+ [[ Get the currently set timeout seconds.]]
+ }
+ values {
+ time: double;
+ }
+ }
}
implements {
class.constructor;
Efl.Gfx.position { set; }
+ Efl.Gfx.visible { 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
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
Evas_Object *win_parent;
Evas_Object *event_bg;
Efl_Ui_Popup_Align align;
+ Ecore_Timer *timer;
+ double timeout;
Eina_Bool bg_repeat_events : 1;
};