diff options
author | nick_m <mainsbridge@gmail.com> | 2016-11-21 04:02:21 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-11-21 04:02:21 +1100 |
commit | 5bcb9adbf801f436c17932e75915c160c7ced33f (patch) | |
tree | 969b9494df6b2afbf7ef8ab481bacf5b4301b195 /gtk2_ardour/editor_drag.cc | |
parent | 4d0422a0fc101e33b9ec93f473c7cf39d6319b0a (diff) |
rework mouse hit creation (percussive mode) - mostly as per #7130.
- snap behaviour is round to nearest
- holding down button 1 while dragging creates many
(if not already present) hits.
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index bc082e9c8c..6a663daf9f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -6333,6 +6333,100 @@ NoteCreateDrag::aborted (bool) } +PercussiveCreateDrag::PercussiveCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv) + : Drag (e, i) + , _region_view (rv) + , _y (0.0) +{ +} + +PercussiveCreateDrag::~PercussiveCreateDrag () +{ +} + +framecnt_t +PercussiveCreateDrag::grid_frames (framepos_t t) const +{ + bool success; + Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t); + if (!success) { + grid_beats = Evoral::Beats(1); + } + const Evoral::Beats t_beats = _region_view->region_frames_to_region_beats (t); + + return _region_view->region_beats_to_region_frames (t_beats + grid_beats) + - _region_view->region_beats_to_region_frames (t_beats); + +} + +void +PercussiveCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) +{ + Drag::start_grab (event, cursor); + + TempoMap& map (_editor->session()->tempo_map()); + + const framepos_t pf = _drags->current_pointer_frame (); + const int32_t divisions = _editor->get_grid_music_divisions (event->button.state); + + bool success = false; + Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf); + if (!success) { + grid_beats = Evoral::Beats(1); + } + + const double eqaf = map.exact_qn_at_frame (pf, divisions); + const framepos_t start = map.frame_at_quarter_note (eqaf) - _region_view->region()->position(); + + MidiStreamView* sv = _region_view->midi_stream_view (); + _y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y))); + + _region_view->create_note_at (start, _y, grid_beats, event->button.state, false); +} + +void +PercussiveCreateDrag::motion (GdkEvent* event, bool) +{ + TempoMap& map (_editor->session()->tempo_map()); + + const framepos_t pf = _drags->current_pointer_frame (); + const int32_t divisions = _editor->get_grid_music_divisions (event->button.state); + const double eqaf = map.exact_qn_at_frame (pf, divisions); + const framepos_t start = map.frame_at_quarter_note (eqaf) - _region_view->region()->position (); + + MidiStreamView* sv = _region_view->midi_stream_view (); + _y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y))); + + bool success = false; + Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf); + if (!success) { + grid_beats = Evoral::Beats(1); + } + + _region_view->create_note_at (start, _y, grid_beats, event->button.state, false); + +} + +void +PercussiveCreateDrag::finished (GdkEvent* /* ev */, bool /* had_movement */) +{ + +} + +double +PercussiveCreateDrag::y_to_region (double y) const +{ + double x = 0; + _region_view->get_canvas_group()->canvas_to_item (x, y); + return y; +} + +void +PercussiveCreateDrag::aborted (bool) +{ + // umm.. +} + CrossfadeEdgeDrag::CrossfadeEdgeDrag (Editor* e, AudioRegionView* rv, ArdourCanvas::Item* i, bool start_yn) : Drag (e, i) , arv (rv) |