win: Move main menu back to win.edc (fix sizing)

As Andy reported, the main menu geometry is not correct after
my recent changes, as the application contents slide underneath
the menu bar. In fact the menu bar is just floating above
everything else.

So I've tried to move the menu to the framespace (as it should
belong to the frame), but the sizing algos for both the window
and the menu make some assumptions that render this task quite
difficult. Eventually I would like to be able to swallow the
menu somewhere else inside the border... but not right now.
This commit is contained in:
Jean-Philippe Andre 2016-11-28 15:43:25 +09:00
parent 51ba193bda
commit 8a21384759
3 changed files with 50 additions and 62 deletions

View File

@ -1,10 +1,12 @@
/* Window client-side decorations and extra slots /* Window client-side decorations and extra slots
* Includes swallows for: * Includes swallows for:
* - app content * - app content
* - main menu
* - indicator * - indicator
* - soft key * - soft key
* - virtual keyboard * - virtual keyboard
*
* Not included:
* - main menu (sizing issues - needs rework of the menu itself)
*/ */
group { name: "elm/border/base/default"; group { name: "elm/border/base/default";
@ -91,34 +93,11 @@ group { name: "elm/border/base/default";
required; // @since 1.19 required; // @since 1.19
clip: "client_clip"; clip: "client_clip";
} }
/* main menu */
rect { "menu_bg";
desc { "default";
color: 64 64 64 255; // FIXME: color_class
align: 0.5 0.0;
rel.to: "elm.swallow.menu";
}
}
swallow { "elm.swallow.menu";
required: 1; // since 1.19
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;
}
desc { "visible"; inherit: "default";
visible: 1;
fixed: 0 1;
}
}
/* application contents - spacer and clipper (without main menu) */ /* application contents - spacer and clipper */
spacer { "client_spacer"; spacer { "client_spacer";
desc { "default"; desc { "default";
rel1.to: "elm.swallow.menu"; rel1.to: "top_clip";
rel1.relative: 0.0 1.0; rel1.relative: 0.0 1.0;
rel2.to: "bottom_clip"; rel2.to: "bottom_clip";
rel2.relative: 1.0 0.0; rel2.relative: 1.0 0.0;
@ -805,18 +784,6 @@ group { name: "elm/border/base/default";
UNSET_MODE(MAXIMIZED); UNSET_MODE(MAXIMIZED);
} }
/* application desktop menu */
program { name: "show_menu";
signal: "elm,action,show_menu"; source: "elm";
action: STATE_SET "visible";
target: "elm.swallow.menu";
}
program { name: "hide_menu";
signal: "elm,action,hide"; source: "elm";
action: STATE_SET "default";
target: "elm.swallow.menu";
}
/* modal windows */ /* modal windows */
program { name: "hide_blocker"; program { name: "hide_blocker";
signal: "elm,action,hide_blocker"; source: "elm"; signal: "elm,action,hide_blocker"; source: "elm";

View File

@ -1,6 +1,28 @@
group { name: "elm/win/base/default"; group { name: "elm/win/base/default";
data.item: "elm_win_version" "119"; data.item: "elm_win_version" "119";
parts { parts {
/* main menu */
part { name: "menu_bg"; type: RECT;
description { state: "default" 0.0;
color: 64 64 64 255;
align: 0.5 0;
rel2.to: "elm.swallow.menu";
}
}
part { name: "elm.swallow.menu"; type: SWALLOW;
description { state: "default" 0.0;
rel2.relative: 1.0 0.0;
visible: 0;
align: 0.5 0;
fixed: 1 1;
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
fixed: 0 1;
}
}
/* application content */
rect { "client_clip"; nomouse; rect { "client_clip"; nomouse;
desc { "default"; desc { "default";
rel.to: "elm.swallow.contents"; rel.to: "elm.swallow.contents";
@ -8,6 +30,24 @@ group { name: "elm/win/base/default";
} }
swallow { "elm.swallow.contents"; swallow { "elm.swallow.contents";
clip_to: "client_clip"; clip_to: "client_clip";
desc { "default";
rel1.to: "elm.swallow.menu";
rel1.relative: 0.0 1.0;
}
}
}
programs {
program { name: "show_menu";
signal: "elm,action,show_menu";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "elm.swallow.menu";
}
program { name: "hide_menu";
signal: "elm,action,hide";
source: "elm";
action: STATE_SET "default" 0.0;
target: "elm.swallow.menu";
} }
} }
} }

View File

@ -212,14 +212,12 @@ struct _Efl_Ui_Win_Data
Eina_Bool need_shadow : 1; /**< if true, application draws its csd and shadow */ Eina_Bool need_shadow : 1; /**< if true, application draws its csd and shadow */
Eina_Bool need_borderless : 1; Eina_Bool need_borderless : 1;
Eina_Bool need_bg_solid : 1; Eina_Bool need_bg_solid : 1;
Eina_Bool need_menu : 1;
Eina_Bool need_unresizable : 1; Eina_Bool need_unresizable : 1;
Eina_Bool cur_borderless : 1; Eina_Bool cur_borderless : 1;
Eina_Bool cur_shadow : 1; Eina_Bool cur_shadow : 1;
Eina_Bool cur_focus : 1; Eina_Bool cur_focus : 1;
Eina_Bool cur_maximized : 1; Eina_Bool cur_maximized : 1;
Eina_Bool cur_bg_solid : 1; Eina_Bool cur_bg_solid : 1;
Eina_Bool cur_menu : 1;
Eina_Bool cur_unresizable : 1; Eina_Bool cur_unresizable : 1;
Eina_Bool wayland : 1; Eina_Bool wayland : 1;
} csd; } csd;
@ -4138,8 +4136,7 @@ _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *style)
static void static void
_elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc) _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc)
{ {
Eina_Bool borderless, maximized, shadow, focus, bg_solid, menu, unresizable, Eina_Bool borderless, maximized, shadow, focus, bg_solid, unresizable, alpha;
alpha;
Eina_Bool changed = EINA_FALSE; Eina_Bool changed = EINA_FALSE;
if (!sd->frame_obj) if (!sd->frame_obj)
@ -4155,7 +4152,6 @@ _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool
sd->csd.need_shadow = EINA_FALSE; sd->csd.need_shadow = EINA_FALSE;
sd->csd.need_borderless = EINA_TRUE; sd->csd.need_borderless = EINA_TRUE;
sd->csd.need_unresizable = EINA_TRUE; sd->csd.need_unresizable = EINA_TRUE;
sd->csd.need_menu = EINA_FALSE;
} }
else else
{ {
@ -4170,7 +4166,6 @@ _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool
focus = ecore_evas_focus_get(sd->ee); focus = ecore_evas_focus_get(sd->ee);
bg_solid = sd->csd.need_bg_solid; bg_solid = sd->csd.need_bg_solid;
unresizable = sd->csd.need_unresizable; unresizable = sd->csd.need_unresizable;
menu = sd->csd.need_menu;
/* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME /* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
* At the moment, E Wayland uses SSD for its internal windows. Which means * At the moment, E Wayland uses SSD for its internal windows. Which means
@ -4196,7 +4191,6 @@ _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool
STATE_SET(focus, "elm,action,focus", "elm,action,unfocus"); STATE_SET(focus, "elm,action,focus", "elm,action,unfocus");
STATE_SET(bg_solid, "elm,state,background,solid,on", "elm,state,background,solid,off"); STATE_SET(bg_solid, "elm,state,background,solid,on", "elm,state,background,solid,off");
STATE_SET(unresizable, "elm,state,unresizable,on", "elm,state,unresizable,off"); STATE_SET(unresizable, "elm,state,unresizable,on", "elm,state,unresizable,off");
STATE_SET(menu, "elm,action,show_menu", "elm,action,hide_menu");
#undef STATE_SET #undef STATE_SET
@ -5331,38 +5325,25 @@ _efl_ui_win_fullscreen_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
return sd->fullscreen; return sd->fullscreen;
} }
static inline Eo *
_main_menu_swallow_get(Efl_Ui_Win_Data *sd)
{
if (edje_object_part_exists(sd->legacy.edje, "elm.swallow.menu"))
{
DBG("Detected legacy theme, using legacy swallows.");
return sd->legacy.edje;
}
return sd->legacy.edje;
}
static void static void
_dbus_menu_set(Eina_Bool dbus_connect, void *data) _dbus_menu_set(Eina_Bool dbus_connect, void *data)
{ {
ELM_WIN_DATA_GET_OR_RETURN(data, sd); ELM_WIN_DATA_GET_OR_RETURN(data, sd);
Eo *swallow = _main_menu_swallow_get(sd);
if (dbus_connect) if (dbus_connect)
{ {
DBG("Setting menu to D-Bus"); DBG("Setting menu to D-Bus");
edje_object_part_unswallow(swallow, sd->main_menu); edje_object_part_unswallow(sd->legacy.edje, sd->main_menu);
sd->csd.need_menu = EINA_FALSE; edje_object_signal_emit(sd->legacy.edje, "elm,action,hide", "elm");
_elm_menu_menu_bar_hide(sd->main_menu); _elm_menu_menu_bar_hide(sd->main_menu);
} }
else else
{ {
DBG("Setting menu to local mode"); DBG("Setting menu to local mode");
edje_object_part_swallow(swallow, "elm.swallow.menu", sd->main_menu); edje_object_part_swallow(sd->legacy.edje, "elm.swallow.menu", sd->main_menu);
sd->csd.need_menu = EINA_TRUE; edje_object_signal_emit(sd->legacy.edje, "elm,action,show_menu", "elm");
evas_object_show(sd->main_menu); evas_object_show(sd->main_menu);
} }
_elm_win_frame_style_update(sd, 0, 1);
} }
EOLIAN static void EOLIAN static void