Skip to main content

NavigationSuite

Struct NavigationSuite 

Source
pub struct NavigationSuite { /* private fields */ }
Expand description

Adaptive navigation around caller-owned content.

The selection is controlled: report it through Self::on_change and pass it back with Self::selected. It survives a change of navigation, and so does keyboard focus, because all three forms share this element’s id and therefore their focus handles.

use gpui_kit_material::prelude::*;

let suite = NavigationSuite::new("suite", "Main")
    .items([
        NavItem::new("home", "Home", NavIcon::new("home", "home")),
        NavItem::new("mail", "Mail", NavIcon::new("mail", "mail")),
    ])
    .selected("home")
    .expanded_type(NavigationSuiteType::RailExpanded);

Implementations§

Source§

impl NavigationSuite

Source

pub fn new(id: impl Into<ElementId>, label: impl Into<SharedString>) -> Self

label is the navigation landmark’s accessible name.

Source

pub fn items(self, items: impl IntoIterator<Item = NavItem>) -> Self

The destinations, shown by every form.

Source

pub fn selected(self, value: impl Into<SharedString>) -> Self

The selected destination’s value.

Source

pub fn layout_type(self, layout_type: Option<NavigationSuiteType>) -> Self

Fix the navigation, overriding the adaptive rule. None is adaptive.

Source

pub fn size_class(self, size_class: Option<WindowSizeClass>) -> Self

Classify this size instead of the window’s: for a suite framed inside a larger window, as previews are. None reads the window.

Source

pub fn expanded_from(self, from: Option<WindowWidthClass>) -> Self

The width class the navigation expands at (large by default). None never expands.

Source

pub fn expanded_type(self, expanded_type: NavigationSuiteType) -> Self

What the expanded navigation is: NavigationSuiteType::Drawer by default, or NavigationSuiteType::RailExpanded as m3e defaults to.

Source

pub fn navigation_hidden(self, hidden: bool) -> Self

Hide the navigation; the content takes the freed space. The change animates, and a hidden navigation cannot take focus.

Source

pub fn primary_action(self, action: impl IntoElement) -> Self

The primary action, typically a FAB: floating above a bar, heading a rail, or first in a drawer. It stays above a hidden bar.

Source

pub fn child(self, child: impl IntoElement) -> Self

Add to the content area, which fills the space the navigation leaves.

Source

pub fn on_change( self, handler: impl Fn(&SharedString, &mut Window, &mut App) + 'static, ) -> Self

Called with a newly selected destination’s value.

Source

pub fn on_type_change( self, handler: impl Fn(&NavigationSuiteType, &mut Window, &mut App) + 'static, ) -> Self

Called when the size or an option changes the navigation form.

Trait Implementations§

Source§

impl IntoElement for NavigationSuite

Source§

type Element = ViewElement<NavigationSuite>

The specific type of element into which the implementing type is converted. Useful for converting other types into elements automatically, like Strings
Source§

fn into_element(self) -> Self::Element

Convert self into a type that implements [Element].
Source§

fn into_any_element(self) -> AnyElement

Convert self into a dynamically-typed [AnyElement].
Source§

impl RenderOnce for NavigationSuite

Source§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this component into an element tree. Note that this method takes ownership of self, as compared to [Render::render()] method which takes a mutable reference.

Auto Trait Implementations§

Blanket Implementations§

§

impl<E> AnimationExt for E
where E: IntoElement + 'static,

§

fn with_animation( self, id: impl Into<ElementId>, animation: Animation, animator: impl Fn(Self, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with an animation
§

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations
§

fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
where Self: Sized, T: SpringTarget, <T as SpringTarget>::Output: 'static,

Renders this component or element at the value produced by a spring. Read more
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> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> FluentBuilder for T
where T: IntoElement,

§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.
§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.
§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<E> TestTextExt for E
where E: IntoElement,

§

fn test_text(self, text: impl Into<SharedString>) -> Self::Element

With test-support, records text each time the element paints. Otherwise returns the element it builds.
§

fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element

Like [Self::test_text] for an image’s alternative text, which stands in for what the element draws.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> View for T
where T: RenderOnce,

§

fn entity_id(&self) -> Option<EntityId>

This view’s identity, if it has one. A view typically holds the backing entity as a field and returns its [EntityId] here. Read more
§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this view into an element tree, consuming self.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more