X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=102a3fd29ca172c472ce28a7a981b07f87f5af2b;hb=f93ca1349ce3d56ecd9b90c1b6e88971d46d9952;hp=5e8d2c5514961739476611e00f8a592e87f71377;hpb=883eeb8cf2c717bc0fd121882b484897742f7f28;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 5e8d2c5514..102a3fd29c 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -84,7 +84,8 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv trackview.session().register_with_memento_command_factory(alist->id(), this); - if (alist->parameter().type() == GainAutomation) { + if (alist->parameter().type() == GainAutomation || + alist->parameter().type() == EnvelopeAutomation) { set_uses_gain_mapping (true); } @@ -115,8 +116,9 @@ AutomationLine::queue_reset () void AutomationLine::show () { - if (_interpolation != AutomationList::Discrete) + if (_interpolation != AutomationList::Discrete) { line->show(); + } if (points_visible) { for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { @@ -206,10 +208,10 @@ AutomationLine::modify_point_y (ControlPoint& cp, double y) y = min (1.0, y); y = _height - (y * _height); - double const x = trackview.editor.frame_to_unit ((*cp.model())->when); + double const x = trackview.editor().frame_to_unit ((*cp.model())->when); - trackview.editor.current_session()->begin_reversible_command (_("automation event move")); - trackview.editor.current_session()->add_command (new MementoCommand(*alist.get(), &get_state(), 0)); + trackview.editor().current_session()->begin_reversible_command (_("automation event move")); + trackview.editor().current_session()->add_command (new MementoCommand(*alist.get(), &get_state(), 0)); cp.move_to (x, y, ControlPoint::Full); reset_line_coords (cp); @@ -224,9 +226,9 @@ AutomationLine::modify_point_y (ControlPoint& cp, double y) update_pending = false; - trackview.editor.current_session()->add_command (new MementoCommand(*alist.get(), 0, &alist->get_state())); - trackview.editor.current_session()->commit_reversible_command (); - trackview.editor.current_session()->set_dirty (); + trackview.editor().current_session()->add_command (new MementoCommand(*alist.get(), 0, &alist->get_state())); + trackview.editor().current_session()->commit_reversible_command (); + trackview.editor().current_session()->set_dirty (); } @@ -255,7 +257,7 @@ AutomationLine::modify_view_point (ControlPoint& cp, double x, double y, bool wi already in frames. it needs to be converted to canvas units. */ - x = trackview.editor.frame_to_unit (x); + x = trackview.editor().frame_to_unit (x); /* clamp x position using view coordinates */ @@ -308,7 +310,7 @@ AutomationLine::modify_view_point (ControlPoint& cp, double x, double y, bool wi /* leave the x-coordinate alone */ - x = trackview.editor.frame_to_unit ((*cp.model())->when); + x = trackview.editor().frame_to_unit ((*cp.model())->when); } @@ -380,10 +382,10 @@ AutomationLine::model_representation (ControlPoint& cp, ModelRepresentation& mr) /* if xval has not changed, set it directly from the model to avoid rounding errors */ - if (mr.xval == trackview.editor.frame_to_unit((*cp.model())->when)) { + if (mr.xval == trackview.editor().frame_to_unit((*cp.model())->when)) { mr.xval = (nframes_t) (*cp.model())->when; } else { - mr.xval = trackview.editor.unit_to_frame (mr.xval); + mr.xval = trackview.editor().unit_to_frame (mr.xval); } /* virtual call: this will do the right thing @@ -628,12 +630,13 @@ AutomationLine::determine_visible_control_points (ALPoints& points) line->property_points() = line_points; - if (_visible && _interpolation != AutomationList::Discrete) + if (_visible && _interpolation != AutomationList::Discrete) { line->show(); + } } - set_selected_points (trackview.editor.get_selection().points); + set_selected_points (trackview.editor().get_selection().points); } @@ -717,7 +720,7 @@ AutomationLine::invalidate_point (ALPoints& p, uint32_t index) void AutomationLine::start_drag (ControlPoint* cp, nframes_t x, float fraction) { - if (trackview.editor.current_session() == 0) { /* how? */ + if (trackview.editor().current_session() == 0) { /* how? */ return; } @@ -729,8 +732,8 @@ AutomationLine::start_drag (ControlPoint* cp, nframes_t x, float fraction) str = _("automation range drag"); } - trackview.editor.current_session()->begin_reversible_command (str); - trackview.editor.current_session()->add_command (new MementoCommand(*alist.get(), &get_state(), 0)); + trackview.editor().current_session()->begin_reversible_command (str); + trackview.editor().current_session()->add_command (new MementoCommand(*alist.get(), &get_state(), 0)); drag_x = x; drag_distance = 0; @@ -777,7 +780,7 @@ AutomationLine::line_drag (uint32_t i1, uint32_t i2, float fraction, bool with_p for (uint32_t i = i1 ; i <= i2; i++) { cp = nth (i); - modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push); + modify_view_point (*cp, trackview.editor().unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push); } if (line_points.size() > 1) { @@ -806,9 +809,9 @@ AutomationLine::end_drag (ControlPoint* cp) update_pending = false; - trackview.editor.current_session()->add_command (new MementoCommand(*alist.get(), 0, &alist->get_state())); - trackview.editor.current_session()->commit_reversible_command (); - trackview.editor.current_session()->set_dirty (); + trackview.editor().current_session()->add_command (new MementoCommand(*alist.get(), 0, &alist->get_state())); + trackview.editor().current_session()->commit_reversible_command (); + trackview.editor().current_session()->set_dirty (); } @@ -890,7 +893,7 @@ AutomationLine::control_points_adjacent (double xval, uint32_t & before, uint32_ /* xval is in frames */ - unit_xval = trackview.editor.frame_to_unit (xval); + unit_xval = trackview.editor().frame_to_unit (xval); for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { @@ -951,15 +954,15 @@ AutomationLine::remove_point (ControlPoint& cp) model_representation (cp, mr); - trackview.editor.current_session()->begin_reversible_command (_("remove control point")); + trackview.editor().current_session()->begin_reversible_command (_("remove control point")); XMLNode &before = alist->get_state(); alist->erase (mr.start, mr.end); - trackview.editor.current_session()->add_command(new MementoCommand( + trackview.editor().current_session()->add_command(new MementoCommand( *alist.get(), &before, &alist->get_state())); - trackview.editor.current_session()->commit_reversible_command (); - trackview.editor.current_session()->set_dirty (); + trackview.editor().current_session()->commit_reversible_command (); + trackview.editor().current_session()->set_dirty (); } void @@ -1049,8 +1052,8 @@ AutomationLine::set_selected_points (PointSelection& points) double rstart, rend; - rstart = trackview.editor.frame_to_unit ((*r).start); - rend = trackview.editor.frame_to_unit ((*r).end); + rstart = trackview.editor().frame_to_unit ((*r).start); + rend = trackview.editor().frame_to_unit ((*r).end); if ((*i)->get_x() >= rstart && (*i)->get_x() <= rend) { @@ -1080,7 +1083,7 @@ void AutomationLine::set_colors() { void AutomationLine::show_selection () { - TimeSelection& time (trackview.editor.get_selection().time); + TimeSelection& time (trackview.editor().get_selection().time); for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { @@ -1089,8 +1092,8 @@ AutomationLine::show_selection () for (list::iterator r = time.begin(); r != time.end(); ++r) { double rstart, rend; - rstart = trackview.editor.frame_to_unit ((*r).start); - rend = trackview.editor.frame_to_unit ((*r).end); + rstart = trackview.editor().frame_to_unit ((*r).start); + rend = trackview.editor().frame_to_unit ((*r).end); if ((*i)->get_x() >= rstart && (*i)->get_x() <= rend) { (*i)->set_selected(true); @@ -1146,7 +1149,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) void AutomationLine::add_model_point (ALPoints& tmp_points, double frame, double yfract) { - tmp_points.push_back (ALPoint (trackview.editor.frame_to_unit (frame), + tmp_points.push_back (ALPoint (trackview.editor().frame_to_unit (frame), _height - (yfract * _height))); } @@ -1168,9 +1171,9 @@ AutomationLine::clear () /* parent must create command */ XMLNode &before = get_state(); alist->clear(); - trackview.editor.current_session()->add_command (new MementoCommand(*this, &before, &get_state())); - trackview.editor.current_session()->commit_reversible_command (); - trackview.editor.current_session()->set_dirty (); + trackview.editor().current_session()->add_command (new MementoCommand(*this, &before, &get_state())); + trackview.editor().current_session()->commit_reversible_command (); + trackview.editor().current_session()->set_dirty (); } void @@ -1200,8 +1203,9 @@ AutomationLine::show_all_control_points () void AutomationLine::hide_all_but_selected_control_points () { - if (alist->interpolation() == AutomationList::Discrete) + if (alist->interpolation() == AutomationList::Discrete) { return; + } points_visible = false; @@ -1215,8 +1219,9 @@ AutomationLine::hide_all_but_selected_control_points () void AutomationLine::track_entered() { - if (alist->interpolation() != AutomationList::Discrete) + if (alist->interpolation() != AutomationList::Discrete) { show_all_control_points(); + } } void @@ -1245,7 +1250,8 @@ void AutomationLine::view_to_model_y (double& y) const { /* TODO: This should be more generic ... */ - if (alist->parameter().type() == GainAutomation) { + if (alist->parameter().type() == GainAutomation || + alist->parameter().type() == EnvelopeAutomation) { y = slider_position_to_gain (y); y = max (0.0, y); y = min (2.0, y); @@ -1263,7 +1269,8 @@ void AutomationLine::model_to_view_y (double& y) const { /* TODO: This should be more generic ... */ - if (alist->parameter().type() == GainAutomation) { + if (alist->parameter().type() == GainAutomation || + alist->parameter().type() == EnvelopeAutomation) { y = gain_to_slider_position (y); } else if (alist->parameter().type() == PanAutomation) { // vertical coordinate axis reversal