Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes split out from #1107 . #1119

Merged
merged 3 commits into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
jneem marked this conversation as resolved.
Show resolved Hide resolved

### Visual

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 26 additions & 13 deletions druid/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Command>, target: impl Into<Option<Target>>) {
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`]).
///
Expand All @@ -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<Command>,
target: impl Into<Option<Target>>,
) {
self.state.submit_command(cmd.into(), target.into())
}
}
);

impl EventCtx<'_, '_> {
/// Set the cursor icon.
///
Expand Down
2 changes: 2 additions & 0 deletions druid/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct EnvImpl {
///
/// [`ValueType`]: trait.ValueType.html
/// [`Env`]: struct.Env.html
#[derive(Clone)]
pub struct Key<T> {
key: &'static str,
value_type: PhantomData<*const T>,
Expand Down Expand Up @@ -116,6 +117,7 @@ pub enum Value {
///
/// [`Key<T>`]: struct.Key.html
/// [`Env`]: struct.Env.html
#[derive(Clone)]
pub enum KeyOrValue<T> {
Concrete(Value),
Key(Key<T>),
Expand Down