remove passport

This commit is contained in:
chatlanin
2025-01-20 21:16:50 +03:00
parent 802b5a9a8d
commit 72e4b3b6a8
6 changed files with 41 additions and 60 deletions

View File

@@ -1,10 +1,9 @@
#pragma once #pragma once
#include "VE.hpp" // IWYU pragma: keep #include <VE.hpp>
namespace sandbox namespace sandbox
{ {
class cube : public VE::opengl class cube : public VE::opengl
{ {
public: public:

View File

@@ -6,17 +6,6 @@ namespace sandbox
void test_panel::on_attach() void test_panel::on_attach()
{ {
hack::log()("on_attach"); hack::log()("on_attach");
// set layer params
// m_passport.m_name = "test_panel";
m_passport.m_size = mt::vec2{ 600.f, 100.f };
m_passport.m_pos = mt::vec2{ 100.f, 100.f };
// HERE
// можно сделать это функцией remove_frags(...)
// устанавливаем/убираем флаги отличные от установки по умолчанию
// в данном примере убираем флаг
m_window_flags &= ~ImGuiWindowFlags_NoTitleBar;
} }
void test_panel::on_detach() void test_panel::on_detach()
@@ -26,13 +15,18 @@ namespace sandbox
void test_panel::render() void test_panel::render()
{ {
begin(); ImGui::SetNextWindowPos(m_pos);
ImGui::SetNextWindowSize(m_size);
if (!ImGui::Begin("#test_panel_1", &m_p_open, m_window_flags)) ImGui::End();
if (ImGui::Button("RUN", ImVec2(28, 30))) if (ImGui::Button("RUN", ImVec2(28, 30)))
{ {
VE::event e { test_event::TEST_EVEN , std::string("test event message") }; VE::event e { test_event::TEST_EVEN , std::string("test event message") };
execute(e); execute(e);
} }
end();
ImGui::End();
} }
void test_panel::on_event(VE::event e) void test_panel::on_event(VE::event e)

View File

@@ -1,12 +1,15 @@
#pragma once #pragma once
#include "VE.hpp" // IWYU pragma: keep #include <VE.hpp>
namespace sandbox namespace sandbox
{ {
class test_panel : public VE::layer class test_panel : public VE::layer
{ {
VE_FN_OVERIDE(); VE_FN_OVERIDE();
ImVec2 m_size = ImVec2{ 600.f, 100.f };
ImVec2 m_pos = ImVec2{ 100.f, 100.f };
}; };
} }

View File

@@ -9,8 +9,6 @@ namespace sandbox
// set layer params // set layer params
// m_passport.m_name = "test_panel"; // m_passport.m_name = "test_panel";
m_passport.m_size = mt::vec2{ 400.f, 400.f };
m_passport.m_pos = mt::vec2{ 400.f, 400.f };
} }
void test_panel_2::on_detach() void test_panel_2::on_detach()
@@ -20,7 +18,10 @@ namespace sandbox
void test_panel_2::render() void test_panel_2::render()
{ {
begin(); ImGui::SetNextWindowPos(m_pos);
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))) if (ImGui::Button("RUN", ImVec2(28, 30)))
{ {
VE::event e { test_event::TEST_EVEN , std::string("test event message") }; VE::event e { test_event::TEST_EVEN , std::string("test event message") };
@@ -39,7 +40,8 @@ namespace sandbox
ImGui::Text("\xef\x87\xbc"); ImGui::Text("\xef\x87\xbc");
VE_POP_FONT(); VE_POP_FONT();
end();
ImGui::End();
} }
void test_panel_2::on_event(VE::event e) void test_panel_2::on_event(VE::event e)

View File

@@ -1,12 +1,15 @@
#pragma once #pragma once
#include "VE.hpp" // IWYU pragma: keep #include <VE.hpp>
namespace sandbox namespace sandbox
{ {
class test_panel_2 : public VE::layer class test_panel_2 : public VE::layer
{ {
VE_FN_OVERIDE(); VE_FN_OVERIDE();
ImVec2 m_size = ImVec2{ 400.f, 400.f };
ImVec2 m_pos = ImVec2{ 400.f, 400.f };
}; };
} }

View File

@@ -1,7 +1,5 @@
#pragma once #pragma once
#include "hack/security/uuid.hpp"
#include "event/event.hpp" #include "event/event.hpp"
#include "gui/flags.hpp" #include "gui/flags.hpp"
@@ -26,26 +24,8 @@ namespace VE
void set_event_fn(const event_fn<event&>& fn) { execute = fn; }; void set_event_fn(const event_fn<event&>& fn) { execute = fn; };
void begin()
{
ImGui::SetNextWindowPos(mt::convert<ImVec2>(m_passport.m_pos));
ImGui::SetNextWindowSize(mt::convert<ImVec2>(m_passport.m_size));
if (m_passport.m_name.empty())
m_passport.m_name = hack::security::generate_uuid();
if (!ImGui::Begin(m_passport.m_name.c_str(), &m_p_open, m_window_flags)) end();
}
void end() { ImGui::End(); }
protected: protected:
event_fn<event&> execute; event_fn<event&> execute;
struct passport
{
std::string m_name;
mt::vec2 m_pos;
mt::vec2 m_size;
} m_passport;
}; };
} }