Compare commits

...

3 Commits

Author SHA1 Message Date
Ben Loftis 83d0892777 when drawing notes, the grid should be scaled to the zoom scale
this prevents the case where have enabled snap, and you add a note that
 appears to be on a bar line. but actually it is {some Grid value} off,
 it just looks right because of pixel rounding.
2022-05-11 11:45:33 -05:00
Ben Loftis a60dfc19d2 take Snap enablement into account when drawing new notes
* snap_to_bbt assumes that snap is enabled and you want to snap to bbt
* snap_to() is the generic form to snap to the user's snap+grid settings
2022-05-11 11:38:54 -05:00
Ben Loftis de9f18b4f9 when Drawing MIDI notes, enforce a minimum length
This fixes the issue where you click to create a note, but move the mouse
 just a little, resulting in a note of invisibly small length

Do the calculation in ::motion so it displays the final
 size while you are dragging. "what you see is what you will get"
2022-05-10 20:00:26 -05:00
2 changed files with 9 additions and 9 deletions

View File

@ -6839,7 +6839,9 @@ NoteCreateDrag::~NoteCreateDrag ()
Temporal::Beats
NoteCreateDrag::round_down_to_grid (timepos_t const & pos, GdkEvent const * event) const
{
return _editor->snap_to_bbt (pos, RoundDownMaybe, SnapToGrid_Unscaled).beats ();
timepos_t snapped = pos;
_editor->snap_to (snapped, RoundDownMaybe, SnapToGrid_Scaled);
return snapped.beats();
}
void
@ -6881,6 +6883,10 @@ NoteCreateDrag::motion (GdkEvent* event, bool)
const timepos_t pos = _drags->current_pointer_time ();
Temporal::Beats aligned_beats = round_down_to_grid (pos, event);
//when the user clicks and starts a drag to define the note's length, require notes to be at least |this| long
const Temporal::Beats min_length (_region_view->get_draw_length_beats (pos));
aligned_beats = aligned_beats+min_length;
_note[1] = timepos_t (max (Temporal::Beats(), aligned_beats));
const timepos_t rrp1 (_region_view->region()->region_relative_position (_note[0]));
@ -6902,13 +6908,6 @@ NoteCreateDrag::finished (GdkEvent* ev, bool had_movement)
Beats const start = _region_view->region()->absolute_time_to_region_beats (min (_note[0], _note[1]));
Beats length = max (Beats (0, 1), (_note[0].distance (_note[1]).abs().beats()));
GridType grid_to_use = _editor->draw_length() == DRAW_LEN_AUTO ? _editor->grid_type() : _editor->draw_length();
int32_t div = _editor->get_grid_music_divisions (grid_to_use, ev->button.state);
if (div > 0) {
length = length.round_to_subdivision (div, RoundUpMaybe);
}
/* create_note_at() implements UNDO for us */
_region_view->create_note_at (timepos_t (start), _drag_rect->y0(), length, ev->button.state, false);
}

View File

@ -4092,7 +4092,8 @@ MidiRegionView::update_ghost_note (double x, double y, uint32_t state)
PublicEditor& editor = trackview.editor ();
samplepos_t const unsnapped_sample = editor.pixel_to_sample (global_x);
const Temporal::timepos_t snapped_pos = editor.snap_to_bbt (timepos_t (unsnapped_sample), RoundDownAlways, SnapToGrid_Unscaled);
Temporal::timepos_t snapped_pos = timepos_t (unsnapped_sample);
editor.snap_to (snapped_pos, RoundDownAlways, SnapToGrid_Scaled);
const Temporal::Beats snapped_beats = _region->position().distance (snapped_pos).beats ();
/* prevent Percussive mode from displaying a ghost hit at region end */