diff options
author | sapier <Sapier at GMX dot net> | 2014-06-18 22:38:29 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-06-18 22:38:29 +0200 |
commit | 65a4630f3176feb0f4dd4db6ce12cd6d32e2b369 (patch) | |
tree | c13646c86ee257761ddd676e0e76496cd8f2d90c /src | |
parent | 2a09b7e84fb5ce2d8d08d410529d70d440d48ef0 (diff) | |
download | minetest-65a4630f3176feb0f4dd4db6ce12cd6d32e2b369.tar.gz minetest-65a4630f3176feb0f4dd4db6ce12cd6d32e2b369.tar.bz2 minetest-65a4630f3176feb0f4dd4db6ce12cd6d32e2b369.zip |
Fix bounding rect for formspec elements label vertlabel and checkboxes
Diffstat (limited to 'src')
-rw-r--r-- | src/guiFormSpecMenu.cpp | 26 | ||||
-rw-r--r-- | src/guiFormSpecMenu.h | 7 |
2 files changed, 24 insertions, 9 deletions
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index c16600733..9e9e59fe4 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -62,6 +62,7 @@ with this program; if not, write to the Free Software Foundation, Inc., return; \ } +extern gui::IGUIEnvironment* guienv; /* GUIFormSpecMenu @@ -85,7 +86,8 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev, m_lock(false), m_form_src(fsrc), m_text_dst(tdst), - m_ext_ptr(ext_ptr) + m_ext_ptr(ext_ptr), + m_font(guienv->getSkin()->getFont()) { current_keys_pending.key_down = false; current_keys_pending.key_up = false; @@ -388,8 +390,6 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element) pos.X += stof(v_pos[0]) * (float) spacing.X; pos.Y += stof(v_pos[1]) * (float) spacing.Y; - core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y+((imgsize.Y/2)-15), pos.X+300, pos.Y+((imgsize.Y/2)+15)); - bool fselected = false; if (selected == "true") @@ -397,6 +397,11 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element) std::wstring wlabel = narrow_to_wide(label.c_str()); + core::rect<s32> rect = core::rect<s32>( + pos.X, pos.Y + ((imgsize.Y/2) - 15), + pos.X + m_font->getDimension(wlabel.c_str()).Width + 25, // text size + size of checkbox + pos.Y + ((imgsize.Y/2) + 15)); + FieldSpec spec( narrow_to_wide(name.c_str()), wlabel, //Needed for displaying text on MSVC @@ -1083,8 +1088,6 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element) pos.X += stof(v_pos[0]) * (float)spacing.X; pos.Y += stof(v_pos[1]) * (float)spacing.Y; - core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y+((imgsize.Y/2)-15), pos.X+300, pos.Y+((imgsize.Y/2)+15)); - if(data->bp_set != 2) errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl; @@ -1092,6 +1095,11 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element) std::wstring wlabel = narrow_to_wide(text.c_str()); + core::rect<s32> rect = core::rect<s32>( + pos.X, pos.Y+((imgsize.Y/2)-15), + pos.X + m_font->getDimension(wlabel.c_str()).Width, + pos.Y+((imgsize.Y/2)+15)); + FieldSpec spec( L"", wlabel, @@ -1119,7 +1127,13 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element) pos.X += stof(v_pos[0]) * (float)spacing.X; pos.Y += stof(v_pos[1]) * (float)spacing.Y; - core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y+((imgsize.Y/2)-15), pos.X+15, pos.Y+300); + core::rect<s32> rect = core::rect<s32>( + pos.X, pos.Y+((imgsize.Y/2)-15), + pos.X+15, pos.Y + + (m_font->getKerningHeight() + + m_font->getDimension(text.c_str()).Height) + * (text.length()+1)); + //actually text.length() would be correct but adding +1 avoids to break all mods if(data->bp_set != 2) errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl; diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 474f13cb1..91605bc16 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -312,9 +312,10 @@ protected: video::SColor m_slotbg_h; video::SColor m_slotbordercolor; private: - IFormSource* m_form_src; - TextDest* m_text_dst; - GUIFormSpecMenu** m_ext_ptr; + IFormSource *m_form_src; + TextDest *m_text_dst; + GUIFormSpecMenu **m_ext_ptr; + gui::IGUIFont *m_font; typedef struct { v2s32 size; |