diff --git a/bin/layers/opengl_panel/opengl_panel.hpp b/bin/layers/opengl_panel/opengl_panel.hpp index b84826f..54cb6c4 100755 --- a/bin/layers/opengl_panel/opengl_panel.hpp +++ b/bin/layers/opengl_panel/opengl_panel.hpp @@ -85,7 +85,7 @@ namespace sandbox class opengl_panel : public VE::layer { - VE_FN_OVERIDE(); + VE_FN_OVERIDE(opengl_panel, true); cube m_cb_1; cube m_cb_2; diff --git a/bin/layers/test_panel/test_panel.cpp b/bin/layers/test_panel/test_panel.cpp index ea41ff1..d9e575e 100755 --- a/bin/layers/test_panel/test_panel.cpp +++ b/bin/layers/test_panel/test_panel.cpp @@ -5,7 +5,7 @@ namespace sandbox { void test_panel::on_attach() { - hack::log()("on_attach"); + hack::log()("on_attach", VE::application::get()->get_glfw()->width()); } void test_panel::on_detach() diff --git a/bin/layers/test_panel/test_panel.hpp b/bin/layers/test_panel/test_panel.hpp index 6226352..4ae2f4f 100755 --- a/bin/layers/test_panel/test_panel.hpp +++ b/bin/layers/test_panel/test_panel.hpp @@ -6,7 +6,7 @@ namespace sandbox { class test_panel : public VE::layer { - VE_FN_OVERIDE(); + VE_FN_OVERIDE(test_panel, false); ImVec2 m_size = ImVec2{ 600.f, 100.f }; ImVec2 m_pos = ImVec2{ 100.f, 100.f }; diff --git a/bin/layers/test_panel_2/test_panel_2.hpp b/bin/layers/test_panel_2/test_panel_2.hpp index aa8e5ec..8e7f607 100755 --- a/bin/layers/test_panel_2/test_panel_2.hpp +++ b/bin/layers/test_panel_2/test_panel_2.hpp @@ -6,7 +6,7 @@ namespace sandbox { class test_panel_2 : public VE::layer { - VE_FN_OVERIDE(); + VE_FN_OVERIDE(test_panel_2, true); ImVec2 m_size = ImVec2{ 400.f, 400.f }; ImVec2 m_pos = ImVec2{ 400.f, 400.f }; diff --git a/src/application/application.cpp b/src/application/application.cpp index 2831cf4..f0430c5 100755 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -21,7 +21,7 @@ namespace VE m_glfw->clear(); m_gui->begin_frame(); - for (auto l : m_layers_stack) l->render(); + for (auto l : m_layers_stack) if (l->m_render_permit) l->render(); m_gui->end_frame(); m_glfw->update(); diff --git a/src/glfw/glfw.cpp b/src/glfw/glfw.cpp index 9199789..d7370a4 100755 --- a/src/glfw/glfw.cpp +++ b/src/glfw/glfw.cpp @@ -91,14 +91,12 @@ namespace VE int glfw::width() const { - auto d = static_cast(glfwGetWindowUserPointer(m_win)); - return d->m_width; + return m_win_data.m_width; } int glfw::height() const { - auto d = static_cast(glfwGetWindowUserPointer(m_win)); - return d->m_height; + return m_win_data.m_height; } void glfw::update() @@ -200,8 +198,10 @@ namespace VE glfwSetWindowSizeCallback(m_win, [](GLFWwindow* w, int width, int height) { auto d = static_cast(glfwGetWindowUserPointer(w)); + hack::log()(d->m_width); d->m_width = width; d->m_height = height; + hack::log()(d->m_width); event e{ event_type::WINDOW_RESIZE, std::pair{ static_cast(width), static_cast(height) } }; d->execute(e); diff --git a/src/layer/layer.hpp b/src/layer/layer.hpp index 6b166e1..13c53f1 100755 --- a/src/layer/layer.hpp +++ b/src/layer/layer.hpp @@ -10,7 +10,7 @@ namespace VE using time = time::timestep; public: - layer() = default; + layer(bool p) : m_render_permit { p } {} virtual ~layer() = default; layer(const layer&) = delete; @@ -24,6 +24,11 @@ namespace VE void set_event_fn(const event_fn& fn) { execute = fn; }; + public: + // Внекоторых случаях необходимо чтобы компонент был в системе сигналов, но не + // в системе отрисовки. Например при вкладках. + bool m_render_permit; + protected: event_fn execute; }; diff --git a/src/utils/define.hpp b/src/utils/define.hpp index d56e099..0def5c0 100755 --- a/src/utils/define.hpp +++ b/src/utils/define.hpp @@ -6,7 +6,9 @@ #define VE_EVENT_FN\ std::bind(&application::on_event, this, std::placeholders::_1) -#define VE_FN_OVERIDE()\ +#define VE_FN_OVERIDE(def_class_name, def_render_permit)\ + public:\ + def_class_name() : VE::layer { def_render_permit } {}\ public:\ void on_attach() override;\ void on_detach() override;\