clean up ghost note wrt create drag.

- hide ghost note when add dragging.

	- new note length snaps as per ghost note start (shifted snap).

	- prevent ghost note from appearing before region start.
This commit is contained in:
nick_m
2016-10-26 04:52:09 +11:00
parent 927b16aa53
commit 24846f478b
2 changed files with 44 additions and 6 deletions

View File

@@ -6205,7 +6205,7 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
*/
const double rem = eqaf - qaf;
if (rem >= 0.0 && eqaf - grid_beats.to_double() > _region_view->region()->pulse() * 4.0) {
if (rem >= 0.0) {
eqaf -= grid_beats.to_double();
}
}
@@ -6226,7 +6226,32 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
void
NoteCreateDrag::motion (GdkEvent* event, bool)
{
_note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
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);
double eqaf = map.exact_qn_at_frame (pf, divisions);
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);
/* Hack so that we always snap to the note that we are over, instead of snapping
to the next one if we're more than halfway through the one we're over.
*/
const double rem = eqaf - qaf;
if (rem >= 0.0) {
eqaf -= grid_beats.to_double();
}
eqaf += grid_beats.to_double();
}
_note[1] = max ((framepos_t)0, map.frame_at_quarter_note (eqaf) - _region_view->region()->position ());
double const x0 = _editor->sample_to_pixel (_note[0]);
double const x1 = _editor->sample_to_pixel (_note[1]);
_drag_rect->set_x0 (std::min(x0, x1));

View File

@@ -599,7 +599,12 @@ MidiRegionView::motion (GdkEventMotion* ev)
if (!_note_entered) {
if (!_ghost_note && editor.current_mouse_mode() == MouseContent &&
if (_mouse_state == AddDragging) {
if (_ghost_note) {
remove_ghost_note ();
}
} else if (!_ghost_note && editor.current_mouse_mode() == MouseContent &&
Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()) &&
_mouse_state != AddDragging) {
@@ -3747,9 +3752,17 @@ MidiRegionView::update_ghost_note (double x, double y, uint32_t state)
framepos_t const unsnapped_frame = editor.pixel_to_sample (x);
const int32_t divisions = editor.get_grid_music_divisions (state);
const double snapped_region_qn = snap_frame_to_grid_underneath (unsnapped_frame, divisions, true).to_double();
const Evoral::Beats snapped_beats = snap_frame_to_grid_underneath (unsnapped_frame, divisions, true);
/* ghost note may have been snapped before region */
if (_ghost_note && snapped_beats.to_double() < 0.0) {
_ghost_note->hide();
return;
} else if (_ghost_note) {
_ghost_note->show();
}
Evoral::Beats snapped_beats = Evoral::Beats (snapped_region_qn);
/* calculate time in beats relative to start of source */
const Evoral::Beats length = get_grid_beats(unsnapped_frame + _region->position());
@@ -4132,7 +4145,7 @@ MidiRegionView::snap_frame_to_grid_underneath (framepos_t p, int32_t divisions,
*/
const Evoral::Beats grid_beats = get_grid_beats (p + _region->position());
const double rem = eqaf - qaf;
if (rem >= 0.0 && eqaf - grid_beats.to_double() > _region->pulse() * 4.0) {
if (rem >= 0.0) {
eqaf -= grid_beats.to_double();
}
}