use egui::Ui;
use crate::Icons;
use crate::tabs::show_tab_strip;
pub use crate::tabs::{TabEvent, TabIcon, TabItem};
pub struct TabStrip<'a> {
tabs: &'a [TabItem<'a>],
active: usize,
close_tooltip: &'a str,
controls_width: f32,
}
impl<'a> TabStrip<'a> {
pub fn new(tabs: &'a [TabItem<'a>], active: usize) -> Self {
Self {
tabs,
active,
close_tooltip: "Close",
controls_width: 276.0,
}
}
pub fn close_tooltip(mut self, tooltip: &'a str) -> Self {
self.close_tooltip = tooltip;
self
}
pub fn controls_width(mut self, width: f32) -> Self {
self.controls_width = width;
self
}
pub fn show(self, ui: &mut Ui, icons: &mut Icons, controls: impl FnOnce(&mut Ui, &mut Icons)) -> Option<TabEvent> {
show_tab_strip(
ui,
icons,
self.tabs,
self.active,
self.close_tooltip,
self.controls_width,
controls,
)
}
}