fix push-drags of automation data - previously we did not resync the model with the...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 19 Dec 2012 15:55:06 +0000 (15:55 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 19 Dec 2012 15:55:06 +0000 (15:55 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13681 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_line.cc
gtk2_ardour/automation_line.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/region_gain_line.cc
gtk2_ardour/region_gain_line.h

index b067757cb0eaff7c14c514b30264dfb7611142bb..63b9740c00a8260ae4a555b4782b5051111e9025 100644 (file)
@@ -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<double, float>
-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<double,float> (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;
index 16a410a2fce54b91217d7bd5e8754d203ed5d822..cafeeee2ac1f811bbb145722f6fee0a84f168441 100644 (file)
@@ -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<ControlPoint*>, float, XMLNode *);
-        virtual std::pair<double, float> drag_motion (double, float, bool, bool with_push);
-       virtual void end_drag ();
+        virtual std::pair<double, float> 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;
index a8e9a78dc5f1ebc95a07b65506f2337297329a63..0c309d723458ddb727de2def826b36fc0421d27d 100644 (file)
@@ -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<Line>::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<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
-               i->line->end_drag ();
+               i->line->end_drag (false, 0);
        }
 
        _editor->session()->commit_reversible_command ();
index e78a9fa96a4d0ff52dd91b666ff5a2c682bc0dda..e3e4b5e665cf2ec48d8bfa7ad2910e5b464ccda6 100644 (file)
@@ -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;
 };
 
index 39e1b7fda34bad6d1621ca8aaa59feeada1edca1..8dfbdeeff49edbea1c774102a98605e72d645d99 100644 (file)
@@ -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<AudioRegion>(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state()));
        }
 
-       AutomationLine::end_drag ();
+       AutomationLine::end_drag (with_push, final_index);
 }
 
index aca8b523a180567cd8bcb9ca453eea519c1adecd..c0b843acd076b103b6692052d2e7240a6d9728b2 100644 (file)
@@ -39,7 +39,7 @@ class AudioRegionGainLine : public AutomationLine
        AudioRegionGainLine (const std::string & name, AudioRegionView&, ArdourCanvas::Group& parent, boost::shared_ptr<ARDOUR::AutomationList>);
 
         void start_drag_single (ControlPoint*, double, float);
-       void end_drag ();
+        void end_drag (bool with_push, uint32_t final_index);
 
        void remove_point (ControlPoint&);