mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
This commit is contained in:
parent
1e4a89177e
commit
2d3250923c
@ -795,7 +795,7 @@ public:
|
|||||||
/* Position scrollbar to selected group */
|
/* Position scrollbar to selected group */
|
||||||
for (uint i = 0; i < this->rows; i++) {
|
for (uint i = 0; i < this->rows; i++) {
|
||||||
if (this->groups[i]->index == sel) {
|
if (this->groups[i]->index == sel) {
|
||||||
this->vscroll->SetPosition(Clamp(i - this->vscroll->GetCapacity() / 2, 0, std::max(this->vscroll->GetCount() - this->vscroll->GetCapacity(), 0)));
|
this->vscroll->SetPosition(i - this->vscroll->GetCapacity() / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,9 +866,7 @@ struct ScriptDebugWindow : public Window {
|
|||||||
}
|
}
|
||||||
if (this->autoscroll) {
|
if (this->autoscroll) {
|
||||||
int scroll_pos = std::max(0, log->used - this->vscroll->GetCapacity());
|
int scroll_pos = std::max(0, log->used - this->vscroll->GetCapacity());
|
||||||
if (scroll_pos != this->vscroll->GetPosition()) {
|
if (this->vscroll->SetPosition(scroll_pos)) {
|
||||||
this->vscroll->SetPosition(scroll_pos);
|
|
||||||
|
|
||||||
/* We need a repaint */
|
/* We need a repaint */
|
||||||
this->SetWidgetDirty(WID_SCRD_SCROLLBAR);
|
this->SetWidgetDirty(WID_SCRD_SCROLLBAR);
|
||||||
this->SetWidgetDirty(WID_SCRD_LOG_PANEL);
|
this->SetWidgetDirty(WID_SCRD_LOG_PANEL);
|
||||||
|
@ -746,10 +746,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool 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;
|
uint16 old_pos = this->pos;
|
||||||
this->pos = position;
|
this->pos = Clamp(position, 0, std::max(this->count - this->cap, 0));
|
||||||
return this->pos != old_pos;
|
return this->pos != old_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +766,7 @@ public:
|
|||||||
case SS_BIG: difference *= this->cap; break;
|
case SS_BIG: difference *= this->cap; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return this->SetPosition(Clamp(this->pos + difference, 0, std::max(this->count - this->cap, 0)));
|
return this->SetPosition(this->pos + difference);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user