pub struct TabBar<'a, Message, TabId, Theme = Theme, Renderer = Renderer>{ /* private fields */ }Expand description
A tab bar to show tabs.
§Example
#[derive(Debug, Clone)]
enum Message {
TabSelected(TabId),
}
#[derive(PartialEq, Hash)]
enum TabId {
One,
Two,
Three,
}
let tab_bar = TabBar::new(
Message::TabSelected,
)
.push(TabId::One, TabLabel::Text(String::from("One")))
.push(TabId::Two, TabLabel::Text(String::from("Two")))
.push(TabId::Three, TabLabel::Text(String::from("Three")))
.set_active_tab(&TabId::One);Implementations§
Source§impl<'a, Message, TabId, Theme, Renderer> TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> TabBar<'a, Message, TabId, Theme, Renderer>
Sourcepub fn new<F>(on_select: F) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
pub fn new<F>(on_select: F) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
Creates a new TabBar with the index of the selected tab and a specified
message which will be send when a tab is selected by the user.
It expects: * the index of the currently active tab. * the function that will be called if a tab is selected by the user. It takes the index of the selected tab.
Sourcepub fn with_tab_labels<F>(
tab_labels: Vec<(TabId, TabLabel)>,
on_select: F,
) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
pub fn with_tab_labels<F>(
tab_labels: Vec<(TabId, TabLabel)>,
on_select: F,
) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
Sourcepub fn close_size(self, close_size: f32) -> Self
pub fn close_size(self, close_size: f32) -> Self
Sourcepub fn get_active_tab_id(&self) -> Option<&TabId>
pub fn get_active_tab_id(&self) -> Option<&TabId>
Gets the id of the currently active tab on the TabBar.
Sourcepub fn get_active_tab_idx(&self) -> usize
pub fn get_active_tab_idx(&self) -> usize
Gets the index of the currently active tab on the TabBar.
Sourcepub fn get_height(&self) -> Length
pub fn get_height(&self) -> Length
Gets the width of the TabBar.
Sourcepub fn max_height(self, max_height: f32) -> Self
pub fn max_height(self, max_height: f32) -> Self
Sets the maximum height of the TabBar.
Sourcepub fn on_close<F>(self, on_close: F) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
pub fn on_close<F>(self, on_close: F) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
Sets the message that will be produced when the close icon of a tab
on the TabBar is pressed.
Setting this enables the drawing of a close icon on the tabs.
Sourcepub fn padding(self, padding: impl Into<Padding>) -> Self
pub fn padding(self, padding: impl Into<Padding>) -> Self
Sets the padding of the tabs of the TabBar.
Sourcepub fn spacing(self, spacing: impl Into<Pixels>) -> Self
pub fn spacing(self, spacing: impl Into<Pixels>) -> Self
Sets the spacing between the tabs of the TabBar.
Sourcepub fn set_active_tab(self, active_tab: &TabId) -> Self
pub fn set_active_tab(self, active_tab: &TabId) -> Self
Sets up the active tab on the TabBar.
Sourcepub fn set_position(self, position: Position) -> Self
pub fn set_position(self, position: Position) -> Self
Sets the Position of the Icon next to Text, Only used in TabLabel::IconText
Sourcepub fn style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
pub fn style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
Sets the style of the TabBar.
Trait Implementations§
Source§impl<'a, Message, TabId, Theme, Renderer> From<TabBar<'a, Message, TabId, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> From<TabBar<'a, Message, TabId, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
Source§impl<Message, TabId, Theme, Renderer> Widget<Message, Theme, Renderer> for TabBar<'_, Message, TabId, Theme, Renderer>
impl<Message, TabId, Theme, Renderer> Widget<Message, Theme, Renderer> for TabBar<'_, Message, TabId, Theme, Renderer>
Source§fn update(
&mut self,
_state: &mut Tree,
event: &Event,
layout: Layout<'_>,
cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, _state: &mut Tree, event: &Event, layout: Layout<'_>, cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
Source§fn mouse_interaction(
&self,
_state: &Tree,
layout: Layout<'_>,
cursor: Cursor,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, _state: &Tree, layout: Layout<'_>, cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction
Source§fn draw(
&self,
_state: &Tree,
renderer: &mut Renderer,
theme: &Theme,
_style: &Style,
layout: Layout<'_>,
cursor: Cursor,
viewport: &Rectangle,
)
fn draw( &self, _state: &Tree, renderer: &mut Renderer, theme: &Theme, _style: &Style, layout: Layout<'_>, cursor: Cursor, viewport: &Rectangle, )
Widget using the associated Renderer.Auto Trait Implementations§
impl<'a, Message, TabId, Theme, Renderer> Freeze for TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !RefUnwindSafe for TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !Send for TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !Sync for TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> Unpin for TabBar<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !UnwindSafe for TabBar<'a, Message, TabId, Theme, Renderer>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more