improve text node
This commit is contained in:
@@ -120,6 +120,7 @@ void NodeText::set_text_format(const char* fmt, ...)
|
||||
|
||||
void NodeText::update_layout()
|
||||
{
|
||||
auto pad = GetPadding();
|
||||
if (auto_width)
|
||||
{
|
||||
YGNodeStyleSetWidth(y_node, m_text_mesh.bb.x);
|
||||
@@ -131,9 +132,8 @@ void NodeText::update_layout()
|
||||
m_size.y = m_text_mesh.bb.y;
|
||||
}
|
||||
|
||||
auto pad = GetPadding();
|
||||
float h = GetHeight() - (pad[1] + pad[3]);
|
||||
float w = GetWidth() - (pad[0] + pad[2]);
|
||||
float h = m_size.y - (pad[1] + pad[3]);
|
||||
float w = m_size.x - (pad[0] + pad[2]);
|
||||
|
||||
if (m_text_align_v == TextAlign::Begin)
|
||||
m_off.y = pad[0];
|
||||
@@ -152,11 +152,10 @@ void NodeText::update_layout()
|
||||
|
||||
void NodeText::draw()
|
||||
{
|
||||
glm::mat4 pos = glm::translate(glm::vec3(glm::floor(m_pos), 0));
|
||||
m_mvp = m_proj * pos;
|
||||
glm::mat4 pos = glm::translate(glm::vec3(glm::floor(m_pos + m_off), 0));
|
||||
ShaderManager::use(kShader::Font);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_proj * pos);
|
||||
ShaderManager::u_vec4(kShaderUniform::Col, m_color);
|
||||
glEnable(GL_BLEND);
|
||||
m_text_mesh.draw();
|
||||
|
||||
Reference in New Issue
Block a user