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§
Source§impl Clone for SettingItem
impl Clone for SettingItem
Source§fn clone(&self) -> SettingItem
fn clone(&self) -> SettingItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SettingItem
impl !Send for SettingItem
impl !Sync for SettingItem
impl !UnwindSafe for SettingItem
impl Freeze for SettingItem
impl Unpin for SettingItem
impl UnsafeUnpin for SettingItem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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