summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-01-09 15:25:33 +0000
committeralberth <alberth@openttd.org>2011-01-09 15:25:33 +0000
commitd8567d269926e10e95c079c4fa13d59e8fe8c6ea (patch)
treec70efcc99665f52bfa1c5c94b2e8a4f72519d812 /src
parentec54970058ecbdb6611b1c9b2e7a76adfa6c5ac0 (diff)
downloadopenttd-d8567d269926e10e95c079c4fa13d59e8fe8c6ea.tar.xz
(svn r21754) -Codechange: Scroll the matrix widget to make a clicked entry fully visible.
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 4f2c498f2..559f8d391 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1374,6 +1374,13 @@ void NWidgetMatrix::SetColour(Colours colour)
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);
+ }
}
/**