X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_ops.cc;h=b70d0f06647ec4088b86be5c501061515b7091ad;hb=5dca8270eb589cc60c756e09bd02ce323805b741;hp=02bf220b4d268c12260ef2c7bb49603b7af3708a;hpb=9c733915a0bc4b5274fac749b1adc874da79a6ee;p=ardour.git diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 02bf220b4d..b70d0f0664 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -31,6 +31,7 @@ #include "pbd/basename.h" #include "pbd/pthread_utils.h" #include "pbd/memento_command.h" +#include "pbd/unwind.h" #include "pbd/whitespace.h" #include "pbd/stateful_diff_command.h" @@ -38,24 +39,21 @@ #include #include -#include "ardour/audioengine.h" -#include "ardour/session.h" -#include "ardour/audioplaylist.h" +#include "ardour/audio_track.h" #include "ardour/audioregion.h" -#include "ardour/audio_diskstream.h" -#include "ardour/utils.h" +#include "ardour/dB.h" #include "ardour/location.h" -#include "ardour/audio_track.h" -#include "ardour/audioplaylist.h" -#include "ardour/region_factory.h" +#include "ardour/midi_region.h" +#include "ardour/midi_track.h" +#include "ardour/operations.h" #include "ardour/playlist_factory.h" -#include "ardour/reverse.h" -#include "ardour/transient_detector.h" -#include "ardour/dB.h" #include "ardour/quantize.h" +#include "ardour/region_factory.h" +#include "ardour/reverse.h" +#include "ardour/session.h" +#include "ardour/session_playlists.h" #include "ardour/strip_silence.h" -#include "ardour/route_group.h" -#include "ardour/operations.h" +#include "ardour/transient_detector.h" #include "ardour_ui.h" #include "debug.h" @@ -64,6 +62,7 @@ #include "route_time_axis.h" #include "audio_time_axis.h" #include "automation_time_axis.h" +#include "control_point.h" #include "streamview.h" #include "audio_streamview.h" #include "audio_region_view.h" @@ -106,6 +105,10 @@ using Gtkmm2ext::Keyboard; void Editor::undo (uint32_t n) { + if (_drags->active ()) { + _drags->abort (); + } + if (_session) { _session->undo (n); } @@ -114,6 +117,10 @@ Editor::undo (uint32_t n) void Editor::redo (uint32_t n) { + if (_drags->active ()) { + _drags->abort (); + } + if (_session) { _session->redo (n); } @@ -146,7 +153,7 @@ Editor::split_regions_at (framepos_t where, RegionSelection& regions) } } else { snap_to (where); - + frozen = true; EditorFreeze(); /* Emit Signal */ } @@ -198,7 +205,7 @@ Editor::split_regions_at (framepos_t where, RegionSelection& regions) } commit_reversible_command (); - + if (frozen){ EditorThaw(); /* Emit Signal */ } @@ -245,7 +252,7 @@ Editor::move_range_selection_start_or_end_to_region_boundary (bool move_end, boo if (end < start) { return; } - + begin_reversible_command (_("alter selection")); selection->set_preserving_all_ranges (start, end); commit_reversible_command (); @@ -300,7 +307,7 @@ Editor::nudge_forward (bool next, bool force_playhead) } r->clear_changes (); - r->set_position (r->position() + distance, this); + r->set_position (r->position() + distance); _session->add_command (new StatefulDiffCommand (r)); } @@ -379,13 +386,13 @@ Editor::nudge_backward (bool next, bool force_playhead) if (next) { distance = next_distance; } - + r->clear_changes (); if (r->position() > distance) { - r->set_position (r->position() - distance, this); + r->set_position (r->position() - distance); } else { - r->set_position (0, this); + r->set_position (0); } _session->add_command (new StatefulDiffCommand (r)); } @@ -453,23 +460,23 @@ void Editor::nudge_forward_capture_offset () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (!_session || rs.empty()) { return; } begin_reversible_command (_("nudge forward")); - + framepos_t const distance = _session->worst_output_latency(); - + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { boost::shared_ptr r ((*i)->region()); - + r->clear_changes (); - r->set_position (r->position() + distance, this); + r->set_position (r->position() + distance); _session->add_command(new StatefulDiffCommand (r)); } - + commit_reversible_command (); } @@ -482,23 +489,23 @@ Editor::nudge_backward_capture_offset () return; } - begin_reversible_command (_("nudge forward")); - + begin_reversible_command (_("nudge backward")); + framepos_t const distance = _session->worst_output_latency(); for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { boost::shared_ptr r ((*i)->region()); - + r->clear_changes (); - + if (r->position() > distance) { - r->set_position (r->position() - distance, this); + r->set_position (r->position() - distance); } else { - r->set_position (0, this); + r->set_position (0); } _session->add_command(new StatefulDiffCommand (r)); } - + commit_reversible_command (); } @@ -554,11 +561,11 @@ Editor::build_region_boundary_cache () TimeAxisView *ontrack = 0; TrackViewList tlist; - + if (!selection->tracks.empty()) { - tlist = selection->tracks; + tlist = selection->tracks.filter_to_unique_playlists (); } else { - tlist = track_views; + tlist = track_views.filter_to_unique_playlists (); } while (pos < _session->current_end_frame() && !at_end) { @@ -705,7 +712,7 @@ Editor::find_next_region_boundary (framepos_t pos, int32_t dir, const TrackViewL for (TrackViewList::const_iterator i = tracks.begin(); i != tracks.end(); ++i) { framepos_t contender; framecnt_t d; - + RouteTimeAxisView* rtv = dynamic_cast (*i); if (!rtv) { @@ -1238,7 +1245,7 @@ Editor::scroll_tracks_down () if (vert_value > vertical_adjustment.get_upper() - _canvas_height) { vert_value = vertical_adjustment.get_upper() - _canvas_height; } - + vertical_adjustment.set_value (vert_value); } @@ -1256,7 +1263,7 @@ Editor::scroll_tracks_down_line () if (vert_value > vertical_adjustment.get_upper() - _canvas_height) { vert_value = vertical_adjustment.get_upper() - _canvas_height; } - + vertical_adjustment.set_value (vert_value); } @@ -1271,11 +1278,17 @@ Editor::scroll_tracks_up_line () void Editor::tav_zoom_step (bool coarser) { - ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser) - _routes->suspend_redisplay (); - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + TrackViewList* ts; + + if (selection->tracks.empty()) { + ts = &track_views; + } else { + ts = &selection->tracks; + } + + for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) { TimeAxisView *tv = (static_cast(*i)); tv->step_height (coarser); } @@ -1283,28 +1296,78 @@ Editor::tav_zoom_step (bool coarser) _routes->resume_redisplay (); } +void +Editor::tav_zoom_smooth (bool coarser, bool force_all) +{ + _routes->suspend_redisplay (); + + TrackViewList* ts; + + if (selection->tracks.empty() || force_all) { + ts = &track_views; + } else { + ts = &selection->tracks; + } + + for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) { + TimeAxisView *tv = (static_cast(*i)); + uint32_t h = tv->current_height (); + + if (coarser) { + if (h > 5) { + h -= 5; // pixels + if (h >= TimeAxisView::preset_height (HeightSmall)) { + tv->set_height (h); + } + } + } else { + tv->set_height (h + 5); + } + } + + _routes->resume_redisplay (); +} + +bool +Editor::clamp_frames_per_unit (double& fpu) const +{ + bool clamped = false; + + if (fpu < 2.0) { + fpu = 2.0; + clamped = true; + } + + if (max_framepos / fpu < 800) { + fpu = max_framepos / 800.0; + clamped = true; + } + + return clamped; +} + void Editor::temporal_zoom_step (bool coarser) { ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser) - double nfpu; - - nfpu = frames_per_unit; + double nfpu = frames_per_unit; if (coarser) { - nfpu *= 1.61803399; + nfpu = min (9e6, nfpu * 1.61803399); } else { - nfpu = max(1.0,(nfpu/1.61803399)); + nfpu = max (1.0, nfpu / 1.61803399); } temporal_zoom (nfpu); } void -Editor::temporal_zoom (gdouble fpu) +Editor::temporal_zoom (double fpu) { - if (!_session) return; + if (!_session) { + return; + } framepos_t current_page = current_page_frames(); framepos_t current_leftmost = leftmost_frame; @@ -1318,13 +1381,19 @@ Editor::temporal_zoom (gdouble fpu) double nfpu; double l; - /* XXX this limit is also in ::set_frames_per_unit() */ - - if (frames_per_unit <= 1.0 && fpu <= frames_per_unit) { + clamp_frames_per_unit (fpu); + if (fpu == frames_per_unit) { return; } nfpu = fpu; + + // Imposing an arbitrary limit to zoom out as too much zoom out produces + // segfaults for lack of memory. If somebody decides this is not high enough I + // believe it can be raisen to higher values but some limit must be in place. + if (nfpu > 8e+08) { + nfpu = 8e+08; + } new_page_size = (framepos_t) floor (_canvas_width * nfpu); half_page_size = new_page_size / 2; @@ -1479,16 +1548,15 @@ Editor::temporal_zoom_region (bool both_axes) end = max_framepos; } - if (both_axes) { - /* save visual state with track states included, and prevent - set_frames_per_unit() from doing it again. - */ - undo_visual_stack.push_back (current_visual_state(true)); - no_save_visual = true; - } + /* if we're zooming on both axes we need to save track heights etc. + */ + + undo_visual_stack.push_back (current_visual_state (both_axes)); - temporal_zoom_by_frame (start, end, "zoom to region"); + PBD::Unwinder nsv (no_save_visual, true); + temporal_zoom_by_frame (start, end); + if (both_axes) { uint32_t per_track_height = (uint32_t) floor ((_canvas_height - canvas_timebars_vsize - 10.0) / tracks.size()); @@ -1511,10 +1579,9 @@ Editor::temporal_zoom_region (bool both_axes) _routes->resume_redisplay (); vertical_adjustment.set_value (0.0); - no_save_visual = false; } - redo_visual_stack.push_back (current_visual_state()); + redo_visual_stack.push_back (current_visual_state (both_axes)); } void @@ -1535,7 +1602,7 @@ Editor::temporal_zoom_selection () framepos_t start = selection->time[clicked_selection].start; framepos_t end = selection->time[clicked_selection].end; - temporal_zoom_by_frame (start, end, "zoom to selection"); + temporal_zoom_by_frame (start, end); } void @@ -1550,12 +1617,12 @@ Editor::temporal_zoom_session () s = 0; } framecnt_t const e = _session->current_end_frame() + l * 0.01; - temporal_zoom_by_frame (framecnt_t (s), e, "zoom to _session"); + temporal_zoom_by_frame (framecnt_t (s), e); } } void -Editor::temporal_zoom_by_frame (framepos_t start, framepos_t end, const string & /*op*/) +Editor::temporal_zoom_by_frame (framepos_t start, framepos_t end) { if (!_session) return; @@ -1575,6 +1642,10 @@ Editor::temporal_zoom_by_frame (framepos_t start, framepos_t end, const string & new_leftmost = 0; } + if (new_leftmost < 0) { + new_leftmost = 0; + } + reposition_and_zoom (new_leftmost, new_fpu); } @@ -1709,7 +1780,7 @@ void Editor::add_locations_from_region () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -1736,7 +1807,7 @@ void Editor::add_location_from_region () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -1776,13 +1847,13 @@ Editor::jump_forward_to_mark () return; } - Location *location = _session->locations()->first_location_after (playhead_cursor->current_frame); + framepos_t pos = _session->locations()->first_mark_after (playhead_cursor->current_frame); - if (location) { - _session->request_locate (location->start(), _session->transport_rolling()); - } else { - _session->request_locate (_session->current_end_frame()); + if (pos < 0) { + return; } + + _session->request_locate (pos, _session->transport_rolling()); } void @@ -1792,13 +1863,13 @@ Editor::jump_backward_to_mark () return; } - Location *location = _session->locations()->first_location_before (playhead_cursor->current_frame); + framepos_t pos = _session->locations()->first_mark_before (playhead_cursor->current_frame); - if (location) { - _session->request_locate (location->start(), _session->transport_rolling()); - } else { - _session->goto_start (); + if (pos < 0) { + return; } + + _session->request_locate (pos, _session->transport_rolling()); } void @@ -1808,11 +1879,11 @@ Editor::set_mark () string markername; _session->locations()->next_available_name (markername, "mark"); - + if (!choose_new_marker_name (markername)) { return; } - + _session->locations()->add (new Location (*_session, pos, 0, markername, Location::IsMark), true); } @@ -1838,11 +1909,13 @@ Editor::clear_ranges () Location * looploc = _session->locations()->auto_loop_location(); Location * punchloc = _session->locations()->auto_punch_location(); + Location * sessionloc = _session->locations()->session_range_location(); _session->locations()->clear_ranges (); // re-add these if (looploc) _session->locations()->add (looploc); if (punchloc) _session->locations()->add (punchloc); + if (sessionloc) _session->locations()->add (sessionloc); XMLNode &after = _session->locations()->get_state(); _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); @@ -1936,7 +2009,6 @@ Editor::insert_route_list_drag (boost::shared_ptr route, int x, int y) { double wx, wy; double cx, cy; - framepos_t where; RouteTimeAxisView *dest_rtv = 0; RouteTimeAxisView *source_rtv = 0; @@ -1949,7 +2021,7 @@ Editor::insert_route_list_drag (boost::shared_ptr route, int x, int y) event.button.x = wx; event.button.y = wy; - where = event_frame (&event, &cx, &cy); + event_frame (&event, &cx, &cy); std::pair const tv = trackview_by_y_position (cy); if (tv.first == 0) { @@ -2035,7 +2107,7 @@ Editor::transition_to_rolling (bool fwd) } if (_session->config.get_external_sync()) { - switch (_session->config.get_sync_source()) { + switch (Config->get_sync_source()) { case JACK: break; default: @@ -2098,6 +2170,55 @@ Editor::play_selection () _session->request_play_range (&selection->time, true); } +framepos_t +Editor::get_preroll () +{ + return 1.0 /*Config->get_edit_preroll_seconds()*/ * _session->frame_rate(); +} + + +void +Editor::maybe_locate_with_edit_preroll ( framepos_t location ) +{ + if ( _session->transport_rolling() || !Config->get_always_play_range() ) + return; + + location -= get_preroll(); + + //don't try to locate before the beginning of time + if ( location < 0 ) + location = 0; + + //if follow_playhead is on, keep the playhead on the screen + if ( _follow_playhead ) + if ( location < leftmost_frame ) + location = leftmost_frame; + + _session->request_locate( location ); +} + +void +Editor::play_with_preroll () +{ + if (selection->time.empty()) { + return; + } else { + framepos_t preroll = get_preroll(); + + framepos_t start = 0; + if (selection->time[clicked_selection].start > preroll) + start = selection->time[clicked_selection].start - preroll; + + framepos_t end = selection->time[clicked_selection].end + preroll; + + AudioRange ar (start, end, 0); + list lar; + lar.push_back (ar); + + _session->request_play_range (&lar, true); + } +} + void Editor::play_location (Location& location) { @@ -2126,28 +2247,101 @@ Editor::loop_location (Location& location) } } +void +Editor::do_layer_operation (LayerOperation op) +{ + if (selection->regions.empty ()) { + return; + } + + bool const multiple = selection->regions.size() > 1; + switch (op) { + case Raise: + if (multiple) { + begin_reversible_command (_("raise regions")); + } else { + begin_reversible_command (_("raise region")); + } + break; + + case RaiseToTop: + if (multiple) { + begin_reversible_command (_("raise regions to top")); + } else { + begin_reversible_command (_("raise region to top")); + } + break; + + case Lower: + if (multiple) { + begin_reversible_command (_("lower regions")); + } else { + begin_reversible_command (_("lower region")); + } + break; + + case LowerToBottom: + if (multiple) { + begin_reversible_command (_("lower regions to bottom")); + } else { + begin_reversible_command (_("lower region")); + } + break; + } + + set > playlists = selection->regions.playlists (); + for (set >::iterator i = playlists.begin(); i != playlists.end(); ++i) { + (*i)->clear_owned_changes (); + } + + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + boost::shared_ptr r = (*i)->region (); + switch (op) { + case Raise: + r->raise (); + break; + case RaiseToTop: + r->raise_to_top (); + break; + case Lower: + r->lower (); + break; + case LowerToBottom: + r->lower_to_bottom (); + } + } + + for (set >::iterator i = playlists.begin(); i != playlists.end(); ++i) { + vector cmds; + (*i)->rdiff (cmds); + _session->add_commands (cmds); + } + + commit_reversible_command (); +} + void Editor::raise_region () { - selection->foreach_region (&Region::raise); + do_layer_operation (Raise); } void Editor::raise_region_to_top () { - selection->foreach_region (&Region::raise_to_top); + do_layer_operation (RaiseToTop); } void Editor::lower_region () { - selection->foreach_region (&Region::lower); + do_layer_operation (Lower); } void Editor::lower_region_to_bottom () { - selection->foreach_region (&Region::lower_to_bottom); + do_layer_operation (LowerToBottom); } /** Show the region editor for the selected regions */ @@ -2168,7 +2362,7 @@ void Editor::rename_region () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -2189,9 +2383,8 @@ Editor::rename_region () d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); d.set_size_request (300, -1); - d.set_position (Gtk::WIN_POS_MOUSE); - entry.set_text (selection->regions.front()->region()->name()); + entry.set_text (rs.front()->region()->name()); entry.select_region (0, -1); entry.signal_activate().connect (sigc::bind (sigc::mem_fun (d, &Dialog::response), RESPONSE_OK)); @@ -2207,7 +2400,7 @@ Editor::rename_region () if (ret != RESPONSE_OK) { return; } - + std::string str = entry.get_text(); strip_whitespace_edges (str); if (!str.empty()) { @@ -2253,7 +2446,7 @@ Editor::play_selected_region () framepos_t end = 0; RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -2311,8 +2504,8 @@ Editor::region_from_selection () internal_start = start - current->position(); RegionFactory::region_name (new_name, current->name(), true); - PropertyList plist; - + PropertyList plist; + plist.add (ARDOUR::Properties::start, current->start() + internal_start); plist.add (ARDOUR::Properties::length, selection_cnt); plist.add (ARDOUR::Properties::name, new_name); @@ -2332,9 +2525,10 @@ Editor::create_region_from_selection (vector >& new_re framepos_t start = selection->time[clicked_selection].start; framepos_t end = selection->time[clicked_selection].end; - sort_track_selection (); + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + sort_track_selection (ts); - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) { boost::shared_ptr current; boost::shared_ptr playlist; framepos_t internal_start; @@ -2351,8 +2545,8 @@ Editor::create_region_from_selection (vector >& new_re internal_start = start - current->position(); RegionFactory::region_name (new_name, current->name(), true); - PropertyList plist; - + PropertyList plist; + plist.add (ARDOUR::Properties::start, current->start() + internal_start); plist.add (ARDOUR::Properties::length, end - start + 1); plist.add (ARDOUR::Properties::name, new_name); @@ -2365,7 +2559,7 @@ void Editor::split_multichannel_region () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -2388,7 +2582,7 @@ static void add_if_covered (RegionView* rv, const AudioRange* ar, RegionSelection* rs) { switch (rv->region()->coverage (ar->start, ar->end - 1)) { - case OverlapNone: + case Evoral::OverlapNone: break; default: rs->push_back (rv); @@ -2430,7 +2624,7 @@ Editor::get_tracks_for_range_action () const t = selection->tracks; } - return t; + return t.filter_to_unique_playlists(); } void @@ -2441,7 +2635,7 @@ Editor::separate_regions_between (const TimeSelection& ts) RegionSelection new_selection; TrackViewList tmptracks = get_tracks_for_range_action (); - sort_track_selection (&tmptracks); + sort_track_selection (tmptracks); for (TrackSelection::iterator i = tmptracks.begin(); i != tmptracks.end(); ++i) { @@ -2483,12 +2677,12 @@ Editor::separate_regions_between (const TimeSelection& ts) rtv->view()->foreach_regionview (sigc::bind ( sigc::ptr_fun (add_if_covered), &(*t), &new_selection)); - + if (!in_command) { begin_reversible_command (_("separate")); in_command = true; } - + /* pick up changes to existing regions */ vector cmds; @@ -2531,7 +2725,7 @@ Editor::separate_region_from_selection () returns a single range. */ - if (mouse_mode == MouseRange && !selection->time.empty()) { + if (!selection->time.empty()) { separate_regions_between (selection->time); @@ -2591,7 +2785,7 @@ Editor::separate_under_selected_regions () vector playlists; RegionSelection rs; - + rs = get_regions_from_selection_and_entered(); if (!_session || rs.empty()) { @@ -2645,7 +2839,7 @@ Editor::separate_under_selected_regions () //Partition on the region bounds playlist->partition ((*rl)->first_frame() - 1, (*rl)->last_frame() + 1, true); - + //Re-add region that was just removed due to the partition operation playlist->add_region( (*rl), (*rl)->first_frame() ); } @@ -2684,16 +2878,17 @@ Editor::crop_region_to (framepos_t start, framepos_t end) { vector > playlists; boost::shared_ptr playlist; - TrackViewList* ts; + TrackViewList ts; if (selection->tracks.empty()) { - ts = &track_views; + ts = track_views.filter_to_unique_playlists(); } else { - sort_track_selection (); - ts = &selection->tracks; + ts = selection->tracks.filter_to_unique_playlists (); } - for (TrackSelection::iterator i = ts->begin(); i != ts->end(); ++i) { + sort_track_selection (ts); + + for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) { RouteTimeAxisView* rtv; @@ -2744,7 +2939,7 @@ Editor::crop_region_to (framepos_t start, framepos_t end) cnt = the_end - the_start + 1; region->clear_changes (); - region->trim_to (the_start, cnt, this); + region->trim_to (the_start, cnt); _session->add_command (new StatefulDiffCommand (region)); } @@ -2818,7 +3013,9 @@ Editor::region_fill_selection () begin_reversible_command (Operations::fill_selection); - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + + for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { if ((playlist = (*i)->playlist()) == 0) { continue; @@ -2871,20 +3068,20 @@ void Editor::remove_region_sync () { RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } begin_reversible_command (_("remove region sync")); - + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { (*i)->region()->clear_changes (); (*i)->region()->clear_sync_position (); _session->add_command(new StatefulDiffCommand ((*i)->region())); } - + commit_reversible_command (); } @@ -2902,13 +3099,13 @@ Editor::naturalize_region () } else { begin_reversible_command (_("move region to original position")); } - + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { (*i)->region()->clear_changes (); - (*i)->region()->move_to_natural_position (this); + (*i)->region()->move_to_natural_position (); _session->add_command (new StatefulDiffCommand ((*i)->region())); } - + commit_reversible_command (); } @@ -2916,7 +3113,7 @@ void Editor::align_regions (RegionPoint what) { RegionSelection const rs = get_regions_from_selection_and_edit_point (); - + if (rs.empty()) { return; } @@ -2942,7 +3139,7 @@ void Editor::align_regions_relative (RegionPoint point) { RegionSelection const rs = get_regions_from_selection_and_edit_point (); - + if (rs.empty()) { return; } @@ -3000,7 +3197,7 @@ Editor::align_regions_relative (RegionPoint point) /* move first one specially */ r->clear_changes (); - r->set_position (pos, this); + r->set_position (pos); _session->add_command(new StatefulDiffCommand (r)); /* move rest by the same amount */ @@ -3014,11 +3211,11 @@ Editor::align_regions_relative (RegionPoint point) region->clear_changes (); if (dir > 0) { - region->set_position (region->position() + distance, this); + region->set_position (region->position() + distance); } else { - region->set_position (region->position() - distance, this); + region->set_position (region->position() - distance); } - + _session->add_command(new StatefulDiffCommand (region)); } @@ -3041,17 +3238,17 @@ Editor::align_region_internal (boost::shared_ptr region, RegionPoint poi switch (point) { case SyncPoint: - region->set_position (region->adjust_to_sync (position), this); + region->set_position (region->adjust_to_sync (position)); break; case End: if (position > region->length()) { - region->set_position (position - region->length(), this); + region->set_position (position - region->length()); } break; case Start: - region->set_position (position, this); + region->set_position (position); break; } @@ -3076,28 +3273,25 @@ Editor::trim_region (bool front) framepos_t where = get_preferred_edit_position(); RegionSelection rs = get_regions_from_selection_and_edit_point (); - cerr << "trim regions\n"; - if (rs.empty()) { - cerr << " no regions\n"; return; } - cerr << "where = " << where << endl; - begin_reversible_command (front ? _("trim front") : _("trim back")); for (list::const_iterator i = rs.by_layer().begin(); i != rs.by_layer().end(); ++i) { if (!(*i)->region()->locked()) { - + (*i)->region()->clear_changes (); - + if (front) { - (*i)->region()->trim_front (where, this); + (*i)->region()->trim_front (where); + maybe_locate_with_edit_preroll ( where ); } else { - (*i)->region()->trim_end (where, this); + (*i)->region()->trim_end (where); + maybe_locate_with_edit_preroll ( where ); } - + _session->add_command (new StatefulDiffCommand ((*i)->region())); } } @@ -3138,7 +3332,7 @@ Editor::trim_region_to_location (const Location& loc, const char* str) /* require region to span proposed trim */ switch (rv->region()->coverage (loc.start(), loc.end())) { - case OverlapInternal: + case Evoral::OverlapInternal: break; default: continue; @@ -3159,9 +3353,9 @@ Editor::trim_region_to_location (const Location& loc, const char* str) start = session_frame_to_track_frame (loc.start(), speed); end = session_frame_to_track_frame (loc.end(), speed); - + rv->region()->clear_changes (); - rv->region()->trim_to (start, (end - start), this); + rv->region()->trim_to (start, (end - start)); _session->add_command(new StatefulDiffCommand (rv->region())); } @@ -3223,7 +3417,7 @@ Editor::trim_to_region(bool forward) continue; } - region->trim_end((framepos_t) ( (next_region->first_frame() - 1) * speed), this); + region->trim_end((framepos_t) ( (next_region->first_frame() - 1) * speed)); arv->region_changed (PropertyChange (ARDOUR::Properties::length)); } else { @@ -3234,7 +3428,7 @@ Editor::trim_to_region(bool forward) continue; } - region->trim_front((framepos_t) ((next_region->last_frame() + 1) * speed), this); + region->trim_front((framepos_t) ((next_region->last_frame() + 1) * speed)); arv->region_changed (ARDOUR::bounds_change); } @@ -3258,41 +3452,72 @@ Editor::unfreeze_route () void* Editor::_freeze_thread (void* arg) { - SessionEvent::create_per_thread_pool ("freeze events", 64); - return static_cast(arg)->freeze_thread (); } void* Editor::freeze_thread () { + /* create event pool because we may need to talk to the session */ + SessionEvent::create_per_thread_pool ("freeze events", 64); + /* create per-thread buffers for process() tree to use */ + current_interthread_info->process_thread.get_buffers (); clicked_routeview->audio_track()->freeze_me (*current_interthread_info); current_interthread_info->done = true; + current_interthread_info->process_thread.drop_buffers(); return 0; } void Editor::freeze_route () { - if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) { + if (!_session) { return; } - if (!clicked_routeview->track()->bounceable()) { - RouteTimeAxisView* rtv = dynamic_cast (clicked_routeview); - if (rtv && !rtv->track()->bounceable()) { - MessageDialog d ( - _("This route cannot be frozen because it has more outputs than inputs. " - "You can fix this by increasing the number of inputs.") - ); - d.set_title (_("Cannot freeze")); - d.run (); - return; - } - } + /* stop transport before we start. this is important */ - InterThreadInfo itt; - current_interthread_info = &itt; + _session->request_transport_speed (0.0); + + /* wait for just a little while, because the above call is asynchronous */ + + ::usleep (250000); + + if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) { + return; + } + + if (!clicked_routeview->track()->bounceable (clicked_routeview->track()->main_outs(), true)) { + MessageDialog d ( + _("This track/bus cannot be frozen because the signal adds or loses channels before reaching the outputs.\n" + "This is typically caused by plugins that generate stereo output from mono input or vice versa.") + ); + d.set_title (_("Cannot freeze")); + d.run (); + return; + } + + if (clicked_routeview->track()->has_external_redirects()) { + MessageDialog d (string_compose (_("%1\n\nThis track has at least one send/insert/return as part of its signal flow.\n\n" + "Freezing will only process the signal as far as the first send/insert/return."), + clicked_routeview->track()->name()), true, MESSAGE_INFO, BUTTONS_NONE, true); + + d.add_button (_("Freeze anyway"), Gtk::RESPONSE_OK); + d.add_button (_("Don't freeze"), Gtk::RESPONSE_CANCEL); + d.set_title (_("Freeze Limits")); + + int response = d.run (); + + switch (response) { + case Gtk::RESPONSE_CANCEL: + return; + default: + break; + } + } + + InterThreadInfo itt; + current_interthread_info = &itt; InterthreadProgressWindow ipw (current_interthread_info, _("Freeze"), _("Cancel Freeze")); @@ -3318,15 +3543,21 @@ Editor::bounce_range_selection (bool replace, bool enable_processing) TrackSelection views = selection->tracks; for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) { - RouteTimeAxisView* rtv = dynamic_cast (*i); - if (rtv && rtv->track() && !rtv->track()->bounceable()) { - MessageDialog d ( - _("One or more selected tracks cannot be bounced because it has more outputs than inputs. " - "You can fix this by increasing the number of inputs on that track.") - ); - d.set_title (_("Cannot bounce")); - d.run (); - return; + + if (enable_processing) { + + RouteTimeAxisView* rtv = dynamic_cast (*i); + + if (rtv && rtv->track() && replace && enable_processing && !rtv->track()->bounceable (rtv->track()->main_outs(), false)) { + MessageDialog d ( + _("You can't perform this operation because the processing of the signal " + "will cause one or more of the tracks to end up with a region with more channels than this track has inputs.\n\n" + "You can do this without processing, which is a different operation.") + ); + d.set_title (_("Cannot bounce")); + d.run (); + return; + } } } @@ -3354,8 +3585,18 @@ Editor::bounce_range_selection (bool replace, bool enable_processing) playlist->clear_changes (); playlist->clear_owned_changes (); - - boost::shared_ptr r = rtv->track()->bounce_range (start, start+cnt, itt, enable_processing); + + boost::shared_ptr r; + + if (enable_processing) { + r = rtv->track()->bounce_range (start, start+cnt, itt, rtv->track()->main_outs(), false); + } else { + r = rtv->track()->bounce_range (start, start+cnt, itt, boost::shared_ptr(), false); + } + + if (!r) { + continue; + } if (replace) { list ranges; @@ -3374,6 +3615,13 @@ Editor::bounce_range_selection (bool replace, bool enable_processing) commit_reversible_command (); } +/** Delete selected regions, automation points or a time range */ +void +Editor::delete_ () +{ + cut_copy (Delete); +} + /** Cut selected regions, automation points or a time range */ void Editor::cut () @@ -3393,7 +3641,7 @@ Editor::copy () bool Editor::can_cut_copy () const { - switch (current_mouse_mode()) { + switch (effective_mouse_mode()) { case MouseObject: if (!selection->regions.empty() || !selection->points.empty()) { @@ -3426,6 +3674,9 @@ Editor::cut_copy (CutCopyOp op) string opname; switch (op) { + case Delete: + opname = _("delete"); + break; case Cut: opname = _("cut"); break; @@ -3443,13 +3694,14 @@ Editor::cut_copy (CutCopyOp op) this function. */ - if (op == Cut || op == Clear) { + if (op == Delete || op == Cut || op == Clear) { if (_drags->active ()) { _drags->abort (); } } - cut_buffer->clear (); + if ( op != Clear ) //"Delete" doesn't change copy/paste buf + cut_buffer->clear (); if (entered_marker) { @@ -3468,7 +3720,7 @@ Editor::cut_copy (CutCopyOp op) if (internal_editing()) { - switch (current_mouse_mode()) { + switch (effective_mouse_mode()) { case MouseObject: case MouseRange: cut_copy_midi (op); @@ -3479,24 +3731,63 @@ Editor::cut_copy (CutCopyOp op) } else { - RegionSelection rs; + RegionSelection rs; - /* we only want to cut regions if some are selected */ + /* we only want to cut regions if some are selected */ - if (!selection->regions.empty()) { - rs = selection->regions; - } + if (!selection->regions.empty()) { + rs = selection->regions; + } - switch (current_mouse_mode()) { - case MouseObject: + switch (effective_mouse_mode()) { +/* + * case MouseGain: { + //find regions's gain line + AudioRegionView *rview = dynamic_cast(clicked_regionview); + AutomationTimeAxisView *tview = dynamic_cast(clicked_trackview); + if (rview) { + AudioRegionGainLine *line = rview->get_gain_line(); + if (!line) break; + + //cut region gain points in the selection + AutomationList& alist (line->the_list()); + XMLNode &before = alist.get_state(); + AutomationList* what_we_got = 0; + if ((what_we_got = alist.cut (selection->time.front().start - rview->audio_region()->position(), selection->time.front().end - rview->audio_region()->position())) != 0) { + session->add_command(new MementoCommand(alist, &before, &alist.get_state())); + delete what_we_got; + what_we_got = 0; + } + + rview->set_envelope_visible(true); + rview->audio_region()->set_envelope_active(true); + + } else if (tview) { + AutomationLine *line = *(tview->lines.begin()); + if (!line) break; + + //cut auto points in the selection + AutomationList& alist (line->the_list()); + XMLNode &before = alist.get_state(); + AutomationList* what_we_got = 0; + if ((what_we_got = alist.cut (selection->time.front().start, selection->time.front().end)) != 0) { + session->add_command(new MementoCommand(alist, &before, &alist.get_state())); + delete what_we_got; + what_we_got = 0; + } + } else + break; + } break; +*/ + case MouseObject: + case MouseRange: if (!rs.empty() || !selection->points.empty()) { - begin_reversible_command (opname + _(" objects")); if (!rs.empty()) { cut_copy_regions (op, rs); - - if (op == Cut) { + + if (op == Cut || op == Delete) { selection->clear_regions (); } } @@ -3504,21 +3795,15 @@ Editor::cut_copy (CutCopyOp op) if (!selection->points.empty()) { cut_copy_points (op); - if (op == Cut) { + if (op == Cut || op == Delete) { selection->clear_points (); } } - commit_reversible_command (); - break; // terminate case statement here - } - if (!selection->time.empty()) { - /* don't cause suprises */ + commit_reversible_command (); break; - } - // fall thru if there was nothing selected - - case MouseRange: + } + if (selection->time.empty()) { framepos_t start, end; if (!get_edit_op_range (start, end)) { @@ -3526,40 +3811,108 @@ Editor::cut_copy (CutCopyOp op) } selection->set (start, end); } - + begin_reversible_command (opname + _(" range")); cut_copy_ranges (op); commit_reversible_command (); - - if (op == Cut) { + + if (op == Cut || op == Delete) { selection->clear_time (); } break; - + default: break; } } - if (op == Cut || op == Clear) { + if (op == Delete || op == Cut || op == Clear) { _drags->abort (); } } +struct AutomationRecord { + AutomationRecord () : state (0) {} + AutomationRecord (XMLNode* s) : state (s) {} + + XMLNode* state; ///< state before any operation + boost::shared_ptr copy; ///< copied events for the cut buffer +}; + /** Cut, copy or clear selected automation points. - * @param op Operation (Cut, Copy or Clear) + * @param op Operation (Cut, Copy or Clear) */ void Editor::cut_copy_points (CutCopyOp op) { + if (selection->points.empty ()) { + return; + } + + /* XXX: not ideal, as there may be more than one track involved in the point selection */ + _last_cut_copy_source_track = &selection->points.front()->line().trackview; + + /* Keep a record of the AutomationLists that we end up using in this operation */ + typedef std::map, AutomationRecord> Lists; + Lists lists; + + /* Go through all selected points, making an AutomationRecord for each distinct AutomationList */ for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + if (lists.find (al) == lists.end ()) { + /* We haven't seen this list yet, so make a record for it. This includes + taking a copy of its current state, in case this is needed for undo later. + */ + lists[al] = AutomationRecord (&al->get_state ()); + } + } - AutomationTimeAxisView* atv = dynamic_cast((*i).track); - _last_cut_copy_source_track = atv; + if (op == Cut || op == Copy) { + /* This operation will involve putting things in the cut buffer, so create an empty + ControlList for each of our source lists to put the cut buffer data in. + */ + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + i->second.copy = i->first->create (i->first->parameter ()); + } - if (atv) { - atv->cut_copy_clear_objects (selection->points, op); + /* Add all selected points to the relevant copy ControlLists */ + for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + AutomationList::const_iterator j = (*i)->model (); + lists[al].copy->add ((*j)->when, (*j)->value); + } + + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + /* Correct this copy list so that it starts at time 0 */ + double const start = i->second.copy->front()->when; + for (AutomationList::iterator j = i->second.copy->begin(); j != i->second.copy->end(); ++j) { + (*j)->when -= start; + } + + /* And add it to the cut buffer */ + cut_buffer->add (i->second.copy); + } + } + + if (op == Delete || op == Cut) { + /* This operation needs to remove things from the main AutomationList, so do that now */ + + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + i->first->freeze (); + } + + /* Remove each selected point from its AutomationList */ + for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + al->erase ((*i)->model ()); + } + + /* Thaw the lists and add undo records for them */ + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + boost::shared_ptr al = i->first; + al->thaw (); + _session->add_command (new MementoCommand (*al.get(), i->second.state, &(al->get_state ()))); } } } @@ -3603,7 +3956,16 @@ Editor::remove_clicked_region () begin_reversible_command (_("remove region")); playlist->clear_changes (); + playlist->clear_owned_changes (); playlist->remove_region (clicked_regionview->region()); + + /* We might have removed regions, which alters other regions' layering_index, + so we need to do a recursive diff here. + */ + vector cmds; + playlist->rdiff (cmds); + _session->add_commands (cmds); + _session->add_command(new StatefulDiffCommand (playlist)); commit_reversible_command (); } @@ -3647,23 +4009,16 @@ Editor::remove_selected_regions () continue; } - vector >::iterator i; - - //only prep history if this is a new playlist. - for (i = playlists.begin(); i != playlists.end(); ++i) { - if ((*i) == playlist) { - break; - } - } - - if (i == playlists.end()) { + /* get_regions_from_selection_and_entered() guarantees that + the playlists involved are unique, so there is no need + to check here. + */ - playlist->clear_changes (); - playlist->freeze (); - - playlists.push_back (playlist); - } + playlists.push_back (playlist); + playlist->clear_changes (); + playlist->clear_owned_changes (); + playlist->freeze (); playlist->remove_region (*rl); } @@ -3671,6 +4026,14 @@ Editor::remove_selected_regions () for (pl = playlists.begin(); pl != playlists.end(); ++pl) { (*pl)->thaw (); + + /* We might have removed regions, which alters other regions' layering_index, + so we need to do a recursive diff here. + */ + vector cmds; + (*pl)->rdiff (cmds); + _session->add_commands (cmds); + _session->add_command(new StatefulDiffCommand (*pl)); } @@ -3702,13 +4065,13 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) first_position = min ((framepos_t) (*x)->region()->position(), first_position); - if (op == Cut || op == Clear) { + if (op == Cut || op == Clear || op == Delete) { boost::shared_ptr pl = (*x)->region()->playlist(); if (pl) { FreezeList::iterator fl; - //only take state if this is a new playlist. + // only take state if this is a new playlist. for (fl = freezelist.begin(); fl != freezelist.end(); ++fl) { if ((*fl) == pl) { break; @@ -3717,6 +4080,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) if (fl == freezelist.end()) { pl->clear_changes(); + pl->clear_owned_changes (); pl->freeze (); freezelist.insert (pl); } @@ -3756,22 +4120,25 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) tmp = x; ++tmp; - vector::iterator z; + if (op != Delete) { - for (z = pmap.begin(); z != pmap.end(); ++z) { - if ((*z).tv == &tv) { - break; + vector::iterator z; + + for (z = pmap.begin(); z != pmap.end(); ++z) { + if ((*z).tv == &tv) { + break; + } + } + + assert (z != pmap.end()); + + if (!(*z).pl) { + npl = PlaylistFactory::create (pl->data_type(), *_session, "cutlist", true); + npl->freeze(); + (*z).pl = npl; + } else { + npl = (*z).pl; } - } - - assert (z != pmap.end()); - - if (!(*z).pl) { - npl = PlaylistFactory::create (pl->data_type(), *_session, "cutlist", true); - npl->freeze(); - (*z).pl = npl; - } else { - npl = (*z).pl; } boost::shared_ptr r = (*x)->region(); @@ -3780,6 +4147,10 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) assert (r != 0); switch (op) { + case Delete: + pl->remove_region (r); + break; + case Cut: _xx = RegionFactory::create (r); npl->add_region (_xx, r->position() - first_position); @@ -3792,36 +4163,47 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) break; case Clear: - pl->remove_region (r); + pl->remove_region (r); break; } x = tmp; } - list > foo; - - /* the pmap is in the same order as the tracks in which selected regions occured */ + if (op != Delete) { - for (vector::iterator i = pmap.begin(); i != pmap.end(); ++i) { - if ((*i).pl) { - (*i).pl->thaw(); - foo.push_back ((*i).pl); + list > foo; + + /* the pmap is in the same order as the tracks in which selected regions occured */ + + for (vector::iterator i = pmap.begin(); i != pmap.end(); ++i) { + if ((*i).pl) { + (*i).pl->thaw(); + foo.push_back ((*i).pl); + } + } + + if (!foo.empty()) { + cut_buffer->set (foo); + } + + if (pmap.empty()) { + _last_cut_copy_source_track = 0; + } else { + _last_cut_copy_source_track = pmap.front().tv; } } - if (!foo.empty()) { - cut_buffer->set (foo); - } - - if (pmap.empty()) { - _last_cut_copy_source_track = 0; - } else { - _last_cut_copy_source_track = pmap.front().tv; - } - for (FreezeList::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) { (*pl)->thaw (); + + /* We might have removed regions, which alters other regions' layering_index, + so we need to do a recursive diff here. + */ + vector cmds; + (*pl)->rdiff (cmds); + _session->add_commands (cmds); + _session->add_command (new StatefulDiffCommand (*pl)); } } @@ -3829,36 +4211,34 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) void Editor::cut_copy_ranges (CutCopyOp op) { - TrackViewList* ts; - TrackViewList entered; + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); /* Sort the track selection now, so that it if is used, the playlists selected by the calls below to cut_copy_clear are in the order that their tracks appear in the editor. This makes things like paste of ranges work properly. */ - sort_track_selection (&selection->tracks); - if (selection->tracks.empty()) { + sort_track_selection (ts); + + if (ts.empty()) { if (!entered_track) { return; } - entered.push_back (entered_track); - ts = &entered; - } else { - ts = &selection->tracks; - } + ts.push_back (entered_track); + } - for (TrackSelection::iterator i = ts->begin(); i != ts->end(); ++i) { + for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { (*i)->cut_copy_clear (*selection, op); } } void -Editor::paste (float times) +Editor::paste (float times, bool from_context) { DEBUG_TRACE (DEBUG::CutNPaste, "paste to preferred edit pos\n"); - paste_internal (get_preferred_edit_position(), times); + + paste_internal (get_preferred_edit_position (false, from_context), times); } void @@ -3901,12 +4281,15 @@ Editor::paste_internal (framepos_t position, float times) /* get everything in the correct order */ - if (!selection->tracks.empty()) { - /* there are some selected tracks, so paste to them */ - sort_track_selection (); - ts = selection->tracks; + if (_edit_point == Editing::EditAtMouse && entered_track) { + /* With the mouse edit point, paste onto the track under the mouse */ + ts.push_back (entered_track); + } else if (!selection->tracks.empty()) { + /* Otherwise, if there are some selected tracks, paste to them */ + ts = selection->tracks.filter_to_unique_playlists (); + sort_track_selection (ts); } else if (_last_cut_copy_source_track) { - /* otherwise paste to the track that the cut/copy came from; + /* Otherwise paste to the track that the cut/copy came from; see discussion in mantis #3333. */ ts.push_back (_last_cut_copy_source_track); @@ -3915,15 +4298,15 @@ Editor::paste_internal (framepos_t position, float times) if (internal_editing ()) { /* undo/redo is handled by individual tracks/regions */ - + for (nth = 0, i = ts.begin(); i != ts.end(); ++i, ++nth) { - + RegionSelection rs; RegionSelection::iterator r; MidiNoteSelection::iterator cb; - + get_regions_at (rs, position, ts); - + for (cb = cut_buffer->midi_notes.begin(), r = rs.begin(); cb != cut_buffer->midi_notes.end() && r != rs.end(); ++r) { MidiRegionView* mrv = dynamic_cast (*r); @@ -3933,17 +4316,17 @@ Editor::paste_internal (framepos_t position, float times) } } } - + } else { /* we do redo (do you do voodoo?) */ begin_reversible_command (Operations::paste); - + for (nth = 0, i = ts.begin(); i != ts.end(); ++i, ++nth) { (*i)->paste (position, times, *cut_buffer, nth); } - + commit_reversible_command (); } } @@ -4009,7 +4392,9 @@ Editor::duplicate_selection (float times) ri = new_regions.begin(); - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + + for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { if ((playlist = (*i)->playlist()) == 0) { continue; } @@ -4026,18 +4411,13 @@ Editor::duplicate_selection (float times) commit_reversible_command (); } +/** Reset all selected points to the relevant default value */ void Editor::reset_point_selection () { - /* reset all selected points to the relevant default value */ - for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { - - AutomationTimeAxisView* atv = dynamic_cast((*i).track); - - if (atv) { - atv->reset_objects (selection->points); - } + ARDOUR::AutomationList::iterator j = (*i)->model (); + (*j)->value = (*i)->line().the_list()->default_value (); } } @@ -4088,7 +4468,9 @@ Editor::nudge_track (bool use_edit, bool forwards) begin_reversible_command (_("nudge track")); - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + + for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) { if ((playlist = (*i)->playlist()) == 0) { continue; @@ -4098,12 +4480,12 @@ Editor::nudge_track (bool use_edit, bool forwards) playlist->clear_owned_changes (); playlist->nudge_after (start, distance, forwards); - + vector cmds; - + playlist->rdiff (cmds); _session->add_commands (cmds); - + _session->add_command (new StatefulDiffCommand (playlist)); } @@ -4148,7 +4530,7 @@ Editor::normalize_region () } RegionSelection rs = get_regions_from_selection_and_entered (); - + if (rs.empty()) { return; } @@ -4181,7 +4563,7 @@ Editor::normalize_region () set_canvas_cursor (current_canvas_cursor); return; } - + max_amps.push_back (a); max_amp = max (max_amp, a); dialog.ascend (); @@ -4191,7 +4573,7 @@ Editor::normalize_region () begin_reversible_command (_("normalize")); list::const_iterator a = max_amps.begin (); - + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { AudioRegionView* const arv = dynamic_cast (*r); if (!arv) { @@ -4201,7 +4583,7 @@ Editor::normalize_region () arv->region()->clear_changes (); double const amp = dialog.normalize_individually() ? *a : max_amp; - + arv->audio_region()->normalize (amp, dialog.target ()); _session->add_command (new StatefulDiffCommand (arv->region())); @@ -4312,13 +4694,13 @@ Editor::strip_region_silence () int const r = d.run (); d.drop_rects (); - + if (r == Gtk::RESPONSE_OK) { ARDOUR::AudioIntervalMap silences; d.silences (silences); StripSilence s (*_session, silences, d.fade_length()); apply_filter (s, _("strip silence"), &d); - } + } } Command* @@ -4330,7 +4712,10 @@ Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv vector::Notes> v; v.push_back (selected); - return op (mrv.midi_region()->model(), v); + framepos_t pos_frames = mrv.midi_region()->position(); + double pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames); + + return op (mrv.midi_region()->model(), pos_beats, v); } void @@ -4389,7 +4774,7 @@ Editor::fork_region () if (mrv) { boost::shared_ptr playlist = mrv->region()->playlist(); boost::shared_ptr newregion = mrv->midi_region()->clone (); - + playlist->clear_changes (); playlist->replace_region (mrv->region(), newregion, mrv->region()->position()); _session->add_command(new StatefulDiffCommand (playlist)); @@ -4436,8 +4821,7 @@ Editor::quantize_region () qd->hide (); if (r == Gtk::RESPONSE_OK) { - Quantize quant (*_session, Plain, - qd->snap_start(), qd->snap_end(), + Quantize quant (*_session, qd->snap_start(), qd->snap_end(), qd->start_grid_size(), qd->end_grid_size(), qd->strength(), qd->swing(), qd->threshold()); @@ -4446,18 +4830,25 @@ Editor::quantize_region () } void -Editor::insert_patch_change () +Editor::insert_patch_change (bool from_context) { RegionSelection rs = get_regions_from_selection_and_entered (); + if (rs.empty ()) { return; } - framepos_t const p = get_preferred_edit_position (false); + const framepos_t p = get_preferred_edit_position (false, from_context); + + /* XXX: bit of a hack; use the MIDNAM from the first selected region; + there may be more than one, but the PatchChangeDialog can only offer + one set of patch menus. + */ + MidiRegionView* first = dynamic_cast (rs.front ()); Evoral::PatchChange empty (0, 0, 0, 0); - PatchChangeDialog d (0, _session, empty, Gtk::Stock::ADD); - + PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD); + if (d.run() == RESPONSE_CANCEL) { return; } @@ -4488,7 +4879,7 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress int n = 0; int const N = rs.size (); - + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ) { RegionSelection::iterator tmp = r; ++tmp; @@ -4504,6 +4895,7 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress if (arv->audio_region()->apply (filter, progress) == 0) { playlist->clear_changes (); + playlist->clear_owned_changes (); if (filter.results.empty ()) { @@ -4526,6 +4918,13 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress } + /* We might have removed regions, which alters other regions' layering_index, + so we need to do a recursive diff here. + */ + vector cmds; + playlist->rdiff (cmds); + _session->add_commands (cmds); + _session->add_command(new StatefulDiffCommand (playlist)); } else { goto out; @@ -4578,25 +4977,49 @@ Editor::reset_region_gain_envelopes () } void -Editor::toggle_gain_envelope_visibility () +Editor::set_region_gain_visibility (RegionView* rv) +{ + AudioRegionView* arv = dynamic_cast (rv); + if (arv) { + arv->update_envelope_visibility(); + } +} + +void +Editor::set_gain_envelope_visibility () +{ + if (!_session) { + return; + } + + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + AudioTimeAxisView* v = dynamic_cast(*i); + if (v) { + v->audio_view()->foreach_regionview (sigc::mem_fun (this, &Editor::set_region_gain_visibility)); + } + } +} + +void +Editor::toggle_gain_envelope_active () { if (_ignore_region_action) { return; } - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { return; } - _session->begin_reversible_command (_("region gain envelope visible")); + _session->begin_reversible_command (_("region gain envelope active")); for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { AudioRegionView* const arv = dynamic_cast(*i); if (arv) { arv->region()->clear_changes (); - arv->set_envelope_visible (!arv->envelope_visible()); + arv->audio_region()->set_envelope_active (!arv->audio_region()->envelope_active()); _session->add_command (new StatefulDiffCommand (arv->region())); } } @@ -4605,34 +5028,31 @@ Editor::toggle_gain_envelope_visibility () } void -Editor::toggle_gain_envelope_active () +Editor::toggle_region_lock () { if (_ignore_region_action) { return; } - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { return; } - _session->begin_reversible_command (_("region gain envelope active")); + _session->begin_reversible_command (_("toggle region lock")); for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { - AudioRegionView* const arv = dynamic_cast(*i); - if (arv) { - arv->region()->clear_changes (); - arv->audio_region()->set_envelope_active (!arv->audio_region()->envelope_active()); - _session->add_command (new StatefulDiffCommand (arv->region())); - } + (*i)->region()->clear_changes (); + (*i)->region()->set_locked (!(*i)->region()->locked()); + _session->add_command (new StatefulDiffCommand ((*i)->region())); } _session->commit_reversible_command (); } void -Editor::toggle_region_lock () +Editor::toggle_region_video_lock () { if (_ignore_region_action) { return; @@ -4644,11 +5064,11 @@ Editor::toggle_region_lock () return; } - _session->begin_reversible_command (_("toggle region lock")); + _session->begin_reversible_command (_("Toggle Video Lock")); for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { (*i)->region()->clear_changes (); - (*i)->region()->set_locked (!(*i)->region()->locked()); + (*i)->region()->set_video_locked (!(*i)->region()->video_locked()); _session->add_command (new StatefulDiffCommand ((*i)->region())); } @@ -4661,7 +5081,7 @@ Editor::toggle_region_lock_style () if (_ignore_region_action) { return; } - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { @@ -4686,7 +5106,7 @@ Editor::toggle_opaque_region () if (_ignore_region_action) { return; } - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { @@ -4725,6 +5145,60 @@ Editor::toggle_record_enable () } } +void +Editor::toggle_solo () +{ + bool new_state = false; + bool first = true; + boost::shared_ptr rl (new RouteList); + + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + RouteTimeAxisView *rtav = dynamic_cast(*i); + + if (!rtav) { + continue; + } + + if (first) { + new_state = !rtav->route()->soloed (); + first = false; + } + + rl->push_back (rtav->route()); + } + + _session->set_solo (rl, new_state, Session::rt_cleanup, true); +} + +void +Editor::toggle_mute () +{ + bool new_state = false; + bool first = true; + boost::shared_ptr rl (new RouteList); + + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + RouteTimeAxisView *rtav = dynamic_cast(*i); + + if (!rtav) { + continue; + } + + if (first) { + new_state = !rtav->route()->muted(); + first = false; + } + + rl->push_back (rtav->route()); + } + + _session->set_mute (rl, new_state, Session::rt_cleanup, true); +} + +void +Editor::toggle_solo_isolate () +{ +} void Editor::set_fade_length (bool in) @@ -4878,7 +5352,7 @@ Editor::set_fade_in_active (bool yn) boost::shared_ptr ar (tmp->audio_region()); - + ar->clear_changes (); ar->set_fade_in_active (yn); _session->add_command (new StatefulDiffCommand (ar)); @@ -4918,8 +5392,12 @@ Editor::set_fade_out_active (bool yn) void Editor::toggle_region_fades (int dir) { + if (_ignore_region_action) { + return; + } + boost::shared_ptr ar; - bool yn; + bool yn = false; RegionSelection rs = get_regions_from_selection_and_entered (); @@ -4927,7 +5405,7 @@ Editor::toggle_region_fades (int dir) return; } - RegionSelection::iterator i; + RegionSelection::iterator i; for (i = rs.begin(); i != rs.end(); ++i) { if ((ar = boost::dynamic_pointer_cast((*i)->region())) != 0) { if (dir == -1) { @@ -4978,24 +5456,6 @@ Editor::update_region_fade_visibility () } } -/** Update crossfade visibility after its configuration has been changed */ -void -Editor::update_xfade_visibility () -{ - _xfade_visibility = _session->config.get_xfades_visible (); - - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - AudioTimeAxisView* v = dynamic_cast(*i); - if (v) { - if (_xfade_visibility) { - v->show_all_xfades (); - } else { - v->hide_all_xfades (); - } - } - } -} - void Editor::set_edit_point () { @@ -5042,17 +5502,18 @@ Editor::set_playhead_cursor () _session->request_locate (where, _session->transport_rolling()); } } + + if ( Config->get_always_play_range() ) + cancel_time_selection(); } void Editor::split_region () { - if (((mouse_mode == MouseRange) || - (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) && - !selection->time.empty()) { + if ( !selection->time.empty()) { separate_regions_between (selection->time); return; - } + } RegionSelection rs = get_regions_from_selection_and_edit_point (); @@ -5065,28 +5526,9 @@ Editor::split_region () split_regions_at (where, rs); } -void -Editor::ensure_entered_track_selected (bool op_really_wants_one_track_if_none_are_selected) -{ - if (entered_track && mouse_mode == MouseObject) { - if (!selection->tracks.empty()) { - if (!selection->selected (entered_track)) { - selection->add (entered_track); - } - } else { - /* there is no selection, but this operation requires/prefers selected objects */ - - if (op_really_wants_one_track_if_none_are_selected) { - selection->set (entered_track); - } - } - } -} - struct EditorOrderRouteSorter { bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - /* use of ">" forces the correct sort order */ - return a->order_key ("editor") < b->order_key ("editor"); + return a->order_key (EditorSort) < b->order_key (EditorSort); } }; @@ -5385,7 +5827,9 @@ Editor::define_one_bar (framepos_t start, framepos_t end) we have frames per bar, and beats per bar, so ... */ - double frames_per_beat = length / m.beats_per_bar(); + /* XXXX METER MATH */ + + double frames_per_beat = length / m.divisions_per_bar(); /* beats per minute = */ @@ -5418,7 +5862,7 @@ Editor::define_one_bar (framepos_t start, framepos_t end) _("Do you want to set the global tempo or add a new tempo marker?"), options ); - + c.set_default_response (2); switch (c.run()) { @@ -5449,7 +5893,9 @@ Editor::define_one_bar (framepos_t start, framepos_t end) } else if (t.frame() == start) { _session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type()); } else { - _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), start); + Timecode::BBT_Time bbt; + _session->tempo_map().bbt_time (start, bbt); + _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), bbt); } XMLNode& after (_session->tempo_map().get_state()); @@ -5496,9 +5942,9 @@ void Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList& positions, bool can_ferret, bool select_new) { bool use_rhythmic_rodent = false; - + boost::shared_ptr pl = r->playlist(); - + list > new_regions; if (!pl) { @@ -5529,7 +5975,7 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList int response = msg.run(); msg.hide (); - + switch (response) { case RESPONSE_OK: break; @@ -5549,6 +5995,7 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList AnalysisFeatureList::const_iterator x; pl->clear_changes (); + pl->clear_owned_changes (); x = positions.begin(); @@ -5562,7 +6009,7 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList framepos_t pos = 0; while (x != positions.end()) { - + /* deal with positons that are out of scope of present region bounds */ if (*x <= 0 || *x > r->length()) { ++x; @@ -5578,7 +6025,7 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList */ framepos_t len = (*x) - pos; - + /* XXX we do we really want to allow even single-sample regions? shouldn't we have some kind of lower limit on region size? */ @@ -5595,14 +6042,18 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList /* do NOT announce new regions 1 by one, just wait till they are all done */ - PropertyList plist; - + PropertyList plist; + plist.add (ARDOUR::Properties::start, file_start); plist.add (ARDOUR::Properties::length, len); plist.add (ARDOUR::Properties::name, new_name); plist.add (ARDOUR::Properties::layer, 0); boost::shared_ptr nr = RegionFactory::create (r->sources(), plist, false); + /* because we set annouce to false, manually add the new region to the + RegionFactory map + */ + RegionFactory::map_add (nr); pl->add_region (nr, r->position() + pos); @@ -5617,26 +6068,37 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList string new_name; RegionFactory::region_name (new_name, r->name()); - + /* Add the final region */ - PropertyList plist; - + PropertyList plist; + plist.add (ARDOUR::Properties::start, r->start() + pos); plist.add (ARDOUR::Properties::length, r->last_frame() - (r->position() + pos) + 1); plist.add (ARDOUR::Properties::name, new_name); plist.add (ARDOUR::Properties::layer, 0); boost::shared_ptr nr = RegionFactory::create (r->sources(), plist, false); + /* because we set annouce to false, manually add the new region to the + RegionFactory map + */ + RegionFactory::map_add (nr); pl->add_region (nr, r->position() + pos); - + if (select_new) { new_regions.push_front(nr); } pl->thaw (); - _session->add_command (new StatefulDiffCommand (pl)); + /* We might have removed regions, which alters other regions' layering_index, + so we need to do a recursive diff here. + */ + vector cmds; + pl->rdiff (cmds); + _session->add_commands (cmds); + _session->add_command (new StatefulDiffCommand (pl)); + if (select_new) { for (list >::iterator i = new_regions.begin(); i != new_regions.end(); ++i){ @@ -5657,16 +6119,16 @@ Editor::place_transient() if (rs.empty()) { return; } - + framepos_t where = get_preferred_edit_position(); _session->begin_reversible_command (_("place transient")); - + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { framepos_t position = (*r)->region()->position(); (*r)->region()->add_transient(where - position); } - + _session->commit_reversible_command (); } @@ -5688,19 +6150,19 @@ void Editor::snap_regions_to_grid () { list > used_playlists; - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { return; } - + _session->begin_reversible_command (_("snap regions to grid")); - + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { - + boost::shared_ptr pl = (*r)->region()->playlist(); - + if (!pl->frozen()) { /* we haven't seen this playlist before */ @@ -5711,9 +6173,9 @@ Editor::snap_regions_to_grid () framepos_t start_frame = (*r)->region()->first_frame (); snap_to (start_frame); - (*r)->region()->set_position (start_frame, this); + (*r)->region()->set_position (start_frame); } - + while (used_playlists.size() > 0) { list >::iterator i = used_playlists.begin(); (*i)->thaw(); @@ -5727,7 +6189,7 @@ void Editor::close_region_gaps () { list > used_playlists; - + RegionSelection rs = get_regions_from_selection_and_entered (); if (!_session || rs.empty()) { @@ -5739,10 +6201,9 @@ Editor::close_region_gaps () Table table (2, 3); table.set_spacings (12); table.set_border_width (12); - Label* l = manage (new Label (_("Crossfade length"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("Crossfade length"))); table.attach (*l, 0, 1, 0, 1); - + SpinButton spin_crossfade (1, 0); spin_crossfade.set_range (0, 15); spin_crossfade.set_increments (1, 1); @@ -5751,10 +6212,9 @@ Editor::close_region_gaps () table.attach (*manage (new Label (_("ms"))), 2, 3, 0, 1); - l = manage (new Label (_("Pull-back length"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Pull-back length"))); table.attach (*l, 0, 1, 1, 2); - + SpinButton spin_pullback (1, 0); spin_pullback.set_range (0, 100); spin_pullback.set_increments (1, 1); @@ -5762,7 +6222,7 @@ Editor::close_region_gaps () table.attach (spin_pullback, 1, 2, 1, 2); table.attach (*manage (new Label (_("ms"))), 2, 3, 1, 2); - + dialog.get_vbox()->pack_start (table); dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL); dialog.add_button (_("Ok"), RESPONSE_ACCEPT); @@ -5772,25 +6232,25 @@ Editor::close_region_gaps () return; } - framepos_t crossfade_len = spin_crossfade.get_value(); + framepos_t crossfade_len = spin_crossfade.get_value(); framepos_t pull_back_frames = spin_pullback.get_value(); crossfade_len = lrintf (crossfade_len * _session->frame_rate()/1000); pull_back_frames = lrintf (pull_back_frames * _session->frame_rate()/1000); /* Iterate over the region list and make adjacent regions overlap by crossfade_len_ms */ - + _session->begin_reversible_command (_("close region gaps")); int idx = 0; boost::shared_ptr last_region; - + rs.sort_by_position_and_track(); - + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) { - + boost::shared_ptr pl = (*r)->region()->playlist(); - + if (!pl->frozen()) { /* we haven't seen this playlist before */ @@ -5800,21 +6260,21 @@ Editor::close_region_gaps () } framepos_t position = (*r)->region()->position(); - + if (idx == 0 || position < last_region->position()){ last_region = (*r)->region(); idx++; continue; } - - (*r)->region()->trim_front( (position - pull_back_frames), this ); - last_region->trim_end( (position - pull_back_frames + crossfade_len), this ); - + + (*r)->region()->trim_front( (position - pull_back_frames)); + last_region->trim_end( (position - pull_back_frames + crossfade_len)); + last_region = (*r)->region(); - + idx++; } - + while (used_playlists.size() > 0) { list >::iterator i = used_playlists.begin(); (*i)->thaw(); @@ -5839,7 +6299,12 @@ Editor::tab_to_transient (bool forward) if (!selection->tracks.empty()) { - for (TrackSelection::iterator t = selection->tracks.begin(); t != selection->tracks.end(); ++t) { + /* don't waste time searching for transients in duplicate playlists. + */ + + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + + for (TrackViewList::iterator t = ts.begin(); t != ts.end(); ++t) { RouteTimeAxisView* rtv = dynamic_cast (*t); @@ -6093,6 +6558,7 @@ Editor::do_insert_time () get_preferred_edit_position(), d.distance(), opt, + d.all_playlists(), d.move_glued(), d.move_markers(), d.move_glued_markers(), @@ -6102,8 +6568,10 @@ Editor::do_insert_time () } void -Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, - bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too) +Editor::insert_time ( + framepos_t pos, framecnt_t frames, InsertTimeOption opt, + bool all_playlists, bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too + ) { bool commit = false; @@ -6113,26 +6581,49 @@ Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, begin_reversible_command (_("insert time")); - for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) { + TrackViewList ts = selection->tracks.filter_to_unique_playlists (); + + for (TrackViewList::iterator x = ts.begin(); x != ts.end(); ++x) { + /* regions */ - boost::shared_ptr pl = (*x)->playlist(); - if (pl) { + /* don't operate on any playlist more than once, which could + * happen if "all playlists" is enabled, but there is more + * than 1 track using playlists "from" a given track. + */ - pl->clear_changes (); - pl->clear_owned_changes (); + set > pl; + + if (all_playlists) { + RouteTimeAxisView* rtav = dynamic_cast (*x); + if (rtav) { + vector > all = _session->playlists->playlists_for_track (rtav->track ()); + for (vector >::iterator p = all.begin(); p != all.end(); ++p) { + pl.insert (*p); + } + } + } else { + if ((*x)->playlist ()) { + pl.insert ((*x)->playlist ()); + } + } + + for (set >::iterator i = pl.begin(); i != pl.end(); ++i) { + + (*i)->clear_changes (); + (*i)->clear_owned_changes (); if (opt == SplitIntersected) { - pl->split (pos); + (*i)->split (pos); } - pl->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue); + (*i)->shift (pos, frames, (opt == MoveIntersected), ignore_music_glue); vector cmds; - pl->rdiff (cmds); + (*i)->rdiff (cmds); _session->add_commands (cmds); - - _session->add_command (new StatefulDiffCommand (pl)); + + _session->add_command (new StatefulDiffCommand (*i)); commit = true; } @@ -6168,7 +6659,7 @@ Editor::insert_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, } moved = true; } - + } if (was_locked) { @@ -6205,7 +6696,7 @@ Editor::fit_selected_tracks () for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) { tvl.push_back (&(*r)->get_time_axis_view ()); } - + if (!tvl.empty()) { fit_tracks (tvl); } @@ -6250,7 +6741,8 @@ Editor::fit_tracks (TrackViewList & tracks) return; } - undo_visual_stack.push_back (current_visual_state()); + undo_visual_stack.push_back (current_visual_state (true)); + no_save_visual = true; /* build a list of all tracks, including children */ @@ -6305,7 +6797,7 @@ Editor::fit_tracks (TrackViewList & tracks) controls_layout.property_height () = full_canvas_height - canvas_timebars_vsize; vertical_adjustment.set_value (first_y_pos); - redo_visual_stack.push_back (current_visual_state()); + redo_visual_stack.push_back (current_visual_state (true)); } void @@ -6315,7 +6807,9 @@ Editor::save_visual_state (uint32_t n) visual_states.push_back (0); } - delete visual_states[n]; + if (visual_states[n] != 0) { + delete visual_states[n]; + } visual_states[n] = current_visual_state (true); gdk_beep (); @@ -6338,38 +6832,19 @@ Editor::goto_visual_state (uint32_t n) void Editor::start_visual_state_op (uint32_t n) { - if (visual_state_op_connection.empty()) { - visual_state_op_connection = Glib::signal_timeout().connect (sigc::bind (sigc::mem_fun (*this, &Editor::end_visual_state_op), n), 1000); - } -} - -void -Editor::cancel_visual_state_op (uint32_t n) -{ - if (!visual_state_op_connection.empty()) { - visual_state_op_connection.disconnect(); - goto_visual_state (n); - } else { - //we land here if called from the menu OR if end_visual_state_op has been called - //so check if we are already in visual state n - // XXX not yet checking it at all, but redoing does not hurt - goto_visual_state (n); - } -} - -bool -Editor::end_visual_state_op (uint32_t n) -{ - visual_state_op_connection.disconnect(); save_visual_state (n); - + PopUp* pup = new PopUp (WIN_POS_MOUSE, 1000, true); char buf[32]; snprintf (buf, sizeof (buf), _("Saved view %u"), n+1); pup->set_text (buf); pup->touch(); +} - return false; // do not call again +void +Editor::cancel_visual_state_op (uint32_t n) +{ + goto_visual_state (n); } void @@ -6378,7 +6853,7 @@ Editor::toggle_region_mute () if (_ignore_region_action) { return; } - + RegionSelection rs = get_regions_from_selection_and_entered (); if (rs.empty ()) { @@ -6390,15 +6865,15 @@ Editor::toggle_region_mute () } else { begin_reversible_command (_("mute region")); } - + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { - + (*i)->region()->playlist()->clear_changes (); (*i)->region()->set_muted (!(*i)->region()->muted ()); _session->add_command (new StatefulDiffCommand ((*i)->region()->playlist())); - + } - + commit_reversible_command (); } @@ -6427,8 +6902,19 @@ Editor::combine_regions () begin_reversible_command (_("combine regions")); + vector new_selection; + for (RTVS::iterator i = tracks.begin(); i != tracks.end(); ++i) { - (*i)->combine_regions (); + RegionView* rv; + + if ((rv = (*i)->combine_regions ()) != 0) { + new_selection.push_back (rv); + } + } + + selection->clear_regions (); + for (vector::iterator i = new_selection.begin(); i != new_selection.end(); ++i) { + selection->add (*i); } commit_reversible_command (); @@ -6461,3 +6947,26 @@ Editor::uncombine_regions () commit_reversible_command (); } +void +Editor::toggle_midi_input_active (bool flip_others) +{ + bool onoff; + boost::shared_ptr rl (new RouteList); + + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + RouteTimeAxisView *rtav = dynamic_cast(*i); + + if (!rtav) { + continue; + } + + boost::shared_ptr mt = rtav->midi_track(); + + if (mt) { + rl->push_back (rtav->route()); + onoff = !mt->input_active(); + } + } + + _session->set_exclusive_input_active (rl, onoff, flip_others); +}