pub struct BrowserTabs { /* private fields */ }Expand description
A horizontal strip of browser-style closable tabs.
See the module-level docs for an example.
Implementations§
Source§impl BrowserTabs
impl BrowserTabs
Sourcepub fn new(id_salt: impl Hash) -> Self
pub fn new(id_salt: impl Hash) -> Self
Create an empty strip. id_salt scopes the widget’s interaction
state in egui memory; two BrowserTabs strips on the same page
need distinct salts.
Sourcepub fn with_tab(self, tab: BrowserTab) -> Self
pub fn with_tab(self, tab: BrowserTab) -> Self
Push a tab at construction time (builder form).
Whether to show the trailing “+” button. Default: true.
Sourcepub fn min_tab_width(self, w: f32) -> Self
pub fn min_tab_width(self, w: f32) -> Self
Minimum width for a single tab in points. Default: 120.0.
Sourcepub fn max_tab_width(self, w: f32) -> Self
pub fn max_tab_width(self, w: f32) -> Self
Maximum width for a single tab in points. Default: 220.0.
Sourcepub fn add_tab(&mut self, tab: BrowserTab)
pub fn add_tab(&mut self, tab: BrowserTab)
Append a tab. If no tab is currently selected, the new tab becomes
the active one. Subsequent calls don’t change the active tab unless
the caller invokes Self::set_selected.
Sourcepub fn remove_tab(&mut self, id: &str) -> bool
pub fn remove_tab(&mut self, id: &str) -> bool
Remove a tab by id. If the removed tab was active, selection moves
to the next tab (or the previous one if it was the last). Returns
true if a tab was actually removed.
Sourcepub fn set_selected(&mut self, id: impl Into<String>)
pub fn set_selected(&mut self, id: impl Into<String>)
Set the active tab. No-op if no tab with that id exists.
Sourcepub fn tabs(&self) -> &[BrowserTab]
pub fn tabs(&self) -> &[BrowserTab]
Borrow the underlying tab list.
Sourcepub fn tab(&self, id: &str) -> Option<&BrowserTab>
pub fn tab(&self, id: &str) -> Option<&BrowserTab>
Find a tab by id.
Sourcepub fn tab_mut(&mut self, id: &str) -> Option<&mut BrowserTab>
pub fn tab_mut(&mut self, id: &str) -> Option<&mut BrowserTab>
Find a tab by id (mutably) so the caller can flip dirty or rename it.
Sourcepub fn take_events(&mut self) -> Vec<BrowserTabsEvent>
pub fn take_events(&mut self) -> Vec<BrowserTabsEvent>
Drain events queued since the last call. Returns events in the order they were emitted.