Permalink
Browse files

Fixed some zoom issues in PositionableWaveDisplay.

  • Loading branch information...
1 parent 9d374b0 commit b267b71ef3c78e2984118f7b6ad73c90e9415b41 @drowaudio committed May 31, 2012
View
24 dRowAudio/gui/audiothumbnail/dRowAudio_PositionableWaveDisplay.cpp
@@ -61,7 +61,7 @@ void PositionableWaveDisplay::setZoomRatio (double newZoomRatio)
zoomRatio = newZoomRatio;
audioTransportCursor.setZoomRatio (newZoomRatio);
- repaint();
+ resized();
}
void PositionableWaveDisplay::setStartOffsetRatio (double newStartOffsetRatio)
@@ -102,11 +102,10 @@ void PositionableWaveDisplay::resized()
{
const ScopedLock sl (imageLock);
- cachedImage = Image (Image::RGB, getWidth(), getHeight(), false);
+ cachedImage = Image (Image::RGB, getWidth() / zoomRatio, getHeight(), false);
cachedImage.clear (cachedImage.getBounds(), backgroundColour);
- drawTimes.setBoth (0.0);
- threadToUse.addTimeSliceClient (this);
+ refreshCachedImage();
audioTransportCursor.setBounds (getLocalBounds());
}
@@ -119,14 +118,15 @@ void PositionableWaveDisplay::paint(Graphics &g)
g.setColour (backgroundColour);
g.fillAll();
+ const int newWidth = roundToInt (w / zoomRatio);
const int startPixelX = roundToInt (w * startOffsetRatio);
const int newHeight = roundToInt (verticalZoomRatio * h);
const int startPixelY = roundToInt ((h * 0.5f) - (newHeight * 0.5f));
const ScopedLock sl (imageLock);
g.drawImage (cachedImage,
- startPixelX, startPixelY, w, newHeight,
- 0, 0, roundToInt (cachedImage.getWidth() * zoomRatio), cachedImage.getHeight(),
+ startPixelX, startPixelY, newWidth, newHeight,
+ 0, 0, cachedImage.getWidth(), cachedImage.getHeight(),
false);
}
@@ -152,9 +152,8 @@ void PositionableWaveDisplay::imageChanged (AudioThumbnailImage* changedAudioThu
currentSampleRate = reader->sampleRate;
fileLength = audioFilePlayer.getLengthInSeconds();
oneOverFileLength = 1.0 / fileLength;
-
- drawTimes.setBoth (0.0);
- threadToUse.addTimeSliceClient (this);
+
+ refreshCachedImage();
}
else
{
@@ -189,3 +188,10 @@ void PositionableWaveDisplay::handleAsyncUpdate()
{
repaint();
}
+
+//====================================================================================
+void PositionableWaveDisplay::refreshCachedImage()
+{
+ drawTimes.setBoth (0.0);
+ threadToUse.addTimeSliceClient (this);
+}
View
3 dRowAudio/gui/audiothumbnail/dRowAudio_PositionableWaveDisplay.h
@@ -110,6 +110,9 @@ class PositionableWaveDisplay : public Component,
AudioTransportCursor audioTransportCursor;
+ //==============================================================================
+ void refreshCachedImage();
+
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PositionableWaveDisplay);
};

0 comments on commit b267b71

Please sign in to comment.