forked from mirror/OpenTTD
Codechange: Don't update window contents if scrollbar position has not moved.
This commit is contained in:
@@ -737,12 +737,15 @@ public:
|
||||
/**
|
||||
* Sets the position of the first visible element
|
||||
* @param position the position of the element
|
||||
* @return true iff the position has changed
|
||||
*/
|
||||
void SetPosition(int position)
|
||||
bool SetPosition(int position)
|
||||
{
|
||||
assert(position >= 0);
|
||||
assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
|
||||
uint16 old_pos = this->pos;
|
||||
this->pos = position;
|
||||
return this->pos != old_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -750,16 +753,17 @@ public:
|
||||
* If the position would be too low or high it will be clamped appropriately
|
||||
* @param difference the amount of change requested
|
||||
* @param unit The stepping unit of \a difference
|
||||
* @return true iff the position has changed
|
||||
*/
|
||||
void UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
|
||||
bool UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
|
||||
{
|
||||
if (difference == 0) return;
|
||||
if (difference == 0) return false;
|
||||
switch (unit) {
|
||||
case SS_SMALL: difference *= this->stepsize; break;
|
||||
case SS_BIG: difference *= this->cap; break;
|
||||
default: break;
|
||||
}
|
||||
this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
|
||||
return this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user