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§
Sourcefn identity(&self) -> SettingIdentity
fn identity(&self) -> SettingIdentity
Unique identity used to route SettingsEvent::UpdateValue to the
correct SettingValue view.
Sourcefn label(&self, settings: &Settings) -> String
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).
Sourcefn fetch(&self, settings: &Settings) -> SettingData
fn fetch(&self, settings: &Settings) -> SettingData
Fetch the current display value and widget configuration from settings.
Provided Methods§
Sourcefn handle(
&self,
_evt: &Event,
_settings: &mut Settings,
_bus: &mut Bus,
) -> Option<String>
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.
Sourcefn as_input_kind(&self) -> Option<&dyn InputSettingKind>
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.
Sourcefn file_chooser_entry_id(&self) -> Option<EntryId>
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).