pub struct Tabs<'a, Message, TabId, Theme = Theme, Renderer = Renderer>{ /* private fields */ }Expand description
A Tabs widget for showing a TabBar
along with the tab’s content.
§Example
#[derive(Debug, Clone)]
enum Message {
TabSelected(TabId),
}
#[derive(Debug, Clone)]
enum TabId {
One,
Two,
Three,
}
let tabs = Tabs::new(Message::TabSelected)
.push(TabId::One, TabLabel::Text(String::from("One")), Text::new(String::from("One")))
.push(TabId::Two, TabLabel::Text(String::from("Two")), Text::new(String::from("Two")))
.push(TabId::Three, TabLabel::Text(String::from("Three")), Text::new(String::from("Three")))
.set_active_tab(&TabId::Two);ThemeImplementations§
Source§impl<'a, Message, TabId, Theme, Renderer> Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> Tabs<'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 Tabs widget 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 new_with_tabs<F>(
tabs: impl IntoIterator<Item = (TabId, TabLabel, Element<'a, Message, Theme, Renderer>)>,
on_select: F,
) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
pub fn new_with_tabs<F>(
tabs: impl IntoIterator<Item = (TabId, TabLabel, Element<'a, Message, Theme, Renderer>)>,
on_select: F,
) -> Selfwhere
F: 'static + Fn(TabId) -> Message,
Similar to new but with a given Vector of the
TabLabel along with the tab’s content.
It expects:
* the index of the currently active tab.
* a vector containing the TabLabels along with the content
Elements of the Tabs.
* the function that will be called if a tab is selected by the user.
It takes the index of the selected tab.
Sourcepub fn close_size(self, close_size: f32) -> Self
pub fn close_size(self, close_size: f32) -> Self
Sourcepub fn tab_icon_position(self, position: Position) -> Self
pub fn tab_icon_position(self, position: Position) -> Self
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 set_active_tab(self, id: &TabId) -> Self
pub fn set_active_tab(self, id: &TabId) -> Self
Sets the active tab of the Tabs using the TabId.
Sourcepub fn tab_bar_height(self, height: Length) -> Self
pub fn tab_bar_height(self, height: Length) -> Self
Sourcepub fn tab_bar_max_height(self, max_height: f32) -> Self
pub fn tab_bar_max_height(self, max_height: f32) -> Self
Sourcepub fn tab_bar_width(self, width: Length) -> Self
pub fn tab_bar_width(self, width: Length) -> Self
Sourcepub fn tab_bar_position(self, position: TabBarPosition) -> Self
pub fn tab_bar_position(self, position: TabBarPosition) -> Self
Sets the TabBarPosition of the TabBar.
Sourcepub fn tab_bar_style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
pub fn tab_bar_style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
Sets the style of the TabBar.
Sourcepub fn tab_label_padding(self, padding: impl Into<Padding>) -> Self
pub fn tab_label_padding(self, padding: impl Into<Padding>) -> Self
Sets the padding of the tabs of the TabBar.
Sourcepub fn tab_label_spacing(self, spacing: impl Into<Pixels>) -> Self
pub fn tab_label_spacing(self, spacing: impl Into<Pixels>) -> Self
Sets the spacing between the tabs of the
TabBar.
Trait Implementations§
Source§impl<'a, Message, TabId, Theme, Renderer> From<Tabs<'a, Message, TabId, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> From<Tabs<'a, Message, TabId, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
Source§impl<Message, TabId, Theme, Renderer> Widget<Message, Theme, Renderer> for Tabs<'_, Message, TabId, Theme, Renderer>
impl<Message, TabId, Theme, Renderer> Widget<Message, Theme, Renderer> for Tabs<'_, 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.Source§fn overlay<'b>(
&'b mut self,
state: &'b mut Tree,
layout: Layout<'b>,
renderer: &Renderer,
viewport: &Rectangle,
translation: Vector,
) -> Option<Element<'b, Message, Theme, Renderer>>
fn overlay<'b>( &'b mut self, state: &'b mut Tree, layout: Layout<'b>, renderer: &Renderer, viewport: &Rectangle, translation: Vector, ) -> Option<Element<'b, Message, Theme, Renderer>>
Widget, if there is any.Auto Trait Implementations§
impl<'a, Message, TabId, Theme, Renderer> Freeze for Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !RefUnwindSafe for Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !Send for Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !Sync for Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme, Renderer> Unpin for Tabs<'a, Message, TabId, Theme, Renderer>
impl<'a, Message, TabId, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> !UnwindSafe for Tabs<'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