From 7c3f355c7a1ab6e3466fc283fcd0aca94b8a15e6 Mon Sep 17 00:00:00 2001 From: "stevethefiddle@gmail.com" Date: Mon, 24 Nov 2014 18:03:33 +0000 Subject: [PATCH] Fix for bug 791. --- src/TrackArtist.cpp | 4 ++-- src/TrackPanel.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 8e27adde8..0569a3853 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -1004,7 +1004,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double l = r.x + lx; w = x - lx; - if (lmaxbot != lmintop - 1) { + if (lmaxbot < lmintop - 1) { dc.DrawRectangle(l, r.y + lmaxtop, w, lmaxbot - lmaxtop); dc.DrawRectangle(l, r.y + lmintop, w, lminbot - lmintop); } @@ -1023,7 +1023,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double dc.SetBrush(lsel ? selectedBrush : unselectedBrush); l = r.x + lx; w = x - lx; - if (lmaxbot != lmintop - 1) { + if (lmaxbot < lmintop - 1) { dc.DrawRectangle(l, r.y + lmaxtop, w, lmaxbot - lmaxtop); dc.DrawRectangle(l, r.y + lmintop, w, lminbot - lmintop); } diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index cce8897ff..fc0b06702 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -4290,8 +4290,12 @@ void TrackPanel::HandleVZoomButtonUp( wxMouseEvent & event ) else { c = 0.5*(min+max); l = (c - min); - min = wxMax( -1.0, c - 2*l); // limit to +/-1 range - max = wxMin( 1.0, c + 2*l); + // limit to +/- 1 range unless already outside that range... + float minRange = (min < -1) ? -2.0 : -1.0; + float maxRange = (max > 1) ? 2.0 : 1.0; + // and enforce vertical zoom limits. + min = wxMin(maxRange - ZOOMLIMIT, wxMax(minRange, c - 2*l)); + max = wxMax(minRange + ZOOMLIMIT, wxMin(maxRange, c + 2*l)); } } }