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
+18
View File
@@ -66,6 +66,20 @@ pub trait UpdateView {
F: FnOnce(&mut T, &mut ViewContext<T>) -> S;
}
pub struct Menu<'a> {
pub name: &'a str,
pub items: &'a [MenuItem<'a>],
}
pub enum MenuItem<'a> {
Action {
name: &'a str,
keystroke: Option<&'a str>,
action: &'a str,
},
Separator,
}
#[derive(Clone)]
pub struct App(Rc<RefCell<MutableAppContext>>);
@@ -365,6 +379,10 @@ impl MutableAppContext {
&self.ctx
}
pub fn platform(&self) -> Arc<dyn platform::App> {
self.platform.clone()
}
pub fn foreground_executor(&self) -> &Rc<executor::Foreground> {
&self.foreground
}