pub struct TabView { /* private fields */ }Expand description
The currently selected tab will have a highlighted background. All others will have the same background (which is usually darker).
Design:
[1] Tab│[2] Tab│[3] Tab│...
-------------
Tab 1 content
-------------
Implementations§
Source§impl TabView
impl TabView
pub const TAB_SEPERATOR: Grapheme
pub const BRACKET_OPEN: Grapheme
pub const BRACKET_CLOSE: Grapheme
pub const ANGLES_RIGHT: Grapheme
pub const ANGLES_LEFT: Grapheme
pub const MIN_TAB_WIDTH: TSize = 4
pub fn default_callback(&mut self)
pub fn default_key_handler(&mut self, event: &mut WindowEvent)
pub fn set_selection_changed_callback<F: Fn(&mut Self) + 'static>( &mut self, callback: F, )
pub fn set_key_handler(&mut self, f: TabViewKeyHandler)
Sourcepub fn select_tab(&mut self, tab: &Tab)
pub fn select_tab(&mut self, tab: &Tab)
Forcibly selects the given tab item
Sourcepub fn enable_tab_enumeration(&mut self)
pub fn enable_tab_enumeration(&mut self)
This will enumerate each tab depending on the order they are in Enumerated Tabs will start with (n), n ∈ ℕ
Examples found in repository?
examples/tabview.rs (line 44)
31 fn default() -> Self {
32 let label = WindowFactory::create::<Label>();
33 label.borrow_mut().set_text("Lorem ipsum");
34 let label2 = WindowFactory::create::<Label>();
35 label2.borrow_mut().set_text("Bibsum loram");
36 let label3 = WindowFactory::create::<Label>();
37 label3.borrow_mut().set_text("Epsum larel");
38 let label4 = WindowFactory::create::<Label>();
39 label4.borrow_mut().set_text("Ipsel Aarel");
40
41 let tabview = WindowFactory::create::<TabView>();
42 {
43 let mut brw = tabview.borrow_mut();
44 brw.enable_tab_enumeration();
45 brw.set_highlight_fg_color(Some(Color::Grey));
46 brw.set_highlight_bg_color(Some(Color::Blue));
47 brw.add_item(Tab::new("WIP Tab Number. 1", label));
48 brw.add_item(Tab::new("WIP Tab Number. 2", label2));
49 brw.add_item(Tab::new("WIP Tab Number. 3", label3));
50 brw.add_item(Tab::new("WIP Tab Number. 4", label4));
51 }
52
53 Self {
54 uid: WindowUID::new(),
55 tabview,
56 running: true,
57 }
58 }Sourcepub fn disable_tab_enumeration(&mut self)
pub fn disable_tab_enumeration(&mut self)
Disables the tab enumeration of all tabs
Sourcepub fn get_selection(&self) -> Option<&Tab>
pub fn get_selection(&self) -> Option<&Tab>
Returns the selected Tab
Sourcepub fn set_highlight_fg_color(&mut self, color: Option<Color>)
pub fn set_highlight_fg_color(&mut self, color: Option<Color>)
Sets the foreground for the highlighted tab
Examples found in repository?
examples/tabview.rs (line 45)
31 fn default() -> Self {
32 let label = WindowFactory::create::<Label>();
33 label.borrow_mut().set_text("Lorem ipsum");
34 let label2 = WindowFactory::create::<Label>();
35 label2.borrow_mut().set_text("Bibsum loram");
36 let label3 = WindowFactory::create::<Label>();
37 label3.borrow_mut().set_text("Epsum larel");
38 let label4 = WindowFactory::create::<Label>();
39 label4.borrow_mut().set_text("Ipsel Aarel");
40
41 let tabview = WindowFactory::create::<TabView>();
42 {
43 let mut brw = tabview.borrow_mut();
44 brw.enable_tab_enumeration();
45 brw.set_highlight_fg_color(Some(Color::Grey));
46 brw.set_highlight_bg_color(Some(Color::Blue));
47 brw.add_item(Tab::new("WIP Tab Number. 1", label));
48 brw.add_item(Tab::new("WIP Tab Number. 2", label2));
49 brw.add_item(Tab::new("WIP Tab Number. 3", label3));
50 brw.add_item(Tab::new("WIP Tab Number. 4", label4));
51 }
52
53 Self {
54 uid: WindowUID::new(),
55 tabview,
56 running: true,
57 }
58 }Sourcepub fn set_highlight_bg_color(&mut self, color: Option<Color>)
pub fn set_highlight_bg_color(&mut self, color: Option<Color>)
Sets the background for the highlighted tab
Examples found in repository?
examples/tabview.rs (line 46)
31 fn default() -> Self {
32 let label = WindowFactory::create::<Label>();
33 label.borrow_mut().set_text("Lorem ipsum");
34 let label2 = WindowFactory::create::<Label>();
35 label2.borrow_mut().set_text("Bibsum loram");
36 let label3 = WindowFactory::create::<Label>();
37 label3.borrow_mut().set_text("Epsum larel");
38 let label4 = WindowFactory::create::<Label>();
39 label4.borrow_mut().set_text("Ipsel Aarel");
40
41 let tabview = WindowFactory::create::<TabView>();
42 {
43 let mut brw = tabview.borrow_mut();
44 brw.enable_tab_enumeration();
45 brw.set_highlight_fg_color(Some(Color::Grey));
46 brw.set_highlight_bg_color(Some(Color::Blue));
47 brw.add_item(Tab::new("WIP Tab Number. 1", label));
48 brw.add_item(Tab::new("WIP Tab Number. 2", label2));
49 brw.add_item(Tab::new("WIP Tab Number. 3", label3));
50 brw.add_item(Tab::new("WIP Tab Number. 4", label4));
51 }
52
53 Self {
54 uid: WindowUID::new(),
55 tabview,
56 running: true,
57 }
58 }pub fn select_next(&mut self)
pub fn select_previous(&mut self)
Trait Implementations§
Source§impl HasWindowUID for TabView
impl HasWindowUID for TabView
Source§impl ItemCollection<Tab> for TabView
impl ItemCollection<Tab> for TabView
Source§fn remove_item(&mut self, item: &Tab)
fn remove_item(&mut self, item: &Tab)
Removes an item from the underlying collection
Source§fn remove_at(&mut self, index: Self::Index) -> Tab
fn remove_at(&mut self, index: Self::Index) -> Tab
Removes an item at the given index from the underlying collection
Might panic if index is invalid
Source§fn get_item(&mut self, index: Self::Index) -> Option<&Tab>
fn get_item(&mut self, index: Self::Index) -> Option<&Tab>
Returns an item from the collection by its index
Source§fn clear_items(&mut self)
fn clear_items(&mut self)
Clears all items in the underlying collection
Source§impl Widget for TabView
impl Widget for TabView
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
fn set_visibility(&mut self, visibility: bool)
fn set_width(&mut self, width: Size)
fn set_height(&mut self, height: Size)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
fn set_width_constraint(&mut self, width: SizeConstraint)
fn set_height_constraint(&mut self, height: SizeConstraint)
Source§impl WidgetColors for TabView
impl WidgetColors for TabView
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for TabView
impl Window for TabView
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§impl WindowLayout for TabView
impl WindowLayout for TabView
fn border(&self) -> BorderStyle
Source§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn is_visible(&self) -> bool
fn margin(&self) -> Thickness
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnAuto Trait Implementations§
impl !RefUnwindSafe for TabView
impl !Send for TabView
impl !Sync for TabView
impl !UnwindSafe for TabView
impl Freeze for TabView
impl Unpin for TabView
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property