diff options
author | TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> | 2021-09-26 12:04:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 18:04:09 +0200 |
commit | 3dcf9e963e3d3c5d209cd3676c2f979a58c6c1ab (patch) | |
tree | c60d824fdbd211710d51b89f60913fccc0ee9d76 /src/gui/modalMenu.cpp | |
parent | 9f85862b7c0d2fd6fe964699bbeabc824026e848 (diff) | |
download | minetest-3dcf9e963e3d3c5d209cd3676c2f979a58c6c1ab.tar.gz minetest-3dcf9e963e3d3c5d209cd3676c2f979a58c6c1ab.tar.bz2 minetest-3dcf9e963e3d3c5d209cd3676c2f979a58c6c1ab.zip |
Touch UI support for desktop builds (#10729)
Diffstat (limited to 'src/gui/modalMenu.cpp')
-rw-r--r-- | src/gui/modalMenu.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp index 1016de389..56a5d2cb9 100644 --- a/src/gui/modalMenu.cpp +++ b/src/gui/modalMenu.cpp @@ -26,6 +26,7 @@ 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 @@ -40,8 +41,8 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, m_remap_dbl_click(remap_dbl_click) { m_gui_scale = g_settings->getFloat("gui_scaling"); -#ifdef __ANDROID__ - float d = porting::getDisplayDensity(); +#ifdef HAVE_TOUCHSCREENGUI + float d = RenderingEngine::getDisplayDensity(); m_gui_scale *= 1.1 - 0.3 * d + 0.2 * d * d; #endif setVisible(true); @@ -183,7 +184,7 @@ static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent) return false; } -#ifdef __ANDROID__ +#ifdef HAVE_TOUCHSCREENGUI bool GUIModalMenu::simulateMouseEvent( gui::IGUIElement *target, ETOUCH_INPUT_EVENT touch_event) @@ -217,6 +218,8 @@ bool GUIModalMenu::simulateMouseEvent( void GUIModalMenu::enter(gui::IGUIElement *hovered) { + if (!hovered) + return; sanity_check(!m_hovered); m_hovered.grab(hovered); SEvent gui_event{}; @@ -286,7 +289,9 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event) return retval; } } +#endif +#ifdef HAVE_TOUCHSCREENGUI if (event.EventType == EET_TOUCH_INPUT_EVENT) { irr_ptr<GUIModalMenu> holder; holder.grab(this); // keep this alive until return (it might be dropped downstream [?]) |