1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-05 18:41:05 +00:00

scrollcontainer: Add automatic scrollbar calculation (#14623)

New parameter 'content padding'. When specified, the scrollbar
max value is calculated automatically. This aims to reduce manual
calculation functions.
This commit is contained in:
SmallJoker 2024-10-08 21:45:27 +02:00 committed by GitHub
parent 291c3ad0c1
commit 13f533d490
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 87 additions and 29 deletions

View file

@ -34,17 +34,18 @@ public:
virtual void draw() override;
inline void setContentPadding(std::optional<s32> padding)
{
m_content_padding_px = padding;
}
inline void onScrollEvent(gui::IGUIElement *caller)
{
if (caller == m_scrollbar)
updateScrolling();
}
inline void setScrollBar(GUIScrollBar *scrollbar)
{
m_scrollbar = scrollbar;
updateScrolling();
}
void setScrollBar(GUIScrollBar *scrollbar);
private:
enum OrientationEnum
@ -56,7 +57,8 @@ private:
GUIScrollBar *m_scrollbar;
OrientationEnum m_orientation;
f32 m_scrollfactor;
f32 m_scrollfactor; //< scrollbar pos * scrollfactor = scroll offset in pixels
std::optional<s32> m_content_padding_px; //< in pixels
void updateScrolling();
};