Index: source/gui/ObjectTypes/CInput.h =================================================================== --- source/gui/ObjectTypes/CInput.h +++ source/gui/ObjectTypes/CInput.h @@ -234,6 +234,7 @@ CGUISimpleSetting m_TextColor; CGUISimpleSetting m_TextColorSelected; CGUISimpleSetting m_PlaceholderColor; + CGUISimpleSetting m_TextVAlign; }; #endif // INCLUDED_CINPUT Index: source/gui/ObjectTypes/CInput.cpp =================================================================== --- source/gui/ObjectTypes/CInput.cpp +++ source/gui/ObjectTypes/CInput.cpp @@ -74,7 +74,8 @@ m_TextColor(this, "textcolor"), m_TextColorSelected(this, "textcolor_selected"), m_PlaceholderText(this, "placeholder_text"), - m_PlaceholderColor(this, "placeholder_color") + m_PlaceholderColor(this, "placeholder_color"), + m_TextVAlign(this, "text_valign") { CFG_GET_VAL("gui.cursorblinkrate", m_CursorBlinkRate); @@ -1268,8 +1269,8 @@ textRenderer.SetCurrentFont(font_name); textRenderer.Translate( - (float)(int)(m_CachedActualSize.left) + m_BufferZone, - (float)(int)(m_CachedActualSize.top+h) + m_BufferZone); + (float)(int)(m_CachedActualSize.left) + m_BufferZone, + floorf((m_CachedActualSize.top + m_CachedActualSize.bottom + h) / 2.f)); // U+FE33: PRESENTATION FORM FOR VERTICAL LOW LINE // (sort of like a | which is aligned to the left of most characters) @@ -1507,8 +1508,8 @@ textRenderer.ResetTranslate(savedTranslate); } - textRenderer.Translate(0.f, ls); - } + textRenderer.Translate(0.f, ls / 2.f); + } canvas.DrawText(textRenderer); @@ -1531,7 +1532,22 @@ if (!m_GeneratedPlaceholderTextValid) SetupGeneratedPlaceholderText(); + switch (m_TextVAlign) + { + case EVAlign::TOP: m_GeneratedPlaceholderText.Draw(m_pGUI, canvas, m_PlaceholderColor, m_CachedActualSize.TopLeft(), clipping); + break; + case EVAlign::CENTER: + // Round to integer pixel values, else the fonts look awful + m_GeneratedPlaceholderText.Draw(m_pGUI, canvas, m_PlaceholderColor, CVector2D(m_CachedActualSize.left, floorf(m_CachedActualSize.CenterPoint().Y - m_GeneratedPlaceholderText.GetSize().Height / 2.f)), clipping); + break; + case EVAlign::BOTTOM: + m_GeneratedPlaceholderText.Draw(m_pGUI, canvas, m_PlaceholderColor, CVector2D(m_CachedActualSize.left, m_CachedActualSize.bottom - m_GeneratedPlaceholderText.GetSize().Height), clipping); + break; + default: + debug_warn(L"Broken EVAlign in CButton::SetupText()"); + break; + } } void CInput::UpdateText(int from, int to_before, int to_after)