diff --git a/include/TGUI/Widgets/ScrollablePanel.hpp b/include/TGUI/Widgets/ScrollablePanel.hpp index cfa200b6..627bd5c9 100644 --- a/include/TGUI/Widgets/ScrollablePanel.hpp +++ b/include/TGUI/Widgets/ScrollablePanel.hpp @@ -183,6 +183,22 @@ namespace tgui Vector2f getContentOffset() const; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Channges the width of the scrollbars + /// + /// @param width Scrollbar width + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void setScrollbarWidth(float width); + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Returns the width of the scrollbars + /// + /// @return Scrollbar width + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + float getScrollbarWidth() const; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @internal ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/TGUI/Widgets/ScrollablePanel.cpp b/src/TGUI/Widgets/ScrollablePanel.cpp index 7cc27169..e22a0d8c 100644 --- a/src/TGUI/Widgets/ScrollablePanel.cpp +++ b/src/TGUI/Widgets/ScrollablePanel.cpp @@ -288,6 +288,22 @@ namespace tgui ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void ScrollablePanel::setScrollbarWidth(float width) + { + m_verticalScrollbar.setSize({width, m_verticalScrollbar.getSize().y}); + m_horizontalScrollbar.setSize({m_horizontalScrollbar.getSize().x, width}); + updateScrollbars(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + float ScrollablePanel::getScrollbarWidth() const + { + return m_verticalScrollbar.getSize().x; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void ScrollablePanel::leftMousePressed(Vector2f pos) { m_mouseDown = true; diff --git a/tests/Widgets/ScrollablePanel.cpp b/tests/Widgets/ScrollablePanel.cpp index d32e3555..e86e8cdb 100644 --- a/tests/Widgets/ScrollablePanel.cpp +++ b/tests/Widgets/ScrollablePanel.cpp @@ -78,6 +78,12 @@ TEST_CASE("[ScrollablePanel]") } } + SECTION("ScrollbarWidth") + { + panel->setScrollbarWidth(25); + REQUIRE(panel->getScrollbarWidth() == 25); + } + SECTION("Events / Signals") { unsigned int mousePressedCount = 0;