From: Paul Davis Date: Wed, 19 Dec 2012 15:55:06 +0000 (+0000) Subject: fix push-drags of automation data - previously we did not resync the model with the... X-Git-Tag: 3.0~421 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=30237aad7f8e56bc97af4f74812e92e76c924258;p=ardour.git fix push-drags of automation data - previously we did not resync the model with the view for the points that were pushed (i.e. not selected, but moved anyway) git-svn-id: svn://localhost/ardour2/branches/3.0@13681 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index b067757cb0..63b9740c00 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -583,7 +583,7 @@ AutomationLine::start_drag_common (double x, float fraction) * @return x position and y fraction that were actually used (once clamped). */ pair -AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push) +AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push, uint32_t& final_index) { if (_drag_points.empty()) { return pair (x,fraction); @@ -662,8 +662,9 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool (*ccp)->move (dx, dy); } if (with_push) { - uint32_t i = contiguous_points.back()->back()->view_index () + 1; + final_index = contiguous_points.back()->back()->view_index () + 1; ControlPoint* p; + uint32_t i = final_index; while ((p = nth (i)) != 0 && p->can_slide()) { p->move_to (p->get_x() + dx, p->get_y(), ControlPoint::Full); reset_line_coords (*p); @@ -688,7 +689,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool /** Should be called to indicate the end of a drag */ void -AutomationLine::end_drag () +AutomationLine::end_drag (bool with_push, uint32_t final_index) { if (!_drag_had_movement) { return; @@ -696,6 +697,16 @@ AutomationLine::end_drag () alist->freeze (); sync_model_with_view_points (_drag_points); + + if (with_push) { + ControlPoint* p; + uint32_t i = final_index; + while ((p = nth (i)) != 0 && p->can_slide()) { + sync_model_with_view_point (*p); + ++i; + } + } + alist->thaw (); update_pending = false; diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h index 16a410a2fc..cafeeee2ac 100644 --- a/gtk2_ardour/automation_line.h +++ b/gtk2_ardour/automation_line.h @@ -83,8 +83,8 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible virtual void start_drag_single (ControlPoint*, double, float); virtual void start_drag_line (uint32_t, uint32_t, float); virtual void start_drag_multiple (std::list, float, XMLNode *); - virtual std::pair drag_motion (double, float, bool, bool with_push); - virtual void end_drag (); + virtual std::pair drag_motion (double, float, bool, bool with_push, uint32_t& final_index); + virtual void end_drag (bool with_push, uint32_t final_index); ControlPoint* nth (uint32_t); ControlPoint const * nth (uint32_t) const; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a8e9a78dc5..0c309d7234 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2885,6 +2885,8 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/) _editor->verbose_cursor()->show (); + _pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier); + if (!_point->can_slide ()) { _x_constrained = true; } @@ -2938,9 +2940,8 @@ ControlPointDrag::motion (GdkEvent* event, bool) cx_frames = min (cx_frames, _point->line().maximum_time()); float const fraction = 1.0 - (cy / _point->line().height()); - bool const push = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier); - _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, push); + _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, _pushing, _final_index); _editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction)); } @@ -2960,7 +2961,7 @@ ControlPointDrag::finished (GdkEvent* event, bool movement_occurred) motion (event, false); } - _point->line().end_drag (); + _point->line().end_drag (_pushing, _final_index); _editor->session()->commit_reversible_command (); } @@ -3051,10 +3052,10 @@ LineDrag::motion (GdkEvent* event, bool) cy = min ((double) _line->height(), cy); double const fraction = 1.0 - (cy / _line->height()); - bool const push = !Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier); + uint32_t ignored; /* we are ignoring x position for this drag, so we can just pass in anything */ - _line->drag_motion (0, fraction, true, push); + _line->drag_motion (0, fraction, true, false, ignored); _editor->verbose_cursor()->set_text (_line->get_verbose_cursor_string (fraction)); } @@ -3063,7 +3064,7 @@ void LineDrag::finished (GdkEvent* event, bool) { motion (event, false); - _line->end_drag (); + _line->end_drag (false, 0); _editor->session()->commit_reversible_command (); } @@ -4376,7 +4377,8 @@ AutomationRangeDrag::motion (GdkEvent*, bool /*first_move*/) for (list::iterator l = _lines.begin(); l != _lines.end(); ++l) { float const f = y_fraction (l->line, _drags->current_pointer_y()); /* we are ignoring x position for this drag, so we can just pass in anything */ - l->line->drag_motion (0, f, true, false); + uint32_t ignored; + l->line->drag_motion (0, f, true, false, ignored); show_verbose_cursor_text (l->line->get_verbose_cursor_relative_string (l->original_fraction, f)); } } @@ -4390,7 +4392,7 @@ AutomationRangeDrag::finished (GdkEvent* event, bool) motion (event, false); for (list::iterator i = _lines.begin(); i != _lines.end(); ++i) { - i->line->end_drag (); + i->line->end_drag (false, 0); } _editor->session()->commit_reversible_command (); diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e78a9fa96a..e3e4b5e665 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -706,6 +706,8 @@ private: double _fixed_grab_y; double _cumulative_x_drag; double _cumulative_y_drag; + bool _pushing; + uint32_t _final_index; static double _zero_gain_fraction; }; diff --git a/gtk2_ardour/region_gain_line.cc b/gtk2_ardour/region_gain_line.cc index 39e1b7fda3..8dfbdeeff4 100644 --- a/gtk2_ardour/region_gain_line.cc +++ b/gtk2_ardour/region_gain_line.cc @@ -87,13 +87,13 @@ AudioRegionGainLine::remove_point (ControlPoint& cp) } void -AudioRegionGainLine::end_drag () +AudioRegionGainLine::end_drag (bool with_push, uint32_t final_index) { if (!rv.audio_region()->envelope_active()) { rv.audio_region()->set_envelope_active(true); trackview.session()->add_command(new MementoCommand(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state())); } - AutomationLine::end_drag (); + AutomationLine::end_drag (with_push, final_index); } diff --git a/gtk2_ardour/region_gain_line.h b/gtk2_ardour/region_gain_line.h index aca8b523a1..c0b843acd0 100644 --- a/gtk2_ardour/region_gain_line.h +++ b/gtk2_ardour/region_gain_line.h @@ -39,7 +39,7 @@ class AudioRegionGainLine : public AutomationLine AudioRegionGainLine (const std::string & name, AudioRegionView&, ArdourCanvas::Group& parent, boost::shared_ptr); void start_drag_single (ControlPoint*, double, float); - void end_drag (); + void end_drag (bool with_push, uint32_t final_index); void remove_point (ControlPoint&);