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
This commit is contained in:
parent
cf49671ab4
commit
e89bdcd9eb
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue