Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Pref< T > Struct Template Reference

Proxy object providing a "live value" interface. More...

#include <preferences.h>

Detailed Description

template<typename T>
struct Inkscape::Pref< T >

Proxy object providing a "live value" interface.

A Pref<T> tracks a preference value. For the most part it behaves just like a T. For example

auto mybool = Pref<bool>("/path/to/mybool");

can be used as a bool. The only difference is that it updates whenever the preference updates, and allows you to perform an action when it does. For example,

mybool.action = [&] { std::cout << mybool << std::endl; };

will cause the new value to be printed after each subsequent change. Pref<T> can be temporarily disabled with a call to

mybool.set_enabled(false);

during which time it will revert to its default value and ignore further updates until re-enabled again.

  • Most common types T are implemented. Feel free to add more as needed.
  • Pref<void> allows listening for updates to a whole group of preferences. Although this entirely duplicates existing preferences functionality, it is provided for consistency.

Definition at line 803 of file preferences.h.


The documentation for this struct was generated from the following file: