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

Make it possible to reset the tree layout #88

Open
porkiedev opened this issue Oct 25, 2024 · 0 comments
Open

Make it possible to reset the tree layout #88

porkiedev opened this issue Oct 25, 2024 · 0 comments

Comments

@porkiedev
Copy link

I'm working on a project that involves allowing the user to to dynamically move tiles around wherever they want. However, in the event that the layout gets too complicated and they want to start over, it'd be nice to be able to call Tree::reset_layout() (or something similar) to reset the layout (i.e. evenly space all of the tiles and remove their nesting)

I tried to achieve this with the following code:

// Get all of the tile ids in this tree except the current root
let tile_ids = tree.tiles.tile_ids().filter(|id| id != &root).collect();
// Insert all of the tile ids into a new grid tile
let new_root = tree.tiles.insert_grid_tile(tile_ids);
// Update the root tile
tree.root = Some(new_root);

This actually did partially work, but only for non-nested layouts. If the tree contains any panes (split panes, tabs, etc), those tiles will be removed from the layout altogether.
Additionally, while I can't determine the exact cause, nor can I reliably reproduce it, this will occasionally cause a panic in tiles.rs:112:9: Failed to find rect for #10

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

No branches or pull requests

1 participant