framecnt_t
NoteCreateDrag::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 grid_beats = _region_view->get_grid_beats (t);
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
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 Evoral::Beats grid_beats = _region_view->get_grid_beats (pf);
double eqaf = map.exact_qn_at_frame (pf, divisions);
eqaf -= grid_beats.to_double();
}
}
- /* minimum initial length is grid beats */
- const double end_qn = eqaf + grid_beats.to_double();
_note[0] = map.frame_at_quarter_note (eqaf) - _region_view->region()->position();
- _note[1] = map.frame_at_quarter_note (end_qn) - _region_view->region()->position();
+ /* minimum initial length is grid beats */
+ _note[1] = map.frame_at_quarter_note (eqaf + grid_beats.to_double()) - _region_view->region()->position();
MidiStreamView* sv = _region_view->midi_stream_view ();
double const x0 = _editor->sample_to_pixel (_note[0]);
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 Evoral::Beats grid_beats = _region_view->get_grid_beats (pf);
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
HitCreateDrag::HitCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv)
: Drag (e, i)
, _region_view (rv)
+ , _last_pos (0)
+ , _last_y (0.0)
{
}
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);
+
+ boost::shared_ptr<MidiRegion> mr = _region_view->midi_region();
+
+ if (eqaf >= mr->quarter_note() + mr->length_beats()) {
+ return;
}
- 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 ();
const double 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);
+ Evoral::Beats length = _region_view->get_grid_beats (pf);
+
+ _region_view->create_note_at (start, y, length, event->button.state, false);
+
+ _last_pos = start;
+ _last_y = y;
}
void
MidiStreamView* sv = _region_view->midi_stream_view ();
const double 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);
+ if (_last_pos == start && y == _last_y) {
+ return;
+ }
+
+ Evoral::Beats length = _region_view->get_grid_beats (pf);
+
+ boost::shared_ptr<MidiRegion> mr = _region_view->midi_region();
+ if (eqaf >= mr->quarter_note() + mr->length_beats()) {
+ return;
}
- _region_view->create_note_at (start, y, grid_beats, event->button.state, false);
+ _region_view->create_note_at (start, y, length, event->button.state, false);
+ _last_pos = start;
+ _last_y = y;
}
void
}
void
-RegionCutDrag::motion (GdkEvent*, bool)
+RegionCutDrag::motion (GdkEvent* event, bool)
{
- framepos_t where = _drags->current_pointer_frame();
- _editor->snap_to (where);
+ framepos_t pos = _drags->current_pointer_frame();
+ _editor->snap_to_with_modifier (pos, event);
- line->set_position (where);
+ line->set_position (pos);
}
void
_editor->get_track_canvas()->canvas()->re_enter();
framepos_t pos = _drags->current_pointer_frame();
+ _editor->snap_to_with_modifier (pos, event);
line->hide ();
return;
}
- _editor->split_regions_at (pos, rs, _editor->get_grid_music_divisions (event->button.state));
+ _editor->split_regions_at (pos, rs, _editor->get_grid_music_divisions (event->button.state),
+ false);
}
void