summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_line.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-07-10 15:44:56 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-07-10 15:44:56 +0000
commite89bdcd9ebb774294119cf349b3faaf0fa9ffd1f (patch)
tree90d75964e9fcdb2346737ca90da56d987a684a55 /gtk2_ardour/automation_line.cc
parentcf49671ab462926139e8b9f5d9a98453d03b3827 (diff)
provide some numerical data during automation trim (range) drags, and correct computation of y-fraction for such drags
git-svn-id: svn://localhost/ardour2/branches/3.0@13011 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/automation_line.cc')
-rw-r--r--gtk2_ardour/automation_line.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index 1c5bfbb4b7..4a21e7905a 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -309,6 +309,31 @@ AutomationLine::get_verbose_cursor_string (double fraction) const
return s;
}
+string
+AutomationLine::get_verbose_cursor_relative_string (double original, double fraction) const
+{
+ std::string s = fraction_to_string (fraction);
+ if (_uses_gain_mapping) {
+ s += " dB";
+ }
+
+ std::string d = fraction_to_relative_string (original, fraction);
+
+ if (!d.empty()) {
+
+ s += " (\u0394";
+ s += d;
+
+ if (_uses_gain_mapping) {
+ s += " dB";
+ }
+
+ s += ')';
+ }
+
+ return s;
+}
+
/**
* @param fraction y fraction
* @return string representation of this value, using dB if appropriate.
@@ -336,6 +361,45 @@ AutomationLine::fraction_to_string (double fraction) const
return buf;
}
+/**
+ * @param original an old y-axis fraction
+ * @param fraction the new y fraction
+ * @return string representation of the difference between original and fraction, using dB if appropriate.
+ */
+string
+AutomationLine::fraction_to_relative_string (double original, double fraction) const
+{
+ char buf[32];
+
+ if (original == fraction) {
+ return "0";
+ }
+
+ if (_uses_gain_mapping) {
+ if (original == 0.0) {
+ /* there is no sensible representation of a relative
+ change from -inf dB, so return an empty string.
+ */
+ return "";
+ } else if (fraction == 0.0) {
+ snprintf (buf, sizeof (buf), "-inf");
+ } else {
+ double old_db = accurate_coefficient_to_dB (slider_position_to_gain_with_max (original, Config->get_max_gain()));
+ double new_db = accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain()));
+ snprintf (buf, sizeof (buf), "%.1f", new_db - old_db);
+ }
+ } else {
+ view_to_model_coord_y (original);
+ view_to_model_coord_y (fraction);
+ if (EventTypeMap::instance().is_integer (alist->parameter())) {
+ snprintf (buf, sizeof (buf), "%d", (int)fraction - (int)original);
+ } else {
+ snprintf (buf, sizeof (buf), "%.2f", fraction - original);
+ }
+ }
+
+ return buf;
+}
/**
* @param s Value string in the form as returned by fraction_to_string.