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-08-31 14:43:04 +0900
commitfaf85a40470edd2b21f526e0206dc4f43b8832c1 (patch)
tree21792583b3322a93e80a02527232c9a414e4acbc
parent47722bdb67e112845388057193f16f8b486d477d (diff)
downloadefl-faf85a40470edd2b21f526e0206dc4f43b8832c1.tar.gz
Efl.Ui.Popup: added align and position feature to Efl.Ui.Popup
Summary: added align feature and position to Efl.Ui.Popup (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.c96
-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, 192 insertions, 15 deletions
diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c
index 6b138554c0..e7fa4f1159 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -967,6 +967,50 @@ _image_change_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
k = !k;
}
+static void
+_center_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_CENTER);
+}
+
+static void
+_left_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_LEFT);
+}
+
+static void
+_right_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_RIGHT);
+}
+
+static void
+_top_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_TOP);
+}
+
+static void
+_bottom_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_align_set(data, EFL_UI_POPUP_ALIGN_BOTTOM);
+}
+
+static void
+_position_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ efl_ui_popup_position_set(data, 0, 0);
+}
+
+
+
void
test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -975,7 +1019,7 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
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_resize(win, 500, 500);
evas_object_show(win);
btn = elm_button_add(win);
@@ -988,7 +1032,6 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
- evas_object_move(efl_ui_popup, 80, 80);
evas_object_resize(efl_ui_popup, 160, 160);
evas_object_show(efl_ui_popup);
@@ -1001,5 +1044,54 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
evas_object_smart_callback_add(btn, "clicked", _image_change_btn_cb, efl_ui_popup);
evas_object_show(btn);
+ Evas_Object *center_btn;
+ center_btn = elm_button_add(win);
+ elm_object_text_set(center_btn, "Center Align");
+ evas_object_move(center_btn, 0, 300);
+ evas_object_resize(center_btn, 100, 50);
+ evas_object_show(center_btn);
+ evas_object_smart_callback_add(center_btn, "clicked", _center_align_cb, efl_ui_popup);
+
+
+ Evas_Object *left_btn;
+ left_btn = elm_button_add(win);
+ elm_object_text_set(left_btn, "Left Align");
+ evas_object_move(left_btn, 100, 300);
+ evas_object_resize(left_btn, 100, 50);
+ evas_object_show(left_btn);
+ evas_object_smart_callback_add(left_btn, "clicked", _left_align_cb, efl_ui_popup);
+
+ Evas_Object *right_btn;
+ right_btn = elm_button_add(win);
+ elm_object_text_set(right_btn, "Right Align");
+ evas_object_move(right_btn, 200, 300);
+ evas_object_resize(right_btn, 100, 50);
+ evas_object_show(right_btn);
+ evas_object_smart_callback_add(right_btn, "clicked", _right_align_cb, efl_ui_popup);
+
+ Evas_Object *top_btn;
+ top_btn = elm_button_add(win);
+ elm_object_text_set(top_btn, "Top Align");
+ evas_object_move(top_btn, 0, 350);
+ evas_object_resize(top_btn, 100, 50);
+ evas_object_show(top_btn);
+ evas_object_smart_callback_add(top_btn, "clicked", _top_align_cb, efl_ui_popup);
+
+ Evas_Object *bottom_btn;
+ bottom_btn = elm_button_add(win);
+ elm_object_text_set(bottom_btn, "Bottom Align");
+ evas_object_move(bottom_btn, 100, 350);
+ evas_object_resize(bottom_btn, 100, 50);
+ evas_object_show(bottom_btn);
+ evas_object_smart_callback_add(bottom_btn, "clicked", _bottom_align_cb, efl_ui_popup);
+
+ Evas_Object *position_btn;
+ position_btn = elm_button_add(win);
+ elm_object_text_set(position_btn, "Position Set");
+ evas_object_move(position_btn, 200, 350);
+ evas_object_resize(position_btn, 100, 50);
+ evas_object_show(position_btn);
+ evas_object_smart_callback_add(position_btn, "clicked", _position_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 2425d64f3c..1d295f8826 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -57,20 +57,51 @@ _efl_ui_popup_efl_gfx_size_set(Eo *obj, Efl_Ui_Popup_Data *pd, int w, int h)
}
static void
-_parent_geom_cb(void *data, const Efl_Event *ev)
+_calc_align(Efl_Ui_Popup_Data *pd)
{
- Evas_Object *event_bg = data;
Evas_Coord x, y, w, h;
- evas_object_geometry_get(ev->object, &x, &y, &w, &h);
+ evas_object_geometry_get(pd->win_parent, &x, &y, &w, &h);
+
+ x = 0;
+ y = 0;
+
+ evas_object_move(pd->event_bg, x, y);
+ evas_object_resize(pd->event_bg, w, h);
- if (efl_isa(ev->object, EFL_UI_WIN_CLASS))
+ Evas_Coord pw, ph;
+ evas_object_geometry_get(pd->self, NULL, NULL, &pw, &ph);
+
+ Efl_Ui_Popup_Align align;
+ align = efl_ui_popup_align_get(pd->self);
+
+ switch (align)
{
- x = 0;
- y = 0;
+ case EFL_UI_POPUP_ALIGN_CENTER:
+ evas_object_move(pd->self, x + ((w - pw ) / 2), y + ((h - ph) / 2));
+ break;
+ case EFL_UI_POPUP_ALIGN_LEFT:
+ evas_object_move(pd->self, x, y + ((h - ph) / 2));
+ break;
+ case EFL_UI_POPUP_ALIGN_RIGHT:
+ evas_object_move(pd->self, x + (w - pw), ((h - ph) / 2));
+ break;
+ case EFL_UI_POPUP_ALIGN_TOP:
+ evas_object_move(pd->self, x + ((w - pw) / 2), y);
+ break;
+ case EFL_UI_POPUP_ALIGN_BOTTOM:
+ evas_object_move(pd->self, x + ((w - pw) / 2), y + (h - ph));
+ break;
+ default:
+ break;
}
+}
- evas_object_move(event_bg, x, y);
- evas_object_resize(event_bg, w, h);
+
+static void
+_parent_geom_cb(void *data, const Efl_Event *ev)
+{
+ Efl_Ui_Popup_Data *pd = data;
+ _calc_align(pd);
}
EOLIAN static void
@@ -88,8 +119,8 @@ _efl_ui_popup_elm_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd, Evas_
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);
+ efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd);
+ efl_event_callback_add(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd);
}
EOLIAN static Efl_Canvas_Object *
@@ -98,6 +129,26 @@ _efl_ui_popup_parent_window_get(Eo *obj, Efl_Ui_Popup_Data *pd)
return pd->win_parent;
}
+EOLIAN void
+_efl_ui_popup_position_set(Eo *obj, Efl_Ui_Popup_Data *pd, int x, int y)
+{
+ evas_object_move(obj, x, y);
+ pd->align = EFL_UI_POPUP_ALIGN_NONE;
+}
+
+EOLIAN static void
+_efl_ui_popup_align_set(Eo *obj, Efl_Ui_Popup_Data *pd, Efl_Ui_Popup_Align type)
+{
+ pd->align = type;
+ _calc_align(pd);
+}
+
+EOLIAN static Efl_Ui_Popup_Align
+_efl_ui_popup_align_get(Eo *obj, Efl_Ui_Popup_Data *pd)
+{
+ return pd->align;
+}
+
EOLIAN static void
_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
{
@@ -106,6 +157,8 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
efl_canvas_group_add(efl_super(obj, MY_CLASS));
elm_widget_sub_object_parent_add(obj);
+ pd->self = obj;
+
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_layout_theme_set(obj, "popup", "base", "view");
@@ -115,14 +168,16 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
evas_object_stack_below(pd->event_bg, wd->resize_obj);
edje_object_signal_callback_add(pd->event_bg, "elm,action,clicked", "*", _bg_clicked_cb, obj);
+
+ pd->align = EFL_UI_POPUP_ALIGN_CENTER;
}
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_event_callback_del(pd->win_parent, EFL_GFX_EVENT_RESIZE, _parent_geom_cb, pd);
+ efl_event_callback_del(pd->win_parent, EFL_GFX_EVENT_MOVE, _parent_geom_cb, pd);
efl_canvas_group_del(efl_super(obj, MY_CLASS));
}
diff --git a/src/lib/elementary/efl_ui_popup.eo b/src/lib/elementary/efl_ui_popup.eo
index 539f47b25d..58380f432e 100644
--- a/src/lib/elementary/efl_ui_popup.eo
+++ b/src/lib/elementary/efl_ui_popup.eo
@@ -1,8 +1,16 @@
import elm_general;
+enum Efl.Ui.Popup.Align {
+ none = 0,
+ center,
+ left,
+ right,
+ top,
+ bottom
+}
+
class Efl.Ui.Popup(Elm.Layout, Elm.Interface.Atspi_Widget_Action)
{
- legacy_prefix: elm_popup;
methods {
@property parent_window @protected {
get {
@@ -33,6 +41,26 @@ class Efl.Ui.Popup(Elm.Layout, Elm.Interface.Atspi_Widget_Action)
repeat: bool; [[If $true, events are passed to lower objects.]]
}
}
+ @property position {
+ set {
+ [[Set the current popup position.]]
+ }
+ values {
+ x: int;
+ y: int;
+ }
+ }
+ @property align {
+ set {
+ [[ Set the popup alignment.]]
+ }
+ get {
+ [[ Get the current popup alignment.]]
+ }
+ values {
+ type: Efl.Ui.Popup.Align;
+ }
+ }
}
implements {
class.constructor;
diff --git a/src/lib/elementary/efl_ui_popup_private.h b/src/lib/elementary/efl_ui_popup_private.h
index bdbbb6a3b6..0e0972b38f 100644
--- a/src/lib/elementary/efl_ui_popup_private.h
+++ b/src/lib/elementary/efl_ui_popup_private.h
@@ -7,8 +7,10 @@
typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data;
struct _Efl_Ui_Popup_Data
{
+ Evas_Object *self;
Evas_Object *win_parent;
Evas_Object *event_bg;
+ Efl_Ui_Popup_Align align;
Eina_Bool bg_repeat_events : 1;
};