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> { ... }
}
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.

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§

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>

Implementors§