pub struct TabView { /* private fields */ }Expand description
Main struct which manages views
Implementations§
Source§impl TabView
impl TabView
Sourcepub fn active_tab(&self) -> Option<&str>
pub fn active_tab(&self) -> Option<&str>
Returns the currently active tab Id.
Sourcepub fn active_view(&self) -> Option<&dyn View>
pub fn active_view(&self) -> Option<&dyn View>
Returns a reference to the underlying view.
Sourcepub fn active_view_mut(&mut self) -> Option<&mut dyn View>
pub fn active_view_mut(&mut self) -> Option<&mut dyn View>
Returns a mutable reference to the underlying view.
pub fn views(&self) -> Vec<&dyn View>
pub fn views_mut(&mut self) -> Vec<&mut dyn View>
Sourcepub fn set_active_tab(&mut self, id: &str) -> Result<(), IdNotFound>
pub fn set_active_tab(&mut self, id: &str) -> Result<(), IdNotFound>
Set the currently active (visible) tab. If the tab id is not known, an error is returned and no action is performed.
Sourcepub fn with_active_tab(self, id: &str) -> Result<Self, Self>
pub fn with_active_tab(self, id: &str) -> Result<Self, Self>
Set the currently active (visible) tab. If the tab id is not known, an error is returned and no action is performed.
This is the consumable variant.
Sourcepub fn add_tab<T: View>(&mut self, view: NamedView<T>)
pub fn add_tab<T: View>(&mut self, view: NamedView<T>)
Add a new tab to the tab view. The new tab will be set active and will be the visible tab for this tab view.
Sourcepub fn with_tab<T: View>(self, view: NamedView<T>) -> Self
pub fn with_tab<T: View>(self, view: NamedView<T>) -> Self
Add a new tab to the tab view. The new tab will be set active and will be the visible tab for this tab view.
This is the consumable variant.
Sourcepub fn add_tab_at<T: View>(&mut self, view: NamedView<T>, pos: usize)
pub fn add_tab_at<T: View>(&mut self, view: NamedView<T>, pos: usize)
Add a new tab at a given position. The new tab will be set active and will be the visible tab for this tab view.
This is designed to not fail, if the given position is greater than the number of current tabs, it simply will be appended.
Sourcepub fn with_tab_at<T: View>(self, view: NamedView<T>, pos: usize) -> Self
pub fn with_tab_at<T: View>(self, view: NamedView<T>, pos: usize) -> Self
Add a new tab at a given position. The new tab will be set active and will be the visible tab for this tab view.
It is designed to be fail-safe, if the given position is greater than the number of current tabs, it simply will be appended.
This is the consumable variant.
Sourcepub fn swap_tabs(&mut self, fst: &str, snd: &str)
pub fn swap_tabs(&mut self, fst: &str, snd: &str)
Swap the tabs position. If one of the given key cannot be found, then no operation is performed.
Sourcepub fn remove_tab(&mut self, id: &str) -> Result<(), IdNotFound>
pub fn remove_tab(&mut self, id: &str) -> Result<(), IdNotFound>
Removes a tab with the given id from the TabView.
If the removed tab is active at the moment, the TabView will unfocus it and
the focus needs to be set manually afterwards, or a new view has to be inserted.
Sourcepub fn tab_order(&self) -> Vec<String>
pub fn tab_order(&self) -> Vec<String>
Returns the current order of keys in a vector. When you’re implementing your own tab bar, be aware that this is the current tab bar and is only a copy of the original order, modification will not be transferred and future updates in the original not displayed.
Sourcepub fn set_bar_rx(&mut self, rx: Receiver<String>)
pub fn set_bar_rx(&mut self, rx: Receiver<String>)
Set the receiver for keys to be changed to
Sourcepub fn set_active_key_tx(&mut self, tx: Sender<String>)
pub fn set_active_key_tx(&mut self, tx: Sender<String>)
Set the sender for the key switched to
Trait Implementations§
Source§impl View for TabView
impl View for TabView
Source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
Source§fn layout(&mut self, size: Vec2)
fn layout(&mut self, size: Vec2)
Source§fn required_size(&mut self, req: Vec2) -> Vec2
fn required_size(&mut self, req: Vec2) -> Vec2
Source§fn on_event(&mut self, evt: Event) -> EventResult
fn on_event(&mut self, evt: Event) -> EventResult
Source§fn take_focus(&mut self, src: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, src: Direction) -> Result<EventResult, CannotFocus>
Source§fn call_on_any<'a>(&mut self, slt: &Selector<'_>, cb: AnyCb<'a>)
fn call_on_any<'a>(&mut self, slt: &Selector<'_>, cb: AnyCb<'a>)
Source§fn focus_view(
&mut self,
slt: &Selector<'_>,
) -> Result<EventResult, ViewNotFound>
fn focus_view( &mut self, slt: &Selector<'_>, ) -> Result<EventResult, ViewNotFound>
Source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
Auto Trait Implementations§
impl Freeze for TabView
impl !RefUnwindSafe for TabView
impl Send for TabView
impl Sync for TabView
impl Unpin for TabView
impl !UnwindSafe for TabView
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> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on with a view::Selector::Name.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self in a ResizedView with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self into a fixed-size ResizedView.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self into a full-screen ResizedView.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self into a full-width ResizedView.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self into a full-height ResizedView.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self into a limited-size ResizedView.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self into a limited-width ResizedView.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self into a limited-height ResizedView.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self into a ResizedView at least sized size.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self in a ResizedView at least min_width wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self in a ResizedView at least min_height tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self in a ScrollView.