Codechange: Rely on Scrollbar::SetPosition to clamp.
Manually clamping scrollbar bounds before calling `SetPosition()` is doubling up work that the function already does.
This commit is contained in:
@@ -2379,13 +2379,10 @@ static void HandleScrollbarScrolling(Window *w)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find the item we want to move to and make sure it's inside bounds. */
|
||||
int pos = std::min(RoundDivSU(std::max(0, i + _scrollbar_start_pos) * sb->GetCount(), _scrollbar_size), std::max(0, sb->GetCount() - sb->GetCapacity()));
|
||||
if (rtl) pos = std::max(0, sb->GetCount() - sb->GetCapacity() - pos);
|
||||
if (pos != sb->GetPosition()) {
|
||||
sb->SetPosition(pos);
|
||||
w->SetDirty();
|
||||
}
|
||||
/* Find the item we want to move to. SetPosition will make sure it's inside bounds. */
|
||||
int pos = RoundDivSU((i + _scrollbar_start_pos) * sb->GetCount(), _scrollbar_size);
|
||||
if (rtl) pos = sb->GetCount() - sb->GetCapacity() - pos;
|
||||
if (sb->SetPosition(pos)) w->SetDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user