Skip to content

Dynamically adding tiles/panes if only one pane exists #83

@canselcik

Description

@canselcik

I am probably doing it wrong but there seems to be some sort of idiosyncrasy to it that I am having a hard time figuring out.

If I created the tree as such:

    let mut tiles = egui_tiles::Tiles::default();
    let children = vec![
        tiles.insert_pane(Pane {
            nr: PaneType::Chart("SOMETHING", "SOMETHING".to_string()),
            retained: true,
        }),
        tiles.insert_pane(Pane {
            nr: PaneType::EmptyDemo(Color32::DARK_BLUE),
            retained: true,
        }),
    ];
    let h2 = tiles.insert_tab_tile(children);
    egui_tiles::Tree::new("tree_root", h2, tiles)

And then try to add a new tile like:

        if ui.button("UI Panels Test").clicked() {
            if let Some(r) = self.tree.root() {
                self.log("Found root");
                let content = Pane {
                    nr: PaneType::EmptyDemo(Color32::DARK_BLUE),
                    retained: true,
                };
                let t = vec![self.tree.tiles.insert_pane(content)];
                let pid = self.tree.tiles.insert_horizontal_tile(t);
                self.tree.move_tile_to_container(pid, r.clone(), 0, true);
            }
        }

It works fine. But if I closed the PaneType::EmptyDemo(Color32::DARK_BLUE) pane before creating another, it never shows up.

Is it about the size of the new panel?

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