Skip to content

Make it possible to reset the tree layout #88

@porkiedev

Description

@porkiedev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions