Main Editor window improved: No longer hiding the application window behind the imgui window. App window is now actually hidden (so no trailing when moving the editor panel).

Gui_Panel_Refactor
Joeyrp 4 years ago
parent cd4f23b732
commit 4be5aa04b2

@ -229,9 +229,15 @@ namespace lunarium
{
mpRunMode = new Tester;
}
else if (RunMode::MODE_EDITOR == mState.Mode)
{
#if BUILD_NO_EDITOR
Logger::Log(mLogCat, LogLevel::FATAL_ERROR, "The Editor is not available with this build");
return;
#else
mpRunMode = new Editor;
#endif
}
// Initialize the Run Mode

@ -17,7 +17,6 @@ namespace lunarium
Editor::Editor()
: mLogCat(-1), mpMainPanel(nullptr)
{
}
OpRes Editor::Initialize()
@ -28,6 +27,7 @@ namespace lunarium
mpMainPanel = &MainPanel::GetInstance();
mpMainPanel->SetEditor(this);
Core::MainWindow().GetPosition(&sx, &sy);
return OpRes::OK();
}
@ -38,15 +38,26 @@ namespace lunarium
void Editor::OnTick(double delta)
{
int x, y, w, h;
mpMainPanel->GetPosition(x, y);
mpMainPanel->GetSize(w, h);
//int x, y, w, h;
//mpMainPanel->GetPosition(x, y);
// mpMainPanel->GetSize(w, h);
if (w > 0 && h > 0)
{
// NOTE TODO: Hardcoding fullscreen to false!
Core::MainWindow().ChangeDisplayMode(false, x, y, 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)
@ -61,4 +72,12 @@ namespace lunarium
{
return mLogCat;
}
////////////////////////////////////////////////////////////
// HELPER METHODS
////////////////////////////////////////////////////////////
void Editor::CreatePanels()
{
}
}

@ -12,8 +12,11 @@
#include <core/iRunMode.h>
#include <utils/opRes.h>
#include <vector>
namespace lunarium
{
class Panel;
class MainPanel;
class Editor : public iRunMode
{
@ -34,6 +37,13 @@ namespace lunarium
private: // Data
uint32_t mLogCat;
MainPanel* mpMainPanel;
std::vector<Panel*> mpPanels;
// TEST
int sx, sy;
private: // HELPERS
void CreatePanels();
};
}

@ -17,11 +17,16 @@ namespace lunarium
{
MainPanel* MainPanel::mpInstance = nullptr;
MainPanel::MainPanel()
: Panel(PT_MAIN, true), mpEditor(nullptr)
: Panel(PT_MAIN, true), mpEditor(nullptr), mSetFocus(false)
{
Core::MainWindow().GetFramebufferSize(&mStartWidth, &mStartHeight);
Core::MainWindow().GetPosition(&mStartX, &mStartY);
// 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);
}
@ -47,19 +52,47 @@ namespace lunarium
mpEditor = e;
}
void MainPanel::Focus()
{
mSetFocus = true;
}
bool MainPanel::DoFrame()
{
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_DockNodeHost))
if (!ImGui::Begin("Lunarium Editor", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking))
{
ImGui::End();
return false;
}
// Logger::Log(mpEditor->GetLogCat(), LogLevel::INFO, "EDITOR WINDOW SHOWING");
ImGui::BeginMenuBar();
// File
if (ImGui::BeginMenu("File"))
{
ImGui::MenuItem("New Project");
ImGui::MenuItem("Open Project");
ImGui::MenuItem("Save Project");
ImGui::MenuItem("Save Project As");
ImGui::Separator();
if (ImGui::MenuItem("Exit"))
{
Core::GetInstance().SignalShutdown();
}
ImGui::EndMenu();
}
ImGui::EndMenuBar();
// NOTE: Must always update these values!
Panel::UpdateMetaInfo();

@ -22,6 +22,7 @@ namespace lunarium
static void FreeInstance();
void SetEditor(Editor* e);
void Focus();
// Returns false if the window is closed
bool DoFrame();
@ -37,6 +38,9 @@ namespace lunarium
int mStartHeight;
int mStartX;
int mStartY;
// Menu Items
bool mSetFocus;
};
}

@ -60,6 +60,7 @@ namespace lunarium
if (state.Mode == RunMode::MODE_EDITOR)
{
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
}
mpWindow = glfwCreateWindow( state.Display.WindowedSize.Width, state.Display.WindowedSize.Height, "Lunarium", NULL, NULL );
@ -189,6 +190,11 @@ namespace lunarium
}
}
bool Window::IsFullScreen() const
{
return glfwGetWindowMonitor(mpWindow) != nullptr;
}
void Window::GetFramebufferSize(int* width, int* height) const
{
glfwGetFramebufferSize(mpWindow, width, height);

@ -37,6 +37,7 @@ namespace lunarium
// TODO: See https://www.glfw.org/docs/latest/window_guide.html#window_full_screen
void ChangeDisplayMode(bool fullscreen, int xPos, int yPos, int width, int height);
bool IsFullScreen() const;
void GetFramebufferSize(int* width, int* height) const;
void GetPosition(int* x, int* y) const;

Loading…
Cancel
Save