diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index e13ea12..bc70b9d 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -31,7 +31,7 @@ namespace editor Editor::Editor() : mLogCat(-1), mpFileBrowser(nullptr), mpPath(nullptr), mDoNewProject(false), mDoOpenProject(false), - mDoSaveProject(false), mDoSaveAs(false), mpMapEditor(nullptr) + mDoSaveProject(false), mDoSaveAs(false), mNextWindowID(0), mpMapEditor(nullptr) { } @@ -93,6 +93,11 @@ namespace editor { return mLogCat; } + + unsigned int Editor::GetNextWindowID() + { + return ++mNextWindowID; + } bool Editor::IsToolOpen(ToolType type) const diff --git a/src/run_modes/editor/editor.h b/src/run_modes/editor/editor.h index 6661a87..5373cf2 100644 --- a/src/run_modes/editor/editor.h +++ b/src/run_modes/editor/editor.h @@ -25,6 +25,7 @@ namespace lunarium enum ToolType { + TT_MAIN_EDITOR, TT_MAP_EDITOR, }; @@ -40,6 +41,7 @@ namespace lunarium uint32_t GetLogCat() const; + unsigned int GetNextWindowID(); bool IsToolOpen(ToolType type) const; private: @@ -52,6 +54,7 @@ namespace lunarium Project mProject; // Tools + unsigned int mNextWindowID; MapEditor* mpMapEditor; FileBrowser* mpFileBrowser; diff --git a/src/run_modes/editor/panel_manager.cpp b/src/run_modes/editor/panel_manager.cpp index 6b601e2..2394597 100644 --- a/src/run_modes/editor/panel_manager.cpp +++ b/src/run_modes/editor/panel_manager.cpp @@ -9,7 +9,6 @@ #include "panel_manager.h" #include "editor.h" #include -#include #include // To use the DockWindowXXX methods #include @@ -52,11 +51,9 @@ namespace lunarium { namespace editor { mpEditor = editor; + memset(&mWindowClass, 0, sizeof(ImGuiWindowClass)); + mWindowClass.ClassId = mpEditor->GetNextWindowID(); - //mpMainPanel = &MainPanel::GetInstance(); - // mpMainPanel->SetEditor(mpEditor); - //mpMainPanel->ResetDockSpace(); - if (!std::filesystem::exists("imgui.ini")) { mResetDockSpace = true; @@ -70,7 +67,6 @@ namespace lunarium { namespace editor void PanelManager::Shutdown() { DestoryPanels(); - //MainPanel::FreeInstance(); } void PanelManager::OpenPanel(PanelType type) @@ -118,6 +114,11 @@ namespace lunarium { namespace editor return nullptr; } + const ImGuiWindowClass* PanelManager::GetWindowClass() const + { + return &mWindowClass; + } + void PanelManager::ResetDocking() { mResetDockSpace = true; @@ -161,6 +162,7 @@ namespace lunarium { namespace editor { if (iter->second->IsOpen()) { + ImGui::SetNextWindowClass(&mWindowClass); iter->second->DoFrame(); } } @@ -193,11 +195,13 @@ namespace lunarium { namespace editor void PanelManager::MakeDockSpaces() { ImGuiViewport* Viewport = ImGui::GetMainViewport(); - mDockSpaceID = ImGui::DockSpace(ImGui::GetID("Lunarium Editor Dockspace")); + ImGuiID windowID = mpEditor->GetNextWindowID(); + mDockSpaceID = ImGui::DockSpace(ImGui::GetID("Lunarium Editor Dockspace"), ImVec2(0, 0), 0, &mWindowClass); if (!ImGui::DockBuilderGetNode(mDockSpaceID) || mResetDockSpace) { Logger::Log(mpEditor->GetLogCat(), LogLevel::INFO, "Resetting Dockspaces"); + mResetDockSpace = false; ImGui::DockBuilderRemoveNode(mDockSpaceID); ImGui::DockBuilderAddNode(mDockSpaceID, ImGuiDockNodeFlags_DockSpace); diff --git a/src/run_modes/editor/panel_manager.h b/src/run_modes/editor/panel_manager.h index f92f667..af02121 100644 --- a/src/run_modes/editor/panel_manager.h +++ b/src/run_modes/editor/panel_manager.h @@ -10,10 +10,12 @@ #define PANEL_MANAGER_H_ #include -//#include "panels/mainPanel.h" +#include #include #include +struct ImGuiWindowClass; + namespace lunarium{ class IGraphics; namespace editor @@ -32,6 +34,7 @@ namespace editor void ClosePanel(gui::PanelType type); bool IsOpen(gui::PanelType type); gui::Panel* GetPanel(gui::PanelType type); + const ImGuiWindowClass* GetWindowClass() const; void ResetDocking(); @@ -44,6 +47,7 @@ namespace editor bool mResetDockSpace; std::map mPanels; unsigned int mDockSpaceID; + ImGuiWindowClass mWindowClass; std::map mDockZoneIDs; private: