73 lines
1.5 KiB
C++
Executable File
73 lines
1.5 KiB
C++
Executable File
#include "ui_layer.hpp"
|
|
|
|
#include "utils.hpp"
|
|
|
|
namespace example
|
|
{
|
|
void ui_layer::on_attach()
|
|
{
|
|
VE::CONNECT(this);
|
|
|
|
hack::log()("on_attach");
|
|
}
|
|
|
|
void ui_layer::on_detach()
|
|
{
|
|
VE::DISCONNECT(this);
|
|
hack::log()("on_detach");
|
|
}
|
|
|
|
void ui_layer::render()
|
|
{
|
|
ImGui::SetNextWindowPos(m_pos);
|
|
ImGui::SetNextWindowSize(m_size);
|
|
|
|
if (!ImGui::Begin(VE_NAME("Test signal"), nullptr, m_win_flags)) ImGui::End();
|
|
|
|
VE_PUSH_FONT(REGULAR, 20);
|
|
if (ImGui::Button("Test signal", ImVec2(128, 130)))
|
|
VE::EMIT(test_event::TEST_EVEN, std::string("test event message"));
|
|
|
|
// try
|
|
// {
|
|
// if (ImGui::Button("Test signal log error", ImVec2(128, 130)))
|
|
// VE::EMIT(test_event::TEST_EVEN, std::string("test event message"));
|
|
// }
|
|
// catch(hack::exception& e)
|
|
// {
|
|
// e.log();
|
|
// auto data = std::any_cast<VE::event>(e.get_data());
|
|
// hack::log()(data.m_id);
|
|
// }
|
|
|
|
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<VE::event_type>(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<test_event>(e.m_type);
|
|
if (t == test_event::TEST_EVEN)
|
|
hack::log()(std::any_cast<std::string>(e.m_data));
|
|
}
|
|
}
|
|
|
|
void ui_layer::update()
|
|
{
|
|
|
|
}
|
|
}
|
|
|