#include "ardour/automation_list.h"
#include "ardour/dB.h"
#include "ardour/debug.h"
+#include "ardour/tempo.h"
#include "evoral/Curve.hpp"
}
void
-AutomationLine::ContiguousControlPoints::compute_x_bounds ()
+AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e)
{
uint32_t sz = size();
if (sz > 0 && sz < line.npoints()) {
+ const TempoMap& map (e.session()->tempo_map());
/* determine the limits on x-axis motion for this
contiguous range of control points
if (front()->view_index() > 0) {
before_x = line.nth (front()->view_index() - 1)->get_x();
+
+ const framepos_t pos = e.pixel_to_sample(before_x);
+ const Meter& meter = map.meter_at (pos);
+ const framecnt_t len = ceil(meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate()) / 1920.0 / meter.divisions_per_bar());
+ const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len);
+
+ before_x += one_tick_in_pixels;
}
/* if our last point has a point after it in the line,
we have an "after" bound
*/
- if (back()->view_index() < (line.npoints() - 2)) {
+ if (back()->view_index() < (line.npoints() - 1)) {
after_x = line.nth (back()->view_index() + 1)->get_x();
+
+ const framepos_t pos = e.pixel_to_sample(after_x);
+ const Meter& meter = map.meter_at (pos);
+ const framecnt_t len = ceil(meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate()) / 1920.0 / meter.divisions_per_bar());
+ const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len);
+
+ after_x -= one_tick_in_pixels;
}
}
}
}
for (vector<CCP>::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) {
- (*ccp)->compute_x_bounds ();
+ (*ccp)->compute_x_bounds (trackview.editor());
}
}
class AutomationTimeAxisView;
class Selectable;
class Selection;
+class PublicEditor;
/** A GUI representation of an ARDOUR::AutomationList */
ContiguousControlPoints (AutomationLine& al);
double clamp_dx (double dx);
void move (double dx, double dy);
- void compute_x_bounds ();
+ void compute_x_bounds (PublicEditor& e);
private:
AutomationLine& line;
double before_x;