summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-02-06 16:41:15 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2017-02-06 16:49:08 +0100
commit5d5d9b8114609ae6d1b822bd6459e0e84dd5a411 (patch)
tree6d9f7297d0f93c35b0de5f1e34c44f9941f1390b
parentedd1061c3d8822ab586e2bbc80894e125b521a52 (diff)
add new API to PBD::Controllable, ::get_save_value()
Designed to allow derived classes to *save* a different value than would be reported by ::get_value(). Specifically there so that slaved controls can save/restore their *own* state, not the value that ::get_value() would return.
-rw-r--r--libs/pbd/controllable.cc3
-rw-r--r--libs/pbd/pbd/controllable.h7
2 files changed, 8 insertions, 2 deletions
diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
index b730a42980..5f7350da63 100644
--- a/libs/pbd/controllable.cc
+++ b/libs/pbd/controllable.cc
@@ -124,7 +124,7 @@ Controllable::get_state ()
id().print (buf, sizeof (buf));
node->add_property (X_("id"), buf);
node->add_property (X_("flags"), enum_2_string (_flags));
- snprintf (buf, sizeof (buf), "%2.12f", get_value());
+ snprintf (buf, sizeof (buf), "%2.12f", get_save_value());
node->add_property (X_("value"), buf);
if (_extra_xml) {
@@ -134,7 +134,6 @@ Controllable::get_state ()
return *node;
}
-
int
Controllable::set_state (const XMLNode& node, int /*version*/)
{
diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
index 51aa28a4fe..3b416b07fd 100644
--- a/libs/pbd/pbd/controllable.h
+++ b/libs/pbd/pbd/controllable.h
@@ -104,6 +104,13 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible {
virtual void set_value (double, GroupControlDisposition group_override) = 0;
virtual double get_value (void) const = 0;
+ /** This is used when saving state. By default it just calls
+ * get_value(), but a class with more complex semantics might override
+ * this to save some value that differs from what get_value() would
+ * return.
+ */
+ virtual double get_save_value () const { return get_value(); }
+
/** Conversions between `internal', 'interface', and 'user' values */
virtual double internal_to_interface (double i) const {return (i-lower())/(upper() - lower());} //by default, the interface range is just a linear interpolation between lower and upper values
virtual double interface_to_internal (double i) const {return lower() + i*(upper() - lower());}