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

Replace generic commands with methods on EventCtx and DelegateCtx #931

Merged
merged 8 commits into from
May 15, 2020

Conversation

luleyleo
Copy link
Collaborator

Third part of #908 .

Replaces NEW_WINDOW, SET_MENU and SHOW_CONTEXT_MENU commands with methods on EventCtx and DelegateCtx.

This will get rid of any generic commands which caused quite some trouble for typed selectors.

When calling any of the methods with the wrong data type, it will panic! in debug mode and log::error! in a release build.

I've not added show_context_menu to DelegateCtx as I could not imagine a real world usecase.
Thus I had to change multiwin a bit to use a Controller for the context menu, which seemed to be much closer to actual usage of a context menu.

@luleyleo luleyleo added the S-needs-review waits for review label May 15, 2020
Copy link
Member

@xStrom xStrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the ergonomics improvements in the multiwin example.

druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/app_delegate.rs Outdated Show resolved Hide resolved
druid/src/app_delegate.rs Outdated Show resolved Hide resolved
@xStrom xStrom added S-waiting-on-author waits for changes from the submitter and removed S-needs-review waits for review labels May 15, 2020
@xStrom xStrom added S-needs-review waits for review and removed S-waiting-on-author waits for changes from the submitter labels May 15, 2020
@luleyleo
Copy link
Collaborator Author

Thanks for the suggestions!

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to block this for a sec and try it out with runebender, and see if it's working as-is; I have some weird stuff there around menus.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one repeated doc tweak, overall I think this is a good ergonomics improvement!

druid/src/app_delegate.rs Outdated Show resolved Hide resolved
druid/src/app_delegate.rs Outdated Show resolved Hide resolved
druid/src/app_delegate.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/app_delegate.rs Outdated Show resolved Hide resolved
);
} else {
const MSG: &str = "ContextMenu<T> - T must match the application state.";
if cfg!(debug_assertions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this becomes a pattern we could consider a custom macro, like log_or_panic!(...).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like it if this becomes a pattern (or log_or_panic!) as panic! makes debugging easier due to the back trace while log::error! does not crash the app once you ship it.

@xStrom xStrom added S-waiting-on-author waits for changes from the submitter and removed S-needs-review waits for review labels May 15, 2020
@luleyleo luleyleo added S-needs-review waits for review and removed S-waiting-on-author waits for changes from the submitter labels May 15, 2020
@luleyleo
Copy link
Collaborator Author

@cmyr Thanks for the review, I think I've addressed everything.

@luleyleo luleyleo merged commit 0acb07b into linebender:master May 15, 2020
@luleyleo luleyleo added the breaking change pull request breaks user code label May 15, 2020
@xStrom xStrom removed the S-needs-review waits for review label May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change pull request breaks user code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants