summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-12-20 20:08:39 +0000
committeralberth <alberth@openttd.org>2009-12-20 20:08:39 +0000
commit5a083f183e5ece4e379a12d7f5b927e54a83d04a (patch)
tree1d1fa960c0fffff8e0462b8086f4c46434b91773 /src/window.cpp
parent20debea202d87ce595b2ebc353d22204e9820efc (diff)
downloadopenttd-5a083f183e5ece4e379a12d7f5b927e54a83d04a.tar.xz
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 48f934f7b..29ddcdff6 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -79,6 +79,23 @@ WindowDesc::~WindowDesc()
}
/**
+ * Set capacity of visible elements from the size and resize properties of a widget.
+ * @param w Window.
+ * @param widget Widget with size and resize properties.
+ * @param padding Padding to subtract from the size.
+ * @note Updates the position if needed.
+ */
+void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding)
+{
+ NWidgetBase *nwid = w->GetWidget<NWidgetBase>(widget);
+ if (this->is_vertical) {
+ this->SetCapacity(((int)nwid->current_y - padding) / (int)nwid->resize_y);
+ } else {
+ this->SetCapacity(((int)nwid->current_x - padding) / (int)nwid->resize_x);
+ }
+}
+
+/**
* Set the window that has the focus
* @param w The window to set the focus on
*/