// region boundaries, don't pay attention to them
if (regions.size() == 1) {
- switch (_snap_type) {
- case SnapToRegionStart:
- case SnapToRegionSync:
- case SnapToRegionEnd:
- break;
- default:
- if (snap_sample) {
+// switch (_snap_type) { //ToDo !!!
+// case SnapToRegionStart:
+// case SnapToRegionSync:
+// case SnapToRegionEnd:
+// break;
+// default:
+// if (snap_sample) {
snap_to (where);
- }
- }
+// }
+// }
} else {
if (snap_sample) {
snap_to (where);
if (rsas & Existing) {
// region selections that existed before the split.
- selection->add ( pre_selected_regions );
+ selection->add (pre_selected_regions);
}
for (RegionSelection::iterator ri = latest_regionviews.begin(); ri != latest_regionviews.end(); ri++) {
void
Editor::build_region_boundary_cache ()
{
+
+ //ToDo: maybe set a timer so we don't recalutate when lots of changes are coming in
+ //ToDo: maybe somehow defer this until session is fully loaded.
+
+ if ( !_region_boundary_cache_dirty )
+ return;
+
samplepos_t pos = 0;
vector<RegionPoint> interesting_points;
boost::shared_ptr<Region> r;
}
bool maybe_first_sample = false;
-
- switch (_snap_type) {
- case SnapToRegionStart:
+
+ if ( UIConfiguration::instance().get_snap_to_region_start() ) {
interesting_points.push_back (Start);
maybe_first_sample = true;
- break;
- case SnapToRegionEnd:
+ }
+
+ if ( UIConfiguration::instance().get_snap_to_region_end() ) {
interesting_points.push_back (End);
- break;
- case SnapToRegionSync:
+ }
+
+ if ( UIConfiguration::instance().get_snap_to_region_sync() ) {
interesting_points.push_back (SyncPoint);
- break;
- case SnapToRegionBoundary:
- interesting_points.push_back (Start);
- interesting_points.push_back (End);
- maybe_first_sample = true;
- break;
- default:
- fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type) << endmsg;
- abort(); /*NOTREACHED*/
- return;
}
-
+
TimeAxisView *ontrack = 0;
TrackViewList tlist;
- if (!selection->tracks.empty()) {
- tlist = selection->tracks.filter_to_unique_playlists ();
- } else {
+ //in the past, we used the track selection to limit snap. I think this is not desired.
+ //or if it is, it needs to be updated every time the track selection changes (so the snapped-cursor can show it)
+// if (!selection->tracks.empty()) {
+// tlist = selection->tracks.filter_to_unique_playlists ();
+// } else {
tlist = track_views.filter_to_unique_playlists ();
- }
+// }
if (maybe_first_sample) {
TrackViewList::const_iterator i;
/* finally sort to be sure that the order is correct */
sort (region_boundary_cache.begin(), region_boundary_cache.end());
+
+ _region_boundary_cache_dirty = false;
}
boost::shared_ptr<Region>
//zoom-behavior-tweaks
//limit our maximum zoom to the session gui extents value
std::pair<samplepos_t, samplepos_t> ext = session_gui_extents();
- samplecnt_t session_extents_pp = ( ext.second - ext.first ) / _visible_canvas_width;
+ samplecnt_t session_extents_pp = (ext.second - ext.first) / _visible_canvas_width;
if (nspp > session_extents_pp)
nspp = session_extents_pp;
//ToDo: if control points are selected, set extents to that selection
- if ( !selection->regions.empty() ) {
+ if (!selection->regions.empty()) {
RegionSelection rs = get_regions_from_selection_and_entered ();
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
samplecnt_t start = _session->current_start_sample();
samplecnt_t end = _session->current_end_sample();
- if (_session->actively_recording () ) {
+ if (_session->actively_recording ()) {
samplepos_t cur = playhead_cursor->current_sample ();
if (cur > end) {
/* recording beyond the end marker; zoom out
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_extents)
if (_session) {
- std::pair<samplepos_t, samplepos_t> ext = session_gui_extents( false ); //in this case we want to zoom to the extents explicitly; ignore the users prefs for extra padding
+ std::pair<samplepos_t, samplepos_t> ext = session_gui_extents (false); //in this case we want to zoom to the extents explicitly; ignore the users prefs for extra padding
samplecnt_t start = ext.first;
samplecnt_t end = ext.second;
- if (_session->actively_recording () ) {
+ if (_session->actively_recording ()) {
samplepos_t cur = playhead_cursor->current_sample ();
if (cur > end) {
/* recording beyond the end marker; zoom out
Location* loc;
if ((loc = _session->locations()->session_range_location()) == 0) { //should never happen
- _session->set_session_extents ( _session->audible_sample(), _session->audible_sample() );
+ _session->set_session_extents (_session->audible_sample(), _session->audible_sample());
} else {
XMLNode &before = loc->get_state();
- _session->set_session_extents ( _session->audible_sample(), loc->end() );
+ _session->set_session_extents (_session->audible_sample(), loc->end());
XMLNode &after = loc->get_state();
Location* loc;
if ((loc = _session->locations()->session_range_location()) == 0) { //should never happen
- _session->set_session_extents ( _session->audible_sample(), _session->audible_sample() );
+ _session->set_session_extents (_session->audible_sample(), _session->audible_sample());
} else {
XMLNode &before = loc->get_state();
- _session->set_session_extents ( loc->start(), _session->audible_sample() );
+ _session->set_session_extents (loc->start(), _session->audible_sample());
XMLNode &after = loc->get_state();
samplepos_t pos = _session->locations()->first_mark_before (playhead_cursor->current_sample());
//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...
- if ( _session->transport_rolling() ) {
- if ( (playhead_cursor->current_sample() - pos) < _session->sample_rate()/2 ) {
- samplepos_t prior = _session->locations()->first_mark_before ( pos );
+ if (_session->transport_rolling()) {
+ if ((playhead_cursor->current_sample() - pos) < _session->sample_rate()/2) {
+ samplepos_t prior = _session->locations()->first_mark_before (pos);
pos = prior;
}
}
samplepos_t start_sample;
samplepos_t return_sample;
- start_sample = get_preferred_edit_position ( EDIT_IGNORE_PHEAD );
+ start_sample = get_preferred_edit_position (EDIT_IGNORE_PHEAD);
if (_session->transport_rolling()) {
_session->request_locate (start_sample, false);
Editor::play_selection ()
{
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
AudioRange ar (start, end, 0);
void
Editor::maybe_locate_with_edit_preroll (samplepos_t location)
{
- if ( _session->transport_rolling() || !UIConfiguration::instance().get_follow_edits() || _session->config.get_external_sync() )
+ if (_session->transport_rolling() || !UIConfiguration::instance().get_follow_edits() || _session->config.get_external_sync())
return;
location -= _session->preroll_samples (location);
}
//if follow_playhead is on, keep the playhead on the screen
- if ( _follow_playhead )
- if ( location < _leftmost_sample )
+ if (_follow_playhead)
+ if (location < _leftmost_sample)
location = _leftmost_sample;
- _session->request_locate( location );
+ _session->request_locate (location);
}
void
Editor::play_with_preroll ()
{
samplepos_t start, end;
- if ( UIConfiguration::instance().get_follow_edits() && get_selection_extents ( start, end) ) {
+ if (UIConfiguration::instance().get_follow_edits() && get_selection_extents (start, end)) {
const samplepos_t preroll = _session->preroll_samples (start);
samplepos_t ret = start;
playlist->partition ((*rl)->first_sample() - 1, (*rl)->last_sample() + 1, true);
//Re-add region that was just removed due to the partition operation
- playlist->add_region( (*rl), (*rl)->first_sample() );
+ playlist->add_region ((*rl), (*rl)->first_sample());
}
vector<PlaylistState>::iterator pl;
//special case: if the user is pointing in the editor/mixer strip, they may be trying to delete a plugin.
//we need this because the editor-mixer strip is in the editor window, so it doesn't get the bindings from the mix window
bool deleted = false;
- if ( current_mixer_strip && current_mixer_strip == MixerStrip::entered_mixer_strip() )
+ if (current_mixer_strip && current_mixer_strip == MixerStrip::entered_mixer_strip())
deleted = current_mixer_strip->delete_processors ();
if (!deleted)
}
}
- if ( op != Delete ) { //"Delete" doesn't change copy/paste buf
+ if (op != Delete) { //"Delete" doesn't change copy/paste buf
cut_buffer->clear ();
}
}
//if a range is selected, separate it
- if ( !selection->time.empty()) {
+ if (!selection->time.empty()) {
separate_regions_between (selection->time);
return;
}
}
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
set_loop_range (start, end, _("set loop range from selection"));
Editor::set_loop_from_region (bool play)
{
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
set_loop_range (start, end, _("set loop range from region"));
}
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
set_punch_range (start, end, _("set punch range from selection"));
}
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
Location* loc;
Editor::set_punch_from_region ()
{
samplepos_t start, end;
- if (!get_selection_extents ( start, end))
+ if (!get_selection_extents (start, end))
return;
set_punch_range (start, end, _("set punch range from region"));
(*r)->region()->clear_changes ();
MusicSample start ((*r)->region()->first_sample (), 0);
- snap_to (start);
+ snap_to (start, RoundNearest, SnapToGrid );
(*r)->region()->set_position (start.sample, start.division);
_session->add_command(new StatefulDiffCommand ((*r)->region()));
}
}
(*r)->region()->clear_changes ();
- (*r)->region()->trim_front( (position - pull_back_samples));
+ (*r)->region()->trim_front((position - pull_back_samples));
last_region->clear_changes ();
- last_region->trim_end( (position - pull_back_samples + crossfade_len));
+ last_region->trim_end ((position - pull_back_samples + crossfade_len));
_session->add_command (new StatefulDiffCommand ((*r)->region()));
_session->add_command (new StatefulDiffCommand (last_region));
if (pos.sample < max_samplepos - 1) {
pos.sample += 2;
- snap_to_internal (pos, RoundUpAlways, false, true);
+ snap_to_internal (pos, RoundUpAlways, SnapToGrid, false, true);
_session->request_locate (pos.sample);
}
}
if (pos.sample > 2) {
pos.sample -= 2;
- snap_to_internal (pos, RoundDownAlways, false, true);
+ snap_to_internal (pos, RoundDownAlways, SnapToGrid, false, true);
_session->request_locate (pos.sample);
}
}
}
}
- } else if ((*i)->start() >= pos && (*i)->start() < pos+samples ) {
+ } else if ((*i)->start() >= pos && (*i)->start() < pos+samples) {
loc_kill_list.push_back(*i);
moved = true;
} else if ((*i)->start() >= pos) {
}
for (list<Location*>::iterator i = loc_kill_list.begin(); i != loc_kill_list.end(); ++i) {
- _session->locations()->remove( *i );
+ _session->locations()->remove (*i);
}
if (moved) {
if (tempo_too) {
XMLNode& before (_session->tempo_map().get_state());
- if (_session->tempo_map().remove_time (pos, samples) ) {
+ if (_session->tempo_map().remove_time (pos, samples)) {
if (!in_command) {
begin_reversible_command (_("remove time"));
in_command = true;