diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-04-27 01:56:31 +0200 |
---|---|---|
committer | Paramat <paramat@users.noreply.github.com> | 2019-04-27 00:56:31 +0100 |
commit | f409f4476539f32dcce3ff6832be4bc48bd25634 (patch) | |
tree | 097f1d1638b940d84a54f96d3ca9e7801d7d98fc /src/gui | |
parent | 66ecfb59164b9f7bf36b33520f22d79c91c95692 (diff) | |
download | minetest-f409f4476539f32dcce3ff6832be4bc48bd25634.tar.gz minetest-f409f4476539f32dcce3ff6832be4bc48bd25634.tar.bz2 minetest-f409f4476539f32dcce3ff6832be4bc48bd25634.zip |
Correct the checkbox selection box position (#8246)
Remove m_btn_height dependency, replace with the text and checkbox size.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/guiFormSpecMenu.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 54434931e..92e654765 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -438,12 +438,16 @@ 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; + const core::dimension2d<u32> label_size = m_font->getDimension(wlabel.c_str()); + s32 cb_size = Environment->getSkin()->getSize(gui::EGDS_CHECK_BOX_WIDTH); + s32 y_center = (std::max(label_size.Height, (u32)cb_size) + 1) / 2; 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 + spacing, - pos.Y + ((imgsize.Y / 2) + m_btn_height)); + pos.X, + pos.Y + imgsize.Y / 2 - y_center, + pos.X + label_size.Width + cb_size + 7, + pos.Y + imgsize.Y / 2 + y_center + ); FieldSpec spec( name, |