add win struct

This commit is contained in:
Andrey Zimin 2024-04-01 11:32:37 +03:00
parent 08bddf39a9
commit 1864f8cd74
4 changed files with 34 additions and 33 deletions

View File

@ -5,21 +5,24 @@ project(
default_options : [ default_options : [
'warning_level=1', 'warning_level=1',
'optimization=3', 'optimization=3',
'default_library=static',
'cpp_std=c++20', 'cpp_std=c++20',
]) ])
add_project_arguments ( add_project_arguments (
'-Wall',
'-Wpedantic', '-Wpedantic',
'-Wno-shadow', '-Wno-shadow',
'-Wno-unused-but-set-variable', '-Wno-unused-but-set-variable',
'-Wno-comment', '-Wno-comment',
'-Wno-unused-parameter', '-Wno-unused-parameter',
'-Wno-unused-value', '-Wno-unused-value',
'-Wno-unused-header',
'-Wno-missing-field-initializers', '-Wno-missing-field-initializers',
'-Wno-narrowing', '-Wno-narrowing',
'-Wno-deprecated-enum-enum-conversion', '-Wno-deprecated-enum-enum-conversion',
'-Wno-volatile', '-Wno-volatile',
'-Wno-format-security',
'-Wno-switch',
'-Wno-ignored-attributes', '-Wno-ignored-attributes',
language: 'cpp' language: 'cpp'
) )

View File

@ -5,6 +5,9 @@ namespace tr::layers
void test_panel::on_attach() void test_panel::on_attach()
{ {
BASE_WINDOW_FLAGS(); BASE_WINDOW_FLAGS();
m_win.m_pos = { 212.f, 35.f };
m_win.m_size = { 720.f, 480.f };
} }
void test_panel::on_detach() void test_panel::on_detach()
@ -14,8 +17,8 @@ namespace tr::layers
void test_panel::gui_render() void test_panel::gui_render()
{ {
ImGui::SetNextWindowPos(ImVec2(m_pos_x, m_pos_y)); ImGui::SetNextWindowPos(m_win.m_pos);
ImGui::SetNextWindowSize(ImVec2(m_width, m_height)); ImGui::SetNextWindowSize(m_win.m_size);
BEGIN_IMGUI_WIN("test_win"); BEGIN_IMGUI_WIN("test_win");

View File

@ -10,12 +10,6 @@ namespace tr::layers
private: private:
bool m_open = true; 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;
}; };
} }

View File

@ -12,18 +12,19 @@
#define BASE_TYPE_DEFINE()\ #define BASE_TYPE_DEFINE()\
using time = try_engine::time::timestep<float>;\ using time = try_engine::time::timestep<float>;\
using event_manager = try_engine::app_event::event;\ 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()\ #define BASE_WINDOW_FLAGS()\
if (f.no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;\ if (m_flags.m_no_titlebar) m_window_flags |= ImGuiWindowFlags_NoTitleBar;\
if (f.no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;\ if (m_flags.m_no_scrollbar) m_window_flags |= ImGuiWindowFlags_NoScrollbar;\
if (!f.no_menu) window_flags |= ImGuiWindowFlags_MenuBar;\ if (!m_flags.m_no_menu) m_window_flags |= ImGuiWindowFlags_MenuBar;\
if (f.no_move) window_flags |= ImGuiWindowFlags_NoMove;\ if (m_flags.m_no_move) m_window_flags |= ImGuiWindowFlags_NoMove;\
if (f.no_resize) window_flags |= ImGuiWindowFlags_NoResize;\ if (m_flags.m_no_resize) m_window_flags |= ImGuiWindowFlags_NoResize;\
if (f.no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;\ if (m_flags.m_no_collapse) m_window_flags |= ImGuiWindowFlags_NoCollapse;\
if (f.no_nav) window_flags |= ImGuiWindowFlags_NoNav;\ if (m_flags.m_no_nav) m_window_flags |= ImGuiWindowFlags_NoNav;\
if (f.no_background) window_flags |= ImGuiWindowFlags_NoBackground;\ if (m_flags.m_no_background) m_window_flags |= ImGuiWindowFlags_NoBackground;\
if (f.no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus if (m_flags.m_no_bring_to_front) m_window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus
#define SET_EVENT_MANAGER_IMPL()\ #define SET_EVENT_MANAGER_IMPL()\
void set_event_manager(event_manager* in_event_manager)\ void set_event_manager(event_manager* in_event_manager)\
@ -46,19 +47,19 @@
#define FLAGS_STRUCT_DEFINED()\ #define FLAGS_STRUCT_DEFINED()\
struct flags\ struct flags\
{\ {\
bool p_open = false;\ bool m_p_open = false;\
bool no_titlebar = true;\ bool m_no_titlebar = true;\
bool no_scrollbar = true;\ bool m_no_scrollbar = true;\
bool no_menu = true;\ bool m_no_menu = true;\
bool no_move = true;\ bool m_no_move = true;\
bool no_resize = true;\ bool m_no_resize = true;\
bool no_collapse = true;\ bool m_no_collapse = true;\
bool no_nav = false;\ bool m_no_nav = false;\
bool no_background = false;\ bool m_no_background = false;\
bool no_bring_to_front = false;\ bool m_no_bring_to_front = false;\
bool no_docking = true;\ bool m_no_docking = true;\
} f;\ } m_flags;\
ImGuiWindowFlags window_flags = 0 ImGuiWindowFlags m_window_flags = 0
#define BASE_IMPL(name)\ #define BASE_IMPL(name)\
@ -75,7 +76,7 @@
event_manager* m_event_manager 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 END_IMGUI_WIN() ImGui::End()
#define TR_PUSH_FONT(def_font, def_size)\ #define TR_PUSH_FONT(def_font, def_size)\