add ui and viewport scale option, fix combobox items height from parent

This commit is contained in:
2019-08-04 12:00:49 +02:00
parent a1436eec4a
commit cc087746bd
10 changed files with 107 additions and 39 deletions

View File

@@ -44,7 +44,7 @@ void NodeComboBox::loaded()
auto btn = popup->add_child<NodeButton>();
btn->m_text->set_text(m_data[i].c_str());
btn->m_border->SetWidthP(100.f);
btn->m_border->SetHeight(30.f);
btn->m_border->SetHeight(GetHeight());
int index = (int)m_items.size();
if (index == m_current_index)
m_selected_child_index = popup->get_child_index(btn);
@@ -62,8 +62,8 @@ void NodeComboBox::loaded()
}
float offset = 0;
for (int i = 0; i <= m_selected_child_index; i++)
offset += (m_data[i] == "-") ? 5.f : 30.f;
float height = m_items.size() * 30.f + (m_data.size() - m_items.size()) * 5.f; // add items and separators
offset += (m_data[i] == "-") ? 5.f : GetHeight();
float height = m_items.size() * GetHeight() + (m_data.size() - m_items.size()) * 5.f; // add items and separators
glm::vec2 pos = m_pos + glm::vec2(0, m_size.y - offset);
auto screen = root()->m_size;
if ((pos.y + height) > screen.y) pos.y = screen.y - height;
@@ -109,3 +109,8 @@ void NodeComboBox::set_index(int index)
//if (on_select)
// on_select(this, index);
}
float NodeComboBox::get_float(int index) const noexcept
{
return std::stof(m_data[index]);
}