From 121d4af3256f3c59ee974e36d3ccad2f6eb12cb9 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Wed, 26 Feb 2025 14:20:46 +0300 Subject: [PATCH] fix revert --- bin/layers/local_panel/local_panel.cpp | 58 ++++++++++++++++++++++++ bin/layers/local_panel/local_panel.hpp | 15 ++++++ bin/layers/meson.build | 2 + bin/layers/test_panel_2/test_panel_2.cpp | 21 +-------- bin/layers/test_panel_2/test_panel_2.hpp | 4 ++ src/application/application.cpp | 3 +- src/layer/layer.hpp | 5 -- src/utils/include.hpp | 14 +++--- 8 files changed, 88 insertions(+), 34 deletions(-) create mode 100755 bin/layers/local_panel/local_panel.cpp create mode 100755 bin/layers/local_panel/local_panel.hpp diff --git a/bin/layers/local_panel/local_panel.cpp b/bin/layers/local_panel/local_panel.cpp new file mode 100755 index 0000000..e6bde8d --- /dev/null +++ b/bin/layers/local_panel/local_panel.cpp @@ -0,0 +1,58 @@ +#include "local_panel.hpp" +#include "utils.hpp" + +namespace sandbox +{ + void local_panel::on_attach() + { + hack::log()("on_attach"); + } + + void local_panel::on_detach() + { + hack::log()("on_attach"); + } + + void local_panel::render() + { + + if (ImGui::Button("RUN", ImVec2(28, 30))) + { + VE::event e { "target_id", test_event::TEST_EVEN , std::string("test event message") }; + execute(e); + } + + VE_PUSH_FONT(ICON, 18); + + if (ImGui::Button(VE::style::icon::ICON_STOP, ImVec2(28, 30))) + { + VE::event e { "target_id", test_event::TEST_EVEN , std::string("test icon button") }; + execute(e); + } + + ImGui::Text(VE::style::icon::ICON_PAINT_BRUSH, " Paint" ); + ImGui::Text("\xef\x87\xbc"); + + VE_POP_FONT(); + + } + + void local_panel::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) + hack::log()(std::any_cast(e.m_data)); + } + } +} + diff --git a/bin/layers/local_panel/local_panel.hpp b/bin/layers/local_panel/local_panel.hpp new file mode 100755 index 0000000..a019cbb --- /dev/null +++ b/bin/layers/local_panel/local_panel.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace sandbox +{ + class local_panel : public VE::layer + { + VE_FN_OVERIDE(); + + ImVec2 m_size = ImVec2{ 400.f, 400.f }; + ImVec2 m_pos = ImVec2{ 400.f, 400.f }; + }; +} + diff --git a/bin/layers/meson.build b/bin/layers/meson.build index b88e217..b59d0e4 100755 --- a/bin/layers/meson.build +++ b/bin/layers/meson.build @@ -3,12 +3,14 @@ inc += include_directories('.') headers = [ 'test_panel/test_panel.hpp', 'test_panel_2/test_panel_2.hpp', + 'local_panel/local_panel.hpp', 'opengl_panel/opengl_panel.hpp', ] sources = [ 'test_panel/test_panel.cpp', 'test_panel_2/test_panel_2.cpp', + 'local_panel/local_panel.cpp', 'opengl_panel/opengl_panel.cpp', ] diff --git a/bin/layers/test_panel_2/test_panel_2.cpp b/bin/layers/test_panel_2/test_panel_2.cpp index 31efa0d..c192a52 100755 --- a/bin/layers/test_panel_2/test_panel_2.cpp +++ b/bin/layers/test_panel_2/test_panel_2.cpp @@ -6,9 +6,6 @@ namespace sandbox void test_panel_2::on_attach() { hack::log()("on_attach"); - - // set layer params - // m_passport.m_name = "test_panel"; } void test_panel_2::on_detach() @@ -22,24 +19,8 @@ namespace sandbox ImGui::SetNextWindowSize(m_size); if (!ImGui::Begin("#test_panel_2", &m_p_open, m_window_flags)) ImGui::End(); - if (ImGui::Button("RUN", ImVec2(28, 30))) - { - VE::event e { "target_id", test_event::TEST_EVEN , std::string("test event message") }; - execute(e); - } - VE_PUSH_FONT(ICON, 18); - - if (ImGui::Button(VE::style::icon::ICON_STOP, ImVec2(28, 30))) - { - VE::event e { "target_id", test_event::TEST_EVEN , std::string("test icon button") }; - execute(e); - } - - ImGui::Text(VE::style::icon::ICON_PAINT_BRUSH, " Paint" ); - ImGui::Text("\xef\x87\xbc"); - - VE_POP_FONT(); + m_local_panel.render(); ImGui::End(); } diff --git a/bin/layers/test_panel_2/test_panel_2.hpp b/bin/layers/test_panel_2/test_panel_2.hpp index aa8e5ec..5595326 100755 --- a/bin/layers/test_panel_2/test_panel_2.hpp +++ b/bin/layers/test_panel_2/test_panel_2.hpp @@ -2,6 +2,8 @@ #include +#include "local_panel/local_panel.hpp" + namespace sandbox { class test_panel_2 : public VE::layer @@ -10,6 +12,8 @@ namespace sandbox ImVec2 m_size = ImVec2{ 400.f, 400.f }; ImVec2 m_pos = ImVec2{ 400.f, 400.f }; + + local_panel m_local_panel; }; } diff --git a/src/application/application.cpp b/src/application/application.cpp index 1f503ed..519541e 100755 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -21,8 +21,7 @@ namespace VE m_glfw->clear(); m_gui->begin_frame(); - for (auto l : m_layers_stack) - if (l->m_no_local_render) l->render(); + for (auto l : m_layers_stack) l->render(); m_gui->end_frame(); m_glfw->update(); diff --git a/src/layer/layer.hpp b/src/layer/layer.hpp index a35af81..a7585d6 100755 --- a/src/layer/layer.hpp +++ b/src/layer/layer.hpp @@ -22,11 +22,6 @@ namespace VE virtual void render() {}; virtual void on_event(event e) {}; - // если нужно отрисовать не вообще, а внутри другого layer, что бывает крайне часто - // т.е. отрисовка слоя при регистрации его в системе может не понадобится, а понадобится только его система сигналов - // по этому этим можно контролить рендер - bool m_no_local_render = true; - void set_event_fn(const event_fn& fn) { execute = fn; }; protected: diff --git a/src/utils/include.hpp b/src/utils/include.hpp index c92939b..7393336 100755 --- a/src/utils/include.hpp +++ b/src/utils/include.hpp @@ -22,10 +22,10 @@ второй это поставить glad первым */ -#include "glad.h" // IWYU pragma: keep -#include "GLFW/glfw3.h" // IWYU pragma: keep -#include "hack/logger/logger.hpp" // IWYU pragma: keep -#include "hack/patterns/singleton.hpp" // IWYU pragma: keep -#include "imgui.h" // IWYU pragma: keep -#include "imgui_impl_glfw.h" // IWYU pragma: keep -#include "imgui_impl_opengl3.h" // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep