From 8d0cd713e283a9802074b5a24f7d6eadcb62af5b Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Wed, 7 Oct 2020 12:03:09 +0200 Subject: [PATCH] allow scrolling to top and bottom from lua --- src/guichan/include/guichan/widgets/scrollarea.h | 4 ++++ src/guichan/widgets/scrollarea.cpp | 10 ++++++++++ src/tolua/ui.pkg | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/guichan/include/guichan/widgets/scrollarea.h b/src/guichan/include/guichan/widgets/scrollarea.h index 4d15c2880..f1ef0b423 100644 --- a/src/guichan/include/guichan/widgets/scrollarea.h +++ b/src/guichan/include/guichan/widgets/scrollarea.h @@ -162,6 +162,10 @@ namespace gcn */ virtual void setScrollPolicy(unsigned int hPolicy, unsigned int vPolicy); + virtual void scrollToBottom(); + + virtual void scrollToTop(); + /** * Sets the amount to scroll verticaly. * diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index f5b4f222d..e5caf35e4 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -181,6 +181,16 @@ namespace gcn checkPolicies(); } + void ScrollArea::scrollToBottom() + { + setVerticalScrollAmount(getVerticalMaxScroll()); + } + + void ScrollArea::scrollToTop() + { + setVerticalScrollAmount(0); + } + void ScrollArea::setVerticalScrollAmount(int vScroll) { int max = getVerticalMaxScroll(); diff --git a/src/tolua/ui.pkg b/src/tolua/ui.pkg index 564c13127..89ccb18a4 100644 --- a/src/tolua/ui.pkg +++ b/src/tolua/ui.pkg @@ -325,6 +325,8 @@ class ScrollArea : public BasicContainer virtual Widget *getContent(); virtual void setScrollbarWidth(int width); virtual int getScrollbarWidth(); + virtual void scrollToBottom(); + virtual void scrollToTop(); }; class ImageWidget : public Widget