Mobile: don't stretch formspec to entire screen if it has a tabheader (#62)

master
luk3yx 2022-06-22 18:00:28 +12:00 committed by GitHub
parent 3991e90bbc
commit 3cf9c06ae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -3289,6 +3289,23 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
mydata.screensize.X,
mydata.screensize.Y
);
// Try and find a tabheader[] element in the formspec
for (unsigned int j = i; j < elements.size(); j++) {
// This could use split() but since we don't parse parameters
// here it's probably faster to use find().
const size_t pos = elements[j].find('[');
if (pos == std::string::npos)
continue;
// If we find a tabheader then decrease padded_screensize.Y and
// stop searching through the formspec.
const std::string element_type = trim(elements[j].substr(0, pos));
if (element_type == "tabheader") {
padded_screensize.Y *= 0.9f;
break;
}
}
#else
// Pad the screensize with 5% of the screensize on all sides to ensure
// that even the largest formspecs don't touch the screen borders.