pub struct Tabs<T: 'static> { /* private fields */ }Expand description
Pages, one shown at a time, with a tab for each to pick it: the platform’s own tab view (an NSTabView on macOS, a notebook on GTK, a selector bar over its pages on Windows, a tab bar on KDE). It’s for a fixed set of views, as in a settings window, not documents the user opens and closes.
Its pages are Tabs. selection holds the value of the page shown,
and picking a tab sets it; a value no tab has shows the first, as every
platform’s tab view shows one. Every page stays built while it’s
hidden, so what’s in it (a half-typed field, a scroll position) is
still there when it’s picked again. The view is as big as its biggest
page, and the platform’s tab strip and border are added to it; put
padding on the pages.
let page = signal(Page::General);
Tabs::new(page).children((
Tab::new("General", Page::General).padding(16).children((/* … */)),
Tab::new("Advanced", Page::Advanced).padding(16).children((/* … */)),
))In view!: <Tabs selection=page>, with
<Tab title="General" value=Page::General>…</Tab>s as children.
Implementations§
Source§impl<T: PartialEq + Clone + 'static> Tabs<T>
impl<T: PartialEq + Clone + 'static> Tabs<T>
pub fn new(selection: Signal<T>) -> Tabs<T>
Sourcepub fn children(self, tabs: impl TabsChildren<T>) -> Tabs<T>
pub fn children(self, tabs: impl TabsChildren<T>) -> Tabs<T>
Its pages, in order.
pub fn tab(self, tab: Tab<T>) -> Tabs<T>
Sourcepub fn tabs_style(self, style: impl IntoValue<TabsStyle>) -> Tabs<T>
pub fn tabs_style(self, style: impl IntoValue<TabsStyle>) -> Tabs<T>
How it shows its tabs, where the platform has more than one way:
navigation tabs (the default: libadwaita’s view switcher,
Kirigami’s navigation bar) or a tab bar (GTK’s notebook, Qt’s tab
bar) on GNOME and KDE. The others show theirs. In view!, after
selection.
Trait Implementations§
Source§impl<T: 'static> ElementBuilder for Tabs<T>
impl<T: 'static> ElementBuilder for Tabs<T>
fn element(&mut self) -> &mut Element
Source§fn style(self, f: impl FnOnce(&mut Style)) -> Self
fn style(self, f: impl FnOnce(&mut Style)) -> Self
Source§fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
f re-runs whenever the
signals it reads change, and must set every field it cares about.fn width(self, value: impl IntoValue<Length>) -> Self
fn height(self, value: impl IntoValue<Length>) -> Self
fn min_width(self, value: impl IntoValue<Length>) -> Self
fn min_height(self, value: impl IntoValue<Length>) -> Self
fn max_width(self, value: impl IntoValue<Length>) -> Self
fn max_height(self, value: impl IntoValue<Length>) -> Self
fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self
fn padding(self, value: impl IntoValue<Length>) -> Self
fn padding_x(self, value: impl IntoValue<Length>) -> Self
fn padding_y(self, value: impl IntoValue<Length>) -> Self
fn padding_start(self, value: impl IntoValue<Length>) -> Self
fn padding_end(self, value: impl IntoValue<Length>) -> Self
fn padding_top(self, value: impl IntoValue<Length>) -> Self
fn padding_bottom(self, value: impl IntoValue<Length>) -> Self
fn margin(self, value: impl IntoValue<Length>) -> Self
fn margin_x(self, value: impl IntoValue<Length>) -> Self
fn margin_y(self, value: impl IntoValue<Length>) -> Self
fn margin_start(self, value: impl IntoValue<Length>) -> Self
fn margin_end(self, value: impl IntoValue<Length>) -> Self
fn margin_top(self, value: impl IntoValue<Length>) -> Self
fn margin_bottom(self, value: impl IntoValue<Length>) -> Self
fn grow(self, value: impl IntoValue<f32>) -> Self
fn shrink(self, value: impl IntoValue<f32>) -> Self
fn basis(self, value: impl IntoValue<Length>) -> Self
fn align_self(self, value: impl IntoValue<Align>) -> Self
Source§fn justify_self(self, value: impl IntoValue<Align>) -> Self
fn justify_self(self, value: impl IntoValue<Align>) -> Self
Source§fn top(self, value: impl IntoValue<Length>) -> Self
fn top(self, value: impl IntoValue<Length>) -> Self
absolute()).fn bottom(self, value: impl IntoValue<Length>) -> Self
Source§fn start(self, value: impl IntoValue<Length>) -> Self
fn start(self, value: impl IntoValue<Length>) -> Self
fn end(self, value: impl IntoValue<Length>) -> Self
fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self
fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self
fn direction(self, value: impl IntoValue<TextDirection>) -> Self
display the node had.fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self
Source§fn tooltip(self, text: impl IntoValue<String>) -> Self
fn tooltip(self, text: impl IntoValue<String>) -> Self
entries, and built again whenever what it
reads changes, as Menu::children_with builds its entries.