From 1864f8cd746b311beb2af96e9f407d81b32de494 Mon Sep 17 00:00:00 2001 From: Andrey Zimin Date: Mon, 1 Apr 2024 11:32:37 +0300 Subject: [PATCH] add win struct --- meson.build | 5 +- src/sandbox/layers/test_panel/test_panel.cpp | 7 ++- src/sandbox/layers/test_panel/test_panel.hpp | 6 --- src/try_engine/utils/define.hpp | 49 ++++++++++---------- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/meson.build b/meson.build index 7a949d8..5daa7ed 100755 --- a/meson.build +++ b/meson.build @@ -5,21 +5,24 @@ project( default_options : [ 'warning_level=1', 'optimization=3', - 'default_library=static', 'cpp_std=c++20', ]) add_project_arguments ( + '-Wall', '-Wpedantic', '-Wno-shadow', '-Wno-unused-but-set-variable', '-Wno-comment', '-Wno-unused-parameter', '-Wno-unused-value', + '-Wno-unused-header', '-Wno-missing-field-initializers', '-Wno-narrowing', '-Wno-deprecated-enum-enum-conversion', '-Wno-volatile', + '-Wno-format-security', + '-Wno-switch', '-Wno-ignored-attributes', language: 'cpp' ) diff --git a/src/sandbox/layers/test_panel/test_panel.cpp b/src/sandbox/layers/test_panel/test_panel.cpp index 88d5ff1..3285d6e 100755 --- a/src/sandbox/layers/test_panel/test_panel.cpp +++ b/src/sandbox/layers/test_panel/test_panel.cpp @@ -5,6 +5,9 @@ namespace tr::layers void test_panel::on_attach() { BASE_WINDOW_FLAGS(); + + m_win.m_pos = { 212.f, 35.f }; + m_win.m_size = { 720.f, 480.f }; } void test_panel::on_detach() @@ -14,8 +17,8 @@ namespace tr::layers void test_panel::gui_render() { - ImGui::SetNextWindowPos(ImVec2(m_pos_x, m_pos_y)); - ImGui::SetNextWindowSize(ImVec2(m_width, m_height)); + ImGui::SetNextWindowPos(m_win.m_pos); + ImGui::SetNextWindowSize(m_win.m_size); BEGIN_IMGUI_WIN("test_win"); diff --git a/src/sandbox/layers/test_panel/test_panel.hpp b/src/sandbox/layers/test_panel/test_panel.hpp index 37a8c36..c836385 100755 --- a/src/sandbox/layers/test_panel/test_panel.hpp +++ b/src/sandbox/layers/test_panel/test_panel.hpp @@ -10,12 +10,6 @@ namespace tr::layers private: bool m_open = true; - - float m_width = 720.f; - float m_height = 480.f; - - float m_pos_x = 212.f; - float m_pos_y = 35.f; }; } diff --git a/src/try_engine/utils/define.hpp b/src/try_engine/utils/define.hpp index 0d373b2..7da4e28 100755 --- a/src/try_engine/utils/define.hpp +++ b/src/try_engine/utils/define.hpp @@ -12,18 +12,19 @@ #define BASE_TYPE_DEFINE()\ using time = try_engine::time::timestep;\ using event_manager = try_engine::app_event::event;\ - using system_event = try_engine::system_event::event + using system_event = try_engine::system_event::event;\ + struct win { ImVec2 m_pos { 0.f, 0.f }; ImVec2 m_size { 0.f, 0.f }; } m_win #define BASE_WINDOW_FLAGS()\ - if (f.no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;\ - if (f.no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;\ - if (!f.no_menu) window_flags |= ImGuiWindowFlags_MenuBar;\ - if (f.no_move) window_flags |= ImGuiWindowFlags_NoMove;\ - if (f.no_resize) window_flags |= ImGuiWindowFlags_NoResize;\ - if (f.no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;\ - if (f.no_nav) window_flags |= ImGuiWindowFlags_NoNav;\ - if (f.no_background) window_flags |= ImGuiWindowFlags_NoBackground;\ - if (f.no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus + if (m_flags.m_no_titlebar) m_window_flags |= ImGuiWindowFlags_NoTitleBar;\ + if (m_flags.m_no_scrollbar) m_window_flags |= ImGuiWindowFlags_NoScrollbar;\ + if (!m_flags.m_no_menu) m_window_flags |= ImGuiWindowFlags_MenuBar;\ + if (m_flags.m_no_move) m_window_flags |= ImGuiWindowFlags_NoMove;\ + if (m_flags.m_no_resize) m_window_flags |= ImGuiWindowFlags_NoResize;\ + if (m_flags.m_no_collapse) m_window_flags |= ImGuiWindowFlags_NoCollapse;\ + if (m_flags.m_no_nav) m_window_flags |= ImGuiWindowFlags_NoNav;\ + if (m_flags.m_no_background) m_window_flags |= ImGuiWindowFlags_NoBackground;\ + if (m_flags.m_no_bring_to_front) m_window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus #define SET_EVENT_MANAGER_IMPL()\ void set_event_manager(event_manager* in_event_manager)\ @@ -46,19 +47,19 @@ #define FLAGS_STRUCT_DEFINED()\ struct flags\ {\ - bool p_open = false;\ - bool no_titlebar = true;\ - bool no_scrollbar = true;\ - bool no_menu = true;\ - bool no_move = true;\ - bool no_resize = true;\ - bool no_collapse = true;\ - bool no_nav = false;\ - bool no_background = false;\ - bool no_bring_to_front = false;\ - bool no_docking = true;\ - } f;\ - ImGuiWindowFlags window_flags = 0 + bool m_p_open = false;\ + bool m_no_titlebar = true;\ + bool m_no_scrollbar = true;\ + bool m_no_menu = true;\ + bool m_no_move = true;\ + bool m_no_resize = true;\ + bool m_no_collapse = true;\ + bool m_no_nav = false;\ + bool m_no_background = false;\ + bool m_no_bring_to_front = false;\ + bool m_no_docking = true;\ + } m_flags;\ + ImGuiWindowFlags m_window_flags = 0 #define BASE_IMPL(name)\ @@ -75,7 +76,7 @@ event_manager* m_event_manager -#define BEGIN_IMGUI_WIN(name) if (!ImGui::Begin(name, &f.p_open, window_flags)) ImGui::End() +#define BEGIN_IMGUI_WIN(name) if (!ImGui::Begin(name, &m_flags.m_p_open, m_window_flags)) ImGui::End() #define END_IMGUI_WIN() ImGui::End() #define TR_PUSH_FONT(def_font, def_size)\