Scroll instantly to the audio playback position when "Lock Scroll on Cursor" is enabled

Originally committed to SVN as r6169.
This commit is contained in:
Thomas Goyne 2011-12-27 01:38:08 +00:00
parent cfc7e009f2
commit 090fdecb95

View file

@ -1274,11 +1274,11 @@ void AudioDisplay::OnPlaybackPosition(int64_t sample_position)
int edge_size = client_width / 20; int edge_size = client_width / 20;
if (scroll_left > 0 && pixel_position < scroll_left + edge_size) if (scroll_left > 0 && pixel_position < scroll_left + edge_size)
{ {
ScrollBy(-std::min(edge_size, scroll_left)); ScrollPixelToLeft(std::max(pixel_position - edge_size, 0));
} }
else if (scroll_left + client_width < std::min(pixel_audio_width - 1, pixel_position + edge_size)) else if (scroll_left + client_width < std::min(pixel_audio_width - 1, pixel_position + edge_size))
{ {
ScrollBy(std::min(edge_size, pixel_audio_width - client_width - scroll_left - 1)); ScrollPixelToLeft(std::min(pixel_position - client_width + edge_size, pixel_audio_width - client_width - 1));
} }
} }
} }