From db1fa42f14c54d9a9714aafe35d669a81469f964 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Jun 2010 21:27:36 +0000 Subject: [PATCH] start tracking note overlaps while moving notes git-svn-id: svn://localhost/ardour2/branches/3.0@7228 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_drag.cc | 30 ++++++++++++++++++++++++++---- libs/evoral/evoral/Sequence.hpp | 6 ++++-- libs/evoral/src/Sequence.cpp | 16 ++++++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 231946f661..7c8c192cdd 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3746,13 +3746,35 @@ NoteDrag::motion (GdkEvent*, bool) } if (dx || dy) { + + CanvasNoteEvent* cnote = dynamic_cast(_item); + Evoral::MusicalTime new_time; + + if (drag_delta_x) { + nframes64_t start_frames = region->beats_to_frames(cnote->note()->time()); + if (drag_delta_x >= 0) { + start_frames += region->snap_frame_to_frame(_editor->pixel_to_frame(drag_delta_x)); + } else { + start_frames -= region->snap_frame_to_frame(_editor->pixel_to_frame(-drag_delta_x)); + } + new_time = region->frames_to_beats(start_frames); + } else { + new_time = cnote->note()->time(); + } + + boost::shared_ptr > check_note ( + new Evoral::Note (cnote->note()->channel(), + new_time, + cnote->note()->length(), + cnote->note()->note() + drag_delta_note, + cnote->note()->velocity())); + bool overlaps = cnote->region_view().midi_region()->model()->overlaps (check_note, cnote->note()); + region->move_selection (dx, dy); - CanvasNoteEvent* cnote = dynamic_cast(_item); - char buf[12]; - snprintf (buf, sizeof (buf), "%s (%g)", Evoral::midi_note_name (cnote->note()->note()).c_str(), - (int) cnote->note()->note() + drag_delta_note); + snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (cnote->note()->note()).c_str(), + (int) floor ((cnote->note()->note() + drag_delta_note))); _editor->show_verbose_canvas_cursor_with (buf); } } diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index ae9ab05104..9e1083b3fd 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -231,7 +231,8 @@ public: bool edited() const { return _edited; } void set_edited(bool yn) { _edited = yn; } - bool overlaps (const boost::shared_ptr< Note