+
+ if (ev->selected())
+ ev->selected(false);
+}
+
+
+void
+MidiRegionView::update_drag_selection(double x1, double x2, double y1, double y2)
+{
+ const double last_y = std::min(y1, y2);
+ const double y = std::max(y1, y2);
+
+ // FIXME: so, so, so much slower than this should be
+
+ if (x1 < x2) {
+ for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) {
+ if ((*i)->x1() >= x1 && (*i)->x1() <= x2 && (*i)->y1() >= last_y && (*i)->y1() <= y) {
+ (*i)->selected(true);
+ _selection.insert(*i);
+ } else {
+ (*i)->selected(false);
+ _selection.erase(*i);
+ }
+ }
+ } else {
+ for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) {
+ if ((*i)->x2() <= x1 && (*i)->x2() >= x2 && (*i)->y1() >= last_y && (*i)->y1() <= y) {
+ (*i)->selected(true);
+ _selection.insert(*i);
+ } else {
+ (*i)->selected(false);
+ _selection.erase(*i);
+ }
+ }
+ }
+}
+
+
+void
+MidiRegionView::move_selection(double dx, double dy)
+{
+ for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i)
+ (*i)->item()->move(dx, dy);
+}
+
+
+void
+MidiRegionView::note_dropped(CanvasMidiEvent* ev, double dt, uint8_t dnote)
+{
+ // TODO: This would be faster/nicer with a MoveCommand that doesn't need to copy...
+ if (_selection.find(ev) != _selection.end()) {
+ start_delta_command();
+
+ for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
+ command_remove_note(*i);
+ MidiModel::Note copy(*(*i)->note());
+
+ copy.set_time((*i)->note()->time() + dt);
+ copy.set_note((*i)->note()->note() + dnote);
+
+ command_add_note(copy);
+ }
+ apply_command();
+ }