Canvas::Rect::contains() should treat its right/left coordinates as exclusive
[ardour.git] / libs / canvas / wave_view.cc
index aa857a8467bf1bd2ff38f3daa7117bc5c0795c7e..bae9d3f8f510f33080b612da5fdb6c243f1cb728 100644 (file)
@@ -34,6 +34,7 @@
 #include "canvas/wave_view.h"
 #include "canvas/utils.h"
 #include "canvas/canvas.h"
+#include "canvas/colors.h"
 
 #include <gdkmm/general.h>
 
@@ -70,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));
@@ -175,12 +177,6 @@ WaveView::set_samples_per_pixel (double samples_per_pixel)
        }
 }
 
-static inline double
-image_to_window (double wave_origin, double image_start)
-{
-       return wave_origin + image_start;
-}
-
 static inline double
 window_to_image (double wave_origin, double image_start)
 {
@@ -688,7 +684,7 @@ WaveView::draw_image (Cairo::RefPtr<Cairo::ImageSurface>& image, PeakData* _peak
                color_to_hsv (_fill_color, h, s, v);
                /* change v towards white */
                v *= 1.0 - gradient_depth();
-               Color center = hsv_to_color (h, s, v, a);
+               Color center = hsva_to_color (h, s, v, a);
                color_to_rgba (center, r, g, b, a);
 
                gradient->add_color_stop_rgba (stops[0], r, g, b, a);
@@ -809,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;
@@ -1036,6 +1032,19 @@ WaveView::set_global_show_waveform_clipping (bool yn)
 {
        if (_global_show_waveform_clipping != yn) {
                _global_show_waveform_clipping = yn;
-               VisualPropertiesChanged (); /* EMIT SIGNAL */
+               ClipLevelChanged ();
        }
 }
+
+void
+WaveView::set_start_shift (double pixels)
+{
+       if (pixels < 0) {
+               return;
+       }
+
+       begin_visual_change ();
+       _start_shift = pixels;
+       end_visual_change ();
+}
+