Codechange: Use SetPosition() to clamp after changing count/capacity.

This commit is contained in:
Peter Nelson 2023-05-07 10:44:50 +01:00 committed by PeterN
parent 6202eae9d5
commit 878c5d8d85
1 changed files with 4 additions and 4 deletions

View File

@ -721,9 +721,8 @@ public:
assert(num <= MAX_UVALUE(uint16));
this->count = ClampTo<uint16_t>(num);
num -= this->cap;
if (num < 0) num = 0;
if (num < this->pos) this->pos = num;
/* Ensure position is within bounds */
this->SetPosition(this->pos);
}
/**
@ -736,7 +735,8 @@ public:
assert(capacity <= MAX_UVALUE(uint16));
this->cap = ClampTo<uint16_t>(capacity);
if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
/* Ensure position is within bounds */
this->SetPosition(this->pos);
}
void SetCapacityFromWidget(Window *w, int widget, int padding = 0);