X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_summary.cc;h=95b54cdf02a3b0981176143dfafb9e8e57335d77;hb=9bc8b32b8eaf8304d0c51c3340e15345b7300988;hp=8d68b6775426d4199a45394ac73b50a8aa7928df;hpb=243d55f3c29c846650c7723b7a2dc2e12d276a99;p=ardour.git diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index 8d68b67754..95b54cdf02 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -21,6 +21,9 @@ #include "canvas/debug.h" +#include +#include + #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 "pbd/i18n.h" + using namespace std; using namespace ARDOUR; using Gtkmm2ext::Keyboard; @@ -46,7 +51,6 @@ EditorSummary::EditorSummary (Editor* e) : EditorComponent (e), _start (0), _end (1), - _overhang_fraction (0.02), _x_scale (1), _track_height (16), _last_playhead (-1), @@ -112,10 +116,10 @@ EditorSummary::set_session (Session* s) _session->StartTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); _session->EndTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); _editor->selection->RegionsChanged.connect (sigc::mem_fun(*this, &EditorSummary::set_background_dirty)); - - _leftmost = _session->current_start_frame(); - _rightmost = min (_session->nominal_frame_rate()*60*2, _session->current_end_frame() ); //always show at least 2 minutes } + + _leftmost = max_framepos; + _rightmost = 0; } void @@ -134,9 +138,9 @@ EditorSummary::render_background_image () /* compute start and end points for the summary */ - framecnt_t const session_length = _session->current_end_frame() - _session->current_start_frame (); - double theoretical_start = _session->current_start_frame() - session_length * _overhang_fraction; - double theoretical_end = _session->current_end_frame(); + std::pair ext = _editor->session_gui_extents(); + double theoretical_start = ext.first; + double theoretical_end = ext.second; /* the summary should encompass the full extent of everywhere we've visited since the session was opened */ if ( _leftmost < theoretical_start) @@ -146,7 +150,7 @@ EditorSummary::render_background_image () /* range-check */ _start = theoretical_start > 0 ? theoretical_start : 0; - _end = theoretical_end + session_length * _overhang_fraction; + _end = theoretical_end < max_framepos ? theoretical_end : max_framepos; /* calculate x scale */ if (_end != _start) { @@ -340,9 +344,9 @@ EditorSummary::set_overlays_dirty () /** Set the summary so that just the overlays (viewbox, playhead etc.) in a given area will be re-rendered */ void -EditorSummary::set_overlays_dirty (int x, int y, int w, int h) +EditorSummary::set_overlays_dirty_rect (int x, int y, int w, int h) { - ENSURE_GUI_THREAD (*this, &EditorSummary::set_overlays_dirty); + ENSURE_GUI_THREAD (*this, &EditorSummary::set_overlays_dirty_rect); queue_draw_area (x, y, w, h); } @@ -425,6 +429,8 @@ EditorSummary::on_key_release_event (GdkEventKey* key) return false; } +#include "gtkmm2ext/utils.h" + /** Handle a button press. * @param ev GTK event. */ @@ -433,6 +439,16 @@ EditorSummary::on_button_press_event (GdkEventButton* ev) { _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; } @@ -557,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) { @@ -638,10 +666,19 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev) double x = _start_editor_x.first; x += ev->x - _start_mouse_x; + if (x < 0) { x = 0; } - set_editor (x); + + //zoom-behavior-tweaks + //protect the right edge from expanding beyond the end + pair xr; + get_editor (&xr); + double w = xr.second - xr.first; + if ( x + w < get_width() ) { + set_editor (x); + } } _last_my = my; @@ -658,7 +695,13 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev) if (_zoom_trim_position == LEFT) { xr.first += dx; } else if (_zoom_trim_position == RIGHT) { - xr.second += dx; + + //zoom-behavior-tweaks + //protect the right edge from expanding beyond the edge + if ( (xr.second + dx) < get_width() ) { + xr.second += dx; + } + } else { assert (0); xr.first = -1; /* do not change */ @@ -854,7 +897,7 @@ EditorSummary::playhead_position_changed (framepos_t p) if (_session && o != n) { int a = max(2, min (o, n)); int b = max (o, n); - set_overlays_dirty (a - 2, 0, b + 2, get_height ()); + set_overlays_dirty_rect (a - 2, 0, b + 2, get_height ()); } }