Skip to main content

SettingKind

Trait SettingKind 

Source
pub trait SettingKind {
    // Required methods
    fn identity(&self) -> SettingIdentity;
    fn label(&self, settings: &Settings) -> String;
    fn fetch(&self, settings: &Settings) -> SettingData;

    // Provided methods
    fn handle(
        &self,
        _evt: &Event,
        _settings: &mut Settings,
        _bus: &mut Bus,
    ) -> (Option<String>, bool) { ... }
    fn as_input_kind(&self) -> Option<&dyn InputSettingKind> { ... }
    fn file_chooser_entry_id(&self) -> Option<EntryId> { ... }
    fn hold_event(&self, _rect: Rectangle) -> Option<Event> { ... }
    fn keep_menu_open(&self) -> bool { ... }
}
Expand description

A self-contained description of a single setting.

Implementing this trait is sufficient to add a new setting to the editor.

Required Methods§

Source

fn identity(&self) -> SettingIdentity

Unique identity used to route SettingsEvent::UpdateValue to the correct SettingValue view.

Source

fn label(&self, settings: &Settings) -> String

Human-readable label shown on the left side of the setting row.

settings is provided for dynamic labels (e.g. library names).

Source

fn fetch(&self, settings: &Settings) -> SettingData

Fetch the current display value and widget configuration from settings.

Provided Methods§

Source

fn handle( &self, _evt: &Event, _settings: &mut Settings, _bus: &mut Bus, ) -> (Option<String>, bool)

Handle an incoming event that may apply a change to this setting.

Mutates settings if the event is relevant and returns:

  • Some(display_string) as the first element when the event changes this setting’s display value, or None if the event does not apply.
  • true as the second element when the event has been fully consumed and should stop propagating; false to allow further handlers to see it.

bus is available for settings that need to propagate side-effects.

Source

fn as_input_kind(&self) -> Option<&dyn InputSettingKind>

Returns this setting as an InputSettingKind if it supports text input.

InputSettingKind implementors override this to return Some(self). All other settings inherit the default None.

Source

fn file_chooser_entry_id(&self) -> Option<EntryId>

Returns the EntryId that triggers opening a file chooser for this setting.

Default None. Implement on settings that offer a “Custom Image…” option (currently the three intermission kinds).

Source

fn hold_event(&self, _rect: Rectangle) -> Option<Event>

The event that should be emitted if the settings is held.

Source

fn keep_menu_open(&self) -> bool

Whether a submenu should remain open after this setting handles a selection.

Implementations on Foreign Types§

Source§

impl<T: SettingKind + ?Sized> SettingKind for &T

Source§

fn identity(&self) -> SettingIdentity

Source§

fn label(&self, settings: &Settings) -> String

Source§

fn fetch(&self, settings: &Settings) -> SettingData

Source§

fn handle( &self, evt: &Event, settings: &mut Settings, bus: &mut Bus, ) -> (Option<String>, bool)

Source§

fn as_input_kind(&self) -> Option<&dyn InputSettingKind>

Source§

fn file_chooser_entry_id(&self) -> Option<EntryId>

Source§

fn hold_event(&self, rect: Rectangle) -> Option<Event>

Source§

fn keep_menu_open(&self) -> bool

Source§

impl<T: SettingKind + ?Sized> SettingKind for Box<T>

Source§

fn identity(&self) -> SettingIdentity

Source§

fn label(&self, settings: &Settings) -> String

Source§

fn fetch(&self, settings: &Settings) -> SettingData

Source§

fn handle( &self, evt: &Event, settings: &mut Settings, bus: &mut Bus, ) -> (Option<String>, bool)

Source§

fn as_input_kind(&self) -> Option<&dyn InputSettingKind>

Source§

fn file_chooser_entry_id(&self) -> Option<EntryId>

Source§

fn hold_event(&self, rect: Rectangle) -> Option<Event>

Source§

fn keep_menu_open(&self) -> bool

Implementors§

Source§

impl SettingKind for DictionaryInfo

Source§

impl SettingKind for AutoFrontlight

Source§

impl SettingKind for AutoFrontlightBrightness

Source§

impl SettingKind for AutoFrontlightManualCoordinates

Source§

impl SettingKind for AutoPowerOff

Source§

impl SettingKind for AutoShare

Source§

impl SettingKind for AutoSuspend

Source§

impl SettingKind for AutoTime

Source§

impl SettingKind for ButtonScheme

Source§

impl SettingKind for DbBackupRetentionSetting

Source§

impl SettingKind for KeyboardLayout

Source§

impl SettingKind for Locale

Source§

impl SettingKind for SettingsRetention

Source§

impl SettingKind for SleepCover

Source§

impl SettingKind for StartupModeSetting

Source§

impl SettingKind for AllowedKindsSetting

Source§

impl SettingKind for ForceFullImport

Source§

impl SettingKind for ImportSyncMetadata

Source§

impl SettingKind for IntermissionPowerOff

Source§

impl SettingKind for IntermissionShare

Source§

impl SettingKind for IntermissionSuspend

Source§

impl SettingKind for LibraryFinishedAction

Source§

impl SettingKind for LibraryInfo

Source§

impl SettingKind for LibraryName

Source§

impl SettingKind for LibraryPath

Source§

impl SettingKind for DitheredKindsSetting

Source§

impl SettingKind for FinishedActionSetting

Source§

impl SettingKind for RefreshRateByKindInfo

Source§

impl SettingKind for RefreshRateByKindInverted

Source§

impl SettingKind for RefreshRateByKindRegular

Source§

impl SettingKind for RefreshRateInfo

Source§

impl SettingKind for RefreshRateInvertedSetting

Source§

impl SettingKind for RefreshRateRegularSetting

Source§

impl SettingKind for LogLevel

Source§

impl SettingKind for LoggingEnabled