1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 15:39:27 +02:00

Fix problem with waveform disappearing when zooming in using mouse wheel. Aligns audio right with mouse position, if mouse position is to right of audio right.

This commit is contained in:
james.k.crook@gmail.com 2012-05-06 11:50:29 +00:00
parent dfcda8dfaf
commit 4dc68db335

View File

@ -4678,11 +4678,28 @@ void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
p->ZoomOutByFactor( ZoomFactor );
#endif
// MM: Zoom in/out when used with Control key down
// MM: I don't understand what trackLeftEdge does
// We're converting pixel positions to times,
// counting pixels from the left edge of the track.
int trackLeftEdge = GetLeftOffset();
// Time corresponding to mouse position
double center_h = PositionToTime(event.m_x, trackLeftEdge);
mViewInfo->zoom = wxMin(mViewInfo->zoom * pow(2.0, steps), gMaxZoom);
// Time corresponding to last (most far right) audio.
double audioEndTime = mTracks->GetEndTime();
// When zooming in in empty space, it's easy to 'lose' the waveform.
// This prevents it.
// IF zooming in
if( steps > 0)
{
// IF mouse is to right of audio
if( center_h > audioEndTime )
// Zooming brings far right of audio to mouse.
center_h = audioEndTime;
}
// Constrain maximum as well as minimum zoom.
mViewInfo->zoom = wxMax( gMinZoom, wxMin(mViewInfo->zoom * pow(2.0, steps), gMaxZoom));
double new_center_h = PositionToTime(event.m_x, trackLeftEdge);
mViewInfo->h += (center_h - new_center_h);