summaryrefslogtreecommitdiff
path: root/src/window_gui.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-02 08:08:30 +0000
committerrubidium <rubidium@openttd.org>2009-09-02 08:08:30 +0000
commit59ac4f6b21fd6c3a8b0b81154706050af99d7848 (patch)
treecde726f9cad661d8e8805bc7d36c1ded8207fb62 /src/window_gui.h
parent78c9827000d3a3c42045798c66f8791b6b63b2cd (diff)
downloadopenttd-59ac4f6b21fd6c3a8b0b81154706050af99d7848.tar.xz
(svn r17370) -Codechange: make the saveload and network GUIs use the scrollbar wrappers
Diffstat (limited to 'src/window_gui.h')
-rw-r--r--src/window_gui.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/window_gui.h b/src/window_gui.h
index 312b954bf..0a2e4159e 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -289,6 +289,23 @@ public:
if (difference == 0) return;
this->SetPosition(Clamp(this->pos + difference, 0, this->count - this->cap));
}
+
+ /**
+ * Scroll towards the given position; if the item is visible nothing
+ * happens, otherwise it will be shown either at the bottom or top of
+ * the window depending on where in the list it was.
+ * @param position the position to scroll towards.
+ */
+ void ScrollTowards(int position)
+ {
+ if (position < this->GetPosition()) {
+ /* scroll up to the item */
+ this->SetPosition(position);
+ } else if (position >= this->GetPosition() + this->GetCapacity()) {
+ /* scroll down so that the item is at the bottom */
+ this->SetPosition(position - this->GetCapacity() + 1);
+ }
+ }
};
/**