Reduce the amount of repainting done when the selection changes to a new one that doesn't overlap the old selection

Originally committed to SVN as r5068.
This commit is contained in:
Thomas Goyne 2010-12-30 22:19:24 +00:00
parent 364f398c5f
commit f3d1bc23bd

View file

@ -1206,13 +1206,15 @@ void AudioDisplay::OnSelectionChanged()
SampleRange sel(controller->GetPrimaryPlaybackRange());
scrollbar->SetSelection(AbsoluteXFromSamples(sel.begin()), AbsoluteXFromSamples(sel.length()));
int s1 = RelativeXFromSamples(sel.begin());
int e1 = RelativeXFromSamples(sel.end());
int s2 = RelativeXFromSamples(old_selection.begin());
int e2 = RelativeXFromSamples(old_selection.end());
if (sel.overlaps(old_selection))
{
// Only redraw the parts of the selection that changed, to avoid flicker
int s1 = RelativeXFromSamples(sel.begin());
int e1 = RelativeXFromSamples(sel.end());
int s2 = RelativeXFromSamples(old_selection.begin());
int e2 = RelativeXFromSamples(old_selection.end());
if (s1 != s2)
{
wxRect r(std::min(s1, s2)-10, audio_top, abs(s1-s2)+20, audio_height);
@ -1226,7 +1228,8 @@ void AudioDisplay::OnSelectionChanged()
}
else
{
RefreshRect(wxRect(0, audio_top, GetClientSize().GetX(), audio_height));
RefreshRect(wxRect(s1 - 10, audio_top, e1 + 20, audio_height));
RefreshRect(wxRect(s2 - 10, audio_top, e2 + 20, audio_height));
}
RefreshRect(scrollbar->GetBounds());