cleaner version of previous commit
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 15 Sep 2010 16:54:17 +0000 (16:54 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 15 Sep 2010 16:54:17 +0000 (16:54 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7783 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h

index 35183c59f5d82f7cbb34a895b03e2000c30d120e..14b0bd83d3c40b4ec58340b0bc24d2a66d72c20e 100644 (file)
@@ -3715,21 +3715,15 @@ NoteDrag::motion (GdkEvent *, bool)
        double const tdy = dy * _note_height - _cumulative_dy;
 
        if (tdx || tdy) {
-               _region->move_selection (tdx, tdy);
                _cumulative_dx += tdx;
                _cumulative_dy += tdy;
 
+               _region->move_selection (tdx, tdy, _cumulative_dy);
+
                 char buf[12];
                 snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (_primary->note()->note() + dy).c_str(),
                           (int) floor (_primary->note()->note() + dy));
                 
-                if (dy) {
-                        boost::shared_ptr<Evoral::Note<Evoral::MusicalTime> > 
-                                moved_note (new Evoral::Note<Evoral::MusicalTime> (*(_primary->note())));
-                        moved_note->set_note (moved_note->note() + dy);
-                        _region->play_midi_note (moved_note);
-                }
-
                _editor->show_verbose_canvas_cursor_with (buf);
         }
 }
index ee86a3869721deb9f025a88b9c92fa0ec7dd5eed..cd26a0c81fb1e6b64eb2e1bbd4c4f66be928d943 100644 (file)
@@ -1316,7 +1316,10 @@ MidiRegionView::play_midi_note(boost::shared_ptr<NoteType> note)
        }
 
        RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
-       assert(route_ui);
+        
+        if (!route_ui || !route_ui->midi_track()) {
+                return;
+        }
 
        route_ui->midi_track()->write_immediate_event(
                        note->on_event().size(), note->on_event().buffer());
@@ -1337,7 +1340,10 @@ bool
 MidiRegionView::play_midi_note_off(boost::shared_ptr<NoteType> note)
 {
        RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
-       assert(route_ui);
+
+        if (!route_ui || !route_ui->midi_track()) {
+                return false;
+        }
 
        route_ui->midi_track()->write_immediate_event(
                        note->off_event().size(), note->off_event().buffer());
@@ -1953,10 +1959,17 @@ MidiRegionView::add_to_selection (CanvasNoteEvent* ev)
 }
 
 void
-MidiRegionView::move_selection(double dx, double dy)
+MidiRegionView::move_selection(double dx, double dy, double cumulative_dy)
 {
        for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
                (*i)->move_event(dx, dy);
+
+                if (dy) {
+                        boost::shared_ptr<NoteType> 
+                                moved_note (new NoteType (*((*i)->note())));
+                        moved_note->set_note (moved_note->note() + cumulative_dy);
+                        play_midi_note (moved_note);
+                }
        }
 }
 
index ce7b3082c16f1fd21f3af03935e9ce9762e63074..b0cc505aeee519eed45a1b233d41e092716cabae 100644 (file)
@@ -199,7 +199,7 @@ class MidiRegionView : public RegionView
        void   delete_note (boost::shared_ptr<NoteType>);
        size_t selection_size() { return _selection.size(); }
 
-       void move_selection(double dx, double dy);
+       void move_selection(double dx, double dy, double cumulative_dy);
        void note_dropped (ArdourCanvas::CanvasNoteEvent* ev, ARDOUR::frameoffset_t, int8_t d_note);
 
        void select_matching_notes (uint8_t notenum, uint16_t channel_mask, bool add, bool extend);
@@ -303,7 +303,6 @@ class MidiRegionView : public RegionView
   private:
 
        friend class EditNoteDialog;
-        friend class NoteDrag;
 
        /** Play the NoteOn event of the given note immediately
         * and schedule the playback of the corresponding NoteOff event.