new_grid: The Return of the snap_to_X functions.
We no longer assume that Snap always uses the visible ruler lines. If you want to snap to the grid, and ignore the users zoom scale, use SnapPref::SnapToGrid_Unscaled This fixes 2 (known) oversights: "snap region(s) to grid" and "regions whose start are left of the canvas edge".
This commit is contained in:
parent
83ce11e411
commit
0883f02de9
|
@ -2692,7 +2692,7 @@ Editor::set_snapped_cursor_position (samplepos_t pos)
|
|||
* @param event Event to get current key modifier information from, or 0.
|
||||
*/
|
||||
void
|
||||
Editor::snap_to_with_modifier (MusicSample& start, GdkEvent const * event, RoundMode direction, SnapPref pref, bool for_mark)
|
||||
Editor::snap_to_with_modifier (MusicSample& start, GdkEvent const * event, RoundMode direction, SnapPref pref)
|
||||
{
|
||||
if (!_session || !event) {
|
||||
return;
|
||||
|
@ -2700,16 +2700,16 @@ Editor::snap_to_with_modifier (MusicSample& start, GdkEvent const * event, Round
|
|||
|
||||
if (ArdourKeyboard::indicates_snap (event->button.state)) {
|
||||
if (_snap_mode == SnapOff) {
|
||||
snap_to_internal (start, direction, pref, for_mark);
|
||||
snap_to_internal (start, direction, pref);
|
||||
} else {
|
||||
start.set (start.sample, 0);
|
||||
}
|
||||
} else {
|
||||
if (_snap_mode != SnapOff) {
|
||||
snap_to_internal (start, direction, pref, for_mark);
|
||||
snap_to_internal (start, direction, pref);
|
||||
} else if (ArdourKeyboard::indicates_snap_delta (event->button.state)) {
|
||||
/* SnapOff, but we pressed the snap_delta modifier */
|
||||
snap_to_internal (start, direction, pref, for_mark);
|
||||
snap_to_internal (start, direction, pref);
|
||||
} else {
|
||||
start.set (start.sample, 0);
|
||||
}
|
||||
|
@ -2717,14 +2717,14 @@ Editor::snap_to_with_modifier (MusicSample& start, GdkEvent const * event, Round
|
|||
}
|
||||
|
||||
void
|
||||
Editor::snap_to (MusicSample& start, RoundMode direction, SnapPref pref, bool for_mark, bool ensure_snap)
|
||||
Editor::snap_to (MusicSample& start, RoundMode direction, SnapPref pref, bool ensure_snap)
|
||||
{
|
||||
if (!_session || (_snap_mode == SnapOff && !ensure_snap)) {
|
||||
start.set (start.sample, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
snap_to_internal (start, direction, pref, for_mark, ensure_snap);
|
||||
snap_to_internal (start, direction, pref, ensure_snap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2739,61 +2739,239 @@ check_best_snap (samplepos_t presnap, samplepos_t &test, samplepos_t &dist, samp
|
|||
test = max_samplepos; // reset this so it doesn't get accidentally reused
|
||||
}
|
||||
|
||||
samplepos_t
|
||||
Editor::snap_to_grid (vector<ArdourCanvas::Ruler::Mark> marks, samplepos_t presnap, RoundMode direction)
|
||||
MusicSample
|
||||
Editor::snap_to_timecode ( MusicSample presnap, RoundMode direction, SnapPref gpref )
|
||||
{
|
||||
if (marks.empty()) return presnap;
|
||||
samplepos_t start = presnap.sample;
|
||||
const samplepos_t one_timecode_second = (samplepos_t)(rint(_session->timecode_frames_per_second()) * _session->samples_per_timecode_frame());
|
||||
samplepos_t one_timecode_minute = (samplepos_t)(rint(_session->timecode_frames_per_second()) * _session->samples_per_timecode_frame() * 60);
|
||||
|
||||
samplepos_t before;
|
||||
samplepos_t after;
|
||||
samplepos_t test = presnap;
|
||||
TimecodeRulerScale scale = ( gpref != SnapToGrid_Unscaled ) ? timecode_ruler_scale : timecode_show_samples;
|
||||
|
||||
before = after = max_samplepos;
|
||||
|
||||
/* get marks to either side of presnap */
|
||||
vector<ArdourCanvas::Ruler::Mark>::const_iterator m = marks.begin();
|
||||
while (m != marks.end() && (m->position < presnap)) {
|
||||
++m;
|
||||
}
|
||||
|
||||
if (m == marks.end ()) {
|
||||
/* ran out of marks */
|
||||
before = marks.back().position;
|
||||
}
|
||||
|
||||
after = m->position;
|
||||
|
||||
if (m != marks.begin ()) {
|
||||
--m;
|
||||
before = m->position;
|
||||
}
|
||||
|
||||
if (before == max_samplepos && after == max_samplepos) {
|
||||
/* No grid to snap to, so just don't snap */
|
||||
return presnap;
|
||||
} else if (before == max_samplepos) {
|
||||
test = after;
|
||||
} else if (after == max_samplepos) {
|
||||
test = before;
|
||||
} else {
|
||||
if ((direction == RoundUpMaybe || direction == RoundUpAlways))
|
||||
test = after;
|
||||
else if ((direction == RoundDownMaybe || direction == RoundDownAlways))
|
||||
test = before;
|
||||
else if (direction == 0) {
|
||||
if ((presnap - before) < (after - presnap)) {
|
||||
test = before;
|
||||
} else {
|
||||
test = after;
|
||||
}
|
||||
switch (scale) {
|
||||
case timecode_show_bits:
|
||||
case timecode_show_samples:
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
fmod((double)start, (double)_session->samples_per_timecode_frame()) == 0) {
|
||||
/* start is already on a whole timecode frame, do nothing */
|
||||
} else if (((direction == 0) && (fmod((double)start, (double)_session->samples_per_timecode_frame()) > (_session->samples_per_timecode_frame() / 2))) || (direction > 0)) {
|
||||
start = (samplepos_t) (ceil ((double) start / _session->samples_per_timecode_frame()) * _session->samples_per_timecode_frame());
|
||||
} else {
|
||||
start = (samplepos_t) (floor ((double) start / _session->samples_per_timecode_frame()) * _session->samples_per_timecode_frame());
|
||||
}
|
||||
break;
|
||||
|
||||
case timecode_show_seconds:
|
||||
if (_session->config.get_timecode_offset_negative()) {
|
||||
start += _session->config.get_timecode_offset ();
|
||||
} else {
|
||||
start -= _session->config.get_timecode_offset ();
|
||||
}
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
(start % one_timecode_second == 0)) {
|
||||
/* start is already on a whole second, do nothing */
|
||||
} else if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
|
||||
start = (samplepos_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
|
||||
} else {
|
||||
start = (samplepos_t) floor ((double) start / one_timecode_second) * one_timecode_second;
|
||||
}
|
||||
|
||||
if (_session->config.get_timecode_offset_negative()) {
|
||||
start -= _session->config.get_timecode_offset ();
|
||||
} else {
|
||||
start += _session->config.get_timecode_offset ();
|
||||
}
|
||||
break;
|
||||
|
||||
case timecode_show_minutes:
|
||||
case timecode_show_hours:
|
||||
case timecode_show_many_hours:
|
||||
if (_session->config.get_timecode_offset_negative()) {
|
||||
start += _session->config.get_timecode_offset ();
|
||||
} else {
|
||||
start -= _session->config.get_timecode_offset ();
|
||||
}
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
(start % one_timecode_minute == 0)) {
|
||||
/* start is already on a whole minute, do nothing */
|
||||
} else if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
|
||||
start = (samplepos_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
|
||||
} else {
|
||||
start = (samplepos_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
|
||||
}
|
||||
if (_session->config.get_timecode_offset_negative()) {
|
||||
start -= _session->config.get_timecode_offset ();
|
||||
} else {
|
||||
start += _session->config.get_timecode_offset ();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fatal << "Editor::smpte_snap_to_internal() called with non-timecode snap type!" << endmsg;
|
||||
}
|
||||
|
||||
return test;
|
||||
MusicSample ret(start,0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MusicSample
|
||||
Editor::snap_to_minsec ( MusicSample presnap, RoundMode direction, SnapPref gpref )
|
||||
{
|
||||
MusicSample ret(presnap);
|
||||
|
||||
const samplepos_t one_second = _session->sample_rate();
|
||||
const samplepos_t one_minute = one_second * 60;
|
||||
const samplepos_t one_hour = one_minute * 60;
|
||||
|
||||
MinsecRulerScale scale = ( gpref != SnapToGrid_Unscaled ) ? minsec_ruler_scale : minsec_show_seconds;
|
||||
|
||||
switch (scale) {
|
||||
case minsec_show_msecs:
|
||||
case minsec_show_seconds: {
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
presnap.sample % one_second == 0) {
|
||||
/* start is already on a whole second, do nothing */
|
||||
} else if (((direction == 0) && (presnap.sample % one_second > one_second / 2)) || (direction > 0)) {
|
||||
ret.sample = (samplepos_t) ceil ((double) presnap.sample / one_second) * one_second;
|
||||
} else {
|
||||
ret.sample = (samplepos_t) floor ((double) presnap.sample / one_second) * one_second;
|
||||
}
|
||||
} break;
|
||||
|
||||
case minsec_show_minutes: {
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
presnap.sample % one_minute == 0) {
|
||||
/* start is already on a whole minute, do nothing */
|
||||
} else if (((direction == 0) && (presnap.sample % one_minute > one_minute / 2)) || (direction > 0)) {
|
||||
ret.sample = (samplepos_t) ceil ((double) presnap.sample / one_minute) * one_minute;
|
||||
} else {
|
||||
ret.sample = (samplepos_t) floor ((double) presnap.sample / one_minute) * one_minute;
|
||||
}
|
||||
} break;
|
||||
|
||||
default: {
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
presnap.sample % one_hour == 0) {
|
||||
/* start is already on a whole hour, do nothing */
|
||||
} else if (((direction == 0) && (presnap.sample % one_hour > one_hour / 2)) || (direction > 0)) {
|
||||
ret.sample = (samplepos_t) ceil ((double) presnap.sample / one_hour) * one_hour;
|
||||
} else {
|
||||
ret.sample = (samplepos_t) floor ((double) presnap.sample / one_hour) * one_hour;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MusicSample
|
||||
Editor::snap_to_cd_frames ( MusicSample presnap, RoundMode direction, SnapPref gpref )
|
||||
{
|
||||
if ( (gpref != SnapToGrid_Unscaled) && (minsec_ruler_scale != minsec_show_msecs) ) {
|
||||
return snap_to_minsec( presnap, direction, gpref );
|
||||
}
|
||||
|
||||
const samplepos_t one_second = _session->sample_rate();
|
||||
|
||||
MusicSample ret(presnap);
|
||||
|
||||
if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
|
||||
presnap.sample % (one_second/75) == 0) {
|
||||
/* start is already on a whole CD sample, do nothing */
|
||||
} else if (((direction == 0) && (presnap.sample % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
|
||||
ret.sample = (samplepos_t) ceil ((double) presnap.sample / (one_second / 75)) * (one_second / 75);
|
||||
} else {
|
||||
ret.sample = (samplepos_t) floor ((double) presnap.sample / (one_second / 75)) * (one_second / 75);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MusicSample
|
||||
Editor::snap_to_bbt ( MusicSample presnap, RoundMode direction, SnapPref gpref )
|
||||
{
|
||||
MusicSample ret(presnap);
|
||||
|
||||
if ( gpref != SnapToGrid_Unscaled ) { //use the visual grid lines which are limited by the zoom scale that the user selected
|
||||
|
||||
int divisor = 2;
|
||||
switch (_grid_type) {
|
||||
case GridTypeBeatDiv3:
|
||||
case GridTypeBeatDiv6:
|
||||
case GridTypeBeatDiv12:
|
||||
case GridTypeBeatDiv24:
|
||||
divisor = 3;
|
||||
break;
|
||||
case GridTypeBeatDiv5:
|
||||
case GridTypeBeatDiv10:
|
||||
case GridTypeBeatDiv20:
|
||||
divisor = 5;
|
||||
break;
|
||||
case GridTypeBeatDiv7:
|
||||
case GridTypeBeatDiv14:
|
||||
case GridTypeBeatDiv28:
|
||||
divisor = 7;
|
||||
break;
|
||||
default:
|
||||
divisor = 2;
|
||||
};
|
||||
|
||||
BBTRulerScale scale = bbt_ruler_scale;
|
||||
switch (scale) {
|
||||
case bbt_show_many:
|
||||
case bbt_show_64:
|
||||
case bbt_show_16:
|
||||
case bbt_show_4:
|
||||
case bbt_show_1:
|
||||
ret = _session->tempo_map().round_to_bar (presnap.sample, direction);
|
||||
break;
|
||||
case bbt_show_quarters:
|
||||
ret = _session->tempo_map().round_to_beat (presnap.sample, direction);
|
||||
break;
|
||||
case bbt_show_eighths:
|
||||
ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 1 * divisor, direction);
|
||||
break;
|
||||
case bbt_show_sixteenths:
|
||||
ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 2 * divisor, direction);
|
||||
break;
|
||||
case bbt_show_thirtyseconds:
|
||||
ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 4 * divisor, direction);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, get_grid_beat_divisions(_grid_type), direction);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ARDOUR::MusicSample
|
||||
Editor::snap_to_grid ( MusicSample presnap, RoundMode direction, SnapPref gpref )
|
||||
{
|
||||
MusicSample ret(presnap);
|
||||
|
||||
if ( grid_musical() ) {
|
||||
ret = snap_to_bbt (presnap, direction, gpref);
|
||||
}
|
||||
|
||||
switch (_grid_type) {
|
||||
case GridTypeTimecode:
|
||||
ret = snap_to_timecode(presnap, direction, gpref);
|
||||
break;
|
||||
case GridTypeMinSec:
|
||||
ret = snap_to_minsec(presnap, direction, gpref);
|
||||
break;
|
||||
case GridTypeCDFrame:
|
||||
ret = snap_to_cd_frames(presnap, direction, gpref);
|
||||
break;
|
||||
default:
|
||||
{}
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
samplepos_t
|
||||
Editor::marker_snap_to_internal (samplepos_t presnap, RoundMode direction)
|
||||
Editor::snap_to_marker (samplepos_t presnap, RoundMode direction)
|
||||
{
|
||||
samplepos_t before;
|
||||
samplepos_t after;
|
||||
|
@ -2826,7 +3004,7 @@ Editor::marker_snap_to_internal (samplepos_t presnap, RoundMode direction)
|
|||
}
|
||||
|
||||
void
|
||||
Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref, bool for_mark, bool ensure_snap)
|
||||
Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref, bool ensure_snap)
|
||||
{
|
||||
const samplepos_t presnap = start.sample;
|
||||
|
||||
|
@ -2835,18 +3013,14 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref
|
|||
samplepos_t best = max_samplepos; // this records the best snap-result we've found so far
|
||||
|
||||
/* check snap-to-marker */
|
||||
if ( (pref == SnapToAny) && UIConfiguration::instance().get_snap_to_marks()) {
|
||||
if (for_mark) {
|
||||
return;
|
||||
}
|
||||
|
||||
test = marker_snap_to_internal (presnap, direction);
|
||||
if ( (pref == SnapToAny_Visual) && UIConfiguration::instance().get_snap_to_marks()) {
|
||||
test = snap_to_marker (presnap, direction);
|
||||
check_best_snap(presnap, test, dist, best);
|
||||
}
|
||||
|
||||
/* check snap-to-region-{start/end/sync} */
|
||||
if (
|
||||
(pref == SnapToAny) &&
|
||||
(pref == SnapToAny_Visual) &&
|
||||
(UIConfiguration::instance().get_snap_to_region_start() || UIConfiguration::instance().get_snap_to_region_end() || UIConfiguration::instance().get_snap_to_region_sync())
|
||||
) {
|
||||
if (!region_boundary_cache.empty()) {
|
||||
|
@ -2877,8 +3051,9 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref
|
|||
|
||||
/* check Grid */
|
||||
if (UIConfiguration::instance().get_snap_to_grid() && (_grid_type != GridTypeNone)) {
|
||||
test = snap_to_grid (grid_marks, presnap, direction);
|
||||
check_best_snap(presnap, test, dist, best);
|
||||
MusicSample pre(presnap, 0);
|
||||
MusicSample post = snap_to_grid ( pre, direction, pref);
|
||||
check_best_snap(presnap, post.sample, dist, best);
|
||||
}
|
||||
|
||||
/* now check "magnetic" state: is the grid within reasonable on-screen distance to trigger a snap?
|
||||
|
|
|
@ -454,15 +454,13 @@ public:
|
|||
|
||||
void snap_to (ARDOUR::MusicSample& first,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
|
||||
ARDOUR::SnapPref pref = ARDOUR::SnapToAny,
|
||||
bool for_mark = false,
|
||||
ARDOUR::SnapPref pref = ARDOUR::SnapToAny_Visual,
|
||||
bool ensure_snap = false);
|
||||
|
||||
void snap_to_with_modifier (ARDOUR::MusicSample& first,
|
||||
GdkEvent const * ev,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
|
||||
ARDOUR::SnapPref pref = ARDOUR::SnapToAny,
|
||||
bool for_mark = false);
|
||||
ARDOUR::SnapPref pref = ARDOUR::SnapToAny_Visual);
|
||||
|
||||
void set_snapped_cursor_position (samplepos_t pos);
|
||||
|
||||
|
@ -2189,18 +2187,33 @@ private:
|
|||
void select_next_stripable (bool routes_only = true);
|
||||
void select_prev_stripable (bool routes_only = true);
|
||||
|
||||
samplepos_t snap_to_grid ( std::vector<ArdourCanvas::Ruler::Mark> marks,
|
||||
samplepos_t presnap,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest);
|
||||
ARDOUR::MusicSample snap_to_minsec ( ARDOUR::MusicSample start,
|
||||
ARDOUR::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref);
|
||||
|
||||
ARDOUR::MusicSample snap_to_cd_frames ( ARDOUR::MusicSample start,
|
||||
ARDOUR::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref );
|
||||
|
||||
ARDOUR::MusicSample snap_to_bbt ( ARDOUR::MusicSample start,
|
||||
ARDOUR::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref );
|
||||
|
||||
ARDOUR::MusicSample snap_to_timecode ( ARDOUR::MusicSample start,
|
||||
ARDOUR::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref );
|
||||
|
||||
ARDOUR::MusicSample snap_to_grid ( ARDOUR::MusicSample start,
|
||||
ARDOUR::RoundMode direction,
|
||||
ARDOUR::SnapPref gpref );
|
||||
|
||||
void snap_to_internal (ARDOUR::MusicSample& first,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny,
|
||||
bool for_mark = false,
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual,
|
||||
bool ensure_snap = false);
|
||||
|
||||
samplepos_t marker_snap_to_internal (samplepos_t presnap,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest);
|
||||
samplepos_t snap_to_marker (samplepos_t presnap,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest);
|
||||
|
||||
RhythmFerret* rhythm_ferret;
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ Drag::setup_snap_delta (MusicSample pos)
|
|||
{
|
||||
TempoMap& map (_editor->session()->tempo_map());
|
||||
MusicSample snap (pos);
|
||||
_editor->snap_to (snap, ARDOUR::RoundNearest, ARDOUR::SnapToAny, false, true);
|
||||
_editor->snap_to (snap, ARDOUR::RoundNearest, ARDOUR::SnapToAny_Visual, true);
|
||||
_snap_delta = snap.sample - pos.sample;
|
||||
|
||||
_snap_delta_music = 0.0;
|
||||
|
@ -5092,7 +5092,7 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
|
|||
MusicSample grab (grab_sample (), 0);
|
||||
|
||||
if (UIConfiguration::instance().get_rubberbanding_snaps_to_grid ()) {
|
||||
_editor->snap_to_with_modifier (grab, event, RoundNearest, SnapToGrid);
|
||||
_editor->snap_to_with_modifier (grab, event, RoundNearest, SnapToGrid_Scaled);
|
||||
} else {
|
||||
grab.sample = raw_grab_sample ();
|
||||
}
|
||||
|
@ -6075,7 +6075,7 @@ NoteDrag::total_dx (GdkEvent * event) const
|
|||
|
||||
/* possibly snap and return corresponding delta in quarter notes */
|
||||
MusicSample snap (st, 0);
|
||||
_editor->snap_to_with_modifier (snap, event, RoundNearest, SnapToGrid);
|
||||
_editor->snap_to_with_modifier (snap, event, RoundNearest, SnapToGrid_Unscaled);
|
||||
double ret = map.exact_qn_at_sample (snap.sample, snap.division) - n_qn - snap_delta_music (event->button.state);
|
||||
|
||||
/* prevent the earliest note being dragged earlier than the region's start position */
|
||||
|
|
|
@ -317,10 +317,10 @@ Editor::mouse_mode_toggled (MouseMode m)
|
|||
/* Switch snap type/mode if we're moving to/from an internal tool. Note
|
||||
this must toggle the actions and not call set_snap_*() directly,
|
||||
otherwise things get out of sync and the combo box stops working. */
|
||||
if (!UIConfiguration::instance().get_grid_follows_internal()) {
|
||||
if (!UIConfiguration::instance().get_grid_follows_internal()) {
|
||||
grid_type_action(pre_internal_grid_type)->set_active(true);
|
||||
snap_mode_action(pre_internal_snap_mode)->set_active(true);
|
||||
} else if (!was_internal && internal_editing()) {
|
||||
} else if (!was_internal && internal_editing()) {
|
||||
grid_type_action(internal_grid_type)->set_active(true);
|
||||
snap_mode_action(internal_snap_mode)->set_active(true);
|
||||
} else if (was_internal && !internal_editing()) {
|
||||
|
@ -1599,7 +1599,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
|
||||
case MarkerBarItem:
|
||||
if (!_dragging_playhead) {
|
||||
snap_to_with_modifier (where, event, RoundNearest, SnapToAny, true);
|
||||
snap_to_with_modifier (where, event, RoundNearest, SnapToGrid_Scaled);
|
||||
mouse_add_new_marker (where.sample);
|
||||
}
|
||||
return true;
|
||||
|
@ -1607,7 +1607,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
case CdMarkerBarItem:
|
||||
if (!_dragging_playhead) {
|
||||
/* if we get here then a dragged range wasn't done */
|
||||
snap_to_with_modifier (where, event, RoundNearest, SnapToAny, true);
|
||||
snap_to_with_modifier (where, event, RoundNearest, SnapToGrid_Scaled);
|
||||
mouse_add_new_marker (where.sample, true);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -7151,7 +7151,7 @@ Editor::snap_regions_to_grid ()
|
|||
(*r)->region()->clear_changes ();
|
||||
|
||||
MusicSample start ((*r)->region()->first_sample (), 0);
|
||||
snap_to (start, RoundNearest, SnapToGrid);
|
||||
snap_to (start, RoundNearest, SnapToGrid_Unscaled, true);
|
||||
(*r)->region()->set_position (start.sample, start.division);
|
||||
_session->add_command(new StatefulDiffCommand ((*r)->region()));
|
||||
}
|
||||
|
@ -7369,7 +7369,7 @@ Editor::playhead_forward_to_grid ()
|
|||
|
||||
if (pos.sample < max_samplepos - 1) {
|
||||
pos.sample += 2;
|
||||
snap_to_internal (pos, RoundUpAlways, SnapToGrid, false, true);
|
||||
snap_to_internal (pos, RoundUpAlways, SnapToGrid_Scaled, true);
|
||||
_session->request_locate (pos.sample);
|
||||
}
|
||||
}
|
||||
|
@ -7402,14 +7402,14 @@ Editor::playhead_backward_to_grid ()
|
|||
|
||||
if (pos.sample > 2) {
|
||||
pos.sample -= 2;
|
||||
snap_to_internal (pos, RoundDownAlways, SnapToGrid, false, true);
|
||||
snap_to_internal (pos, RoundDownAlways, SnapToGrid_Scaled, true);
|
||||
}
|
||||
|
||||
//handle the case where we are rolling, and we're less than one-half second past the mark, we want to go to the prior mark...
|
||||
//also see: jump_backward_to_mark
|
||||
if (_session->transport_rolling()) {
|
||||
if ((playhead_cursor->current_sample() - pos.sample) < _session->sample_rate()/2) {
|
||||
snap_to_internal (pos, RoundDownAlways, SnapToGrid, false, true);
|
||||
snap_to_internal (pos, RoundDownAlways, SnapToGrid_Scaled, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3515,7 +3515,7 @@ MidiRegionView::nudge_notes (bool forward, bool fine)
|
|||
next_pos.sample -= 1;
|
||||
}
|
||||
|
||||
trackview.editor().snap_to (next_pos, (forward ? RoundUpAlways : RoundDownAlways), SnapToGrid, false);
|
||||
trackview.editor().snap_to (next_pos, (forward ? RoundUpAlways : RoundDownAlways), SnapToGrid_Unscaled, false);
|
||||
const samplecnt_t distance = ref_point - next_pos.sample;
|
||||
delta = region_samples_to_region_beats (fabs ((double)distance));
|
||||
}
|
||||
|
|
|
@ -149,8 +149,7 @@ public:
|
|||
*/
|
||||
virtual void snap_to (ARDOUR::MusicSample& first,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny,
|
||||
bool for_mark = false,
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual,
|
||||
bool ensure_snap = false) = 0;
|
||||
|
||||
/** Undo some transactions.
|
||||
|
@ -462,8 +461,7 @@ public:
|
|||
virtual void snap_to_with_modifier (ARDOUR::MusicSample& first,
|
||||
GdkEvent const * ev,
|
||||
ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny,
|
||||
bool for_mark = false) = 0;
|
||||
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual) = 0;
|
||||
|
||||
virtual void set_snapped_cursor_position (samplepos_t pos) = 0;
|
||||
|
||||
|
|
|
@ -948,12 +948,12 @@ RegionView::snap_sample_to_sample (sampleoffset_t x, bool ensure_snap) const
|
|||
|
||||
/* try a snap in either direction */
|
||||
MusicSample sample (session_sample, 0);
|
||||
editor.snap_to (sample, RoundNearest, SnapToAny, false, ensure_snap);
|
||||
editor.snap_to (sample, RoundNearest, SnapToAny_Visual, ensure_snap);
|
||||
|
||||
/* if we went off the beginning of the region, snap forwards */
|
||||
if (sample.sample < _region->position ()) {
|
||||
sample.sample = session_sample;
|
||||
editor.snap_to (sample, RoundUpAlways, SnapToAny, false, ensure_snap);
|
||||
editor.snap_to (sample, RoundUpAlways, SnapToAny_Visual, ensure_snap);
|
||||
}
|
||||
|
||||
/* back to region relative, keeping the relevant divisor */
|
||||
|
|
Loading…
Reference in New Issue
Block a user