aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvidenceB <49488517+EvidenceBKidscode@users.noreply.github.com>2020-08-23 22:50:14 +0200
committerGitHub <noreply@github.com>2020-08-23 22:50:14 +0200
commit287f3fb2e3317bb6bd6d8608f1aa051c601aeca4 (patch)
treeab8379bb9007e151a6b5ab1bb481e310e20a7ed0 /src
parent3c2890692bb4c292023a8260cf9ce70f82b2e780 (diff)
downloadminetest-287f3fb2e3317bb6bd6d8608f1aa051c601aeca4.tar.gz
minetest-287f3fb2e3317bb6bd6d8608f1aa051c601aeca4.tar.bz2
minetest-287f3fb2e3317bb6bd6d8608f1aa051c601aeca4.zip
Avoid drawing clipped out formspec elements (#10095)
Diffstat (limited to 'src')
-rw-r--r--src/gui/guiFormSpecMenu.cpp10
-rw-r--r--src/gui/guiScrollContainer.cpp12
-rw-r--r--src/gui/guiScrollContainer.h2
3 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 76441c645..7e3ad3b15 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -3483,10 +3483,14 @@ void GUIFormSpecMenu::drawMenu()
e->setVisible(true);
/*
- Call base class
- (This is where all the drawing happens.)
+ This is where all the drawing happens.
*/
- gui::IGUIElement::draw();
+ core::list<IGUIElement*>::Iterator it = Children.begin();
+ for (; it != Children.end(); ++it)
+ if ((*it)->isNotClipped() ||
+ AbsoluteClippingRect.isRectCollided(
+ (*it)->getAbsolutePosition()))
+ (*it)->draw();
for (gui::IGUIElement *e : m_clickthrough_elements)
e->setVisible(false);
diff --git a/src/gui/guiScrollContainer.cpp b/src/gui/guiScrollContainer.cpp
index 88cdc7057..0fe4c41bd 100644
--- a/src/gui/guiScrollContainer.cpp
+++ b/src/gui/guiScrollContainer.cpp
@@ -56,6 +56,18 @@ bool GUIScrollContainer::OnEvent(const SEvent &event)
return IGUIElement::OnEvent(event);
}
+void GUIScrollContainer::draw()
+{
+ if (isVisible()) {
+ core::list<IGUIElement *>::Iterator it = Children.begin();
+ for (; it != Children.end(); ++it)
+ if ((*it)->isNotClipped() ||
+ AbsoluteClippingRect.isRectCollided(
+ (*it)->getAbsolutePosition()))
+ (*it)->draw();
+ }
+}
+
void GUIScrollContainer::updateScrolling()
{
s32 pos = m_scrollbar->getPos();
diff --git a/src/gui/guiScrollContainer.h b/src/gui/guiScrollContainer.h
index a0306291e..9e3ec6e93 100644
--- a/src/gui/guiScrollContainer.h
+++ b/src/gui/guiScrollContainer.h
@@ -32,6 +32,8 @@ public:
virtual bool OnEvent(const SEvent &event) override;
+ virtual void draw() override;
+
inline void onScrollEvent(gui::IGUIElement *caller)
{
if (caller == m_scrollbar)