Skip to content

Commit f409f44

Browse files
SmallJokerparamat
authored andcommitted
Correct the checkbox selection box position (#8246)
Remove m_btn_height dependency, replace with the text and checkbox size.
1 parent 66ecfb5 commit f409f44

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/gui/guiFormSpecMenu.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,16 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data, const std::string &element
438438
fselected = true;
439439

440440
std::wstring wlabel = translate_string(utf8_to_wide(unescape_string(label)));
441-
s32 spacing = Environment->getSkin()->getSize(gui::EGDS_CHECK_BOX_WIDTH) + 7;
441+
const core::dimension2d<u32> label_size = m_font->getDimension(wlabel.c_str());
442+
s32 cb_size = Environment->getSkin()->getSize(gui::EGDS_CHECK_BOX_WIDTH);
443+
s32 y_center = (std::max(label_size.Height, (u32)cb_size) + 1) / 2;
442444

443445
core::rect<s32> rect = core::rect<s32>(
444-
pos.X, pos.Y + ((imgsize.Y / 2) - m_btn_height),
445-
pos.X + m_font->getDimension(wlabel.c_str()).Width + spacing,
446-
pos.Y + ((imgsize.Y / 2) + m_btn_height));
446+
pos.X,
447+
pos.Y + imgsize.Y / 2 - y_center,
448+
pos.X + label_size.Width + cb_size + 7,
449+
pos.Y + imgsize.Y / 2 + y_center
450+
);
447451

448452
FieldSpec spec(
449453
name,

0 commit comments

Comments
 (0)