#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 "route_time_axis.h"
#include "ui_config.h"
+#include "pbd/i18n.h"
+
using namespace std;
using namespace ARDOUR;
using Gtkmm2ext::Keyboard;
: EditorComponent (e),
_start (0),
_end (1),
- _overhang_fraction (0.02),
_x_scale (1),
_track_height (16),
_last_playhead (-1),
_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
/* 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<framepos_t, framepos_t> 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)
/* 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) {
int32_t width = _view_rectangle_x.second - _view_rectangle_x.first;
std::min(8, width);
- int32_t height = _view_rectangle_y.second - _view_rectangle_y.first;
cairo_rectangle (cr, _view_rectangle_x.first, 0, width, get_height ());
cairo_set_source_rgba (cr, 1, 1, 1, 0.15);
cairo_fill (cr);
/** 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);
}
return false;
}
+#include "gtkmm2ext/utils.h"
+
/** Handle a button press.
* @param ev GTK event.
*/
{
_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;
}
}
}
+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)
{
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<double, double> xr;
+ get_editor (&xr);
+ double w = xr.second - xr.first;
+ if ( x + w < get_width() ) {
+ set_editor (x);
+ }
}
_last_my = my;
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 */
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 ());
}
}