forked from enlightenment/efl
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
This commit is contained in:
parent
bccd97bd62
commit
0005b3105e
|
@ -967,6 +967,48 @@ _image_change_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
k = !k;
|
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
|
void
|
||||||
test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -975,7 +1017,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");
|
win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
|
||||||
elm_win_autodel_set(win, EINA_TRUE);
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
|
||||||
evas_object_resize(win, 320, 320);
|
evas_object_resize(win, 500, 500);
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
|
|
||||||
btn = elm_button_add(win);
|
btn = elm_button_add(win);
|
||||||
|
@ -988,7 +1030,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_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_resize(efl_ui_popup, 160, 160);
|
||||||
evas_object_show(efl_ui_popup);
|
evas_object_show(efl_ui_popup);
|
||||||
|
|
||||||
|
@ -1001,5 +1042,53 @@ 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_smart_callback_add(btn, "clicked", _image_change_btn_cb, efl_ui_popup);
|
||||||
evas_object_show(btn);
|
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);
|
efl_content_set(efl_ui_popup, btn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,20 +30,51 @@ _efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, E
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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_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);
|
||||||
|
|
||||||
if (efl_isa(ev->object, EFL_UI_WIN_CLASS))
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
|
||||||
|
evas_object_move(pd->event_bg, x, y);
|
||||||
|
evas_object_resize(pd->event_bg, w, h);
|
||||||
|
|
||||||
|
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;
|
case EFL_UI_POPUP_ALIGN_CENTER:
|
||||||
y = 0;
|
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 EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Efl_Ui_Popup_Data *pd = data;
|
||||||
|
_calc_align(pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
|
@ -61,8 +92,8 @@ _efl_ui_popup_elm_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_U
|
||||||
evas_object_move(pd->event_bg, x, y);
|
evas_object_move(pd->event_bg, x, y);
|
||||||
evas_object_resize(pd->event_bg, w, h);
|
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_RESIZE, _parent_geom_cb, pd);
|
||||||
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_MOVE, _parent_geom_cb, pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
|
@ -89,6 +120,26 @@ _efl_ui_popup_parent_window_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
|
||||||
return pd->win_parent;
|
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 EINA_UNUSED, 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 EINA_UNUSED, Efl_Ui_Popup_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->align;
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
|
_efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +148,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));
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
||||||
elm_widget_sub_object_parent_add(obj);
|
elm_widget_sub_object_parent_add(obj);
|
||||||
|
|
||||||
|
pd->self = obj;
|
||||||
|
|
||||||
elm_widget_can_focus_set(obj, EINA_TRUE);
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
||||||
elm_layout_theme_set(obj, "popup", "base", "view");
|
elm_layout_theme_set(obj, "popup", "base", "view");
|
||||||
|
|
||||||
|
@ -106,14 +159,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);
|
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);
|
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
|
EOLIAN static void
|
||||||
_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd)
|
_efl_ui_popup_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Data *pd)
|
||||||
{
|
{
|
||||||
ELM_SAFE_FREE(pd->event_bg, evas_object_del);
|
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_RESIZE, _parent_geom_cb, pd);
|
||||||
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_MOVE, _parent_geom_cb, pd);
|
||||||
|
|
||||||
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
enum Efl.Ui.Popup.Align {
|
||||||
|
none = 0,
|
||||||
|
center,
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
top,
|
||||||
|
bottom
|
||||||
|
}
|
||||||
|
|
||||||
class Efl.Ui.Popup(Efl.Ui.Layout)
|
class Efl.Ui.Popup(Efl.Ui.Layout)
|
||||||
{
|
{
|
||||||
legacy_prefix: elm_popup;
|
|
||||||
methods {
|
methods {
|
||||||
@property parent_window @protected {
|
@property parent_window @protected {
|
||||||
get {
|
get {
|
||||||
|
@ -31,6 +39,26 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
|
||||||
repeat: bool; [[If $true, events are passed to lower objects.]]
|
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 {
|
implements {
|
||||||
class.constructor;
|
class.constructor;
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data;
|
typedef struct _Efl_Ui_Popup_Data Efl_Ui_Popup_Data;
|
||||||
struct _Efl_Ui_Popup_Data
|
struct _Efl_Ui_Popup_Data
|
||||||
{
|
{
|
||||||
|
Evas_Object *self;
|
||||||
Evas_Object *win_parent;
|
Evas_Object *win_parent;
|
||||||
Evas_Object *event_bg;
|
Evas_Object *event_bg;
|
||||||
|
Efl_Ui_Popup_Align align;
|
||||||
Eina_Bool bg_repeat_events : 1;
|
Eina_Bool bg_repeat_events : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue