fix Pianoroll::zoom_to_show() so that it does what it says
... and also interacts with EditingContext::reset_zoom() correctly due to the scaling factor that, for the Pianoroll, tries to show a bit more time than is represented by the data
This commit is contained in:
@@ -2510,7 +2510,7 @@ void
|
||||
EditingContext::reset_zoom (samplecnt_t spp)
|
||||
{
|
||||
std::pair<timepos_t, timepos_t> ext = max_zoom_extent();
|
||||
samplecnt_t max_extents_pp = (ext.second.samples() - ext.first.samples()) / _visible_canvas_width;
|
||||
samplecnt_t max_extents_pp = (max_extents_scale() * (ext.second.samples() - ext.first.samples())) / _visible_canvas_width;
|
||||
|
||||
if (spp > max_extents_pp) {
|
||||
spp = max_extents_pp;
|
||||
|
||||
@@ -320,6 +320,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
|
||||
void reset_x_origin (samplepos_t);
|
||||
void reset_y_origin (double);
|
||||
void reset_zoom (samplecnt_t);
|
||||
virtual double max_extents_scale() const { return 1.0; }
|
||||
virtual void set_samples_per_pixel (samplecnt_t) = 0;
|
||||
virtual void on_samples_per_pixel_changed () {}
|
||||
|
||||
|
||||
@@ -2002,7 +2002,7 @@ Pianoroll::set_region (std::shared_ptr<ARDOUR::MidiRegion> r)
|
||||
{
|
||||
EditingContext::TempoMapScope tms (*this, map);
|
||||
/* Compute zoom level to show entire source plus some margin if possible */
|
||||
zoom_to_show (timecnt_t (timepos_t (Temporal::BeatTime), timepos_t (max_zoom_extent ().second.beats() * 1.1)));
|
||||
zoom_to_show (timecnt_t (timepos_t (max_zoom_extent ().second.beats())));
|
||||
|
||||
}
|
||||
|
||||
@@ -2017,8 +2017,7 @@ Pianoroll::zoom_to_show (Temporal::timecnt_t const & duration)
|
||||
}
|
||||
|
||||
/* make it 20% wider than we need */
|
||||
samplecnt_t samples = (samplecnt_t) floor (1.2 * duration.samples());
|
||||
std::cerr << "new spp from " << samples << " / " << _visible_canvas_width << std::endl;
|
||||
samplecnt_t samples = (samplecnt_t) floor (max_extents_scale() * duration.samples());
|
||||
samplecnt_t spp = floor (samples / _visible_canvas_width);
|
||||
reset_zoom (spp);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ class Pianoroll : public CueEditor
|
||||
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
|
||||
ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; }
|
||||
|
||||
double max_extents_scale() const { return 1.2; }
|
||||
void set_samples_per_pixel (samplecnt_t);
|
||||
|
||||
void set_mouse_mode (Editing::MouseMode, bool force = false);
|
||||
|
||||
Reference in New Issue
Block a user