Remove unused op parameter to temporal_zoom_by_frame. Add Zoom to Range option to...
authorCarl Hetherington <carl@carlh.net>
Thu, 22 Mar 2012 16:41:44 +0000 (16:41 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 22 Mar 2012 16:41:44 +0000 (16:41 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11750 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_markers.cc
gtk2_ardour/editor_ops.cc

index b02ef1452bd5e82d31cf9a44ff216e4c6b4743b2..d5b2cb9172454483479fa48683378e72d2c35235 100644 (file)
@@ -1201,7 +1201,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void zoom_to_region (bool both_axes);
        void temporal_zoom_session ();
        void temporal_zoom (gdouble scale);
-       void temporal_zoom_by_frame (framepos_t start, framepos_t end, const std::string & op);
+       void temporal_zoom_by_frame (framepos_t start, framepos_t end);
        void temporal_zoom_to_frame (bool coarser, framepos_t frame);
 
        void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
@@ -1501,6 +1501,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void marker_menu_set_from_playhead ();
        void marker_menu_set_from_selection ();
        void marker_menu_range_to_next ();
+       void marker_menu_zoom_to_range ();
        void new_transport_marker_menu_set_loop ();
        void new_transport_marker_menu_set_punch ();
        void update_loop_range_view (bool visibility=false);
index 04c6494d9d2c0bb6029af462e22140eb485109e4..21b47c388f1c5965fb204652ef1e076ada8d3ac1 100644 (file)
@@ -3915,9 +3915,9 @@ MouseZoomDrag::finished (GdkEvent* event, bool movement_occurred)
                motion (event, false);
 
                if (grab_frame() < last_pointer_frame()) {
-                       _editor->temporal_zoom_by_frame (grab_frame(), last_pointer_frame(), "mouse zoom");
+                       _editor->temporal_zoom_by_frame (grab_frame(), last_pointer_frame());
                } else {
-                       _editor->temporal_zoom_by_frame (last_pointer_frame(), grab_frame(), "mouse zoom");
+                       _editor->temporal_zoom_by_frame (last_pointer_frame(), grab_frame());
                }
        } else {
                if (Keyboard::the_keyboard().key_is_down (GDK_Shift_L)) {
index f66b7d02c63808b6485c3588e08430b2cce91fe3..96ae8e66e0eaa1fe280af930d7e0029e21be8c2f 100644 (file)
@@ -879,6 +879,8 @@ Editor::build_range_marker_menu (bool loop_or_punch, bool session)
                items.push_back (MenuElem (_("Set Range from Range Selection"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection)));
        }
 
+       items.push_back (MenuElem (_("Zoom to Range"), sigc::mem_fun (*this, &Editor::marker_menu_zoom_to_range)));
+
        items.push_back (SeparatorElem());
        items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range)));
        items.push_back (SeparatorElem());
@@ -1215,6 +1217,33 @@ Editor::marker_menu_loop_range ()
        }
 }
 
+/** Temporal zoom to the range of the marker_menu_item (plus 5% either side) */
+void
+Editor::marker_menu_zoom_to_range ()
+{
+       Marker* marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"));
+       assert (marker);
+
+       bool is_start;
+       Location* l = find_location_from_marker (marker, is_start);
+       if (l == 0) {
+               return;
+       }
+
+       framecnt_t const extra = l->length() * 0.05;
+       framepos_t a = l->start ();
+       if (a >= extra) {
+               a -= extra;
+       }
+       
+       framepos_t b = l->end ();
+       if (b < (max_framepos - extra)) {
+               b += extra;
+       }
+
+       temporal_zoom_by_frame (a, b);
+}
+
 void
 Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) const
 {
index bcc596a352b11a06ed284c4dce8d4434ce82a79c..1dbad3ac2e34c73a2363cf7bbf57a88dea5ef6ae 100644 (file)
@@ -1493,7 +1493,7 @@ Editor::temporal_zoom_region (bool both_axes)
 
        PBD::Unwinder<bool> nsv (no_save_visual, true);
 
-       temporal_zoom_by_frame (start, end, "zoom to region");
+       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());
@@ -1540,7 +1540,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
@@ -1555,12 +1555,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;