From 7c0eb5a77a00905017eabaedb1f2a73720fdf15c Mon Sep 17 00:00:00 2001 From: Joeyrp Date: Wed, 3 Nov 2021 14:04:24 -0400 Subject: [PATCH] Main editor panel now sits on-top of the application window again. But this time the it uses the application window title-bar. --- src/core/core.cpp | 2 ++ src/run_modes/editor/editor.cpp | 24 +------------ src/run_modes/editor/editor.h | 3 -- src/run_modes/editor/panels/mainPanel.cpp | 43 +++++++++++++---------- src/run_modes/editor/panels/mainPanel.h | 8 ++--- src/window/window.cpp | 4 +-- 6 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 9c02c86..ed8c104 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -237,6 +237,8 @@ namespace lunarium return; #else mpRunMode = new Editor; + LogGui::GetInstance().SetStickToWindow(false); + LuaConsole::GetInstance().SetStickToWindow(false); #endif } diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index 3b1f577..528e027 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -21,13 +21,10 @@ namespace lunarium OpRes Editor::Initialize() { - //Core::MainWindow().Hide(); - mLogCat = Logger::RegisterCategory("EDITOR"); mpMainPanel = &MainPanel::GetInstance(); mpMainPanel->SetEditor(this); - Core::MainWindow().GetPosition(&sx, &sy); return OpRes::OK(); } @@ -38,26 +35,7 @@ namespace lunarium void Editor::OnTick(double delta) { - //int x, y, w, h; - //mpMainPanel->GetPosition(x, y); - // mpMainPanel->GetSize(w, h); - - // if (w > 0 && h > 0) - // { - // // NOTE: Should not be able to run in full screen while in editor mode - // // Unless testing the game maybe? - // Core::MainWindow().ChangeDisplayMode(false, x, y, w, h); - // } - - // if (x > 0 && y > 0) - // { - // if (sx != x || sy != y) - // { - // Core::MainWindow().Hide(); - // mpMainPanel->Focus(); - // } - - // } + } void Editor::OnRender(IGraphics* g) diff --git a/src/run_modes/editor/editor.h b/src/run_modes/editor/editor.h index bc0fe88..da6ec76 100644 --- a/src/run_modes/editor/editor.h +++ b/src/run_modes/editor/editor.h @@ -39,9 +39,6 @@ namespace lunarium MainPanel* mpMainPanel; std::vector mpPanels; - // TEST - int sx, sy; - private: // HELPERS void CreatePanels(); }; diff --git a/src/run_modes/editor/panels/mainPanel.cpp b/src/run_modes/editor/panels/mainPanel.cpp index 475e414..cb879c9 100644 --- a/src/run_modes/editor/panels/mainPanel.cpp +++ b/src/run_modes/editor/panels/mainPanel.cpp @@ -20,13 +20,13 @@ namespace lunarium : Panel(PT_MAIN, true), mpEditor(nullptr), mSetFocus(false) { - Core::MainWindow().GetFramebufferSize(&mStartWidth, &mStartHeight); - Core::MainWindow().GetPosition(&mStartX, &mStartY); + Core::MainWindow().GetFramebufferSize(&mWidth, &mHeight); + Core::MainWindow().GetPosition(&mX, &mY); // Make the application window small so that the imgui window will start outside of // it's bounds and be detached from it. This prevents the window from disappearing // and/or losing focus when the application window disappears. - Core::MainWindow().ChangeDisplayMode(false, mStartX + 10, mStartY + 10, 10, 10); + // Core::MainWindow().ChangeDisplayMode(false, mX + 10, mY + 10, 10, 10); } @@ -62,20 +62,7 @@ namespace lunarium if (!mIsOpen) return false; - if (mSetFocus) - { - ImGui::SetNextWindowFocus(); - mSetFocus = false; - } - ImGui::SetNextWindowSize(ImVec2(mStartWidth, mStartHeight), ImGuiCond_Appearing); - ImGui::SetNextWindowPos(ImVec2(mStartX, mStartY), ImGuiCond_Appearing); - if (!ImGui::Begin("Lunarium Editor", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking)) - { - ImGui::End(); - return false; - } - - ImGui::BeginMenuBar(); + ImGui::BeginMainMenuBar(); // File if (ImGui::BeginMenu("File")) @@ -92,7 +79,27 @@ namespace lunarium ImGui::EndMenu(); } - ImGui::EndMenuBar(); + ImGui::EndMainMenuBar(); + + if (mSetFocus) + { + ImGui::SetNextWindowFocus(); + mSetFocus = false; + } + + Core::MainWindow().GetFramebufferSize(&mWidth, &mHeight); + Core::MainWindow().GetPosition(&mX, &mY); + + ImGui::SetNextWindowSize(ImVec2(mWidth, mHeight - ImGui::GetFrameHeight()), ImGuiCond_Always); + ImGui::SetNextWindowPos(ImVec2(mX, mY + ImGui::GetFrameHeight()), ImGuiCond_Always); + if (!ImGui::Begin("Lunarium Editor", &mIsOpen, ImGuiWindowFlags_NoCollapse + | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoTitleBar )) + { + ImGui::End(); + return false; + } + // NOTE: Must always update these values! Panel::UpdateMetaInfo(); diff --git a/src/run_modes/editor/panels/mainPanel.h b/src/run_modes/editor/panels/mainPanel.h index b546223..ee3ac2e 100644 --- a/src/run_modes/editor/panels/mainPanel.h +++ b/src/run_modes/editor/panels/mainPanel.h @@ -34,10 +34,10 @@ namespace lunarium private: Editor* mpEditor; - int mStartWidth; - int mStartHeight; - int mStartX; - int mStartY; + // int mStartWidth; + // int mStartHeight; + // int mStartX; + // int mStartY; // Menu Items bool mSetFocus; diff --git a/src/window/window.cpp b/src/window/window.cpp index 54851c7..5529fdd 100644 --- a/src/window/window.cpp +++ b/src/window/window.cpp @@ -59,8 +59,8 @@ namespace lunarium if (state.Mode == RunMode::MODE_EDITOR) { - glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); - glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + // glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); + //glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); } mpWindow = glfwCreateWindow( state.Display.WindowedSize.Width, state.Display.WindowedSize.Height, "Lunarium", NULL, NULL );