Create an API for assigning the menubar contents

This commit is contained in:
Max Brunsfeld
2021-04-08 16:01:36 -07:00
parent 0a12774680
commit 334de06322
9 changed files with 216 additions and 60 deletions
+5 -2
View File
@@ -15,7 +15,7 @@ use crate::{
vector::Vector2F,
},
text_layout::Line,
Scene,
Menu, Scene,
};
use anyhow::Result;
use async_task::Runnable;
@@ -23,11 +23,13 @@ pub use event::Event;
use std::{ops::Range, path::PathBuf, rc::Rc, sync::Arc};
pub trait Runner {
fn on_finish_launching<F: 'static + FnOnce()>(self, callback: F) -> Self where;
fn on_finish_launching<F: 'static + FnOnce()>(self, callback: F) -> Self;
fn on_menu_command<F: 'static + FnMut(&str)>(self, callback: F) -> Self;
fn on_become_active<F: 'static + FnMut()>(self, callback: F) -> Self;
fn on_resign_active<F: 'static + FnMut()>(self, callback: F) -> Self;
fn on_event<F: 'static + FnMut(Event) -> bool>(self, callback: F) -> Self;
fn on_open_files<F: 'static + FnMut(Vec<PathBuf>)>(self, callback: F) -> Self;
fn set_menus(self, menus: &[Menu]) -> Self;
fn run(self);
}
@@ -40,6 +42,7 @@ pub trait App {
executor: Rc<executor::Foreground>,
) -> Result<Box<dyn Window>>;
fn fonts(&self) -> Arc<dyn FontSystem>;
fn quit(&self);
}
pub trait Dispatcher: Send + Sync {