pub struct TabStack<W: Widget> { /* private fields */ }
Expand description
A tabbed stack of widgets
A stack consists a set of child widgets, “pages”, all of equal size.
Only a single page is visible at a time. The page is “turned” via tab
handles or calling Self::set_active
.
Type parameter D
controls the position of tabs relative to the stack;
default value is Direction::Up
: tabs are positioned above the stack.
Within the bar, items are always left-to-right
(TODO: support for vertical bars).
This may only be parametrised with a single widget type, thus usually
it will be necessary to box children (this is what BoxTabStack
is).
See also the main implementing widget: Stack
.
Implementations§
Source§impl<W: Widget> TabStack<W>
impl<W: Widget> TabStack<W>
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new, empty instance
See also TabStack::from
.
Sourcepub fn set_direction(&mut self, direction: Direction) -> Action
pub fn set_direction(&mut self, direction: Direction) -> Action
Set the position of tabs relative to content
Default value: Direction::Up
Source§impl<W: Widget> TabStack<W>
impl<W: Widget> TabStack<W>
Sourcepub fn set_size_limit(&mut self, limit: usize)
pub fn set_size_limit(&mut self, limit: usize)
Limit the number of pages considered and sized
By default, this is usize::MAX
: all pages are configured and affect
the stack’s size requirements.
Set this to 0 to avoid configuring all hidden pages.
Set this to n
to configure the active page and the first n
pages.
Sourcepub fn with_size_limit(self, limit: usize) -> Self
pub fn with_size_limit(self, limit: usize) -> Self
Limit the number of pages configured and sized (inline)
By default, this is usize::MAX
: all pages are configured and affect
the stack’s size requirements.
Set this to 0 to avoid configuring all hidden pages.
Set this to n
to configure the active page and the first n
pages.
Sourcepub fn with_active(self, active: usize) -> Self
pub fn with_active(self, active: usize) -> Self
Set the active page (inline)
Unlike Self::set_active
, this does not update anything; it is
assumed that sizing happens afterwards.
Sourcepub fn set_active(
&mut self,
cx: &mut ConfigCx<'_>,
data: &W::Data,
index: usize,
)
pub fn set_active( &mut self, cx: &mut ConfigCx<'_>, data: &W::Data, index: usize, )
Set the active page
Sourcepub fn get_active(&self) -> Option<&W>
pub fn get_active(&self) -> Option<&W>
Get a direct reference to the active child widget, if any
Sourcepub fn get_tab_mut(&mut self, index: usize) -> Option<&mut Tab>
pub fn get_tab_mut(&mut self, index: usize) -> Option<&mut Tab>
Get a tab
Sourcepub fn push(
&mut self,
cx: &mut ConfigCx<'_>,
data: &W::Data,
tab: Tab,
widget: W,
) -> usize
pub fn push( &mut self, cx: &mut ConfigCx<'_>, data: &W::Data, tab: Tab, widget: W, ) -> usize
Append a page
The new page is not made active (the active index may be changed to
avoid this). Consider calling Self::set_active
.
Returns the new page’s index.
Sourcepub fn pop(&mut self, cx: &mut EventState) -> Option<(Tab, W)>
pub fn pop(&mut self, cx: &mut EventState) -> Option<(Tab, W)>
Remove the last child widget (if any) and return
If this page was active then no page will be left active.
Consider also calling Self::set_active
.
Sourcepub fn insert(
&mut self,
cx: &mut ConfigCx<'_>,
data: &W::Data,
index: usize,
tab: Tab,
widget: W,
)
pub fn insert( &mut self, cx: &mut ConfigCx<'_>, data: &W::Data, index: usize, tab: Tab, widget: W, )
Inserts a child widget position index
Panics if index > len
.
The active page does not change (the index of the active page may change instead).
Sourcepub fn remove(&mut self, cx: &mut EventState, index: usize) -> (Tab, W)
pub fn remove(&mut self, cx: &mut EventState, index: usize) -> (Tab, W)
Removes the child widget at position index
Panics if index
is out of bounds.
If this page was active then no page will be left active.
Consider also calling Self::set_active
.
Sourcepub fn replace(
&mut self,
cx: &mut ConfigCx<'_>,
data: &W::Data,
index: usize,
w: W,
) -> W
pub fn replace( &mut self, cx: &mut ConfigCx<'_>, data: &W::Data, index: usize, w: W, ) -> W
Replace the child at index
Panics if index
is out of bounds.
If the new child replaces the active page then Action::RESIZE
is triggered.
Sourcepub fn extend<T: IntoIterator<Item = (Tab, W)>>(
&mut self,
cx: &mut ConfigCx<'_>,
data: &W::Data,
iter: T,
)
pub fn extend<T: IntoIterator<Item = (Tab, W)>>( &mut self, cx: &mut ConfigCx<'_>, data: &W::Data, iter: T, )
Append child widgets from an iterator
The new pages are not made active (the active index may be changed to
avoid this). Consider calling Self::set_active
.
Trait Implementations§
Source§impl<W: Widget> Events for TabStack<W>
impl<W: Widget> Events for TabStack<W>
Source§fn handle_messages(&mut self, cx: &mut EventCx<'_>, data: &W::Data)
fn handle_messages(&mut self, cx: &mut EventCx<'_>, data: &W::Data)
Source§fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§impl<W: Widget> Layout for TabStack<W>
impl<W: Widget> Layout for TabStack<W>
Source§fn widget_name(&self) -> &'static str
fn widget_name(&self) -> &'static str
Source§fn num_children(&self) -> usize
fn num_children(&self) -> usize
Source§fn get_child(&self, index: usize) -> Option<&dyn Layout>
fn get_child(&self, index: usize) -> Option<&dyn Layout>
dyn Layout
Read moreSource§fn size_rules(&mut self, sizer: SizeCx<'_>, axis: AxisInfo) -> SizeRules
fn size_rules(&mut self, sizer: SizeCx<'_>, axis: AxisInfo) -> SizeRules
Source§fn set_rect(&mut self, cx: &mut ConfigCx<'_>, rect: Rect, hints: AlignHints)
fn set_rect(&mut self, cx: &mut ConfigCx<'_>, rect: Rect, hints: AlignHints)
Source§fn find_child_index(&self, id: &Id) -> Option<usize>
fn find_child_index(&self, id: &Id) -> Option<usize>
id
, if any Read moreSource§fn translation(&self) -> Offset
fn translation(&self) -> Offset
Source§impl<W: Widget> LayoutVisitor for TabStack<W>
impl<W: Widget> LayoutVisitor for TabStack<W>
Auto Trait Implementations§
impl<W> Freeze for TabStack<W>
impl<W> !RefUnwindSafe for TabStack<W>
impl<W> !Send for TabStack<W>
impl<W> !Sync for TabStack<W>
impl<W> Unpin for TabStack<W>where
W: Unpin,
impl<W> !UnwindSafe for TabStack<W>
Blanket Implementations§
Source§impl<W> AdaptWidget for Wwhere
W: Widget,
impl<W> AdaptWidget for Wwhere
W: Widget,
Source§fn pack(self, hints: AlignHints) -> Pack<Self>
fn pack(self, hints: AlignHints) -> Pack<Self>
Source§fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self>
fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self>
Source§fn on_configure<F>(self, f: F) -> AdaptEvents<Self>where
F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static,
fn on_configure<F>(self, f: F) -> AdaptEvents<Self>where
F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static,
Events::configure
Read moreSource§fn on_update<F>(self, f: F) -> AdaptEvents<Self>
fn on_update<F>(self, f: F) -> AdaptEvents<Self>
Events::update
Read moreSource§fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self>
fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self>
M
Read moreSource§fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self>
fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self>
Source§fn on_messages<H>(self, handler: H) -> AdaptEvents<Self>
fn on_messages<H>(self, handler: H) -> AdaptEvents<Self>
Source§fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self>
fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self>
Source§fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self>
fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self>
Source§fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D>
fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D>
Source§impl<W> AdaptWidgetAny for W
impl<W> AdaptWidgetAny for W
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<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> 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<W> LayoutExt for W
impl<W> LayoutExt for W
Source§fn identify(&self) -> IdentifyWidget<'_>
fn identify(&self) -> IdentifyWidget<'_>
Source§fn is_strict_ancestor_of(&self, id: &Id) -> bool
fn is_strict_ancestor_of(&self, id: &Id) -> bool
id
is not self and is a descendant Read more