fix revert

This commit is contained in:
2025-02-26 14:20:46 +03:00
parent 1bdf330eb8
commit 121d4af325
8 changed files with 88 additions and 34 deletions

View File

@@ -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<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));
}
}
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include <VE.hpp>
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 };
};
}

View File

@@ -3,12 +3,14 @@ inc += include_directories('.')
headers = [ headers = [
'test_panel/test_panel.hpp', 'test_panel/test_panel.hpp',
'test_panel_2/test_panel_2.hpp', 'test_panel_2/test_panel_2.hpp',
'local_panel/local_panel.hpp',
'opengl_panel/opengl_panel.hpp', 'opengl_panel/opengl_panel.hpp',
] ]
sources = [ sources = [
'test_panel/test_panel.cpp', 'test_panel/test_panel.cpp',
'test_panel_2/test_panel_2.cpp', 'test_panel_2/test_panel_2.cpp',
'local_panel/local_panel.cpp',
'opengl_panel/opengl_panel.cpp', 'opengl_panel/opengl_panel.cpp',
] ]

View File

@@ -6,9 +6,6 @@ namespace sandbox
void test_panel_2::on_attach() void test_panel_2::on_attach()
{ {
hack::log()("on_attach"); hack::log()("on_attach");
// set layer params
// m_passport.m_name = "test_panel";
} }
void test_panel_2::on_detach() void test_panel_2::on_detach()
@@ -22,24 +19,8 @@ namespace sandbox
ImGui::SetNextWindowSize(m_size); ImGui::SetNextWindowSize(m_size);
if (!ImGui::Begin("#test_panel_2", &m_p_open, m_window_flags)) ImGui::End(); 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); m_local_panel.render();
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();
ImGui::End(); ImGui::End();
} }

View File

@@ -2,6 +2,8 @@
#include <VE.hpp> #include <VE.hpp>
#include "local_panel/local_panel.hpp"
namespace sandbox namespace sandbox
{ {
class test_panel_2 : public VE::layer class test_panel_2 : public VE::layer
@@ -10,6 +12,8 @@ namespace sandbox
ImVec2 m_size = ImVec2{ 400.f, 400.f }; ImVec2 m_size = ImVec2{ 400.f, 400.f };
ImVec2 m_pos = ImVec2{ 400.f, 400.f }; ImVec2 m_pos = ImVec2{ 400.f, 400.f };
local_panel m_local_panel;
}; };
} }

View File

@@ -21,8 +21,7 @@ namespace VE
m_glfw->clear(); m_glfw->clear();
m_gui->begin_frame(); m_gui->begin_frame();
for (auto l : m_layers_stack) for (auto l : m_layers_stack) l->render();
if (l->m_no_local_render) l->render();
m_gui->end_frame(); m_gui->end_frame();
m_glfw->update(); m_glfw->update();

View File

@@ -22,11 +22,6 @@ namespace VE
virtual void render() {}; virtual void render() {};
virtual void on_event(event e) {}; virtual void on_event(event e) {};
// если нужно отрисовать не вообще, а внутри другого layer, что бывает крайне часто
// т.е. отрисовка слоя при регистрации его в системе может не понадобится, а понадобится только его система сигналов
// по этому этим можно контролить рендер
bool m_no_local_render = true;
void set_event_fn(const event_fn<event>& fn) { execute = fn; }; void set_event_fn(const event_fn<event>& fn) { execute = fn; };
protected: protected:

View File

@@ -22,10 +22,10 @@
второй это поставить glad первым второй это поставить glad первым
*/ */
#include "glad.h" // IWYU pragma: keep #include <glad.h> // IWYU pragma: keep
#include "GLFW/glfw3.h" // IWYU pragma: keep #include <GLFW/glfw3.h> // IWYU pragma: keep
#include "hack/logger/logger.hpp" // IWYU pragma: keep #include <hack/logger/logger.hpp> // IWYU pragma: keep
#include "hack/patterns/singleton.hpp" // IWYU pragma: keep #include <hack/patterns/singleton.hpp> // IWYU pragma: keep
#include "imgui.h" // IWYU pragma: keep #include <imgui.h> // IWYU pragma: keep
#include "imgui_impl_glfw.h" // IWYU pragma: keep #include <imgui_impl_glfw.h> // IWYU pragma: keep
#include "imgui_impl_opengl3.h" // IWYU pragma: keep #include <imgui_impl_opengl3.h> // IWYU pragma: keep