-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always use same default tabheader height #9319
Always use same default tabheader height #9319
Conversation
This code is valid and works, but I'm trying to think of a better way to structure it. Having the string -> float conversion in v_geom is annoying to my logic. This is as far I got: // Work out the formspec-coordinate size, if in real-coordinates mode
bool auto_width = true;
std::vector<std::string> v_geom = {"1", "1"}; // Dummy width and height
if (data->real_coordinates) {
if (parts.size() == 7) {
i++;
v_geom = split(parts[1], ',');
if (v_geom.size() == 1)
v_geom.insert(v_geom.begin(), std::to_string(2.f * (float)m_btn_height / (float)imgsize.Y));
else
auto_width = false;
} else {
v_geom[1] = std::to_string(2.f * (float)m_btn_height / (float)imgsize.Y);
}
} I was attempting to get the formspec parsing done in one place, so that the formspec coord -> irrlicht coord conversion part wouldn't care about it |
perhaps: // Work out the formspec-coordinate size, if in real-coordinates mode
const auto default_height = std::to_string(2.f * (float)m_btn_height / (float)imgsize.Y);
bool auto_width = true;
std::vector<std::string> v_geom = {"1", default_height};
if (parts.size() == 7) {
i++;
v_geom = split(parts[1], ',');
if (v_geom.size() == 1)
v_geom.insert(v_geom.begin(), default_height);
else
auto_width = false;
} |
Previously the default tabheader height was different when using real coordinates. This resulted in the height of tabs changing when switching tabs in sfinv if some tabs used real coordinates.
504516f
to
d3ca31c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works.
Previously the default tabheader height was different when using
real coordinates. This resulted in the height of tabs changing when
switching tabs in sfinv if some tabs used real coordinates.
To do
This PR is a Ready for Review.
How to test
Apply the patch below to sfinv. Open sfinv and switch between the crafting tab and other tabs (ignore the messed up contents of the crafting tab).
Before this PR: tabheader height changes when switching between crafting tab and other tabs.
After: tabheader hight unchanged between tabs.
Note: the form width of 10.5 comes from the conversion formula in lua_api.txt, but that formula did not give the correct height (I arrived at 11.375 by guess and check, the formula suggested 11.875). Not sure what's going on there.