Skip to main content

Tabview

Struct Tabview 

Source
pub struct Tabview {
    pub style: Style,
    pub tab_color: Color,
    pub active_tab_color: Color,
    pub tab_text_color: Color,
    pub active_tab_text_color: Color,
    /* private fields */
}
Expand description

Tab bar + content-pane navigation widget.

Create with Tabview::new, add tabs with Tabview::add_tab, and switch the active tab with Tabview::set_active or the navigation helpers.

Fields§

§style: Style

Overall widget background style (Part::MAIN).

§tab_color: Color

Background color for inactive tab buttons (Part::ITEMS).

§active_tab_color: Color

Background color for the active tab button (Part::SELECTED).

§tab_text_color: Color

Text color for inactive tabs.

§active_tab_text_color: Color

Text color for the active tab.

Implementations§

Source§

impl Tabview

Source

pub const TAB_NONE: TabId

Sentinel TabId meaning “no tab selected / invalid”.

Source

pub fn new(bounds: Rect, bar_pos: TabBarPos) -> Self

Create a new tabview with the given bounds and tab bar position.

The tab bar uses the default thickness of 24 pixels. Adjust with set_bar_pos and set_bounds.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn add_tab(&mut self, name: &str) -> TabId

Append a tab with the given name and return its TabId.

If this is the first tab, it becomes the active tab automatically.

Source

pub fn rename_tab(&mut self, id: TabId, name: &str)

Rename the tab with the given id.

No-op if the id is out of range or TAB_NONE.

Source

pub fn set_active(&mut self, id: TabId)

Make the tab with the given id the active one.

No-op if the id is out of range or TAB_NONE.

Source

pub fn active_tab(&self) -> TabId

Return the TabId of the currently active tab, or TAB_NONE.

Source

pub fn tab_count(&self) -> usize

Return the number of registered tabs.

Source

pub fn tab_content_bounds(&self, id: TabId) -> Rect

Return the content-area rect for the given tab id.

All tabs share the same content-area geometry (the bounding rect minus the tab bar). Returns a zero-area rect if id is out of range.

Source

pub fn bar_pos(&self) -> TabBarPos

Return the tab bar position.

Source

pub fn set_bar_pos(&mut self, pos: TabBarPos)

Set the tab bar position and recompute internal geometry.

Source

pub fn navigate_next_tab(&mut self)

Advance to the next tab, wrapping from the last back to the first.

No-op when there are fewer than two tabs.

Wire to ObjectEvent::Key(Key::ArrowRight) or Key::Tab from the application handler.

Source

pub fn navigate_prev_tab(&mut self)

Move to the previous tab, wrapping from the first back to the last.

No-op when there are fewer than two tabs.

Wire to ObjectEvent::Key(Key::ArrowLeft) from the application handler.

Trait Implementations§

Source§

impl Widget for Tabview

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, _event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.