pub struct SidebarState { /* private fields */ }Expand description
Whether the sidebar is open, how wide it is, and how it collapses.
Shared by every page that shows the sidebar, so the width and the open state survive navigation. Edit it through its methods so the layout and the trigger observe the change.
Implementations§
Source§impl SidebarState
impl SidebarState
Sourcepub fn new(cx: &App) -> Self
pub fn new(cx: &App) -> Self
An open sidebar at the theme’s sidebar width that narrows to a rail of icons when closed.
Sourcepub fn with_width(self, width: Pixels) -> Self
pub fn with_width(self, width: Pixels) -> Self
Starts at width, clamped to the range.
Sourcepub fn with_width_range(self, range: Range<Pixels>) -> Self
pub fn with_width_range(self, range: Range<Pixels>) -> Self
The widths a drag can reach. The current width is clamped into it.
Sourcepub fn with_collapsible(self, collapsible: SidebarCollapsible) -> Self
pub fn with_collapsible(self, collapsible: SidebarCollapsible) -> Self
How the sidebar closes.
Sourcepub fn with_icon_width(self, width: Pixels) -> Self
pub fn with_icon_width(self, width: Pixels) -> Self
The width of the rail when collapsed to icons. The theme’s
icon_sidebar_width unless set. A window whose rail sits under the
macOS window controls gives it the theme’s window_controls_inset.
Sourcepub fn icon_width(&self) -> Pixels
pub fn icon_width(&self) -> Pixels
The width of the rail when collapsed to icons.
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Whether the sidebar is open. A sidebar that cannot collapse is always open beside the content; as a sheet it still opens and closes.
Sourcepub fn is_icon_only(&self) -> bool
pub fn is_icon_only(&self) -> bool
Whether the sidebar is showing only icons: closed beside the content, and collapsing to icons. A sheet never shows icons.
Sourcepub fn is_sheet(&self) -> bool
pub fn is_sheet(&self) -> bool
Whether the sidebar floats over the content as a sheet, which the layout decides from the window width. A sheet starts closed, opens from the trigger, and closes from the trigger or a tap outside it.
Sourcepub fn width_range(&self) -> &Range<Pixels> ⓘ
pub fn width_range(&self) -> &Range<Pixels> ⓘ
The widths a drag can reach.
Sourcepub fn collapsible(&self) -> SidebarCollapsible
pub fn collapsible(&self) -> SidebarCollapsible
How the sidebar closes.
Sourcepub fn is_resizing(&self) -> bool
pub fn is_resizing(&self) -> bool
Whether a drag on the handle is in progress.
Sourcepub fn set_open(&mut self, open: bool, cx: &mut Context<'_, Self>)
pub fn set_open(&mut self, open: bool, cx: &mut Context<'_, Self>)
Opens or closes the sidebar: the sheet while the sidebar is one, the sidebar beside the content otherwise.
Sourcepub fn toggle(&mut self, cx: &mut Context<'_, Self>)
pub fn toggle(&mut self, cx: &mut Context<'_, Self>)
Closes an open sidebar and opens a closed one.
Sourcepub fn set_width(&mut self, width: Pixels, cx: &mut Context<'_, Self>)
pub fn set_width(&mut self, width: Pixels, cx: &mut Context<'_, Self>)
Sets the width, clamped to the range.
Sourcepub fn set_icon_width(&mut self, width: Pixels, cx: &mut Context<'_, Self>)
pub fn set_icon_width(&mut self, width: Pixels, cx: &mut Context<'_, Self>)
Changes the width of the rail when collapsed to icons.
Sourcepub fn set_collapsible(
&mut self,
collapsible: SidebarCollapsible,
cx: &mut Context<'_, Self>,
)
pub fn set_collapsible( &mut self, collapsible: SidebarCollapsible, cx: &mut Context<'_, Self>, )
Changes how the sidebar closes.
Trait Implementations§
impl EventEmitter<SidebarEvent> for SidebarState
Auto Trait Implementations§
impl Freeze for SidebarState
impl RefUnwindSafe for SidebarState
impl Send for SidebarState
impl Sync for SidebarState
impl Unpin for SidebarState
impl UnsafeUnpin for SidebarState
impl UnwindSafe for SidebarState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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