[][src]Struct cursive_tabs::TabPanel

pub struct TabPanel<K: Hash + Eq + Display + Copy + 'static> { /* fields omitted */ }

The TabPanel is an ease of use wrapper around a TabView and its TabBar. Additionally the TabBar in the Panel can be horizontally aligned, by default it is set to be left aligned.

Example

use cursive_tabs::{Align, TabPanel};
use cursive::views::TextView;

let mut tabs = TabPanel::new()
      .with_tab("First", TextView::new("First"))
      .with_tab("Second", TextView::new("Second"))
      .with_bar_alignment(Align::Center);

A TabView is also usable separately, so if you prefer the tabs without the TabBar and Panel around have a look at TabView.

Methods

impl<K: Hash + Eq + Copy + Display + 'static> TabPanel<K>[src]

pub fn new() -> Self[src]

Returns a new instance of a TabPanel. Alignment is set by default to left, to change this use set_bar_alignment to change to any other HAlign provided by cursive.

pub fn active_tab(&self) -> Option<K>[src]

Returns the current active tab of the TabView. Note: Calls active_tab on the enclosed TabView.

pub fn set_active_tab(&mut self, id: K) -> Result<(), ()>[src]

Non-consuming variant to set the active tab in the TabView. Note: Calls set_active_tab on the enclosed TabView.

pub fn with_active_tab(self, id: K) -> Result<Self, ()>[src]

Consuming & Chainable variant to set the active tab in the TabView. Note: Calls set_active_tab on the enclosed TabView.

Be careful! Failure in this case means the panel get dropped this has to with some trait restrictions in cursive, at the moment just avoid using the chainable variant if you are unsure that the operation will succeed.

pub fn add_tab<T: View>(&mut self, id: K, view: T)[src]

Non-consuming variant to add new tabs to the TabView. Note: Calls add_tab on the enclosed TabView.

pub fn with_tab<T: View>(self, id: K, view: T) -> Self[src]

Consuming & Chainable variant to add a new tab. Note: Calls add_tab on the enclosed TabView.

pub fn swap_tabs(&mut self, fst: K, snd: K)[src]

Swaps the given tab keys. If at least one of them cannot be found then no operation is performed

pub fn add_tab_at<T: View>(&mut self, id: K, view: T, pos: usize)[src]

Non-consuming variant to add new tabs to the TabView at a certain position. It is fail-safe, if the postion is greater than the amount of tabs, it is appended to the end. Note: Calls add_tab_at on the enclosed TabView.

pub fn with_tab_at<T: View>(self, id: K, view: T, pos: usize) -> Self[src]

Consuming & Chainable variant to add a new tab at a certain position. It is fail-safe, if the postion is greater than the amount of tabs, it is appended to the end. Note: Calls add_tab_at on the enclosed TabView.

pub fn remove_tab(&mut self, id: K) -> Result<(), ()>[src]

Remove a tab of the enclosed TabView.

pub fn next(&mut self)[src]

Proceeds to the next view in order of addition.

pub fn prev(&mut self)[src]

Go back to the previous view in order of addition.

pub fn with_bar_alignment(self, align: Align) -> Self[src]

Consumable & Chainable variant to set the bar alignment.

pub fn set_bar_alignment(&mut self, align: Align)[src]

Non-consuming variant to set the bar alignment.

pub fn with_bar_placement(self, placement: Placement) -> Self[src]

pub fn set_bar_placement(&mut self, placement: Placement)[src]

pub fn tab_order(&self) -> Vec<K>[src]

Returns the current order of tabs as an Vector with the keys of the views.

Trait Implementations

impl<K: Hash + Eq + Copy + Display + 'static> View for TabPanel<K>[src]

Auto Trait Implementations

impl<K> !RefUnwindSafe for TabPanel<K>

impl<K> !Send for TabPanel<K>

impl<K> !Sync for TabPanel<K>

impl<K> Unpin for TabPanel<K> where
    K: Unpin

impl<K> !UnwindSafe for TabPanel<K>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyView for T where
    T: View
[src]

fn as_any(&self) -> &(dyn Any + 'static)[src]

Downcast self to a Any.

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

Downcast self to a mutable Any.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Boxable for T where
    T: View
[src]

impl<T> Erased for T

impl<T> Finder for T where
    T: View
[src]

impl<T> From<T> for T[src]

impl<T> Identifiable for T where
    T: View
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoBoxedView for T where
    T: View
[src]

impl<T> Scrollable for T where
    T: View
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> View for T where
    T: ViewWrapper
[src]

impl<T> With for T[src]