mirror of https://github.com/OpenTTD/OpenTTD
(svn r21754) -Codechange: Scroll the matrix widget to make a clicked entry fully visible.
parent
ec54970058
commit
d8567d2699
|
@ -1374,6 +1374,13 @@ void NWidgetMatrix::SetColour(Colours colour)
|
||||||
void NWidgetMatrix::SetClicked(int clicked)
|
void NWidgetMatrix::SetClicked(int clicked)
|
||||||
{
|
{
|
||||||
this->clicked = clicked;
|
this->clicked = clicked;
|
||||||
|
if (this->sb != NULL && this->widgets_x != 0) {
|
||||||
|
int vpos = (this->clicked / this->widgets_x) * this->widget_h; // Vertical position of the top.
|
||||||
|
/* Need to scroll down -> Scroll to the bottom.
|
||||||
|
* However, last entry has no 'this->pip_inter' underneath, and we must stay below this->sb->GetCount() */
|
||||||
|
if (this->sb->GetPosition() < vpos) vpos += this->widget_h - this->pip_inter - 1;
|
||||||
|
this->sb->ScrollTowards(vpos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue