Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,22 @@ impl egui_tiles::Behavior<Pane> for TreeBehavior {
_tabs: &egui_tiles::Tabs,
_scroll_offset: &mut f32,
) {
let _response = ui.small_button("⚙");
if ui.button("➕").clicked() {
self.add_child_to = Some(tile_id);
}
}

fn tab_bar_left_ui(
&mut self,
_tiles: &egui_tiles::Tiles<Pane>,
ui: &mut egui::Ui,
_tile_id: egui_tiles::TileId,
_tabs: &egui_tiles::Tabs,
) {
ui.label("☰");
}

// ---
// Settings:

Expand Down
18 changes: 18 additions & 0 deletions src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ pub trait Behavior<Pane> {
// }
}

/// Adds custom UI to the leftmost edge of each tab bar, pinned outside the
/// scrollable tab strip and to the LEFT of the left scroll-arrow.
///
/// Width consumed by widgets added here is automatically subtracted from
/// the area available to the scrollable tab strip — tabs shrink rather
/// than overlap. The slot does not move when tabs are scrolled.
///
/// To match the visual height of the scroll arrows, use
/// `ui.add_sized(egui::Vec2::splat(self.tab_bar_height(...)), widget)`.
fn tab_bar_left_ui(
&mut self,
_tiles: &Tiles<Pane>,
_ui: &mut Ui,
_tile_id: TileId,
_tabs: &crate::Tabs,
) {
}

/// The height of the bar holding tab titles.
fn tab_bar_height(&self, _style: &egui::Style) -> f32 {
24.0
Expand Down
10 changes: 10 additions & 0 deletions src/container/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,18 @@ impl Tabs {
ui.available_size(),
egui::Layout::left_to_right(egui::Align::Center),
|ui| {
// Left custom slot — first call in this LTR child layout
// means leftmost on screen, so it sits to the left of the
// left scroll-arrow.
behavior.tab_bar_left_ui(&tree.tiles, ui, tile_id, self);

scroll_state.left_arrow(ui, arrow_size);

// Clamp the precomputed width so it can't exceed what's
// left after the leading slot + left arrow consumed space
// inside this LTR child ui.
let scroll_area_width = scroll_area_width.min(ui.available_width()).max(0.0);

// Prepare to show the scroll area with the tabs:

scroll_state.offset = scroll_state
Expand Down
Loading