pub enum SettingItem {
Item {
title: SharedString,
description: Option<Text>,
keywords: Vec<SharedString>,
layout: Axis,
disabled: bool,
field: Rc<dyn AnySettingField>,
},
Element {
disabled: bool,
keywords: Vec<SharedString>,
reset_handler: Option<(Rc<dyn Fn(&App) -> bool>, Rc<dyn Fn(&mut Window, &mut App)>)>,
render: Rc<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement + 'static>,
},
}Expand description
Setting item.
Variants§
Item
A normal setting item with a title, description, and field.
Element
A full custom element to render.
Fields
keywords: Vec<SharedString>reset_handler: Option<(Rc<dyn Fn(&App) -> bool>, Rc<dyn Fn(&mut Window, &mut App)>)>Optional custom reset behavior. The first closure reports whether the item is “dirty” (controls reset button visibility), the second performs the reset.
render: Rc<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement + 'static>Implementations§
Source§impl SettingItem
impl SettingItem
Sourcepub fn new<F>(title: impl Into<SharedString>, field: F) -> Selfwhere
F: AnySettingField + 'static,
pub fn new<F>(title: impl Into<SharedString>, field: F) -> Selfwhere
F: AnySettingField + 'static,
Create a new setting item.
Sourcepub fn render<R, E>(render: R) -> Self
pub fn render<R, E>(render: R) -> Self
Create a new custom element setting item with a render closure.
Sourcepub fn on_reset<D, R>(self, is_dirty: D, reset: R) -> Self
pub fn on_reset<D, R>(self, is_dirty: D, reset: R) -> Self
Provide custom reset behavior for a custom element item.
Only applies to SettingItem::Element (created via
SettingItem::render). When set, the page-level reset button will
appear while is_dirty returns true, and clicking it invokes reset.
is_dirtyreports whether the item differs from its default state.resetperforms the reset.
Sourcepub fn keywords<I, S>(self, keywords: I) -> Self
pub fn keywords<I, S>(self, keywords: I) -> Self
Set additional keywords used only for search matching (not rendered).
For example, an item titled “Enable Two-factor auth” can be made searchable via “MFA”. This is also useful for custom elements that have no title/description but should still show up in search results.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Set whether the setting item is disabled, default is false.
A disabled item is rendered with reduced opacity. For
SettingItem::Item the underlying field is also rendered in a
non-interactive state. For SettingItem::Element the disabled flag
is forwarded via RenderOptions::disabled so the custom renderer can
disable its interactive controls.
Sourcepub fn description(self, description: impl Into<Text>) -> Self
pub fn description(self, description: impl Into<Text>) -> Self
Set the description of the setting item.
Only applies to SettingItem::Item.
Sourcepub fn layout(self, layout: Axis) -> Self
pub fn layout(self, layout: Axis) -> Self
Set the layout of the setting item.
Only applies to SettingItem::Item.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SettingItem
impl !Send for SettingItem
impl !Sync for SettingItem
impl !UnwindSafe for SettingItem
impl Forget for SettingItem
impl Freeze for SettingItemwhere
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const TextView is !null: Freeze,
PhantomData<TextView>: Freeze,
*const u8 is !null: Freeze,
PhantomData<SharedString>: Freeze,
*const RcInner<dyn AnySettingField> is !null: Freeze,
PhantomData<RcInner<dyn AnySettingField>>: Freeze,
*const RcInner<dyn Fn(&App) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&App) -> bool>>: Freeze,
*const RcInner<dyn Fn(&mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App)>>: Freeze,
*const RcInner<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement>>: Freeze,
impl Move for SettingItem
impl Unpin for SettingItem
impl UnsafeUnpin for SettingItemwhere
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const TextView is !null: UnsafeUnpin,
PhantomData<TextView>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<SharedString>: UnsafeUnpin,
*const RcInner<dyn AnySettingField> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn AnySettingField>>: UnsafeUnpin,
*const RcInner<dyn Fn(&App) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&App) -> bool>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&RenderOptions, &mut Window, &mut App) -> AnyElement>>: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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