Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings improvement: Notify plugins of settings change; mark settings as "requiring read-all to take effect" in settings UI #122

Open
fredjk-gh opened this issue Oct 9, 2023 · 2 comments
Labels
Core enhancement New feature or request Framework

Comments

@fredjk-gh
Copy link
Collaborator

Related to #121: Today, plugins cannot detect when settings are changed. Furthermore, some settings, may require a read-all to take effect.

Changes requested:

  • Add an "OnSettingsChanged" event which provides plugins with an indication that settings have changed and, ideally, provide a before/after values so the plugin can determine what has changed. This would help inform whether a plugin requires a read-all. Ideally, this fires when the settings view for the plugin is closed, not on every individual value change (ie. on every single value change like in a number scroller or something) in order to suppress notifications for intermediate/non-committed values, thereby reducing false-positives.
  • Add a setting annotation which plugin authors can use to mark a setting as requiring a read-all if changed. When present, core will render the setting with a visual style which indicates that changing the setting will not take immediate effect. It is a visual indication ONLY. When the plugin receives the new "OnSettingsChanged" event, proposed above, and detects if the setting has in fact changed (because it may have been changed, then changed back), it can set the "RequiresReadAll" property, proposed in Feature Request: Provide an API to allow plugins to indicate it would like a re-read all #121, in order to request the read-all.
@fredjk-gh fredjk-gh added enhancement New feature or request Core Framework labels Oct 9, 2023
@fredjk-gh
Copy link
Collaborator Author

For request 1: This can be accomplished with accessors in your settings class.

e.g.:

class PluginSettings
{
  [SettingDisplayName("Cool Setting")]
  public bool CoolSetting
  {
    get => _cool;
    set
    {
      SomethingINeedToDoWhenThisIsChanged();
      _cool = value;
    }
  }

  [SettingIgnore]
  private bool _cool;
}

@fredjk-gh
Copy link
Collaborator Author

A more formal way to be notified of setting value changes would be to implement INotifyPropertyChanged and the interested parties can subscribe to the PropertyChanged event...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core enhancement New feature or request Framework
Projects
None yet
Development

No branches or pull requests

1 participant