Skip to main content

Sidebar

Struct Sidebar 

Source
pub struct Sidebar<T: 'static> { /* private fields */ }
Expand description

The sidebar of the window it’s declared in: the list down its leading side that picks what the window shows, as in macOS’s System Settings and GNOME’s Settings (a source list on macOS, libadwaita’s navigation split view on GTK, a NavigationView’s pane on Windows, a first column of Kirigami’s page row on KDE). Declare it anywhere in the window’s content; it stays while it does.

Its items are SidebarItems, in SidebarSections or on their own. selection holds the value of the chosen item, and choosing another sets it; a value no item has chooses none. The window’s content is what’s beside the sidebar: show the page for the selection there. The platform draws the sidebar, sizes it, and collapses it in a narrow window its own way. The window’s size is its content’s, and the sidebar is added to it.

ⓘ
let page = signal(Page::General);
Column::new().children((
    Sidebar::new(page).children((
        SidebarItem::new("General", Page::General).icon(platform! {
            macos => "gearshape",
            gtk | kde => "preferences-system-symbolic",
            windows => "\u{E713}",
        }),
        SidebarSection::new("Network").children((
            SidebarItem::new("Wi-Fi", Page::WiFi),
            SidebarItem::new("Bluetooth", Page::Bluetooth),
        )),
    )),
    Show::new(move || page.get() == Page::General, general),
))

In view!: <Sidebar selection=page>, with <SidebarItem value=Page::General>"General"</SidebarItem>s and <SidebarSection title="Network">s as children.

Implementations§

Source§

impl<T: PartialEq + Clone + 'static> Sidebar<T>

Source

pub fn new(selection: Signal<T>) -> Sidebar<T>

Source

pub fn shown(self, shown: Signal<bool>) -> Sidebar<T>

Shown beside the window’s content while shown is true, hidden otherwise, as the platform shows and hides a sidebar. The user can change it too (the platform’s toggle, its divider dragged away), which sets the signal. Where the platform’s sidebar can’t be hidden in a wide window (GTK), it’s the page shown in a narrow one.

Source

pub fn native(self, tweak: Tweak<Sidebar<T>>) -> Sidebar<T>

Raw platform settings: see Tweak. How wide a sidebar is, say, is each platform’s own.

Source

pub fn children(self, children: impl SidebarEntries<T>) -> Sidebar<T>

Items and sections, in order. Items outside a section next to each other are one section without a heading.

Source

pub fn item(self, item: SidebarItem<T>) -> Sidebar<T>

Source

pub fn section(self, section: SidebarSection<T>) -> Sidebar<T>

Trait Implementations§

Source§

impl<T: PartialEq + Clone + 'static> View for Sidebar<T>

Source§

fn build(self, ui: &Ui) -> NodeId

A placeholder in the tree, which takes no room; the sidebar is the window’s.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Sidebar<T>

§

impl<T> !Send for Sidebar<T>

§

impl<T> !Sync for Sidebar<T>

§

impl<T> !UnwindSafe for Sidebar<T>

§

impl<T> Freeze for Sidebar<T>

§

impl<T> Unpin for Sidebar<T>

§

impl<T> UnsafeUnpin for Sidebar<T>

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<V> Children for V
where V: View,

Source§

fn into_views(self, out: &mut Vec<AnyView>)

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.