use concinnity_core::ecs::World;
use crate::editor::hook::EditorHook;
impl EditorHook {
#[cfg(target_os = "macos")]
pub(crate) fn with_app_menu(self) -> Self {
crate::editor::app_menu::install(self.panel_marks());
self
}
#[cfg(not(target_os = "macos"))]
pub(crate) fn with_app_menu(self) -> Self {
self
}
#[cfg(target_os = "macos")]
pub(in crate::editor::hook) fn drive_app_menu(&mut self, world: &mut World) {
use crate::editor::app_menu::{self, MenuCommand};
for command in app_menu::take_chosen() {
match command {
MenuCommand::PanelToggle(i) => self.toggle_view_row(i, world),
MenuCommand::Quit => {
if let Some(shutdown) = &self.shutdown {
shutdown.cancel();
}
}
}
}
app_menu::sync(self.panel_marks());
}
#[cfg(not(target_os = "macos"))]
pub(in crate::editor::hook) fn drive_app_menu(&mut self, _world: &mut World) {}
#[cfg(target_os = "macos")]
fn panel_marks(&self) -> crate::editor::app_menu::PanelMarks {
use crate::editor::panels::registry;
crate::editor::app_menu::PanelMarks::from_open(
registry::view_toggles().map(|p| p.is_open(self)),
)
}
}