summaryrefslogtreecommitdiff
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
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
-rw-r--r--gtk2_ardour/automation_line.cc64
-rw-r--r--gtk2_ardour/automation_line.h2
-rw-r--r--gtk2_ardour/editor_drag.cc13
-rw-r--r--gtk2_ardour/editor_drag.h3
4 files changed, 76 insertions, 6 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.
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index b78c2da676..6be7ccd6b8 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -113,7 +113,9 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
ArdourCanvas::Item& grab_item() const { return *line; }
std::string get_verbose_cursor_string (double) const;
+ std::string get_verbose_cursor_relative_string (double, double) const;
std::string fraction_to_string (double) const;
+ std::string fraction_to_relative_string (double, double) const;
double string_to_fraction (std::string const &) const;
void view_to_model_coord (double& x, double& y) const;
void view_to_model_coord_y (double &) const;
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 8a601d25cb..8157011c5a 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -4106,7 +4106,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView
, _nothing_to_drag (false)
{
DEBUG_TRACE (DEBUG::Drags, "New AutomationRangeDrag\n");
-
+ track_view = atv;
setup (atv->lines ());
}
@@ -4120,6 +4120,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AudioRegionView* rv, l
list<boost::shared_ptr<AutomationLine> > lines;
lines.push_back (rv->get_gain_line ());
+ track_view = &rv->get_time_axis_view();
setup (lines);
}
@@ -4169,6 +4170,7 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
/* Get line states before we start changing things */
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
i->state = &i->line->get_state ();
+ i->original_fraction = 1 - ((_drags->current_pointer_y() - track_view->y_position()) / i->line->height());
}
if (_ranges.empty()) {
@@ -4274,7 +4276,7 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
}
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
- i->line->start_drag_multiple (i->points, 1 - (_drags->current_pointer_y() / i->line->height ()), i->state);
+ i->line->start_drag_multiple (i->points, 1 - ((_drags->current_pointer_y() - track_view->y_position()) / i->line->height ()), i->state);
}
}
@@ -4285,11 +4287,12 @@ AutomationRangeDrag::motion (GdkEvent*, bool /*first_move*/)
return;
}
- for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
- float const f = 1 - (_drags->current_pointer_y() / i->line->height());
+ for (list<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
+ float const f = 1 - ((_drags->current_pointer_y() - track_view->y_position()) / l->line->height());
/* we are ignoring x position for this drag, so we can just pass in anything */
- i->line->drag_motion (0, f, true, false);
+ l->line->drag_motion (0, f, true, false);
+ show_verbose_cursor_text (l->line->get_verbose_cursor_relative_string (l->original_fraction, f));
}
}
diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h
index 1579a178a8..6127355965 100644
--- a/gtk2_ardour/editor_drag.h
+++ b/gtk2_ardour/editor_drag.h
@@ -966,10 +966,11 @@ private:
std::list<ControlPoint*> points; ///< points to drag on the line
std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
XMLNode* state; ///< the XML state node before the drag
+ double original_fraction; ///< initial y-fraction before the drag
};
std::list<Line> _lines;
-
+ TimeAxisView* track_view;
bool _nothing_to_drag;
};