Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
guiScrollContainer.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2020 DS
4
5#pragma once
6
8#include "util/string.h"
9#include "guiScrollBar.h"
10
11class GUIScrollContainer : public gui::IGUIElement
12{
13public:
14 GUIScrollContainer(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
15 const core::rect<s32> &rectangle, const std::string &orientation,
16 f32 scrollfactor);
17
18 virtual bool OnEvent(const SEvent &event) override;
19
20 virtual void draw() override;
21
22 inline void setContentPadding(std::optional<s32> padding)
23 {
24 m_content_padding_px = padding;
25 }
26
27 inline void onScrollEvent(gui::IGUIElement *caller)
28 {
29 if (caller == m_scrollbar)
31 }
32
33 void setScrollBar(GUIScrollBar *scrollbar);
34
35private:
42
45 f32 m_scrollfactor; //< scrollbar pos * scrollfactor = scroll offset in pixels
46 std::optional<s32> m_content_padding_px; //< in pixels
47
48 void updateScrolling();
49};
Definition guiScrollBar.h:24
Definition guiScrollContainer.h:12
GUIScrollContainer(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, const core::rect< s32 > &rectangle, const std::string &orientation, f32 scrollfactor)
Definition guiScrollContainer.cpp:7
void setContentPadding(std::optional< s32 > padding)
Definition guiScrollContainer.h:22
void setScrollBar(GUIScrollBar *scrollbar)
Definition guiScrollContainer.cpp:55
GUIScrollBar * m_scrollbar
Definition guiScrollContainer.h:43
void updateScrolling()
Definition guiScrollContainer.cpp:99
virtual bool OnEvent(const SEvent &event) override
Definition guiScrollContainer.cpp:21
virtual void draw() override
Definition guiScrollContainer.cpp:44
void onScrollEvent(gui::IGUIElement *caller)
Definition guiScrollContainer.h:27
OrientationEnum
Definition guiScrollContainer.h:37
@ VERTICAL
Definition guiScrollContainer.h:38
@ HORIZONTAL
Definition guiScrollContainer.h:39
@ UNDEFINED
Definition guiScrollContainer.h:40
std::optional< s32 > m_content_padding_px
Definition guiScrollContainer.h:46
OrientationEnum m_orientation
Definition guiScrollContainer.h:44
f32 m_scrollfactor
Definition guiScrollContainer.h:45