add messagebox to template binding, add absolute positioning layout, add observer instead of stack based node traversal which is not great in case of hierarchical traversal
This commit is contained in:
@@ -128,6 +128,35 @@ void App::init()
|
||||
{
|
||||
button->on_click = [] { exit(0); };
|
||||
}
|
||||
if (auto* button = layout[main_id].find<NodeButton>("btn-popup"))
|
||||
{
|
||||
button->on_click = [this] {
|
||||
// auto nb = new NodeButton();
|
||||
// nb->init();
|
||||
// nb->SetWidth(50);
|
||||
// nb->SetHeightP(100);
|
||||
// nb->m_border->SetWidthP(100);
|
||||
// nb->m_border->SetHeightP(100);
|
||||
// nb->m_text->m_text = "NB";
|
||||
// nb->create();
|
||||
// layout[main_id].find("toolbar")->add_child(nb);
|
||||
// layout[main_id].update(width, height);
|
||||
msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->init();
|
||||
layout[main_id].add_child(msgbox);
|
||||
layout[main_id].update(width, height);
|
||||
};
|
||||
}
|
||||
|
||||
msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->init();
|
||||
layout[main_id].add_child(msgbox);
|
||||
|
||||
//msgbox->find<NodeButton>("btn-ok")->on_click = [] { exit(0); };
|
||||
// msgbox->find<NodeButton>("btn-ok")->m_text->m_text = "DO";
|
||||
// msgbox->find<NodeButton>("btn-ok")->m_text->create();
|
||||
|
||||
sampler.create(GL_NEAREST);
|
||||
ShaderManager::create(kShader::Texture, shader_v, shader_f);
|
||||
@@ -171,28 +200,29 @@ void App::update(float dt)
|
||||
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (layout.reload())
|
||||
{
|
||||
layout[main_id].update(width, height);
|
||||
}
|
||||
// if (layout.reload())
|
||||
// {
|
||||
// layout[main_id].update(width, height);
|
||||
// }
|
||||
|
||||
auto observer = [this](Node* n)
|
||||
{
|
||||
if (n->m_display)
|
||||
{
|
||||
auto box = n->m_clip;
|
||||
glScissor((int)box.x-1, (int)(height - box.y - box.w)-1, (int)box.z+2, (int)box.w+2);
|
||||
n->draw();
|
||||
}
|
||||
};
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (auto& n : layout[main_id])
|
||||
{
|
||||
if (n.m_display)
|
||||
{
|
||||
auto box = n.m_clip;
|
||||
glScissor((int)box.x, (int)(height - box.y - box.w), (int)box.z, (int)box.w);
|
||||
n.draw();
|
||||
}
|
||||
}
|
||||
layout[main_id].watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
void App::resize(float w, float h)
|
||||
{
|
||||
constexpr auto main_id = const_hash("main");
|
||||
width = w;
|
||||
height = h;
|
||||
layout[main_id].update(w, h);
|
||||
|
||||
Reference in New Issue
Block a user