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 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 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 (); +} +