summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-11-20 04:49:18 +1100
committernick_m <mainsbridge@gmail.com>2016-11-20 04:49:18 +1100
commitcb64e926c2b2719096061272e87fa96f2f1b1079 (patch)
tree3577ccb9eacc08e8cd6c6794ecf4cb637d995c8d /gtk2_ardour
parent0e0b7667edf1686d36bc2bad85d7396321e1e2ec (diff)
NoteCreateDrag starts on button press.
- removes the separation between click and drag-creation of notes noth now handled by the drag code).
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_drag.cc32
-rw-r--r--gtk2_ardour/midi_region_view.cc37
2 files changed, 27 insertions, 42 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 48b985da99..6477d47843 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -6226,14 +6226,16 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
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);
+ }
+
double eqaf = map.exact_qn_at_frame (pf, divisions);
+ double end_qn = eqaf;
if (divisions != 0) {
- bool success = false;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf);
- if (!success) {
- grid_beats = Evoral::Beats(1);
- }
const double qaf = map.quarter_note_at_frame (pf);
@@ -6246,15 +6248,18 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
eqaf -= grid_beats.to_double();
}
}
+ /* minimum initial length is grid beats */
+ end_qn = eqaf + grid_beats.to_double();
_note[0] = map.frame_at_quarter_note (eqaf) - _region_view->region()->position();
- _note[1] = _note[0];
+ _note[1] = map.frame_at_quarter_note (end_qn) - _region_view->region()->position();
MidiStreamView* sv = _region_view->midi_stream_view ();
- double const x = _editor->sample_to_pixel (_note[0]);
+ double const x0 = _editor->sample_to_pixel (_note[0]);
+ double const x1 = _editor->sample_to_pixel (_note[1]);
double const y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
- _drag_rect->set (ArdourCanvas::Rect (x, y, x, y + floor (_region_view->midi_stream_view()->note_height ())));
+ _drag_rect->set (ArdourCanvas::Rect (x0, y, x1, y + floor (_region_view->midi_stream_view()->note_height ())));
_drag_rect->set_outline_all ();
_drag_rect->set_outline_color (0xffffff99);
_drag_rect->set_fill_color (0xffffff66);
@@ -6298,25 +6303,20 @@ NoteCreateDrag::motion (GdkEvent* event, bool)
void
NoteCreateDrag::finished (GdkEvent* ev, bool had_movement)
{
- if (!had_movement) {
- return;
- }
-
+ /* we create a note even if there was no movement */
framepos_t const start = min (_note[0], _note[1]);
framepos_t const start_sess_rel = start + _region_view->region()->position();
framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
-
framecnt_t const g = grid_frames (start);
- Evoral::Beats const one_tick = Evoral::Beats::ticks(1);
if (_editor->get_grid_music_divisions (ev->button.state) != 0 && length < g) {
length = g;
}
TempoMap& map (_editor->session()->tempo_map());
- const double qn_length = map.quarter_note_at_frame (start_sess_rel + length) - map.quarter_note_at_frame (start_sess_rel);
+ const double qn_length = map.quarter_notes_between_frames (start_sess_rel, start_sess_rel + length);
+ Evoral::Beats qn_length_beats = max (Evoral::Beats::ticks(1), Evoral::Beats (qn_length));
- Evoral::Beats qn_length_beats = max (one_tick, Evoral::Beats (qn_length));
_region_view->create_note_at (start, _drag_rect->y0(), qn_length_beats, ev->button.state, false);
}
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 45ad01613c..34226aab2e 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -499,6 +499,13 @@ MidiRegionView::button_press (GdkEventButton* ev)
_pressed_button = ev->button;
_mouse_state = Pressed;
+ if (m == MouseDraw || (m == MouseContent && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()))) {
+ editor->drags()->set (new NoteCreateDrag (dynamic_cast<Editor *> (editor), group, this), (GdkEvent *) ev);
+ _mouse_state = AddDragging;
+ remove_ghost_note ();
+ hide_verbose_cursor ();
+ }
+
return true;
}
@@ -541,29 +548,13 @@ MidiRegionView::button_release (GdkEventButton* ev)
case MouseTimeFX:
{
_mouse_changed_selection = true;
-
- if (Keyboard::is_insert_note_event(ev)) {
-
- double event_x, event_y;
-
- event_x = ev->x;
- event_y = ev->y;
- group->canvas_to_item (event_x, event_y);
-
- Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x) + _region->position());
- create_note_at (editor.pixel_to_sample (event_x), event_y, beats, ev->state, true);
- } else {
- clear_editor_note_selection ();
- }
+ clear_editor_note_selection ();
break;
}
case MouseDraw:
- {
- Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x) + _region->position());
- create_note_at (editor.pixel_to_sample (event_x), event_y, beats, ev->state, true);
- break;
- }
+ break;
+
default:
break;
}
@@ -644,13 +635,7 @@ MidiRegionView::motion (GdkEventMotion* ev)
MouseMode m = editor.current_mouse_mode();
- if (m == MouseDraw || (m == MouseContent && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()))) {
- editor.drags()->set (new NoteCreateDrag (dynamic_cast<Editor *> (&editor), group, this), (GdkEvent *) ev);
- _mouse_state = AddDragging;
- remove_ghost_note ();
- hide_verbose_cursor ();
- return true;
- } else if (m == MouseContent) {
+ if (m == MouseContent && !Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
editor.drags()->set (new MidiRubberbandSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
if (!Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
clear_editor_note_selection ();