diff options
author | 2021-07-20 21:44:33 +0700 | |
---|---|---|
committer | 2021-07-20 21:44:33 +0700 | |
commit | 8e29709b69ec0eae211887c8c6d91558175997b5 (patch) | |
tree | c6fe2b40d4be34867e61b9061d27ae44916ad4ab /src | |
parent | a6dbaf0f5fd3590a8cfe92f924184c5d78e00152 (diff) | |
parent | 82db3c78b6cfa2cc55ece6ffa46811bfb5195f60 (diff) | |
download | iced-8e29709b69ec0eae211887c8c6d91558175997b5.tar.gz iced-8e29709b69ec0eae211887c8c6d91558175997b5.tar.bz2 iced-8e29709b69ec0eae211887c8c6d91558175997b5.zip |
Merge pull request #945 from derezzedex/menu
feat: add menus
Diffstat (limited to '')
-rw-r--r-- | src/application.rs | 15 | ||||
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/sandbox.rs | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/src/application.rs b/src/application.rs index bda8558c..ae85c841 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,6 +1,6 @@ use crate::window; use crate::{ - Clipboard, Color, Command, Element, Executor, Settings, Subscription, + Clipboard, Color, Command, Element, Executor, Menu, Settings, Subscription, }; /// An interactive cross-platform application. @@ -99,7 +99,7 @@ pub trait Application: Sized { type Executor: Executor; /// The type of __messages__ your [`Application`] will produce. - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Clone + Send; /// The data needed to initialize your [`Application`]. type Flags; @@ -191,6 +191,13 @@ pub trait Application: Sized { false } + /// Returns the current system [`Menu`] of the [`Application`]. + /// + /// By default, it returns an empty [`Menu`]. + fn menu(&self) -> Menu<Self::Message> { + Menu::new() + } + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -296,6 +303,10 @@ where fn should_exit(&self) -> bool { self.0.should_exit() } + + fn menu(&self) -> Menu<Self::Message> { + self.0.menu() + } } #[cfg(target_arch = "wasm32")] @@ -245,7 +245,7 @@ pub use sandbox::Sandbox; pub use settings::Settings; pub use runtime::{ - futures, Align, Background, Clipboard, Color, Command, Font, - HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector, - VerticalAlignment, + futures, menu, Align, Background, Clipboard, Color, Command, Font, + HorizontalAlignment, Length, Menu, Point, Rectangle, Size, Subscription, + Vector, VerticalAlignment, }; diff --git a/src/sandbox.rs b/src/sandbox.rs index 10b05a92..cb3cf624 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -88,7 +88,7 @@ use crate::{ /// ``` pub trait Sandbox { /// The type of __messages__ your [`Sandbox`] will produce. - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Clone + Send; /// Initializes the [`Sandbox`]. /// |