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> { ... }
    fn as_input_kind(&self) -> Option<&dyn InputSettingKind> { ... }
    fn file_chooser_entry_id(&self) -> Option<EntryId> { ... }
}
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>

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

Mutates settings if the event is relevant and returns the updated display string. Returns None if this event does not apply to this setting. 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).

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>

Source§

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

Source§

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

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>

Source§

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

Source§

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

Implementors§