From d4efb3215aa57736d8c2c55f5999b66becea7186 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 8 May 2023 11:04:59 +0200 Subject: [PATCH] Make sure the tab buttons don't cover the RTL "add tab" buttons --- crates/egui_extras/src/dock/branch/tabs.rs | 3 +++ crates/egui_extras/src/dock/mod.rs | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/egui_extras/src/dock/branch/tabs.rs b/crates/egui_extras/src/dock/branch/tabs.rs index 5ad17cb42..ea8079832 100644 --- a/crates/egui_extras/src/dock/branch/tabs.rs +++ b/crates/egui_extras/src/dock/branch/tabs.rs @@ -88,11 +88,14 @@ impl Tabs { .rect_filled(ui.max_rect(), 0.0, behavior.tab_bar_color(ui.visuals())); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + // Add buttons such as "add new tab" behavior.top_bar_rtl_ui(ui, node_id); ui.spacing_mut().item_spacing.x = 0.0; // Tabs have spacing built-in ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| { + ui.set_clip_rect(ui.max_rect()); // Don't cover the `rtl_ui` buttons. + for (i, &child_id) in self.children.iter().enumerate() { let is_being_dragged = is_being_dragged(ui.ctx(), child_id); diff --git a/crates/egui_extras/src/dock/mod.rs b/crates/egui_extras/src/dock/mod.rs index ae748ab41..fbebd6684 100644 --- a/crates/egui_extras/src/dock/mod.rs +++ b/crates/egui_extras/src/dock/mod.rs @@ -42,10 +42,6 @@ // Everything is quite dynamic, so we have a bunch of defensive coding that call `warn!` on failure. // These situations should not happen in normal use, but could happen if the user messes with // the internals of the tree, putting it in an invalid state. -// -// ## TODO before release: -// * Auto-grid layouts (re-arange as parent is resized) -// * Clip tab titles to not cover "add new tab" button use egui::{Id, Pos2, Rect};