From c0ffdc78f453f2455c3b907ccdc7017911a45c46 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 22 Mar 2021 07:58:20 +0800 Subject: [PATCH] Improve appearance of dialog with display cutout --- src/guiengine/abstract_top_level_container.hpp | 1 + src/guiengine/layout_manager.cpp | 11 +++++++---- src/guiengine/modaldialog.cpp | 7 ++++++- src/guiengine/modaldialog.hpp | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/guiengine/abstract_top_level_container.hpp b/src/guiengine/abstract_top_level_container.hpp index 29bd8dea0..5dc95aed3 100644 --- a/src/guiengine/abstract_top_level_container.hpp +++ b/src/guiengine/abstract_top_level_container.hpp @@ -105,6 +105,7 @@ namespace GUIEngine void elementsWereDeleted(PtrVector* within_vector = NULL); bool isMyChild(Widget* widget) const; + virtual bool enableScreenPadding() const { return true; } }; // AbstractTopLevelContainer } // namespace GUIEngine diff --git a/src/guiengine/layout_manager.cpp b/src/guiengine/layout_manager.cpp index 7b9b066f0..e23a130a0 100644 --- a/src/guiengine/layout_manager.cpp +++ b/src/guiengine/layout_manager.cpp @@ -321,14 +321,17 @@ void LayoutManager::applyCoords(Widget* self, AbstractTopLevelContainer* topLeve //parent_w = frame_size.Width; //parent_h = frame_size.Height; parent_w = topLevelContainer->getWidth(); - int total_padding = irr_driver->getDevice()->getLeftPadding() + - irr_driver->getDevice()->getRightPadding(); + int left_padding = irr_driver->getDevice()->getLeftPadding(); + int right_padding = irr_driver->getDevice()->getRightPadding(); + if (!topLevelContainer->enableScreenPadding()) + left_padding = right_padding = 0; + int total_padding = left_padding + right_padding; if (parent_w - total_padding > 0) parent_w -= total_padding; parent_h = topLevelContainer->getHeight(); parent_x = 0; - if (irr_driver->getDevice()->getLeftPadding() > 0) - parent_x = irr_driver->getDevice()->getLeftPadding(); + if (left_padding > 0) + parent_x = left_padding; parent_y = 0; } else diff --git a/src/guiengine/modaldialog.cpp b/src/guiengine/modaldialog.cpp index 61741ad88..99a0d049a 100644 --- a/src/guiengine/modaldialog.cpp +++ b/src/guiengine/modaldialog.cpp @@ -97,7 +97,12 @@ void ModalDialog::doInit() const core::dimension2d& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); - const int w = (int)(frame_size.Width* m_percent_width); + int left_padding = irr_driver->getDevice()->getLeftPadding(); + int right_padding = irr_driver->getDevice()->getRightPadding(); + int total_padding = left_padding + right_padding; + int w = (int)(frame_size.Width* m_percent_width); + if (w > total_padding) + w -= total_padding; const int h = (int)(frame_size.Height* m_percent_height); assert(frame_size.Width > 0); diff --git a/src/guiengine/modaldialog.hpp b/src/guiengine/modaldialog.hpp index d12847610..deb2f9b43 100644 --- a/src/guiengine/modaldialog.hpp +++ b/src/guiengine/modaldialog.hpp @@ -139,6 +139,7 @@ namespace GUIEngine bool fadeBackground() const { return m_fade_background; } bool isMyIrrChild(irr::gui::IGUIElement* widget) const { return m_irrlicht_window->isMyChild(widget); } + virtual bool enableScreenPadding() const { return false; } }; }