summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-20 02:54:23 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-20 02:54:23 +0000
commit5de9a8f38b0e18317b2b23c5b8698d0d29eba12b (patch)
tree2068d91f2e1af148386e855cee397d332709f4c6 /gtk2_ardour/midi_region_view.cc
parentc2a93a9b3855f85830a715757b8c131113bc9a3e (diff)
make mouse range mode do something interesting when in internal/note edit mode. not entirely finished because the usual modifiers to add/extend the selection don't work correctly. note that this works both on the scroomer (where the modifiers do work correctly) and in the track (where they do not)
git-svn-id: svn://localhost/ardour2/branches/3.0@11273 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc48
1 files changed, 44 insertions, 4 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 196f0f0960..dcd760484c 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -435,7 +435,7 @@ MidiRegionView::button_press (GdkEventButton* ev)
Editor* editor = dynamic_cast<Editor *> (&trackview.editor());
MouseMode m = editor->current_mouse_mode();
-
+
if (m == MouseObject && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
pre_press_cursor = editor->get_canvas_cursor ();
editor->set_canvas_cursor (editor->cursors()->midi_pencil);
@@ -480,6 +480,11 @@ MidiRegionView::button_release (GdkEventButton* ev)
case Pressed: // Clicked
switch (editor.current_mouse_mode()) {
+ case MouseRange:
+ /* no motion occured - simple click */
+ clear_selection ();
+ break;
+
case MouseObject:
case MouseTimeFX:
{
@@ -595,20 +600,23 @@ MidiRegionView::motion (GdkEventMotion* ev)
_mouse_state = AddDragging;
remove_ghost_note ();
editor.verbose_cursor()->hide ();
- cerr << "starting note create drag\n";
-
return true;
- } else {
+ } else if (m == MouseObject) {
editor.drags()->set (new MidiRubberbandSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
_mouse_state = SelectRectDragging;
return true;
+ } else if (m == MouseRange) {
+ editor.drags()->set (new MidiVerticalSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
+ _mouse_state = SelectVerticalDragging;
+ return true;
}
}
return false;
case SelectRectDragging:
+ case SelectVerticalDragging:
case AddDragging:
editor.drags()->motion_handler ((GdkEvent *) ev, false);
break;
@@ -2209,6 +2217,38 @@ MidiRegionView::update_drag_selection(double x1, double x2, double y1, double y2
}
void
+MidiRegionView::update_vertical_drag_selection (double y1, double y2, bool extend)
+{
+ if (y1 > y2) {
+ swap (y1, y2);
+ }
+
+ // TODO: Make this faster by storing the last updated selection rect, and only
+ // adjusting things that are in the area that appears/disappeared.
+ // We probably need a tree to be able to find events in O(log(n)) time.
+
+ for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
+
+ /* check if any corner of the note is inside the rect
+
+ Notes:
+ 1) this is computing "touched by", not "contained by" the rect.
+ 2) this does not require that events be sorted in time.
+ */
+
+ if (((*i)->y1() >= y1 && (*i)->y1() <= y2)) {
+ // within y- (note-) range
+ if (!(*i)->selected()) {
+ add_to_selection (*i);
+ }
+ } else if ((*i)->selected() && !extend) {
+ // Not inside rectangle
+ remove_from_selection (*i);
+ }
+ }
+}
+
+void
MidiRegionView::remove_from_selection (CanvasNoteEvent* ev)
{
Selection::iterator i = _selection.find (ev);