#include "ui_layer.hpp" #include "utils.hpp" namespace example { void ui_layer::on_attach() { CONNECT(this); hack::log()("on_attach"); } void ui_layer::on_detach() { DISCONNECT(); hack::log()("on_detach"); } void ui_layer::render() { VE_PUSH_FONT(REGULAR, 20); if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("New")) {} if (ImGui::MenuItem("Open", "Ctrl+O")) {} ImGui::EndMenu(); } if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Undo", "CTRL+Z")) {} if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item ImGui::Separator(); if (ImGui::MenuItem("Cut", "CTRL+X")) {} if (ImGui::MenuItem("Copy", "CTRL+C")) {} if (ImGui::MenuItem("Paste", "CTRL+V")) {} ImGui::EndMenu(); } ImGui::EndMainMenuBar(); } ImGui::SetNextWindowPos(m_pos); ImGui::SetNextWindowSize(m_size); if (!ImGui::Begin(VE_NAME("Test signal"), nullptr, m_win_flags)) ImGui::End(); if (ImGui::Button("Test signal", ImVec2(128, 130))) { VE::event e { test_event::TEST_EVEN_1, std::string("test event 1 message"), "asdf-asdf-asdf" }; EMIT(e); auto r = std::any_cast(e.m_result); hack::log()(r); e = { test_event::TEST_EVEN_2, std::string("test event 2 message") }; EMIT(e); r = std::any_cast(e.m_result); hack::log()(r); } VE_POP_FONT(); ImGui::End(); } void ui_layer::on_event(VE::event& e) { // для событий от перефирии // if (e.m_type.type() == typeid(VE::event_type)) // { // auto t = std::any_cast(e.m_type); // if (t != VE::event_type::MOUSE_CURSOR_POSITION) // hack::log()((int)t); // } if (e.m_type.type() == typeid(test_event)) { auto t = std::any_cast(e.m_type); if (t == test_event::TEST_EVEN_1) { hack::log()(std::any_cast(e.m_data)); e.m_result = std::string("test_event_1"); } } } void ui_layer::update() { } }