Fix problems with summary when the session start marker is not at zero (#2924)
[ardour.git] / gtk2_ardour / editor_ops.cc
index 0e1c4d12e4069677f3a4397ab1334e156c29626f..0dfaecf4fd75b759eb8de02a3e55dedf8a9539c2 100644 (file)
@@ -44,7 +44,6 @@
 #include "ardour/audio_diskstream.h"
 #include "ardour/utils.h"
 #include "ardour/location.h"
-#include "ardour/named_selection.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioplaylist.h"
 #include "ardour/region_factory.h"
@@ -125,7 +124,7 @@ Editor::split_regions_at (nframes64_t where, RegionSelection& regions)
        // region boundaries, don't pay attention to them
 
        if (regions.size() == 1) {
-               switch (snap_type) {
+               switch (_snap_type) {
                case SnapToRegionStart:
                case SnapToRegionSync:
                case SnapToRegionEnd:
@@ -579,7 +578,7 @@ Editor::build_region_boundary_cache ()
                return;
        }
 
-       switch (snap_type) {
+       switch (_snap_type) {
        case SnapToRegionStart:
                interesting_points.push_back (Start);
                break;
@@ -594,7 +593,7 @@ Editor::build_region_boundary_cache ()
                interesting_points.push_back (End);
                break;
        default:
-               fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), snap_type) << endmsg;
+               fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type) << endmsg;
                /*NOTREACHED*/
                return;
        }
@@ -1766,18 +1765,13 @@ Editor::temporal_zoom_region (bool both_axes)
                no_save_visual = false;
        }
 
-       zoomed_to_region = true;
        redo_visual_stack.push_back (current_visual_state());
 }
 
 void
-Editor::toggle_zoom_region (bool both_axes)
+Editor::zoom_to_region (bool both_axes)
 {
-       if (zoomed_to_region) {
-               swap_visual_state ();
-       } else {
-               temporal_zoom_region (both_axes);
-       }
+       temporal_zoom_region (both_axes);
 }
 
 void
@@ -2355,13 +2349,14 @@ Editor::transition_to_rolling (bool fwd)
                return;
        }
 
-       switch (Config->get_slave_source()) {
-       case None:
-       case JACK:
-               break;
-       default:
-               /* transport controlled by the master */
-               return;
+       if (session->config.get_external_sync()) {
+               switch (session->config.get_sync_source()) {
+               case JACK:
+                       break;
+               default:
+                       /* transport controlled by the master */
+                       return;
+               }
        }
 
        if (session->is_auditioning()) {
@@ -2372,37 +2367,6 @@ Editor::transition_to_rolling (bool fwd)
        session->request_transport_speed (fwd ? 1.0f : -1.0f);
 }
 
-void
-Editor::toggle_playback (bool with_abort)
-{
-       if (!session) {
-               return;
-       }
-
-       switch (Config->get_slave_source()) {
-       case None:
-       case JACK:
-               break;
-       default:
-               /* transport controlled by the master */
-               return;
-       }
-
-       if (session->is_auditioning()) {
-               session->cancel_audition ();
-               return;
-       }
-
-       if (session->transport_rolling()) {
-               session->request_stop (with_abort);
-               if (session->get_play_loop()) {
-                       session->request_play_loop (false);
-               }
-       } else {
-               session->request_transport_speed (1.0f);
-       }
-}
-
 void
 Editor::play_from_start ()
 {
@@ -2446,7 +2410,7 @@ Editor::play_selection ()
                return;
        }
 
-       session->request_play_range (true);
+       session->request_play_range (&selection->time, true);
 }
 
 void
@@ -2643,7 +2607,6 @@ Editor::play_selected_region ()
                }
        }
 
-       session->request_stop ();
        session->request_bounded_roll (start, end);
 }
 
@@ -3092,10 +3055,6 @@ Editor::region_fill_track ()
 
                boost::shared_ptr<Region> region ((*i)->region());
 
-               // FIXME
-               boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
-               assert(ar);
-
                boost::shared_ptr<Playlist> pl = region->playlist();
 
                if (end <= region->last_frame()) {
@@ -3109,7 +3068,7 @@ Editor::region_fill_track ()
                }
 
                XMLNode &before = pl->get_state();
-               pl->add_region (RegionFactory::create (ar), ar->last_frame(), times);
+               pl->add_region (RegionFactory::create (region), region->last_frame(), times);
                session->add_command (new MementoCommand<Playlist>(*pl, &before, &pl->get_state()));
        }
 
@@ -3119,7 +3078,7 @@ Editor::region_fill_track ()
 void
 Editor::region_fill_selection ()
 {
-       if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) {
+       if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) {
                return;
        }
 
@@ -4384,62 +4343,6 @@ Editor::paste_internal (nframes64_t position, float times)
        }
 }
 
-void
-Editor::paste_named_selection (float times)
-{
-       TrackSelection::iterator t;
-
-       Glib::RefPtr<TreeSelection> selected = named_selection_display.get_selection();
-
-       if (selected->count_selected_rows() != 1 || selection->tracks.empty()) {
-               return;
-       }
-
-       TreeModel::iterator i = selected->get_selected();
-       NamedSelection* ns = (*i)[named_selection_columns.selection];
-
-       list<boost::shared_ptr<Playlist> >::iterator chunk;
-       list<boost::shared_ptr<Playlist> >::iterator tmp;
-
-       chunk = ns->playlists.begin();
-
-       begin_reversible_command (_("paste chunk"));
-
-       sort_track_selection ();
-
-       for (t = selection->tracks.begin(); t != selection->tracks.end(); ++t) {
-
-               RouteTimeAxisView* rtv;
-               boost::shared_ptr<Playlist> pl;
-               boost::shared_ptr<AudioPlaylist> apl;
-
-               if ((rtv = dynamic_cast<RouteTimeAxisView*> (*t)) == 0) {
-                       continue;
-               }
-
-               if ((pl = rtv->playlist()) == 0) {
-                       continue;
-               }
-
-               if ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) == 0) {
-                       continue;
-               }
-
-               tmp = chunk;
-               ++tmp;
-
-               XMLNode &before = apl->get_state();
-               apl->paste (*chunk, get_preferred_edit_position(), times);
-               session->add_command(new MementoCommand<AudioPlaylist>(*apl, &before, &apl->get_state()));
-
-               if (tmp != ns->playlists.end()) {
-                       chunk = tmp;
-               }
-       }
-
-       commit_reversible_command();
-}
-
 void
 Editor::duplicate_some_regions (RegionSelection& regions, float times)
 {
@@ -4857,15 +4760,17 @@ Editor::quantize_region ()
        QuantizeDialog* qd = new QuantizeDialog (*this);
 
        qd->present ();
-       qd->run ();
+       const int r = qd->run ();
        qd->hide ();
 
-       Quantize quant (*session, Plain,
-                       qd->snap_start(), qd->snap_end(),
-                       qd->start_grid_size(), qd->end_grid_size(),
-                       qd->strength(), qd->swing(), qd->threshold());
+       if (r == Gtk::RESPONSE_OK) {
+               Quantize quant (*session, Plain,
+                               qd->snap_start(), qd->snap_end(),
+                               qd->start_grid_size(), qd->end_grid_size(),
+                               qd->strength(), qd->swing(), qd->threshold());
 
-       apply_midi_note_edit_op (quant);
+               apply_midi_note_edit_op (quant);
+       }
 }
 
 void