diff --git a/CHANGELOG.md b/CHANGELOG.md index 99756ce418..d55bbcf56a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ You can find its changes [documented below](#060---2020-06-01). - `WidgetExt::debug_widget_id` and `debug_paint_layout` now also apply to the widget they are called on. ([#1100] by [@finnerale]) - X11: Fix X11 errors caused by destroyed windows. ([#1103] by [@jneem]) - `ViewSwitcher` now skips the update after switching widgets. ([#1113] by [@finnerale]) +- Key and KeyOrValue derive Clone ([#1119] by [@rjwittams]) +- Allow submit_command from the layout method in Widgets ([#1119] by [@rjwittams]) ### Visual @@ -260,6 +262,7 @@ Last release without a changelog :( [@psychon]: https://github.com/psychon [@sysint64]: https://github.com/sysint64 [@justinmoon]: https://github.com/justinmoon +[@rjwittams]: https://github.com/rjwittams [#599]: https://github.com/linebender/druid/pull/599 [#611]: https://github.com/linebender/druid/pull/611 @@ -378,7 +381,7 @@ Last release without a changelog :( [#1093]: https://github.com/linebender/druid/pull/1093 [#1100]: https://github.com/linebender/druid/pull/1100 [#1103]: https://github.com/linebender/druid/pull/1103 - +[#1119]: https://github.com/linebender/druid/pull/1119 [Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master [0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0 diff --git a/druid/src/contexts.rs b/druid/src/contexts.rs index 284c58fdf5..3d4e156db1 100644 --- a/druid/src/contexts.rs +++ b/druid/src/contexts.rs @@ -318,19 +318,6 @@ impl_context_method!(EventCtx<'_, '_>, UpdateCtx<'_, '_>, LifeCycleCtx<'_, '_>, self.request_layout(); } - /// Submit a [`Command`] to be run after this event is handled. - /// - /// Commands are run in the order they are submitted; all commands - /// submitted during the handling of an event are executed before - /// the [`update`] method is called; events submitted during [`update`] - /// are handled after painting. - /// - /// [`Command`]: struct.Command.html - /// [`update`]: trait.Widget.html#tymethod.update - pub fn submit_command(&mut self, cmd: impl Into, target: impl Into>) { - self.state.submit_command(cmd.into(), target.into()) - } - /// Set the menu of the window containing the current widget. /// `T` must be the application's root `Data` type (the type provided to [`AppLauncher::launch`]). /// @@ -340,6 +327,32 @@ impl_context_method!(EventCtx<'_, '_>, UpdateCtx<'_, '_>, LifeCycleCtx<'_, '_>, } }); +// methods on event, update, and lifecycle +impl_context_method!( + EventCtx<'_, '_>, + UpdateCtx<'_, '_>, + LifeCycleCtx<'_, '_>, + LayoutCtx<'_, '_>, + { + /// Submit a [`Command`] to be run after this event is handled. + /// + /// Commands are run in the order they are submitted; all commands + /// submitted during the handling of an event are executed before + /// the [`update`] method is called; events submitted during [`update`] + /// are handled after painting. + /// + /// [`Command`]: struct.Command.html + /// [`update`]: trait.Widget.html#tymethod.update + pub fn submit_command( + &mut self, + cmd: impl Into, + target: impl Into>, + ) { + self.state.submit_command(cmd.into(), target.into()) + } + } +); + impl EventCtx<'_, '_> { /// Set the cursor icon. /// diff --git a/druid/src/env.rs b/druid/src/env.rs index f5c563f8a6..636c6714b6 100644 --- a/druid/src/env.rs +++ b/druid/src/env.rs @@ -86,6 +86,7 @@ struct EnvImpl { /// /// [`ValueType`]: trait.ValueType.html /// [`Env`]: struct.Env.html +#[derive(Clone)] pub struct Key { key: &'static str, value_type: PhantomData<*const T>, @@ -116,6 +117,7 @@ pub enum Value { /// /// [`Key`]: struct.Key.html /// [`Env`]: struct.Env.html +#[derive(Clone)] pub enum KeyOrValue { Concrete(Value), Key(Key),