Mercurial > hg > openttd
changeset 17017:866761010474 draft
(svn r21754) -Codechange: Scroll the matrix widget to make a clicked entry fully visible.
author | alberth <alberth@openttd.org> |
---|---|
date | Sun, 09 Jan 2011 15:25:33 +0000 |
parents | c36bd970776f |
children | f7ae25ac75a5 |
files | src/widget.cpp |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/widget.cpp +++ b/src/widget.cpp @@ -1374,6 +1374,13 @@ void NWidgetMatrix::SetClicked(int 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); + } } /**