Browse Source

Make sure the tab buttons don't cover the RTL "add tab" buttons

emilk/dock
Emil Ernerfeldt 2 years ago
parent
commit
d4efb3215a
  1. 3
      crates/egui_extras/src/dock/branch/tabs.rs
  2. 4
      crates/egui_extras/src/dock/mod.rs

3
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);

4
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};

Loading…
Cancel
Save