Merge 1c9d03aca6
into a102b08743
This commit is contained in:
commit
2dce113986
2 changed files with 10 additions and 8 deletions
|
@ -253,14 +253,14 @@ impl ApplicationMenu {
|
|||
cx.defer_in(window, move |_, window, cx| next_handle.show(window, cx));
|
||||
}
|
||||
|
||||
pub fn all_menus_shown(&self, cx: &mut Context<Self>) -> bool {
|
||||
pub fn all_menus_shown(&self, cx: &App) -> bool {
|
||||
show_menus(cx)
|
||||
|| self.entries.iter().any(|entry| entry.handle.is_deployed())
|
||||
|| self.pending_menu_open.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn show_menus(cx: &mut App) -> bool {
|
||||
pub(crate) fn show_menus(cx: &App) -> bool {
|
||||
TitleBarSettings::get_global(cx).show_menus
|
||||
&& (cfg!(not(target_os = "macos")) || option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some())
|
||||
}
|
||||
|
|
|
@ -138,7 +138,9 @@ impl Render for TitleBar {
|
|||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let title_bar_settings = *TitleBarSettings::get_global(cx);
|
||||
|
||||
let show_menus = show_menus(cx);
|
||||
let mut render_project_items =
|
||||
title_bar_settings.show_branch_name || title_bar_settings.show_project_items;
|
||||
let show_separate_menus = show_menus(cx) && render_project_items;
|
||||
|
||||
let mut children = Vec::new();
|
||||
|
||||
|
@ -146,14 +148,14 @@ impl Render for TitleBar {
|
|||
h_flex()
|
||||
.gap_1()
|
||||
.map(|title_bar| {
|
||||
let mut render_project_items = title_bar_settings.show_branch_name
|
||||
|| title_bar_settings.show_project_items;
|
||||
title_bar
|
||||
.when_some(
|
||||
self.application_menu.clone().filter(|_| !show_menus),
|
||||
self.application_menu
|
||||
.clone()
|
||||
.filter(|_| !show_separate_menus),
|
||||
|title_bar, menu| {
|
||||
render_project_items &=
|
||||
!menu.update(cx, |menu, cx| menu.all_menus_shown(cx));
|
||||
!menu.read_with(cx, |menu, cx| menu.all_menus_shown(cx));
|
||||
title_bar.child(menu)
|
||||
},
|
||||
)
|
||||
|
@ -200,7 +202,7 @@ impl Render for TitleBar {
|
|||
.into_any_element(),
|
||||
);
|
||||
|
||||
if show_menus {
|
||||
if show_separate_menus {
|
||||
self.platform_titlebar.update(cx, |this, _| {
|
||||
this.set_children(
|
||||
self.application_menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue