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

Implement 'save as' dialog, tweak open/save API #376

Merged
merged 1 commit into from
Dec 4, 2019
Merged

Implement 'save as' dialog, tweak open/save API #376

merged 1 commit into from
Dec 4, 2019

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Dec 3, 2019

This gets the 'save as' dialog working in a similar fashion to
the 'open' dialog.

The API isn't great. In druid-shell, open and save_as are exposed
as two different methods on WinCtx. They could be unified, now,
at the cost of a slightly less ergonomic API; the caller would
have to bring the FileDialogType enum into scope and pass it
directly.

In druid, the API is also slightly different. The Event::Open variant
has been removed, and both open and save are now fully Command based.

The basic idea is that there are two 'special' commands,
SHOW_SAVE_PANEL and SHOW_OPEN_PANEL, that are handled by the framework.
When these commands are received, the framework handles showing the
appropriate panel, and getting the input. If this succeeds,
the framework then sends either the SAVE_FILE or OPEN_FILE command,
which is expected to be handled by the framework author.

This gets the 'save as' dialog working in a similar fashion to
the 'open' dialog.

The API isn't great. In druid-shell, open and save_as are exposed
as two different methods on WinCtx. They could be unified, now,
at the cost of a slightly less ergonomic API; the caller would
have to bring the FileDialogType enum into scope and pass it
directly.

In druid, the API is also slightly different. The Event::Open variant
has been removed, and both open and save are now fully Command based.

The basic idea is that there are two 'special' commands,
SHOW_SAVE_PANEL and SHOW_OPEN_PANEL, that are handled by the framework.
When these commands are received, the framework handles showing the
appropriate panel, and getting the input. If this succeeds,
the framework then sends either the SAVE_FILE or OPEN_FILE command,
which is expected to be handled by the framework author.
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

This seems good enough for now. I agree there are things we could do to make the API's cleaner. As you mentioned on zulip, there's a fundamentally async nature to this - you can think of the file dialog as returning a promise of its eventual results. The "explore async" effort should probably think about whether it can cover this case.

@cmyr cmyr merged commit 26b7ad1 into master Dec 4, 2019
@cmyr cmyr deleted the save-as branch December 4, 2019 15:07
@cmyr cmyr mentioned this pull request Dec 31, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants