Programmatically open / closing windows#3517
Conversation
Fixes: emilk#358 You can open / close windows programmatically to events. See demo about. The good thing about the new API, is that it won't lock the borrowchecker (unlike open). It's maybe a good idea to considering open as deprecated.
e.g: display_event.set(DisplayEvent::ToggleCollapse); To use so rust analyzer won't complain about not handling the return like in insert / replace
| pub fn is_hidden(&self) -> bool { | ||
| self.state.hidden | ||
| } | ||
|
|
||
| pub fn toggle_hidden(&mut self) { | ||
| self.state.hidden = !self.state.hidden; | ||
| } | ||
|
|
||
| pub fn set_hidden(&mut self, hidden: bool) { | ||
| self.state.hidden = hidden; | ||
| } |
There was a problem hiding this comment.
What does it mean for a CollapsingHeader to be hidden?
There was a problem hiding this comment.
Well windows can become hidden, collapsing headers won't do anything but I will update the PR, so this code won't be accessible when not using a window. I also have made the same event option for normal widgets to expand/collapse which I will include in this PR as well.
There was a problem hiding this comment.
I added some comments to notify the dev that its only for window components. The API is not open to end users, I have made another branch where I split the two structs (see comments below).
There was a problem hiding this comment.
I build a split between the two states on this branch (draft): Norlock@40b1fb7#diff-817170c50650af7962ada22bb6459b20eeb54ce921043e4db8522368ccf8933e. I don't know if its a real improvement but you can check it out. If you prefer that version I can clean up the code a bit
Add events to collapsing headers
Add events to collapsing headers, fix some backwards compatibility bug.
Deprecating: `load_with_default_open` as the arguments already infer that's the case
| Expand, | ||
| Collapse, | ||
| Hide, | ||
| ToggleCollapse, | ||
| ToggleHidden, |
There was a problem hiding this comment.
These need docstrings.
What does it mean to hide a window? Does it mean "Close"? If so, please name it that because "Close" is the antonym of "Open".
| // Helper function for user space | ||
| pub trait SetEvent { |
There was a problem hiding this comment.
SetWindowEvent is probably a better name.
What would this be used for?
This is an API redesign for events. You can open/close/hide/show the window programmatically keeping the borrow checker unlocked. I updated the demo application with two new buttons to showcase. Everything is still backwards compatible. I do favor to deprecate the .open() function.
Closes 358