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: StyleOverall widget background style (Part::MAIN).
tab_color: ColorBackground color for inactive tab buttons (Part::ITEMS).
active_tab_color: ColorBackground color for the active tab button (Part::SELECTED).
tab_text_color: ColorText color for inactive tabs.
active_tab_text_color: ColorText color for the active tab.
Implementations§
Source§impl Tabview
impl Tabview
Sourcepub fn new(bounds: Rect, bar_pos: TabBarPos) -> Self
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.
Sourcepub fn set_font(&mut self, font: &'static dyn FontMetrics)
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.
Sourcepub fn add_tab(&mut self, name: &str) -> TabId
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.
Sourcepub fn rename_tab(&mut self, id: TabId, name: &str)
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.
Sourcepub fn set_active(&mut self, id: TabId)
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.
Sourcepub fn active_tab(&self) -> TabId
pub fn active_tab(&self) -> TabId
Sourcepub fn tab_content_bounds(&self, id: TabId) -> Rect
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.
Sourcepub fn set_bar_pos(&mut self, pos: TabBarPos)
pub fn set_bar_pos(&mut self, pos: TabBarPos)
Set the tab bar position and recompute internal geometry.
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.
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.