X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=2094d43eff171c7f894ec663d1f1a354983da059;hb=7db39a206e6ab9f43299e6b8ae148d90b2ee6c4d;hp=e3acc56b3be5dbad0cc5f33a7c4de45790246b62;hpb=dcd3e3823c608a8c9aae352b9f03b222ba449f19;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index e3acc56b3b..2094d43eff 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -30,7 +30,6 @@ #include #include -#include #include "boost/shared_ptr.hpp" @@ -53,12 +52,12 @@ #include "control_point.h" #include "gui_thread.h" #include "rgb_macros.h" -#include "ardour_ui.h" #include "public_editor.h" #include "selection.h" #include "time_axis_view.h" #include "point_selection.h" #include "automation_time_axis.h" +#include "ui_config.h" #include "ardour/event_type_map.h" #include "ardour/session.h" @@ -94,7 +93,7 @@ AutomationLine::AutomationLine (const string& name, } else { _our_time_converter = true; } - + _visible = Line; update_pending = false; @@ -120,8 +119,7 @@ AutomationLine::AutomationLine (const string& name, if (alist->parameter().type() == GainAutomation || alist->parameter().type() == TrimAutomation || - alist->parameter().type() == EnvelopeAutomation || - desc.unit == ParameterDescriptor::DB) { + alist->parameter().type() == EnvelopeAutomation) { set_uses_gain_mapping (true); } @@ -202,9 +200,9 @@ void AutomationLine::hide () { /* leave control points setting unchanged, we are just hiding the - overall line + overall line */ - + set_visibility (AutomationLine::VisibleAspects (_visible & ~Line)); } @@ -522,13 +520,13 @@ struct ControlPointSorter bool operator() (ControlPoint const * a, ControlPoint const * b) const { if (floateq (a->get_x(), b->get_x(), 1)) { return a->view_index() < b->view_index(); - } + } return a->get_x() < b->get_x(); } }; AutomationLine::ContiguousControlPoints::ContiguousControlPoints (AutomationLine& al) - : line (al), before_x (0), after_x (DBL_MAX) + : line (al), before_x (0), after_x (DBL_MAX) { } @@ -540,7 +538,7 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) if (sz > 0 && sz < line.npoints()) { const TempoMap& map (e.session()->tempo_map()); - /* determine the limits on x-axis motion for this + /* determine the limits on x-axis motion for this contiguous range of control points */ @@ -574,8 +572,8 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) } } -double -AutomationLine::ContiguousControlPoints::clamp_dx (double dx) +double +AutomationLine::ContiguousControlPoints::clamp_dx (double dx) { if (empty()) { return dx; @@ -583,10 +581,10 @@ AutomationLine::ContiguousControlPoints::clamp_dx (double dx) /* get the maximum distance we can move any of these points along the x-axis */ - + double tx; /* possible position a point would move to, given dx */ ControlPoint* cp; - + if (dx > 0) { /* check the last point, since we're moving later in time */ cp = back(); @@ -595,14 +593,14 @@ AutomationLine::ContiguousControlPoints::clamp_dx (double dx) cp = front(); } - tx = cp->get_x() + dx; // new possible position if we just add the motion + tx = cp->get_x() + dx; // new possible position if we just add the motion tx = max (tx, before_x); // can't move later than following point tx = min (tx, after_x); // can't move earlier than preceeding point - return tx - cp->get_x (); + return tx - cp->get_x (); } -void -AutomationLine::ContiguousControlPoints::move (double dx, double dy) +void +AutomationLine::ContiguousControlPoints::move (double dx, double dy) { for (std::list::iterator i = begin(); i != end(); ++i) { (*i)->move_to ((*i)->get_x() + dx, (*i)->get_y() - line.height() * dy, ControlPoint::Full); @@ -646,19 +644,19 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool if (!_drag_had_movement) { - /* "first move" ... do some stuff that we don't want to do if + /* "first move" ... do some stuff that we don't want to do if no motion ever took place, but need to do before we handle motion. */ - + /* partition the points we are dragging into (potentially several) * set(s) of contiguous points. this will not happen with a normal * drag, but if the user does a discontiguous selection, it can. */ - + uint32_t expected_view_index = 0; CCP contig; - + for (list::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) { if (i == _drag_points.begin() || (*i)->view_index() != expected_view_index) { contig.reset (new ContiguousControlPoints (*this)); @@ -676,13 +674,13 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool (*ccp)->compute_x_bounds (trackview.editor()); } _drag_had_movement = true; - } + } /* OK, now on to the stuff related to *this* motion event. First, for * each contiguous range, figure out the maximum x-axis motion we are * allowed (because of neighbouring points that are not moving. - * - * if we are moving forwards with push, we don't need to do this, + * + * if we are moving forwards with push, we don't need to do this, * since all later points will move too. */ @@ -696,7 +694,6 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool } /* clamp y */ - for (list::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) { double const y = ((_height - (*i)->get_y()) / _height) + dy; if (y < 0) { @@ -710,7 +707,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool if (dx || dy) { /* and now move each section */ - + for (vector::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) { (*ccp)->move (dx, dy); } @@ -732,13 +729,13 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool line->set_steps (line_points, is_stepped()); } } - + double const result_frac = _last_drag_fraction + dy; _drag_distance += dx; _drag_x += dx; - _last_drag_fraction = fraction; + _last_drag_fraction = result_frac; did_push = with_push; - return pair (_drag_x + dx, _last_drag_fraction + dy); + return pair (_drag_x + dx, result_frac); } /** Should be called to indicate the end of a drag */ @@ -884,8 +881,9 @@ AutomationLine::remove_point (ControlPoint& cp) trackview.editor().begin_reversible_command (_("remove control point")); XMLNode &before = alist->get_state(); + trackview.editor ().get_selection ().clear_points (); alist->erase (cp.model()); - + trackview.editor().session()->add_command( new MementoCommand (memento_command_binder (), &before, &alist->get_state())); @@ -913,7 +911,7 @@ AutomationLine::get_selectables (framepos_t start, framepos_t end, double botfra /* model_when is relative to the start of the source, so we just need to add on the origin_b here (as it is the session frame position of the start of the source) */ - + framepos_t const session_frames_when = _time_converter->to (model_when) + _time_converter->origin_b (); if (session_frames_when >= start && session_frames_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) { @@ -948,9 +946,10 @@ AutomationLine::set_selected_points (PointSelection const & points) set_colors (); } -void AutomationLine::set_colors () +void +AutomationLine::set_colors () { - set_line_color (ARDOUR_UI::config()->color ("automation line")); + set_line_color (UIConfiguration::instance().color ("automation line")); for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->set_color (); } @@ -993,7 +992,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) np = events.size(); Evoral::ControlList& e = const_cast (events); - + for (AutomationList::iterator ai = e.begin(); ai != e.end(); ++ai, ++pi) { double tx = (*ai)->when; @@ -1008,17 +1007,17 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) _name) << endmsg; continue; } - + if (tx >= max_framepos || tx < 0 || tx >= _maximum_time) { continue; } - + /* convert x-coordinate to a canvas unit coordinate (this takes * zoom and scroll into account). */ - + tx = trackview.editor().sample_to_pixel_unrounded (tx); - + /* convert from canonical view height (0..1.0) to actual * height coordinates (using X11's top-left rooted system) */ @@ -1194,12 +1193,12 @@ AutomationLine::view_to_model_coord_y (double& y) const */ if ( alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation - || (_desc.unit == ParameterDescriptor::DB && _desc.lower == 0.)) { + || (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) { y = slider_position_to_gain_with_max (y, _desc.upper); y = max ((double)_desc.lower, y); y = min ((double)_desc.upper, y); } else if (alist->parameter().type() == TrimAutomation - || (_desc.unit == ParameterDescriptor::DB && _desc.lower > 0 && _desc.upper > _desc.lower)) { + || (_desc.logarithmic && _desc.lower * _desc.upper > 0 && _desc.upper > _desc.lower)) { const double lower_db = accurate_coefficient_to_dB (_desc.lower); const double range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db; y = max (0.0, y); @@ -1226,10 +1225,10 @@ AutomationLine::model_to_view_coord_y (double& y) const /* TODO: This should be more generic (use ParameterDescriptor) */ if ( alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation - || (_desc.unit == ParameterDescriptor::DB && _desc.lower == 0.)) { - y = gain_to_slider_position_with_max (y, Config->get_max_gain()); + || (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) { + y = gain_to_slider_position_with_max (y, _desc.upper); } else if (alist->parameter().type() == TrimAutomation - || (_desc.unit == ParameterDescriptor::DB && _desc.lower > 0 && _desc.upper > _desc.lower)) { + || (_desc.logarithmic && _desc.lower * _desc.upper > 0 && _desc.upper > _desc.lower)) { const double lower_db = accurate_coefficient_to_dB (_desc.lower); const double range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db; y = (accurate_coefficient_to_dB (y) - lower_db) / range_db; @@ -1260,7 +1259,7 @@ AutomationLine::interpolation_changed (AutomationList::InterpolationStyle style) } void -AutomationLine::add_visible_control_point (uint32_t view_index, uint32_t pi, double tx, double ty, +AutomationLine::add_visible_control_point (uint32_t view_index, uint32_t pi, double tx, double ty, AutomationList::iterator model, uint32_t npoints) { ControlPoint::ShapeType shape;