added button click event handler
This commit is contained in:
@@ -124,7 +124,10 @@ void App::init()
|
||||
FontManager::load(kFont::Arial_30, ttf, 30);
|
||||
|
||||
layout.load("data/layout.xml");
|
||||
//layout["main"].update(width, height);
|
||||
if (auto* button = layout[main_id].find<NodeButton>("btn-close"))
|
||||
{
|
||||
button->on_click = [] { exit(0); };
|
||||
}
|
||||
|
||||
sampler.create(GL_NEAREST);
|
||||
ShaderManager::create(kShader::Texture, shader_v, shader_f);
|
||||
@@ -164,8 +167,6 @@ void App::init()
|
||||
|
||||
void App::update(float dt)
|
||||
{
|
||||
constexpr auto main_id = const_hash("main");
|
||||
|
||||
glClearColor(.1f, .1f, .1f, 1.f);
|
||||
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
@@ -173,13 +174,10 @@ void App::update(float dt)
|
||||
if (layout.reload())
|
||||
{
|
||||
layout[main_id].update(width, height);
|
||||
//Node* check = layout[main_id].find("check");
|
||||
//if (check)
|
||||
// check->m_display = false;
|
||||
}
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
//glEnable(GL_SCISSOR_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (auto& n : layout[main_id])
|
||||
{
|
||||
if (n.m_display)
|
||||
@@ -190,32 +188,6 @@ void App::update(float dt)
|
||||
}
|
||||
}
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
glm::mat4 proj = glm::ortho(0.f, width, height, 0.f, -1.f, 1.f);
|
||||
glm::mat4 tran = glm::translate(glm::vec3(200, 200, 0));
|
||||
|
||||
/*
|
||||
static int i = 0;
|
||||
i = (i + 1) % 32;
|
||||
auto c = chars["hgfrr56789opk0876ryuewighfcuisdbn"[i] - 32];
|
||||
glm::vec2 a(c.x0, c.y0);
|
||||
glm::vec2 b(c.x1, c.y1);
|
||||
glm::vec2 s(512, 512);
|
||||
glm::vec2 tof = a / s;
|
||||
glm::vec2 tsz = (b - a) / s;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
font_tex.bind();
|
||||
sampler.bind(0);
|
||||
ShaderManager::use(kShader::Font);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj * tran);
|
||||
ShaderManager::u_vec2(kShaderUniform::Tof, tof);
|
||||
ShaderManager::u_vec2(kShaderUniform::Tsz, tsz);
|
||||
//plane.draw_fill();
|
||||
font_tex.unbind();
|
||||
sampler.unbind();
|
||||
*/
|
||||
}
|
||||
|
||||
void App::resize(float w, float h)
|
||||
@@ -228,7 +200,6 @@ void App::resize(float w, float h)
|
||||
|
||||
void App::mouse_down(int button, float x, float y)
|
||||
{
|
||||
constexpr auto main_id = const_hash("main");
|
||||
MouseEvent e;
|
||||
e.m_type = kEventType::MouseDownL;
|
||||
e.m_pos = { x, y };
|
||||
@@ -237,7 +208,6 @@ void App::mouse_down(int button, float x, float y)
|
||||
}
|
||||
void App::mouse_move(float x, float y)
|
||||
{
|
||||
constexpr auto main_id = const_hash("main");
|
||||
MouseEvent e;
|
||||
e.m_type = kEventType::MouseMove;
|
||||
e.m_pos = { x, y };
|
||||
@@ -245,7 +215,6 @@ void App::mouse_move(float x, float y)
|
||||
}
|
||||
void App::mouse_up(int button, float x, float y)
|
||||
{
|
||||
constexpr auto main_id = const_hash("main");
|
||||
MouseEvent e;
|
||||
e.m_type = kEventType::MouseUpL;
|
||||
e.m_pos = { x, y };
|
||||
|
||||
Reference in New Issue
Block a user