Function draw_tabs_bar

Source
pub fn draw_tabs_bar<T: TabsItem>(
    rect: Rect,
    tabs: &[T],
    can_create_path_tab: bool,
    style: TabsStyle,
    text: &mut TextSystem,
) -> (Vec<DrawCmd>, TabsLayout)
Expand description

Draws a tab bar with every optional affordance enabled.

This is equivalent to draw_tabs_bar_with_options with TabsBarOptions::default. It returns commands plus hit geometry and does not handle input. Only complete tabs with at least 120 logical pixels fit; visible tabs target 220 pixels and preserve input order.

ยงExamples

use ailloli_ui_core::Rect;
use ailloli_ui_text::TextSystem;
use ailloli_ui_widgets::controls::tabs::{draw_tabs_bar, TabsItem, TabsStyle};
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { true }
}
let mut text = TextSystem::new();
let (commands, layout) = draw_tabs_bar(
    Rect::new(0.0, 0.0, 400.0, 36.0), &[Tab], true, TabsStyle::default(), &mut text,
);
assert!(!commands.is_empty());
assert_eq!(layout.tab_rects.len(), 1);