make click on empty canvas area clear selection; change zoom-ot-region to be a toggle...
[ardour.git] / gtk2_ardour / editor_ops.cc
index f0290c2d355dc3ea9dd2769011b9e9d133f8772c..f3a493e1959f215e55bd361ddab4777c04ea6453 100644 (file)
@@ -28,6 +28,7 @@
 #include <pbd/basename.h>
 #include <pbd/pthread_utils.h>
 #include <pbd/memento_command.h>
+#include <pbd/whitespace.h>
 
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/choice.h>
@@ -356,6 +357,17 @@ Editor::nudge_forward (bool next)
 
                commit_reversible_command ();
 
+               
+       } else if (!selection->markers.empty()) {
+
+               bool ignored;
+               Location* loc = find_location_from_marker (selection->markers.front(), ignored);
+
+               if (loc) {
+                       distance = get_nudge_distance (loc->start(), next_distance);
+                       loc->set_start (loc->start() + distance);
+               }
+               
        } else {
                distance = get_nudge_distance (playhead_cursor->current_frame, next_distance);
                session->request_locate (playhead_cursor->current_frame + distance);
@@ -544,12 +556,15 @@ Editor::build_region_boundary_cache ()
                        case Start:
                                rpos = r->first_frame();
                                break;
+
                        case End:
                                rpos = r->last_frame();
                                break;  
+
                        case SyncPoint:
                                rpos = r->adjust_to_sync (r->first_frame());
                                break;
+
                        default:
                                break;
                        }
@@ -636,6 +651,7 @@ Editor::find_next_region (nframes_t frame, RegionPoint point, int32_t dir, Track
                        rpos = r->adjust_to_sync (r->first_frame());
                        break;
                }
+
                // rpos is a "track frame", converting it to "session frame"
                rpos = track_frame_to_session_frame(rpos, track_speed);
 
@@ -656,6 +672,85 @@ Editor::find_next_region (nframes_t frame, RegionPoint point, int32_t dir, Track
        return ret;
 }
 
+nframes64_t
+Editor::find_next_region_boundary (nframes64_t pos, int32_t dir, const TrackViewList& tracks)
+{
+       nframes64_t distance = max_frames;
+       nframes64_t current_nearest = -1;
+
+       for (TrackViewList::const_iterator i = tracks.begin(); i != tracks.end(); ++i) {
+               nframes64_t contender;
+               nframes64_t d;
+
+               RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
+
+               if (!rtv) {
+                       continue;
+               }
+
+               if ((contender = rtv->find_next_region_boundary (pos, dir)) < 0) {
+                       continue;
+               }
+
+               d = ::llabs (pos - contender);
+
+               if (d < distance) {
+                       current_nearest = contender;
+                       distance = d;
+               }
+       }
+       
+       return current_nearest;
+}
+
+void
+Editor::cursor_to_region_boundary (Cursor* cursor, int32_t dir)
+{
+       nframes64_t pos = cursor->current_frame;
+       nframes64_t target;
+
+       if (!session) {
+               return;
+       }
+
+       // so we don't find the current region again..
+       if (dir > 0 || pos > 0) {
+               pos += dir;
+       }
+
+       if (!selection->tracks.empty()) {
+               
+               target = find_next_region_boundary (pos, dir, selection->tracks);
+               
+       } else {
+               
+               target = find_next_region_boundary (pos, dir, track_views);
+       }
+       
+       if (target < 0) {
+               return;
+       }
+
+
+       if (cursor == playhead_cursor) {
+               session->request_locate (target);
+       } else {
+               cursor->set_position (target);
+       }
+}
+
+void
+Editor::cursor_to_next_region_boundary (Cursor* cursor)
+{
+       cursor_to_region_boundary (cursor, 1);
+}
+
+void
+Editor::cursor_to_previous_region_boundary (Cursor* cursor)
+{
+       cursor_to_region_boundary (cursor, -1);
+}
+
 void
 Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir)
 {
@@ -794,7 +889,68 @@ Editor::cursor_to_selection_end (Cursor *cursor)
 }
 
 void
-Editor::edit_point_to_region_point (RegionPoint point, int32_t dir)
+Editor::selected_marker_to_region_boundary (int32_t dir)
+{
+       nframes64_t target;
+       Location* loc;
+       bool ignored;
+
+       if (!session) {
+               return;
+       }
+
+       if (selection->markers.empty()) {
+               nframes64_t mouse;
+               bool ignored;
+
+               if (!mouse_frame (mouse, ignored)) {
+                       return;
+               }
+               
+               add_location_mark (mouse);
+       }
+
+       if ((loc = find_location_from_marker (selection->markers.front(), ignored)) == 0) {
+               return;
+       }
+
+       nframes64_t pos = loc->start();
+
+       // so we don't find the current region again..
+       if (dir > 0 || pos > 0) {
+               pos += dir;
+       }
+
+       if (!selection->tracks.empty()) {
+               
+               target = find_next_region_boundary (pos, dir, selection->tracks);
+               
+       } else {
+               
+               target = find_next_region_boundary (pos, dir, track_views);
+       }
+       
+       if (target < 0) {
+               return;
+       }
+
+       loc->move_to (target);
+}
+
+void
+Editor::selected_marker_to_next_region_boundary ()
+{
+       selected_marker_to_region_boundary (1);
+}
+
+void
+Editor::selected_marker_to_previous_region_boundary ()
+{
+       selected_marker_to_region_boundary (-1);
+}
+
+void
+Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir)
 {
        boost::shared_ptr<Region> r;
        nframes_t pos;
@@ -866,19 +1022,19 @@ Editor::edit_point_to_region_point (RegionPoint point, int32_t dir)
 }
 
 void
-Editor::edit_point_to_next_region_point (RegionPoint point)
+Editor::selected_marker_to_next_region_point (RegionPoint point)
 {
-       edit_point_to_region_point (point, 1);
+       selected_marker_to_region_point (point, 1);
 }
 
 void
-Editor::edit_point_to_previous_region_point (RegionPoint point)
+Editor::selected_marker_to_previous_region_point (RegionPoint point)
 {
-       edit_point_to_region_point (point, -1);
+       selected_marker_to_region_point (point, -1);
 }
 
 void
-Editor::edit_point_to_selection_start ()
+Editor::selected_marker_to_selection_start ()
 {
        nframes_t pos = 0;
        Location* loc;
@@ -913,7 +1069,7 @@ Editor::edit_point_to_selection_start ()
 }
 
 void
-Editor::edit_point_to_selection_end ()
+Editor::selected_marker_to_selection_end ()
 {
        nframes_t pos = 0;
        Location* loc;
@@ -1110,7 +1266,7 @@ Editor::edit_cursor_backward ()
 void
 Editor::edit_cursor_forward ()
 {
-       nframes_t pos;
+       //nframes_t pos;
        nframes_t cnt;
        bool was_floating;
        float prefix;
@@ -1384,6 +1540,67 @@ Editor::temporal_zoom (gdouble fpu)
        reposition_and_zoom (leftmost_after_zoom, nfpu);
 }      
 
+void
+Editor::temporal_zoom_region ()
+{
+
+       nframes64_t start = max_frames;
+       nframes64_t end = 0;
+
+       ensure_entered_region_selected (true);
+
+       if (selection->regions.empty()) {
+               info << _("cannot set loop: no region selected") << endmsg;
+               return;
+       }
+
+       for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
+               if ((*i)->region()->position() < start) {
+                       start = (*i)->region()->position();
+               }
+               if ((*i)->region()->last_frame() + 1 > end) {
+                       end = (*i)->region()->last_frame() + 1;
+               }
+       }
+
+       /* now comes an "interesting" hack ... make sure we leave a little space
+          at each end of the editor so that the zoom doesn't fit the region
+          precisely to the screen.
+       */
+
+       GdkScreen* screen = gdk_screen_get_default ();
+       gint pixwidth = gdk_screen_get_width (screen);
+       gint mmwidth = gdk_screen_get_width_mm (screen);
+       double pix_per_mm = (double) pixwidth/ (double) mmwidth;
+       double one_centimeter_in_pixels = pix_per_mm * 10.0;
+       nframes_t extra_samples = unit_to_frame (one_centimeter_in_pixels);
+       
+       if (start > extra_samples) {
+               start -= extra_samples;
+       } else {
+               start = 0;
+       } 
+
+       if (max_frames - extra_samples > end) {
+               end += extra_samples;
+       } else {
+               end = max_frames;
+       }
+
+       temporal_zoom_by_frame (start, end, "zoom to region");
+       zoomed_to_region = true;
+}
+
+void
+Editor::toggle_zoom_region ()
+{
+       if (zoomed_to_region) {
+               swap_visual_state ();
+       } else {
+               temporal_zoom_region ();
+       }
+}
+
 void
 Editor::temporal_zoom_selection ()
 {
@@ -1502,12 +1719,12 @@ Editor::add_location_from_selection ()
 }
 
 void
-Editor::add_location_from_playhead_cursor ()
+Editor::add_location_mark (nframes64_t where)
 {
        string markername;
 
-       nframes_t where = session->audible_frame();
-       
+       select_new_marker = true;
+
        session->locations()->next_available_name(markername,"mark");
        Location *location = new Location (where, where, markername, Location::IsMark);
        session->begin_reversible_command (_("add marker"));
@@ -1518,6 +1735,12 @@ Editor::add_location_from_playhead_cursor ()
        session->commit_reversible_command ();
 }
 
+void
+Editor::add_location_from_playhead_cursor ()
+{
+       add_location_mark (session->audible_frame());
+}
+
 void
 Editor::add_location_from_audio_region ()
 {
@@ -1775,6 +1998,10 @@ Editor::insert_region_list_selection (float times)
                if ((tv = dynamic_cast<RouteTimeAxisView*>(selection->tracks.front())) == 0) {
                        return;
                }
+       } else if (entered_track != 0) {
+               if ((tv = dynamic_cast<RouteTimeAxisView*>(entered_track)) == 0) {
+                       return;
+               }
        } else {
                return;
        }
@@ -1901,16 +2128,6 @@ Editor::play_selection ()
        session->request_play_range (true);
 }
 
-void
-Editor::play_selected_region ()
-{
-       if (!selection->regions.empty()) {
-               RegionView *rv = *(selection->regions.begin());
-
-               session->request_bounded_roll (rv->region()->position(), rv->region()->last_frame());   
-       }
-}
-
 void
 Editor::loop_selected_region ()
 {
@@ -1994,58 +2211,54 @@ Editor::edit_region ()
 }
 
 void
-Editor::rename_region ()
+Editor::rename_region()
 {
-       Dialog dialog;
-       Entry  entry;
-       Button ok_button (_("OK"));
-       Button cancel_button (_("Cancel"));
-
        if (selection->regions.empty()) {
                return;
        }
 
-       WindowTitle title(Glib::get_application_name());
+       WindowTitle title (Glib::get_application_name());
        title += _("Rename Region");
 
-       dialog.set_title (title.get_string());
-       dialog.set_name ("RegionRenameWindow");
-       dialog.set_size_request (300, -1);
-       dialog.set_position (Gtk::WIN_POS_MOUSE);
-       dialog.set_modal (true);
+       ArdourDialog d (*this, title.get_string(), true, false);
+       Entry entry;
+       Label label (_("New name:"));
+       HBox hbox;
 
-       dialog.get_vbox()->set_border_width (10);
-       dialog.get_vbox()->pack_start (entry);
-       dialog.get_action_area()->pack_start (ok_button);
-       dialog.get_action_area()->pack_start (cancel_button);
+       hbox.set_spacing (6);
+       hbox.pack_start (label, false, false);
+       hbox.pack_start (entry, true, true);
 
-       entry.set_name ("RegionNameDisplay");
-       ok_button.set_name ("EditorGTKButton");
-       cancel_button.set_name ("EditorGTKButton");
+       d.get_vbox()->set_border_width (12);
+       d.get_vbox()->pack_start (hbox, false, false);
 
-       region_renamed = false;
+       d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
+       d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 
-       entry.signal_activate().connect (bind (mem_fun(*this, &Editor::rename_region_finished), true));
-       ok_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::rename_region_finished), true));
-       cancel_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::rename_region_finished), false));
+       d.set_size_request (300, -1);
+       d.set_position (Gtk::WIN_POS_MOUSE);
 
-       /* recurse */
+       entry.set_text (selection->regions.front()->region()->name());
+       entry.select_region (0, -1);
 
-       dialog.show_all ();
-       Main::run ();
+       entry.signal_activate().connect (bind (mem_fun (d, &Dialog::response), RESPONSE_OK));
+       
+       d.show_all ();
+       
+       entry.grab_focus();
 
-       if (region_renamed) {
-               (*selection->regions.begin())->region()->set_name (entry.get_text());
-               redisplay_regions ();
-       }
-}
+       int ret = d.run();
 
-void
-Editor::rename_region_finished (bool status)
+       d.hide ();
 
-{
-       region_renamed = status;
-       Main::quit ();
+       if (ret == RESPONSE_OK) {
+               std::string str = entry.get_text();
+               strip_whitespace_edges (str);
+               if (!str.empty()) {
+                       selection->regions.front()->region()->set_name (str);
+                       redisplay_regions ();
+               }
+       }
 }
 
 void
@@ -2068,12 +2281,27 @@ Editor::audition_playlist_region_via_route (boost::shared_ptr<Region> region, Ro
 }
 
 void
-Editor::audition_selected_region ()
+Editor::play_selected_region ()
 {
-       if (!selection->regions.empty()) {
-               RegionView* rv = *(selection->regions.begin());
-               session->audition_region (rv->region());
+       nframes64_t start = max_frames;
+       nframes64_t end = 0;
+
+       ensure_entered_region_selected (true);
+
+       if (selection->regions.empty()) {
+               return;
        }
+
+       for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
+               if ((*i)->region()->position() < start) {
+                       start = (*i)->region()->position();
+               }
+               if ((*i)->region()->last_frame() + 1 > end) {
+                       end = (*i)->region()->last_frame() + 1;
+               }
+       }
+
+       session->request_bounded_roll (start, end);
 }
 
 void
@@ -2332,7 +2560,7 @@ Editor::separate_region_from_selection ()
 
                        /* force track selection */
 
-                       ensure_entered_selected ();
+                       ensure_entered_region_selected ();
                        
                        separate_regions_between (ts);
                }
@@ -2357,13 +2585,13 @@ Editor::separate_regions_using_location (Location& loc)
 void
 Editor::crop_region_to_selection ()
 {
-       ensure_entered_selected (true);
+       ensure_entered_region_selected (true);
 
        if (!selection->time.empty()) {
 
                crop_region_to (selection->time.start(), selection->time.end_frame());
 
-       } else if (_edit_point != EditAtPlayhead) {
+       } else {
 
                nframes64_t start;
                nframes64_t end;
@@ -2547,7 +2775,7 @@ void
 Editor::set_region_sync_from_edit_point ()
 {
        nframes64_t where = get_preferred_edit_position ();
-       ensure_entered_selected ();
+       ensure_entered_region_selected (true);
        set_sync_point (where, selection->regions);
 }
 
@@ -2613,7 +2841,7 @@ Editor::naturalize ()
 void
 Editor::align (RegionPoint what)
 {
-       ensure_entered_selected ();
+       ensure_entered_region_selected ();
 
        nframes64_t where = get_preferred_edit_position();
 
@@ -2779,7 +3007,7 @@ Editor::trim_region_to_punch ()
 void
 Editor::trim_region_to_location (const Location& loc, const char* str)
 {
-       ensure_entered_selected ();
+       ensure_entered_region_selected ();
 
        RegionSelection& rs (get_regions_for_action ());
 
@@ -3085,12 +3313,13 @@ Editor::cut_copy (CutCopyOp op)
 
        switch (current_mouse_mode()) {
        case MouseObject: 
+               cerr << "cutting in object mode\n";
                if (!selection->regions.empty() || !selection->points.empty()) {
 
                        begin_reversible_command (opname + _(" objects"));
 
                        if (!selection->regions.empty()) {
-                               
+                               cerr << "have regions to cut" << endl;
                                cut_copy_regions (op);
                                
                                if (op == Cut) {
@@ -3109,7 +3338,7 @@ Editor::cut_copy (CutCopyOp op)
                        commit_reversible_command ();   
                        break; // terminate case statement here
                } 
-
+               cerr << "nope, now cutting time range" << endl;
                if (!selection->time.empty()) {
                        /* don't cause suprises */
                        break;
@@ -3119,10 +3348,12 @@ Editor::cut_copy (CutCopyOp op)
        case MouseRange:
                if (selection->time.empty()) {
                        nframes64_t start, end;
+                       cerr << "no time selection, get edit op range" << endl;
                        if (!get_edit_op_range (start, end)) {
+                               cerr << "no edit op range" << endl;
                                return;
                        }
-                       selection->set (0, start, end);
+                       selection->set ((TimeAxisView*) 0, start, end);
                }
                        
                begin_reversible_command (opname + _(" range"));
@@ -3346,7 +3577,7 @@ Editor::paste_internal (nframes_t position, float times)
 {
        bool commit = false;
 
-       if (cut_buffer->empty() || selection->tracks.empty()) {
+       if (cut_buffer->empty()) {
                return;
        }
 
@@ -3356,14 +3587,21 @@ Editor::paste_internal (nframes_t position, float times)
 
        begin_reversible_command (_("paste"));
 
+       TrackSelection ts;
        TrackSelection::iterator i;
        size_t nth;
 
        /* get everything in the correct order */
 
-       sort_track_selection ();
 
-       for (nth = 0, i = selection->tracks.begin(); i != selection->tracks.end(); ++i, ++nth) {
+       if (!selection->tracks.empty()) {
+               sort_track_selection ();
+               ts = selection->tracks;
+       } else if (entered_track) {
+               ts.push_back (entered_track);
+       }
+
+       for (nth = 0, i = ts.begin(); i != ts.end(); ++i, ++nth) {
 
                /* undo/redo is handled by individual tracks */
 
@@ -3883,7 +4121,7 @@ Editor::toggle_region_opaque ()
 void
 Editor::set_fade_length (bool in)
 {
-       ensure_entered_selected ();
+       ensure_entered_region_selected (true);
 
        /* we need a region to measure the offset from the start */
 
@@ -3944,6 +4182,44 @@ Editor::set_fade_length (bool in)
        commit_reversible_command ();
 }
 
+
+void
+Editor::toggle_fade_active (bool in)
+{
+       ensure_entered_region_selected (true);
+
+       if (selection->regions.empty()) {
+               return;
+       }
+
+       const char* cmd = (in ? _("toggle fade in active") : _("toggle fade out active"));
+
+       begin_reversible_command (cmd);
+
+       for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
+               AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (*x);
+
+               if (!tmp) {
+                       return;
+               }
+
+               boost::shared_ptr<AudioRegion> region (tmp->audio_region());
+
+               XMLNode &before = region->get_state();
+
+               if (in) {
+                       region->set_fade_in_active (!region->fade_in_active());
+               } else {
+                       region->set_fade_out_active (!region->fade_out_active());
+               }
+
+               XMLNode &after = region->get_state();
+               session->add_command(new MementoCommand<AudioRegion>(*region.get(), &before, &after));
+       }
+
+       commit_reversible_command ();
+}
+
 void
 Editor::set_fade_in_shape (AudioRegion::FadeShape shape)
 {
@@ -4109,7 +4385,7 @@ Editor::set_playhead_cursor ()
 void
 Editor::split ()
 {
-       ensure_entered_selected ();
+       ensure_entered_region_selected ();
 
        nframes64_t where = get_preferred_edit_position();
 
@@ -4126,7 +4402,25 @@ Editor::split ()
 }
 
 void
-Editor::ensure_entered_selected (bool op_really_wants_one_region_if_none_are_selected)
+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);
+                       }
+               }
+       }
+}
+
+void
+Editor::ensure_entered_region_selected (bool op_really_wants_one_region_if_none_are_selected)
 {
        if (entered_regionview && mouse_mode == MouseObject) {
 
@@ -4192,3 +4486,169 @@ Editor::trim_region (bool front)
        }
        commit_reversible_command ();
 }
+
+struct EditorOrderRouteSorter {
+    bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
+           /* use of ">" forces the correct sort order */
+           return a->order_key ("editor") < b->order_key ("editor");
+    }
+};
+
+void
+Editor::select_next_route()
+{
+       if (selection->tracks.empty()) {
+               selection->set (track_views.front());
+               return;
+       }
+
+       TimeAxisView* current = selection->tracks.front();
+
+       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+               if (*i == current) {
+                       ++i;
+                       if (i != track_views.end()) {
+                               selection->set (*i);
+                       } else {
+                               selection->set (*(track_views.begin()));
+                       }
+                       break;
+               }
+       }
+}
+
+void
+Editor::select_prev_route()
+{
+       if (selection->tracks.empty()) {
+               selection->set (track_views.front());
+               return;
+       }
+
+       TimeAxisView* current = selection->tracks.front();
+
+       for (TrackViewList::reverse_iterator i = track_views.rbegin(); i != track_views.rend(); ++i) {
+               if (*i == current) {
+                       ++i;
+                       if (i != track_views.rend()) {
+                               selection->set (*i);
+                       } else {
+                               selection->set (*(track_views.rbegin()));
+                       }
+                       break;
+               }
+       }
+}
+
+void
+Editor::set_loop_from_selection (bool play)
+{
+       if (session == 0 || selection->time.empty()) {
+               return;
+       }
+
+       nframes_t start = selection->time[clicked_selection].start;
+       nframes_t end = selection->time[clicked_selection].end;
+       
+       set_loop_range (start, end,  _("set loop range from selection"));
+
+       if (play) {
+               session->request_play_loop (true);
+               session->request_locate (start, true);
+       }
+}
+
+void
+Editor::set_loop_from_edit_range (bool play)
+{
+       if (session == 0) {
+               return;
+       }
+
+       nframes64_t start;
+       nframes64_t end;
+       
+       if (!get_edit_op_range (start, end)) {
+               return;
+       }
+
+       set_loop_range (start, end,  _("set loop range from edit range"));
+
+       if (play) {
+               session->request_play_loop (true);
+               session->request_locate (start, true);
+       }
+}
+
+void
+Editor::set_loop_from_region (bool play)
+{
+       nframes64_t start = max_frames;
+       nframes64_t end = 0;
+
+       ensure_entered_region_selected (true);
+
+       if (selection->regions.empty()) {
+               info << _("cannot set loop: no region selected") << endmsg;
+               return;
+       }
+
+       for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
+               if ((*i)->region()->position() < start) {
+                       start = (*i)->region()->position();
+               }
+               if ((*i)->region()->last_frame() + 1 > end) {
+                       end = (*i)->region()->last_frame() + 1;
+               }
+       }
+
+       set_loop_range (start, end, _("set loop range from region"));
+
+       if (play) {
+               session->request_play_loop (true);
+               session->request_locate (start, true);
+       }
+}
+
+void
+Editor::set_punch_from_selection ()
+{
+       if (session == 0 || selection->time.empty()) {
+               return;
+       }
+
+       nframes_t start = selection->time[clicked_selection].start;
+       nframes_t end = selection->time[clicked_selection].end;
+       
+       set_punch_range (start, end,  _("set punch range from selection"));
+}
+
+void
+Editor::set_punch_from_edit_range ()
+{
+       if (session == 0) {
+               return;
+       }
+
+       nframes64_t start;
+       nframes64_t end;
+       
+       if (!get_edit_op_range (start, end)) {
+               return;
+       }
+
+       set_punch_range (start, end,  _("set punch range from edit range"));
+}
+
+void
+Editor::pitch_shift_regions ()
+{
+       ensure_entered_region_selected (true);
+       
+       if (selection->regions.empty()) {
+               return;
+       }
+
+       pitch_shift (selection->regions, 1.2);
+}
+