Skip to main content

BrowserTabs

Struct BrowserTabs 

Source
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

Source

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.

Source

pub fn with_tab(self, tab: BrowserTab) -> Self

Push a tab at construction time (builder form).

Source

pub fn show_new_button(self, show: bool) -> Self

Whether to show the trailing “+” button. Default: true.

Source

pub fn min_tab_width(self, w: f32) -> Self

Minimum width for a single tab in points. Default: 120.0.

Source

pub fn max_tab_width(self, w: f32) -> Self

Maximum width for a single tab in points. Default: 220.0.

Source

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.

Source

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.

Source

pub fn selected(&self) -> Option<&str>

Currently active tab id, if any.

Source

pub fn set_selected(&mut self, id: impl Into<String>)

Set the active tab. No-op if no tab with that id exists.

Source

pub fn tabs(&self) -> &[BrowserTab]

Borrow the underlying tab list.

Source

pub fn tab(&self, id: &str) -> Option<&BrowserTab>

Find a tab by id.

Source

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.

Source

pub fn take_events(&mut self) -> Vec<BrowserTabsEvent>

Drain events queued since the last call. Returns events in the order they were emitted.

Source

pub fn show(&mut self, ui: &mut Ui) -> Response

Render the strip. Call once per frame.

Trait Implementations§

Source§

impl Debug for BrowserTabs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BrowserTabs

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.