SettingValue

Struct SettingValue 

Source
pub struct SettingValue {
    id: Id,
    kind: Kind,
    rect: Rectangle,
    children: Vec<Box<dyn View>>,
    entries: Vec<EntryKind>,
}
Expand description

Represents a single setting value display in the settings UI.

This struct manages the display and interaction of a setting value, including the current value, available options (entries), and associated UI components. It acts as a View that can be rendered and handle events related to setting changes.

Fields§

§id: Id

Unique identifier for this setting value view

§kind: Kind

The type of setting this value represents

§rect: Rectangle

The rectangular area occupied by this view

§children: Vec<Box<dyn View>>

Child views, typically containing an ActionLabel for display

§entries: Vec<EntryKind>

Available options/entries for this setting (e.g., radio buttons, checkboxes)

§Important

Whenever this field is modified, the underlying ActionLabel’s event must be updated by calling create_tap_event() and setting it via action_label.set_event(). This ensures the tap behavior reflects the current entries state.

Implementations§

Source§

impl SettingValue

Source

pub fn new( kind: Kind, rect: Rectangle, settings: &Settings, fonts: &mut Fonts, ) -> SettingValue

Source

fn kind_to_child_view( &self, value: String, enabled_toggle: Option<bool>, fonts: &mut Fonts, ) -> Box<dyn View>

Source

pub fn refresh_from_context(&mut self, context: &Context, rq: &mut RenderQueue)

Refreshes the displayed value by re-reading from context.settings.

This method updates the ActionLabel text to reflect the current state of the setting in context.settings. It should be called whenever the underlying setting changes.

Source

fn fetch_data_for_kind( kind: &Kind, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_keyboard_layout_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_sleep_cover_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_auto_share_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_button_scheme_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_auto_suspend_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_auto_power_off_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_settings_retention_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_library_info_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_library_name_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_library_path_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn fetch_library_mode_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

fn get_available_layouts() -> Result<Vec<String>, Error>

Source

fn fetch_intermission_data( kind: IntermKind, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)

Source

pub fn update(&mut self, value: String, rq: &mut RenderQueue)

Source

pub fn value(&self) -> String

Source

fn create_tap_event(&self) -> Option<Event>

Generates the appropriate event to be triggered when this setting value is tapped.

This method determines what event should be emitted based on the type of setting. It’s used during initialization (in new()) and after updates (in various handle_* methods) to ensure the ActionLabel always has the correct tap behavior.

The behavior varies by setting type:

  • Direct edit settings (LibraryInfo, LibraryName, LibraryPath, AutoSuspend, AutoPowerOff): Return specific edit events that trigger their corresponding input dialogs.
  • Settings with multiple options (KeyboardLayout, SleepCover, AutoShare, ButtonScheme, LibraryMode, Intermission*): Return a SubMenu event that displays all available entries as radio buttons or checkboxes.
§Returns

An Option containing:

  • Some(Event) - the event to emit on tap
  • None
§Important

This method must be called every time self.entries is updated to ensure the tap event reflects the current state of available entries.

Trait Implementations§

Source§

impl Debug for SettingValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl View for SettingValue

Source§

fn handle_event( &mut self, _evt: &Event, _hub: &Hub, _bus: &mut Bus, _rq: &mut RenderQueue, _context: &mut Context, ) -> bool

Source§

fn render( &self, _fb: &mut dyn Framebuffer, _rect: Rectangle, _fonts: &mut Fonts, )

Source§

fn rect(&self) -> &Rectangle

Source§

fn rect_mut(&mut self) -> &mut Rectangle

Source§

fn children(&self) -> &Vec<Box<dyn View>>

Source§

fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>

Source§

fn id(&self) -> Id

Source§

fn render_rect(&self, _rect: &Rectangle) -> Rectangle

Source§

fn resize( &mut self, rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )

Source§

fn child(&self, index: usize) -> &dyn View

Source§

fn child_mut(&mut self, index: usize) -> &mut dyn View

Source§

fn len(&self) -> usize

Source§

fn might_skip(&self, _evt: &Event) -> bool

Source§

fn might_rotate(&self) -> bool

Source§

fn is_background(&self) -> bool

Source§

fn view_id(&self) -> Option<ViewId>

Auto Trait Implementations§

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &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> 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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<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