forked from enlightenment/efl
win: Move main menu to the framespace
After reverting 8a21384759
, I figured out how to move
the main menu back to the border group. This time the menu is in the
framespace and its layout algos have been adapted to allow non-zero
root coordinates.
This commit is contained in:
parent
c7f2308e6c
commit
1f9dfe2ed3
|
@ -39,11 +39,11 @@ group { name: "elm/border/base/default";
|
|||
}
|
||||
desc { "max"; inherit: "default"; }
|
||||
}
|
||||
/* covers the entire client contents, including the main menu */
|
||||
/* covers the entire client contents, excluding the main menu */
|
||||
spacer { "elm.spacer.content";
|
||||
required; // since 1.19
|
||||
desc {
|
||||
rel1.to: "top_clip";
|
||||
rel1.to: "elm.swallow.menu";
|
||||
rel1.relative: 0.0 1.0;
|
||||
rel2.to: "bottom_clip";
|
||||
rel2.relative: 1.0 0.0;
|
||||
|
@ -104,7 +104,6 @@ group { name: "elm/border/base/default";
|
|||
desc { "default";
|
||||
rel.to: "top_clip";
|
||||
rel1.relative: 0.0 1.0;
|
||||
rel1.offset: 0 -1;
|
||||
visible: 0;
|
||||
align: 0.5 0.0;
|
||||
fixed: 1 1;
|
||||
|
|
|
@ -761,6 +761,7 @@ group { name: "elm/hover/base/menu/default";
|
|||
part { name: "bottomclip"; type: RECT;
|
||||
description { state: "default" 0.0;
|
||||
color: 255 255 255 0;
|
||||
rel1.offset: 0 -7;
|
||||
}
|
||||
description { state: "visible" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
|
|
|
@ -332,6 +332,7 @@ static Elm_Theme_Apply _elm_win_theme_internal(Eo *obj, Efl_Ui_Win_Data *sd);
|
|||
static void _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *style);
|
||||
static void _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc);
|
||||
static inline void _elm_win_need_frame_adjust(Efl_Ui_Win_Data *sd, const char *engine);
|
||||
static void _elm_win_resize_objects_eval(Evas_Object *obj);
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
static void _elm_win_xwin_update(Efl_Ui_Win_Data *sd);
|
||||
|
@ -874,6 +875,15 @@ _elm_win_resize_job(void *data)
|
|||
evas_object_move(sd->frame_obj, -fx, -fy);
|
||||
evas_object_resize(sd->frame_obj, w + fw, h + fh);
|
||||
}
|
||||
|
||||
if (sd->main_menu)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
efl_gfx_position_get(sd->main_menu, &mx, &my);
|
||||
elm_menu_move(sd->main_menu, mx, my);
|
||||
}
|
||||
|
||||
sd->response++;
|
||||
evas_object_resize(sd->obj, w, h);
|
||||
evas_object_resize(sd->legacy.edje, w, h);
|
||||
|
@ -1394,16 +1404,9 @@ _elm_win_frame_obj_update(Efl_Ui_Win_Data *sd)
|
|||
int fx, fy, fw, fh;
|
||||
int ox, oy, ow, oh;
|
||||
|
||||
if (!sd->frame_obj) return;
|
||||
_elm_win_opaque_dirty(sd);
|
||||
_elm_win_frame_geometry_adjust(sd);
|
||||
if (sd->fullscreen || !sd->csd.need)
|
||||
{
|
||||
_elm_win_opaque_update(sd);
|
||||
evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sd->frame_obj) return;
|
||||
evas_object_geometry_get(sd->frame_obj, &fx, &fy, &fw, &fh);
|
||||
edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.content", &ox, &oy, &ow, &oh);
|
||||
evas_output_framespace_set(sd->evas, ox, oy, fw - ow, fh - oh);
|
||||
|
@ -5339,7 +5342,15 @@ _main_menu_swallow_get(Efl_Ui_Win_Data *sd)
|
|||
DBG("Detected legacy theme, using legacy swallows.");
|
||||
return sd->legacy.edje;
|
||||
}
|
||||
return sd->legacy.edje;
|
||||
return sd->frame_obj;
|
||||
}
|
||||
|
||||
static void
|
||||
_main_menu_resize_cb(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
// After resize, the framespace size has changed, so update the win geometry
|
||||
_elm_win_resize_objects_eval(ev->object);
|
||||
efl_event_callback_del(ev->object, EFL_GFX_EVENT_RESIZE, _main_menu_resize_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5354,15 +5365,18 @@ _dbus_menu_set(Eina_Bool dbus_connect, void *data)
|
|||
edje_object_part_unswallow(swallow, sd->main_menu);
|
||||
sd->csd.need_menu = EINA_FALSE;
|
||||
_elm_menu_menu_bar_hide(sd->main_menu);
|
||||
_elm_win_resize_objects_eval(sd->obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("Setting menu to local mode");
|
||||
efl_event_callback_add(sd->obj, EFL_GFX_EVENT_RESIZE, _main_menu_resize_cb, NULL);
|
||||
edje_object_part_swallow(swallow, "elm.swallow.menu", sd->main_menu);
|
||||
efl_canvas_object_is_frame_object_set(sd->main_menu, (swallow == sd->frame_obj));
|
||||
sd->csd.need_menu = EINA_TRUE;
|
||||
evas_object_show(sd->main_menu);
|
||||
}
|
||||
_elm_win_frame_style_update(sd, 0, 1);
|
||||
sd->deferred_resize_job = EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
|
|
@ -320,8 +320,13 @@ _elm_hover_elm_layout_sizing_eval(Eo *obj, Elm_Hover_Data *sd)
|
|||
evas_object_geometry_get(sd->parent, &x, &y, &w, &h);
|
||||
if (efl_isa(sd->parent, EFL_UI_WIN_CLASS))
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (efl_canvas_object_is_frame_object_get(obj))
|
||||
efl_gfx_position_get(obj, &x, &y);
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
evas_object_geometry_get(obj, &x2, &y2, &w2, &h2);
|
||||
|
@ -329,6 +334,9 @@ _elm_hover_elm_layout_sizing_eval(Eo *obj, Elm_Hover_Data *sd)
|
|||
if (elm_widget_mirrored_get(obj)) ofs_x = w - (x2 - x) - w2;
|
||||
else ofs_x = x2 - x;
|
||||
|
||||
if (y < 0)
|
||||
h += (-y);
|
||||
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||
evas_object_size_hint_min_set(sd->offset, ofs_x, y2 - y);
|
||||
evas_object_size_hint_min_set(sd->size, w2, h2);
|
||||
|
|
|
@ -96,6 +96,22 @@ _elm_menu_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED, Elm_Menu_Ite
|
|||
elm_layout_signal_emit(VIEW(item), emission, source);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_parent_geometry_get(Elm_Menu_Data *sd, int *x, int *y, int *w, int *h)
|
||||
{
|
||||
evas_object_geometry_get(sd->parent, x, y, w, h);
|
||||
if (efl_isa(sd->parent, EFL_UI_WIN_CLASS))
|
||||
{
|
||||
if (sd->menu_bar && efl_canvas_object_is_frame_object_get(sd->obj))
|
||||
efl_gfx_position_get(sd->obj, x, y);
|
||||
else
|
||||
{
|
||||
if (x) *x = 0;
|
||||
if (y) *y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_submenu_sizing_eval(Elm_Menu_Item_Data *parent_it)
|
||||
{
|
||||
|
@ -118,12 +134,8 @@ _submenu_sizing_eval(Elm_Menu_Item_Data *parent_it)
|
|||
(parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p);
|
||||
evas_object_geometry_get(VIEW(parent_it), &x2, &y2, &w2, &h2);
|
||||
evas_object_geometry_get(parent_it->submenu.bx, &bx, &by, &bw, &bh);
|
||||
evas_object_geometry_get(sd->parent, &px, &py, &pw, &ph);
|
||||
if (efl_isa(sd->parent, EFL_UI_WIN_CLASS))
|
||||
{
|
||||
px = 0;
|
||||
py = 0;
|
||||
}
|
||||
_parent_geometry_get(sd, &px, &py, &pw, &ph);
|
||||
ERR("elm_menu parent geom %d,%d %dx%d", px, py, pw, ph);
|
||||
|
||||
if (sd->menu_bar && !parent_it->parent)
|
||||
{
|
||||
|
@ -152,6 +164,9 @@ _submenu_sizing_eval(Elm_Menu_Item_Data *parent_it)
|
|||
if (y_p + bh > py + ph)
|
||||
y_p -= y_p + bh - (py + ph);
|
||||
|
||||
if (sd->menu_bar && (y_p < py))
|
||||
y_p = py;
|
||||
|
||||
evas_object_move(parent_it->submenu.location, x_p, y_p);
|
||||
evas_object_resize(parent_it->submenu.location, bw, h_p);
|
||||
evas_object_size_hint_min_set(parent_it->submenu.location, bw, h_p);
|
||||
|
@ -184,12 +199,7 @@ _sizing_eval(Evas_Object *obj)
|
|||
}
|
||||
|
||||
evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p);
|
||||
evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2);
|
||||
if (efl_isa(sd->parent, EFL_UI_WIN_CLASS))
|
||||
{
|
||||
x2 = 0;
|
||||
y2 = 0;
|
||||
}
|
||||
_parent_geometry_get(sd, &x2, &y2, &w2, &h2);
|
||||
evas_object_geometry_get(sd->bx, NULL, NULL, &bw, &bh);
|
||||
|
||||
x_p = sd->xloc;
|
||||
|
@ -203,8 +213,7 @@ _sizing_eval(Evas_Object *obj)
|
|||
if (y_p + h_p + bh > y2 + h2) y_p -= y_p + h_p + bh - (y2 + h2);
|
||||
if (y_p < y2) y_p = y2;
|
||||
|
||||
evas_object_move(sd->location, x_p, y_p);
|
||||
evas_object_resize(sd->location, bw, h_p);
|
||||
efl_gfx_geometry_set(sd->location, x_p, y_p, bw, h_p);
|
||||
evas_object_size_hint_min_set(sd->location, bw, h_p);
|
||||
evas_object_size_hint_max_set(sd->location, bw, h_p);
|
||||
elm_hover_target_set(sd->hv, sd->location);
|
||||
|
@ -808,6 +817,7 @@ _elm_menu_efl_object_constructor(Eo *obj, Elm_Menu_Data *sd)
|
|||
efl_event_callback_add
|
||||
(obj, ELM_MENU_EVENT_ELM_ACTION_UNBLOCK_MENU, _unblock_menu, sd);
|
||||
|
||||
sd->obj = obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -1033,6 +1043,8 @@ _elm_menu_item_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *parent, const ch
|
|||
it->content = icon_obj;
|
||||
|
||||
_item_obj_create(it);
|
||||
efl_canvas_object_is_frame_object_set(VIEW(it), efl_canvas_object_is_frame_object_get(obj));
|
||||
efl_canvas_object_is_frame_object_set(icon_obj, efl_canvas_object_is_frame_object_get(obj));
|
||||
elm_object_item_text_set(eo_item, label);
|
||||
|
||||
elm_layout_content_set(VIEW(it), "elm.swallow.content",
|
||||
|
|
|
@ -601,6 +601,21 @@ _elm_widget_efl_canvas_object_no_render_set(Eo *obj, Elm_Widget_Smart_Data *_pd
|
|||
efl_canvas_object_no_render_set(efl_super(obj, EFL_CANVAS_GROUP_CLASS), hide);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_widget_efl_canvas_object_is_frame_object_set(Eo *obj, Elm_Widget_Smart_Data *pd, Eina_Bool frame)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Eina_List *li;
|
||||
|
||||
frame = !!frame;
|
||||
efl_canvas_object_is_frame_object_set(efl_super(obj, MY_CLASS), frame);
|
||||
EINA_LIST_FOREACH(pd->subobjs, li, o)
|
||||
{
|
||||
if (evas_object_data_get(o, "_elm_leaveme")) continue;
|
||||
efl_canvas_object_is_frame_object_set(o, frame);
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_widget_efl_canvas_object_clip_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *clip)
|
||||
{
|
||||
|
|
|
@ -833,6 +833,7 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible, Elm.Inter
|
|||
Efl.Gfx.size.set;
|
||||
Efl.Canvas.Object.clip.set;
|
||||
Efl.Canvas.Object.no_render.set;
|
||||
Efl.Canvas.Object.is_frame_object.set;
|
||||
Efl.Canvas.Group.group_calculate;
|
||||
Efl.Canvas.Group.group_member_del;
|
||||
Efl.Canvas.Group.group_add;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
typedef struct _Elm_Menu_Data Elm_Menu_Data;
|
||||
struct _Elm_Menu_Data
|
||||
{
|
||||
Evas_Object *hv, *bx, *location, *parent;
|
||||
Evas_Object *hv, *bx, *location, *parent, *obj;
|
||||
|
||||
Eina_List *items;
|
||||
Evas_Coord xloc, yloc;
|
||||
|
|
Loading…
Reference in New Issue