From fe672c827cb2c08c94b1fa7e527d884c522a1af7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 24 Jun 2015 14:12:13 -0400 Subject: show zero line when a DC offset moves waveform so that it doesn't intersect with the zero line (from Nimal Ratnayake ) --- libs/canvas/wave_view.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index 1a969d60e3..809ea4ec6b 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -575,7 +575,7 @@ WaveView::draw_image (Cairo::RefPtr& image, PeakData* _peak outline_context->stroke (); } else { - const double height_2 = _height * .5; + const int height_zero = floor( _height * .5); for (int i = 0; i < n_peaks; ++i) { @@ -601,10 +601,11 @@ WaveView::draw_image (Cairo::RefPtr& image, PeakData* _peak } } - /* zero line, show only if there is enough spread */ + /* zero line, show only if there is enough spread + or the waveform line does not cross zero line */ - if (tips[i].spread >= 5.0 && show_zero_line()) { - zero_context->move_to (i, floor(height_2)); + if (show_zero_line() && ((tips[i].spread >= 5.0) || (tips[i].top > height_zero ) || (tips[i].bot < height_zero)) ) { + zero_context->move_to (i, height_zero); zero_context->rel_line_to (1.0, 0); } -- cgit v1.2.3