Return back Windows menu (#22339)
Follow-up of https://github.com/zed-industries/zed/pull/21873 Release Notes: - N/A
This commit is contained in:
parent
dbb76100e5
commit
b51a28b75f
2 changed files with 23 additions and 13 deletions
|
@ -48,6 +48,7 @@ pub(crate) struct WindowsPlatform {
|
||||||
|
|
||||||
pub(crate) struct WindowsPlatformState {
|
pub(crate) struct WindowsPlatformState {
|
||||||
callbacks: PlatformCallbacks,
|
callbacks: PlatformCallbacks,
|
||||||
|
menus: Vec<OwnedMenu>,
|
||||||
// NOTE: standard cursor handles don't need to close.
|
// NOTE: standard cursor handles don't need to close.
|
||||||
pub(crate) current_cursor: HCURSOR,
|
pub(crate) current_cursor: HCURSOR,
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,7 @@ impl WindowsPlatformState {
|
||||||
Self {
|
Self {
|
||||||
callbacks,
|
callbacks,
|
||||||
current_cursor,
|
current_cursor,
|
||||||
|
menus: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,8 +451,15 @@ impl Platform for WindowsPlatform {
|
||||||
self.state.borrow_mut().callbacks.reopen = Some(callback);
|
self.state.borrow_mut().callbacks.reopen = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_menus(&self, menus: Vec<Menu>, _keymap: &Keymap) {
|
||||||
|
self.state.borrow_mut().menus = menus.into_iter().map(|menu| menu.owned()).collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_menus(&self) -> Option<Vec<OwnedMenu>> {
|
||||||
|
Some(self.state.borrow().menus.clone())
|
||||||
|
}
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn set_menus(&self, _menus: Vec<Menu>, _keymap: &Keymap) {}
|
|
||||||
fn set_dock_menu(&self, _menus: Vec<MenuItem>, _keymap: &Keymap) {}
|
fn set_dock_menu(&self, _menus: Vec<MenuItem>, _keymap: &Keymap) {}
|
||||||
|
|
||||||
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
||||||
|
|
|
@ -134,18 +134,19 @@ impl Render for TitleBar {
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.when_some(self.application_menu.clone(), |this, menu| {
|
.map(|title_bar| {
|
||||||
let is_any_menu_deployed = menu.read(cx).is_any_deployed();
|
let mut render_project_items = true;
|
||||||
this.child(menu).when(!is_any_menu_deployed, |this| {
|
title_bar
|
||||||
this.children(self.render_project_host(cx))
|
.when_some(self.application_menu.clone(), |title_bar, menu| {
|
||||||
.child(self.render_project_name(cx))
|
render_project_items = !menu.read(cx).is_any_deployed();
|
||||||
.children(self.render_project_branch(cx))
|
title_bar.child(menu)
|
||||||
})
|
})
|
||||||
})
|
.when(render_project_items, |title_bar| {
|
||||||
.when(self.application_menu.is_none(), |this| {
|
title_bar
|
||||||
this.children(self.render_project_host(cx))
|
.children(self.render_project_host(cx))
|
||||||
.child(self.render_project_name(cx))
|
.child(self.render_project_name(cx))
|
||||||
.children(self.render_project_branch(cx))
|
.children(self.render_project_branch(cx))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.on_mouse_down(MouseButton::Left, |_, cx| cx.stop_propagation()),
|
.on_mouse_down(MouseButton::Left, |_, cx| cx.stop_propagation()),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue