summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-08-04 05:34:51 +0000
committerDavid Robillard <d@drobilla.net>2007-08-04 05:34:51 +0000
commita5abcd306ba589411aa8b4e5b2729621bdc77d3a (patch)
tree924691956684b530cf55d66569f376c07e2e3377 /gtk2_ardour
parent604a0079ce5882cd6afd619b79020d9c694d7165 (diff)
Obey snap setting for MIDI stuff.
git-svn-id: svn://localhost/ardour2/trunk@2238 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/midi_region_view.cc19
-rw-r--r--gtk2_ardour/public_editor.h3
2 files changed, 19 insertions, 3 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 6735efce15..fde477ffc0 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -190,9 +190,12 @@ MidiRegionView::canvas_event(GdkEvent* ev)
drag_start_x = event_x;
drag_start_y = event_y;
- drag_rect = new ArdourCanvas::SimpleRect(*group);
- drag_rect->property_x1() = event_x;
+ nframes_t event_frame = midi_view()->editor.pixel_to_frame(event_x);
+ midi_view()->editor.snap_to(event_frame);
+ drag_rect = new ArdourCanvas::SimpleRect(*group);
+ drag_rect->property_x1() = midi_view()->editor.frame_to_pixel(event_frame);
+
drag_rect->property_y1() = midi_stream_view()->note_to_y(midi_stream_view()->y_to_note(event_y));
drag_rect->property_x2() = event_x;
drag_rect->property_y2() = drag_rect->property_y1() + floor(midi_stream_view()->note_height());
@@ -217,6 +220,12 @@ MidiRegionView::canvas_event(GdkEvent* ev)
event_y = t_y;
}
+ if (_state == AddDragging) {
+ nframes_t event_frame = midi_view()->editor.pixel_to_frame(event_x);
+ midi_view()->editor.snap_to(event_frame);
+ event_x = midi_view()->editor.frame_to_pixel(event_frame);
+ }
+
if (drag_rect)
drag_rect->property_x2() = event_x;
@@ -240,8 +249,12 @@ MidiRegionView::canvas_event(GdkEvent* ev)
group->ungrab(ev->button.time);
switch (_state) {
case Pressed: // Clicked
- if (ev->button.button == 3)
+ if (ev->button.button == 3) {
+ nframes_t event_frame = midi_view()->editor.pixel_to_frame(event_x);
+ midi_view()->editor.snap_to(event_frame);
+ event_x = midi_view()->editor.frame_to_pixel(event_frame);
create_note_at(event_x, event_y, _default_note_length);
+ }
_state = None;
return true;
case SelectDragging: // Select drag done
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index 0730d371b9..ffd34469c8 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -112,6 +112,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
* @param t Snap threshold in `units'.
*/
virtual void set_snap_threshold (double t) = 0;
+
+ /** Snap a value according to the current snap setting. */
+ virtual void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false) = 0;
/** Undo some transactions.
* @param n Number of transactions to undo.