Maintain the current scroll position when zooming #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #157.
When the "Zoom" slider or "FFT size" slider is moved, Inspectrum jumps either to the end of the file or to the last location that was zoomed with Ctrl+scrollwheel. This happens because the code that tracks where the center of the window is was commented out in #131.
The change in #131 also reordered
PlotView::updateView
in an attempt to work around a zoom bug, but it only moved the problem. The underlying issue is that when zooming or changing the FFT size,horizontalScrollBar()->setMaximum()
andhorizontalScrollBar()->setValue()
must be called in the correct order. When the total width of the FFT data expands, the scroll maximum must be increased before the scroll value, or else the value might be clipped. Conversely, when the total width of the FFT data shrinks, the scroll value must be decreased before the scroll maximum. I've accomplished that here by havingPlotView::setFFTAndZoom()
determine whether the total width is expanding and pass that information intoPlotView::updateViewRange()
, which can then perform the two steps in the correct order.