fix pixel snapping, add loaded event, remove default border thickness
This commit is contained in:
@@ -123,36 +123,24 @@ void App::init()
|
||||
FontManager::load(kFont::Arial_11, ttf, 15);
|
||||
FontManager::load(kFont::Arial_30, ttf, 30);
|
||||
|
||||
layout.on_loaded = [&] {
|
||||
layout[main_id].update(width, height);
|
||||
if (auto* button = layout[main_id].find<NodeButton>("btn-close"))
|
||||
{
|
||||
button->on_click = [] { exit(0); };
|
||||
}
|
||||
if (auto* button = layout[main_id].find<NodeButton>("btn-popup"))
|
||||
{
|
||||
button->on_click = [this] {
|
||||
msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = &layout;
|
||||
msgbox->init();
|
||||
layout[main_id].add_child(msgbox);
|
||||
layout[main_id].update(width, height);
|
||||
};
|
||||
}
|
||||
};
|
||||
layout.load("data/layout.xml");
|
||||
if (auto* button = layout[main_id].find<NodeButton>("btn-close"))
|
||||
{
|
||||
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";
|
||||
@@ -200,10 +188,7 @@ 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);
|
||||
// }
|
||||
layout.reload();
|
||||
|
||||
auto observer = [this](Node* n)
|
||||
{
|
||||
@@ -235,6 +220,14 @@ void App::mouse_down(int button, float x, float y)
|
||||
e.m_pos = { x, y };
|
||||
layout[main_id].on_event(&e);
|
||||
printf("mouse click %f %f\n", x, y);
|
||||
// NodeBorder* n = new NodeBorder();
|
||||
// n->SetPositioning(YGPositionTypeAbsolute);
|
||||
// n->SetWidth(100);
|
||||
// n->SetHeight(100);
|
||||
// n->SetPosition(x, y);
|
||||
// n->m_color = glm::vec4(.5, .5, .5, .5);
|
||||
// layout[main_id].add_child(n);
|
||||
// layout[main_id].update(width, height);
|
||||
}
|
||||
void App::mouse_move(float x, float y)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user