2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2020 DS
|
2020-04-13 10:50:07 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "guiScrollBar.h"
|
|
|
|
|
|
|
|
class GUIScrollContainer : public gui::IGUIElement
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GUIScrollContainer(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
|
|
|
|
const core::rect<s32> &rectangle, const std::string &orientation,
|
|
|
|
f32 scrollfactor);
|
|
|
|
|
|
|
|
virtual bool OnEvent(const SEvent &event) override;
|
|
|
|
|
2020-08-23 22:50:14 +02:00
|
|
|
virtual void draw() override;
|
|
|
|
|
2024-10-08 21:45:27 +02:00
|
|
|
inline void setContentPadding(std::optional<s32> padding)
|
|
|
|
{
|
|
|
|
m_content_padding_px = padding;
|
|
|
|
}
|
|
|
|
|
2020-04-13 10:50:07 +02:00
|
|
|
inline void onScrollEvent(gui::IGUIElement *caller)
|
|
|
|
{
|
|
|
|
if (caller == m_scrollbar)
|
|
|
|
updateScrolling();
|
|
|
|
}
|
|
|
|
|
2024-10-08 21:45:27 +02:00
|
|
|
void setScrollBar(GUIScrollBar *scrollbar);
|
2025-03-30 18:15:38 +02:00
|
|
|
void updateScrolling();
|
2020-04-13 10:50:07 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum OrientationEnum
|
|
|
|
{
|
|
|
|
VERTICAL,
|
|
|
|
HORIZONTAL,
|
|
|
|
UNDEFINED
|
|
|
|
};
|
|
|
|
|
|
|
|
GUIScrollBar *m_scrollbar;
|
|
|
|
OrientationEnum m_orientation;
|
2024-10-08 21:45:27 +02:00
|
|
|
f32 m_scrollfactor; //< scrollbar pos * scrollfactor = scroll offset in pixels
|
|
|
|
std::optional<s32> m_content_padding_px; //< in pixels
|
2020-04-13 10:50:07 +02:00
|
|
|
|
|
|
|
};
|