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: IdUnique identifier for this setting value view
kind: KindThe type of setting this value represents
rect: RectangleThe 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
impl SettingValue
pub fn new( kind: Kind, rect: Rectangle, settings: &Settings, fonts: &mut Fonts, ) -> SettingValue
fn kind_to_child_view( &self, value: String, enabled_toggle: Option<bool>, fonts: &mut Fonts, ) -> Box<dyn View>
Sourcepub fn refresh_from_context(&mut self, context: &Context, rq: &mut RenderQueue)
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.
fn fetch_data_for_kind( kind: &Kind, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_keyboard_layout_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_sleep_cover_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_auto_suspend_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_auto_power_off_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_settings_retention_data( settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_library_info_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_library_name_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_library_path_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn fetch_library_mode_data( index: usize, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
fn get_available_layouts() -> Result<Vec<String>, Error>
fn fetch_intermission_data( kind: IntermKind, settings: &Settings, ) -> (String, Vec<EntryKind>, Option<bool>)
pub fn update(&mut self, value: String, rq: &mut RenderQueue)
pub fn value(&self) -> String
Sourcefn create_tap_event(&self) -> Option<Event>
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 tapNone
§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
impl Debug for SettingValue
Source§impl View for SettingValue
impl View for SettingValue
fn handle_event( &mut self, _evt: &Event, _hub: &Hub, _bus: &mut Bus, _rq: &mut RenderQueue, _context: &mut Context, ) -> bool
fn render( &self, _fb: &mut dyn Framebuffer, _rect: Rectangle, _fonts: &mut Fonts, )
fn rect(&self) -> &Rectangle
fn rect_mut(&mut self) -> &mut Rectangle
fn children(&self) -> &Vec<Box<dyn View>>
fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>
fn id(&self) -> Id
fn render_rect(&self, _rect: &Rectangle) -> Rectangle
fn resize( &mut self, rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )
fn child(&self, index: usize) -> &dyn View
fn child_mut(&mut self, index: usize) -> &mut dyn View
fn len(&self) -> usize
fn might_skip(&self, _evt: &Event) -> bool
fn might_rotate(&self) -> bool
fn is_background(&self) -> bool
fn view_id(&self) -> Option<ViewId>
Auto Trait Implementations§
impl Freeze for SettingValue
impl !RefUnwindSafe for SettingValue
impl !Send for SettingValue
impl !Sync for SettingValue
impl Unpin for SettingValue
impl !UnwindSafe for SettingValue
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.