fix text node pad and font height bounds

This commit is contained in:
2019-11-29 12:16:20 +01:00
parent 26257e5a37
commit 2aadf9e92c
4 changed files with 13 additions and 9 deletions

View File

@@ -571,6 +571,7 @@
<Xml Include="data\dialogs\panel-quick.xml" />
<Xml Include="data\dialogs\panel-stroke.xml" />
<Xml Include="data\dialogs\progress-bar.xml" />
<Xml Include="data\dialogs\remote-page.xml" />
<Xml Include="data\dialogs\settings.xml" />
<Xml Include="data\dialogs\usermanual.xml" />
<Xml Include="data\layout.xml">

View File

@@ -737,6 +737,9 @@
<Xml Include="data\dialogs\panel-animation.xml">
<Filter>extras\dialogs</Filter>
</Xml>
<Xml Include="data\dialogs\remote-page.xml">
<Filter>extras\dialogs</Filter>
</Xml>
</ItemGroup>
<ItemGroup>
<None Include="data\shaders\texture.glsl">

View File

@@ -140,7 +140,7 @@ void TextMesh::update(kFont id, const std::string& text)
{
font_id = id;
auto& f = FontManager::get(id);
float spacing = f.bounds.w - f.bounds.y;
float spacing = (f.bounds.w - f.bounds.y);
float avg_width = f.bounds.z - f.bounds.x;
cur_box = glm::vec4(0, f.bounds.y, 5, spacing);
@@ -200,8 +200,8 @@ void TextMesh::update(kFont id, const std::string& text)
idx.push_back(n + 0);
idx.push_back(n + 2);
idx.push_back(n + 3);
bbmin = glm::min(bbmin, xy(f.bounds));
bbmax = glm::max(bbmax, { q.x1 / f.scale, y + f.bounds.w });
bbmin = glm::min(bbmin, glm::floor(xy(f.bounds)));
bbmax = glm::max(bbmax, glm::ceil(glm::vec2(q.x1 / f.scale, y / f.scale + f.bounds.w)));
if (max_width > 0 && q.x1 / f.scale + 5 > max_width * f.scale)
cur_box = glm::vec4(0, (y + spacing * f.scale) / f.scale + f.bounds.y, 5, spacing);
else

View File

@@ -123,17 +123,17 @@ void NodeText::update_layout()
auto pad = GetPadding();
if (auto_width)
{
YGNodeStyleSetWidth(y_node, m_text_mesh.bb.x);
m_size.x = m_text_mesh.bb.x;
YGNodeStyleSetWidth(y_node, m_text_mesh.bb.x + (pad[1] + pad[3]));
m_size.x = m_text_mesh.bb.x + (pad[1] + pad[3]);
}
if (auto_height)
{
YGNodeStyleSetHeight(y_node, m_text_mesh.bb.y);
m_size.y = m_text_mesh.bb.y;
YGNodeStyleSetHeight(y_node, m_text_mesh.bb.y + (pad[0] + pad[2]));
m_size.y = m_text_mesh.bb.y + (pad[0] + pad[2]);
}
float h = m_size.y - (pad[1] + pad[3]);
float w = m_size.x - (pad[0] + pad[2]);
float w = m_size.x - (pad[1] + pad[3]);
float h = m_size.y - (pad[0] + pad[2]);
if (m_text_align_v == TextAlign::Begin)
m_off.y = pad[0];