summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Lester <ElliottLester@users.noreply.github.com>2022-08-15 13:19:47 -0700
committersfan5 <sfan5@live.de>2022-09-14 13:48:06 +0200
commit57b4d46dbc84d008db48675b5ff07ce4fd8fb058 (patch)
tree34b74029581523ec34b994e679f35843649ea22c
parent50df5e2f59d173abaf7759c67cfd4322dcac516c (diff)
downloadminetest-57b4d46dbc84d008db48675b5ff07ce4fd8fb058.tar.gz
minetest-57b4d46dbc84d008db48675b5ff07ce4fd8fb058.tar.bz2
minetest-57b4d46dbc84d008db48675b5ff07ce4fd8fb058.zip
Apply DPI Scaling to GUIModalMenu (#12693)
Co-authored-by: sfan5 <sfan5@live.de>
-rw-r--r--src/gui/modalMenu.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp
index cfc4d5c5a..9f5258cdf 100644
--- a/src/gui/modalMenu.cpp
+++ b/src/gui/modalMenu.cpp
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include <cstdlib>
+#include "client/renderingengine.h"
#include "modalMenu.h"
#include "gettext.h"
#include "porting.h"
@@ -26,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h"
-#include "client/renderingengine.h"
#endif
// clang-format off
@@ -41,10 +41,13 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
m_remap_dbl_click(remap_dbl_click)
{
m_gui_scale = std::max(g_settings->getFloat("gui_scaling"), 0.5f);
+ const float screen_dpi_scale = RenderingEngine::getDisplayDensity();
#ifdef HAVE_TOUCHSCREENGUI
- float d = RenderingEngine::getDisplayDensity();
- m_gui_scale *= 1.1 - 0.3 * d + 0.2 * d * d;
+ m_gui_scale *= 1.1f - 0.3f * screen_dpi_scale + 0.2f * screen_dpi_scale * screen_dpi_scale;
+#else
+ m_gui_scale *= screen_dpi_scale;
#endif
+
setVisible(true);
Environment->setFocus(this);
m_menumgr->createdMenu(this);