added right click, popup menu, mark for destroy

This commit is contained in:
2017-02-20 02:25:59 +00:00
parent 4e3f898d4b
commit ee5e4c2d98
8 changed files with 210 additions and 74 deletions

View File

@@ -216,7 +216,7 @@ void App::resize(float w, float h)
void App::mouse_down(int button, float x, float y)
{
MouseEvent e;
e.m_type = kEventType::MouseDownL;
e.m_type = button ? kEventType::MouseDownR : kEventType::MouseDownL;
e.m_pos = { x, y };
layout[main_id].on_event(&e);
printf("mouse click %f %f\n", x, y);
@@ -228,6 +228,20 @@ void App::mouse_down(int button, float x, float y)
// n->m_color = glm::vec4(.5, .5, .5, .5);
// layout[main_id].add_child(n);
// layout[main_id].update(width, height);
if (popup)
{
layout[main_id].remove_child(popup);
popup = nullptr;
}
if (button == 1)
{
popup = (NodePopupMenu*)layout[const_hash("popup-menu")].m_children[0]->clone();
popup->SetPositioning(YGPositionTypeAbsolute);
popup->SetPosition(x, y);
layout[main_id].add_child(popup);
layout[main_id].update(width, height);
}
layout[main_id].update();
}
void App::mouse_move(float x, float y)
{
@@ -239,7 +253,8 @@ void App::mouse_move(float x, float y)
void App::mouse_up(int button, float x, float y)
{
MouseEvent e;
e.m_type = kEventType::MouseUpL;
e.m_type = button ? kEventType::MouseUpR : kEventType::MouseUpL;
e.m_pos = { x, y };
layout[main_id].on_event(&e);
layout[main_id].update();
}