Pane Rework and Pane Group Functionality#170
Pane Rework and Pane Group Functionality#170Clicky02 wants to merge 3 commits intobevyengine:mainfrom
Conversation
|
|
||
| /// Removes and despawns the given content entity. | ||
| pub fn remove(&mut self, entity: Entity) { | ||
| let i = self.contents.iter().position(|val| *val == entity).unwrap(); |
There was a problem hiding this comment.
Should I return an error here instead of unwrapping?
|
|
||
| /// Removes and despawns a pane in this group. | ||
| pub fn remove_pane(&mut self, pane: Entity) -> &'a mut PaneGroupCommands { | ||
| let index = self.panes.iter().position(|val| val.root == pane).unwrap(); |
There was a problem hiding this comment.
Should I return an error here instead of unwrapping?
| } | ||
|
|
||
| /// Removes and despawns the pane in this group at the given index. | ||
| pub fn remove_pane_at(&mut self, index: usize) -> &'a mut PaneGroupCommands { |
There was a problem hiding this comment.
I think moving the remove logic into a command could potentially simplify/improve this struct. Is that worth implementing?
| )]), | ||
| )) | ||
| .set_parent(group_header) | ||
| .observe( |
There was a problem hiding this comment.
Is it better to query for elements or just move/copy the entity handles into the observer functions? Moving the values would simplify the logic of some of these observers.
| } | ||
|
|
||
| /// This is temporary, until we can load maps from the asset browser | ||
| fn initial_layout( |
There was a problem hiding this comment.
Does the layout belong in the bevy_editor crate or in another crate? I had to move it here so that I could reference the types of each Pane.
|
Cool |
|
Is this structured in such a way that you could eventually pull out panes from groups and move them to other areas? I believe so, but want to double check. |
Yeah, you can't pull them out right now, but adding it shouldn't be difficult at all |
|
Hey @Clicky02 what is the latest on this PR? Importantly, what's the protocol for old PR's as we've got a few others that are few months old @alice-i-cecile ? |
This PR adds Pane groups and makes some pretty heavy modifications to how the Bevy Editor UI works internally. This PR is not ready to merged yet, but I wanted to make a PR to get feedback.
Pane Groups
Pane Groups allow multiple Panes to exist in the same area. You can switch between the Panes by clicking on the corresponding header tab. Unselected panes have their container's Node::display value set to Display::None. Selected panes have the SelectedPane component added to them.
Pane Changes
Additionally, I made some changes to how new Pane types are created. Before, new pane types were created in Plugins like this:
And they would be referenced/spawned like this:
After my changes, Panes are created by implementing a Pane trait like this:
And they are referenced/spawned like this:
When panes are spawned, the corresponding Pane component (
TestPanein the above example) will be added to the spawned Pane entity.I believe this has a few advantages:
UI Layout Creation Changes
These changes improve the interface for creating the editor layout. Before it looked like this:
After these changes, it works like this:
The new version does not involve manually spawning the resize handles, and intellisense will tell you all the available actions for a divider or pane group.
This was accomplished by creating a
DividerCommandsstruct and aPaneGroupCommandsstruct. These are wrappers around the Commands object that define the interface by which the layout can be interacted with. If you want to use these command objects in a system, you can use the system paramsDividerCommandsQueryandPaneGroupCommandsQueryrespectively.