diff options
author | stujones11 <stujones111@gmail.com> | 2018-11-18 10:31:19 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-11-18 11:31:19 +0100 |
commit | 3b112889892f6652d4e80d97e45131f179b1fbe4 (patch) | |
tree | 98033eb2cab0639aefc00244411dad94cb9d4c10 /src/gui/guiFormSpecMenu.cpp | |
parent | e5a37543cc7932f6252a086b4b8619b5dde9ae5a (diff) | |
download | minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.tar.gz minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.tar.bz2 minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.zip |
Android: Improve UI scaling on smaller high-density displays (#7834)
* Android: Improve UI scaling on smaller high-density displays
Diffstat (limited to 'src/gui/guiFormSpecMenu.cpp')
-rw-r--r-- | src/gui/guiFormSpecMenu.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 363128012..f23055821 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -284,12 +284,13 @@ void GUIFormSpecMenu::parseSize(parserData* data, const std::string &element) data->invsize.Y = MYMAX(0, stof(parts[1])); lockSize(false); +#ifndef __ANDROID__ if (parts.size() == 3) { if (parts[2] == "true") { lockSize(true,v2u32(800,600)); } } - +#endif data->explicit_size = true; return; } @@ -437,11 +438,12 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data, const std::string &element fselected = true; std::wstring wlabel = translate_string(utf8_to_wide(unescape_string(label))); + s32 spacing = Environment->getSkin()->getSize(gui::EGDS_CHECK_BOX_WIDTH) + 7; core::rect<s32> rect = core::rect<s32>( - pos.X, pos.Y + ((imgsize.Y/2) - m_btn_height), - pos.X + m_font->getDimension(wlabel.c_str()).Width + 25, // text size + size of checkbox - pos.Y + ((imgsize.Y/2) + m_btn_height)); + pos.X, pos.Y + ((imgsize.Y / 2) - m_btn_height), + pos.X + m_font->getDimension(wlabel.c_str()).Width + spacing, + pos.Y + ((imgsize.Y / 2) + m_btn_height)); FieldSpec spec( name, @@ -2145,16 +2147,28 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) // the image size can't be less than 0.3 inch // multiplied by gui_scaling, even if this means // the form doesn't fit the screen. - double prefer_imgsize = mydata.screensize.Y / 15 * - gui_scaling; +#ifdef __ANDROID__ + // For mobile devices these magic numbers are + // different and forms should always use the + // maximum screen space available. + double prefer_imgsize = mydata.screensize.Y / 10 * gui_scaling; double fitx_imgsize = mydata.screensize.X / - ((5.0/4.0) * (0.5 + mydata.invsize.X)); + ((12.0 / 8.0) * (0.5 + mydata.invsize.X)); double fity_imgsize = mydata.screensize.Y / - ((15.0/13.0) * (0.85 * mydata.invsize.Y)); + ((15.0 / 11.0) * (0.85 + mydata.invsize.Y)); + use_imgsize = MYMIN(prefer_imgsize, + MYMIN(fitx_imgsize, fity_imgsize)); +#else + double prefer_imgsize = mydata.screensize.Y / 15 * gui_scaling; + double fitx_imgsize = mydata.screensize.X / + ((5.0 / 4.0) * (0.5 + mydata.invsize.X)); + double fity_imgsize = mydata.screensize.Y / + ((15.0 / 13.0) * (0.85 * mydata.invsize.Y)); double screen_dpi = RenderingEngine::getDisplayDensity() * 96; double min_imgsize = 0.3 * screen_dpi * gui_scaling; use_imgsize = MYMAX(min_imgsize, MYMIN(prefer_imgsize, MYMIN(fitx_imgsize, fity_imgsize))); +#endif } // Everything else is scaled in proportion to the |