summaryrefslogtreecommitdiff
path: root/libs/canvas
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-02-09 17:55:05 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-02-10 19:48:47 -0500
commit34779ee81ea52abfdb658b320726155c44178483 (patch)
tree427e3d686ef478ba498b3c5871b61580093d06d1 /libs/canvas
parent99054ea415c8a28227024bc27152fdf30379bdf9 (diff)
add a sort-of hack to allow us to avoid drawing the first pixel of a waveview when necessary
Diffstat (limited to 'libs/canvas')
-rw-r--r--libs/canvas/canvas/wave_view.h12
-rw-r--r--libs/canvas/wave_view.cc16
2 files changed, 26 insertions, 2 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h
index f26c3a5c10..4820a3696e 100644
--- a/libs/canvas/canvas/wave_view.h
+++ b/libs/canvas/canvas/wave_view.h
@@ -103,6 +103,15 @@ public:
void set_channel (int);
void set_region_start (ARDOUR::frameoffset_t);
+ /** Change the first position drawn by @param pixels.
+ * @param pixels must be positive. This is used by
+ * AudioRegionViews in Ardour to avoid drawing the
+ * first pixel of a waveform, and exists in case
+ * there are uses for WaveView where we do not
+ * want this behaviour.
+ */
+ void set_start_shift (double pixels);
+
void set_fill_color (Color);
void set_outline_color (Color);
@@ -171,7 +180,8 @@ private:
bool _gradient_depth_independent;
double _amplitude_above_axis;
float _region_amplitude;
-
+ double _start_shift;
+
/** The `start' value to use for the region; we can't use the region's
* value as the crossfade editor needs to alter it.
*/
diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc
index 9c4ae778fe..bae9d3f8f5 100644
--- a/libs/canvas/wave_view.cc
+++ b/libs/canvas/wave_view.cc
@@ -71,6 +71,7 @@ WaveView::WaveView (Canvas* c, boost::shared_ptr<ARDOUR::AudioRegion> region)
, _gradient_depth_independent (false)
, _amplitude_above_axis (1.0)
, _region_amplitude (_region->scale_amplitude ())
+ , _start_shift (0.0)
, _region_start (region->start())
{
VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this));
@@ -804,7 +805,7 @@ WaveView::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
* draw "between" pixels at the start and/or end.
*/
- const double draw_start = floor (draw.x0);
+ const double draw_start = floor (draw.x0) + _start_shift;
const double draw_end = floor (draw.x1);
// cerr << "Need to draw " << draw_start << " .. " << draw_end << endl;
@@ -1034,3 +1035,16 @@ WaveView::set_global_show_waveform_clipping (bool yn)
ClipLevelChanged ();
}
}
+
+void
+WaveView::set_start_shift (double pixels)
+{
+ if (pixels < 0) {
+ return;
+ }
+
+ begin_visual_change ();
+ _start_shift = pixels;
+ end_visual_change ();
+}
+