SDK/(Rich)TextAreaWidget: Add character and line spacing offsets
This commit is contained in:
@@ -91,26 +91,6 @@ namespace Ndk
|
||||
SetText(newText);
|
||||
}
|
||||
|
||||
void TextAreaWidget::SetCharacterSize(unsigned int characterSize)
|
||||
{
|
||||
m_drawer.SetCharacterSize(characterSize);
|
||||
|
||||
std::size_t fontCount = m_drawer.GetFontCount();
|
||||
unsigned int lineHeight = 0;
|
||||
int spaceAdvance = 0;
|
||||
for (std::size_t i = 0; i < fontCount; ++i)
|
||||
{
|
||||
Nz::Font* font = m_drawer.GetFont(i);
|
||||
|
||||
const Nz::Font::SizeInfo& sizeInfo = font->GetSizeInfo(characterSize);
|
||||
lineHeight = std::max(lineHeight, sizeInfo.lineHeight);
|
||||
spaceAdvance = std::max(spaceAdvance, sizeInfo.spaceAdvance);
|
||||
}
|
||||
|
||||
Nz::Vector2f size = { float(spaceAdvance), float(lineHeight) + 5.f };
|
||||
SetMinimumSize(size);
|
||||
}
|
||||
|
||||
void TextAreaWidget::Write(const Nz::String& text, std::size_t glyphPosition)
|
||||
{
|
||||
if (glyphPosition >= m_drawer.GetGlyphCount())
|
||||
@@ -252,4 +232,22 @@ namespace Ndk
|
||||
|
||||
SetCursorPosition(m_cursorPositionBegin); //< Refresh cursor position (prevent it from being outside of the text)
|
||||
}
|
||||
|
||||
void TextAreaWidget::UpdateMinimumSize()
|
||||
{
|
||||
std::size_t fontCount = m_drawer.GetFontCount();
|
||||
float lineHeight = 0;
|
||||
int spaceAdvance = 0;
|
||||
for (std::size_t i = 0; i < fontCount; ++i)
|
||||
{
|
||||
Nz::Font* font = m_drawer.GetFont(i);
|
||||
|
||||
const Nz::Font::SizeInfo& sizeInfo = font->GetSizeInfo(m_drawer.GetCharacterSize());
|
||||
lineHeight = std::max(lineHeight, m_drawer.GetLineHeight());
|
||||
spaceAdvance = std::max(spaceAdvance, sizeInfo.spaceAdvance);
|
||||
}
|
||||
|
||||
Nz::Vector2f size = { float(spaceAdvance), lineHeight + 5.f };
|
||||
SetMinimumSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user