summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
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
*/