1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Add scroll_container formspec element (redo) (#9101)

New formspec elements:

 - `scroll_container[<X>,<Y>;<W>,<H>;<scrollbar name>;<orientation>;<scroll factor>]`
 - `scroll_container_end[]`

Other elements can be embedded in this element. Scrollbar must be placed manually.
This commit is contained in:
DS 2020-04-13 10:50:07 +02:00 committed by GitHub
parent 6cf15cf872
commit 0ac999ded7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 411 additions and 50 deletions

View file

@ -0,0 +1,56 @@
/*
Minetest
Copyright (C) 2020 DS
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include "irrlichttypes_extrabloated.h"
#include "util/string.h"
#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;
inline void onScrollEvent(gui::IGUIElement *caller)
{
if (caller == m_scrollbar)
updateScrolling();
}
inline void setScrollBar(GUIScrollBar *scrollbar) { m_scrollbar = scrollbar; }
private:
enum OrientationEnum
{
VERTICAL,
HORIZONTAL,
UNDEFINED
};
GUIScrollBar *m_scrollbar;
OrientationEnum m_orientation;
f32 m_scrollfactor;
void updateScrolling();
};