Editor zooming: right-click on summary -> context menu -> reset to session extents.
authorBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 04:32:02 +0000 (23:32 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Sun, 27 Aug 2017 04:32:02 +0000 (23:32 -0500)
gtk2_ardour/editor_summary.cc
gtk2_ardour/editor_summary.h

index 728773e6b74dcebb869e42f4344fe56cae6743b7..95b54cdf02a3b0981176143dfafb9e8e57335d77 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "canvas/debug.h"
 
 
 #include "canvas/debug.h"
 
+#include <gtkmm/menu.h>
+#include <gtkmm/menuitem.h>
+
 #include "time_axis_view.h"
 #include "streamview.h"
 #include "editor_summary.h"
 #include "time_axis_view.h"
 #include "streamview.h"
 #include "editor_summary.h"
@@ -35,6 +38,8 @@
 #include "route_time_axis.h"
 #include "ui_config.h"
 
 #include "route_time_axis.h"
 #include "ui_config.h"
 
+#include "pbd/i18n.h"
+
 using namespace std;
 using namespace ARDOUR;
 using Gtkmm2ext::Keyboard;
 using namespace std;
 using namespace ARDOUR;
 using Gtkmm2ext::Keyboard;
@@ -424,6 +429,8 @@ EditorSummary::on_key_release_event (GdkEventKey* key)
        return false;
 }
 
        return false;
 }
 
+#include "gtkmm2ext/utils.h"
+
 /** Handle a button press.
  *  @param ev GTK event.
  */
 /** Handle a button press.
  *  @param ev GTK event.
  */
@@ -432,6 +439,16 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
 {
        _old_follow_playhead = _editor->follow_playhead ();
 
 {
        _old_follow_playhead = _editor->follow_playhead ();
 
+       if (ev->button == 3) {  //right-click:  show the reset menu action
+               using namespace Gtk::Menu_Helpers;
+               Gtk::Menu* m = manage (new Gtk::Menu);
+               MenuList& items = m->items ();
+               items.push_back(MenuElem(_("Reset Summary to Extents"),
+                       sigc::mem_fun(*this, &EditorSummary::reset_to_extents)));
+               m->popup (ev->button, ev->time);
+               return true;
+       }
+
        if (ev->button != 1) {
                return true;
        }
        if (ev->button != 1) {
                return true;
        }
@@ -556,6 +573,18 @@ EditorSummary::get_position (double x, double y) const
        }
 }
 
        }
 }
 
+void
+EditorSummary::reset_to_extents()
+{
+       //reset as if the user never went anywhere outside the extents
+       _leftmost = max_framepos;
+       _rightmost = 0;
+
+       _editor->temporal_zoom_extents ();
+       set_background_dirty ();
+}
+
+
 void
 EditorSummary::set_cursor (Position p)
 {
 void
 EditorSummary::set_cursor (Position p)
 {
index 3b75909ad1e87f4667c38e3748674179a630dc59..6639285eea84471eac13ccb31d44a427cd7181cb 100644 (file)
@@ -65,6 +65,8 @@ private:
        bool on_enter_notify_event (GdkEventCrossing*);
        bool on_leave_notify_event (GdkEventCrossing*);
 
        bool on_enter_notify_event (GdkEventCrossing*);
        bool on_leave_notify_event (GdkEventCrossing*);
 
+       void reset_to_extents ();
+
        void centre_on_click (GdkEventButton *);
        void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
        void render_region (RegionView*, cairo_t*, double) const;
        void centre_on_click (GdkEventButton *);
        void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
        void render_region (RegionView*, cairo_t*, double) const;