Adanos020 / egui_dock

Docking support for egui – an immediate-mode GUI library for Rust
MIT License
458 stars 75 forks source link

Problem with "second use" when using new_window #236

Closed patrickelectric closed 6 months ago

patrickelectric commented 6 months ago

Describe the bug image

To Reproduce Steps to reproduce the behavior:

  1. Get the example
  2. Add the following code:

    egui::SidePanel::right("egui_demo_panel")
    .resizable(false)
    .default_width(150.0)
    .show(ctx, |ui| {
      ui.vertical_centered(|ui| {
          ui.heading("Services");
      });
    
      egui::ScrollArea::vertical().show(ui, |ui| {
          ui.with_layout(egui::Layout::top_down_justified(egui::Align::LEFT), |ui| {
              if ui.button("Potato").clicked() {
                  self.tree.add_window(vec!["Potato".to_owned()]);
              }
              if ui.button("Organize windows").clicked() {
                  ui.ctx().memory_mut(|mem| mem.reset_areas());
              }
          });
      });
    
      ui.separator();
    });
  3. Run the code, click in the Potato button on the right side

Expected behavior This should not happens, using egui 0.27

Adanos020 commented 6 months ago

Hey, this is not a bug in the library. Each tab must have a unique ID which by default is derived from the tab title, so if you have two tabs with the same title, naturally there will be an ID conflict. You can override that behaviour by implementing TabViewer::id.

Let me know if that fixes your issue.