From 0368c5b09d2edcf327af7bafeebebcf6330a710b Mon Sep 17 00:00:00 2001 From: cutealien Date: Tue, 1 Dec 2020 13:42:44 +0000 Subject: [PATCH] IGUIEnvironment::drawAll has now a parameter to allow disabling the automatic resize to driver screensize. That makes it easier to use partial screens, while using automatic alignment. Default is still automatic resizing as before, thought it got changed a bit as it looked a bit strange. Before it only set the lower-right corner, but compared to driver screensizes, so it behaved a bit strange when the leftTop corner of the rootGuiElement was changed (different than when the rightBottom corner was set). Could be the idea before was that only clipping matters. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6163 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/IGUIEnvironment.h | 4 +++- source/Irrlicht/CGUIEnvironment.cpp | 15 +++++++-------- source/Irrlicht/CGUIEnvironment.h | 2 +- tests/tests-last-passed-at.txt | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/changes.txt b/changes.txt index 408a87b..02bdce4 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support. - No longer try to set WM_QUIT when using an external Window on Win32. Thx @Marko Mahnic for the patch (https://sourceforge.net/p/irrlicht/bugs/449) - ply meshloader now also supports textures with uv-labels named texture_u/texture_v. diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 695b41b..b670d96 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -74,7 +74,9 @@ class IGUIEnvironment : public virtual IReferenceCounted public: //! Draws all gui elements by traversing the GUI environment starting at the root node. - virtual void drawAll() = 0; + /** \param When true ensure the GuiEnvironment (aka the RootGUIElement) has the same size as the current driver screensize. + Can be set to false to control that size yourself, p.E when not the full size should be used for UI. */ + virtual void drawAll(bool useScreenSize=true) = 0; //! Sets the focus to an element. /** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index e29195b..0f0dc18 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -191,19 +191,18 @@ void CGUIEnvironment::loadBuiltInFont() //! draws all gui elements -void CGUIEnvironment::drawAll() +void CGUIEnvironment::drawAll(bool useScreenSize) { - if (Driver) + if (useScreenSize && Driver) { core::dimension2d dim(Driver->getScreenSize()); if (AbsoluteRect.LowerRightCorner.X != dim.Width || - AbsoluteRect.LowerRightCorner.Y != dim.Height) + AbsoluteRect.UpperLeftCorner.X != 0 || + AbsoluteRect.LowerRightCorner.Y != dim.Height || + AbsoluteRect.UpperLeftCorner.Y != 0 + ) { - // resize gui environment - DesiredRect.LowerRightCorner = dim; - AbsoluteClippingRect = DesiredRect; - AbsoluteRect = DesiredRect; - updateAbsolutePosition(); + setRelativePosition(core::recti(0,0,dim.Width, dim.Height)); } } diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index 58b7f54..f8b0323 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -31,7 +31,7 @@ public: virtual ~CGUIEnvironment(); //! draws all gui elements - virtual void drawAll() _IRR_OVERRIDE_; + virtual void drawAll(bool useScreenSize) _IRR_OVERRIDE_; //! returns the current video driver virtual video::IVideoDriver* getVideoDriver() const _IRR_OVERRIDE_; diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index faa44d9..15f3146 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. -Compiled as RELEASE -Test suite pass at GMT Tue Nov 10 18:42:40 2020 +Compiled as DEBUG +Test suite pass at GMT Tue Dec 01 13:34:31 2020