Removed the gui namespace

Moved panel_manager out of editor and into the core
gui_api_redesign
Joey Pollack 4 years ago
parent 0fb6e94a2f
commit 09953c0e7d

@ -77,6 +77,7 @@ set(LUNARIUM_SRC
"src/graphics/opengl/glShader.cpp"
"src/gui/gui.cpp"
"src/gui/panel.cpp"
"src/gui/panel_manager.cpp"
"src/gui/console.cpp"
"src/internal_data/data_manager.cpp"
"src/assets/asset_manager.cpp"

@ -93,12 +93,14 @@ Core:
To support larger region sizes without needing single images that are like 1048576x1048576 or some nonsense.]
GUI:
☐ Improve the GUI API!
☐ Implement a better way to handle popup windows and context menus
✔ Dear ImGui class with basic initialization @done (9/10/2021, 1:42:19 PM)
✔ Debug log window @done (9/10/2021, 4:44:48 PM)
✔ Add key to show debug log window @done (9/13/2021, 6:47:44 PM)
☐ Add checkboxes to disable log categories and levels
✔ Add LUA Console window @done (10/26/2021, 4:43:41 PM)
Improve the interfaces for the Lua Editor and Console (partial transparancy for one thing) @high
Improve the interfaces for the Lua Editor and Console (partial transparancy for one thing) @high @done(22-06-23 15:54)
FileBrowser:
✔ Allow opening of listed directories @done (11/8/2021, 3:16:26 PM)
✔ Add indication that an item is directory @done (11/8/2021, 6:19:20 PM)

@ -423,7 +423,7 @@ namespace lunarium
// HELPERS
////////////////////////////////////////////////////////////
uint32_t Core::AddPanel(gui::Panel* p)
uint32_t Core::AddPanel(Panel* p)
{
mPanels.push_back(p);
return mPanels.size() - 1;

@ -64,7 +64,7 @@ namespace lunarium
{
uint32_t CoreConsole;
} mPanelIDs;
std::vector<gui::Panel*> mPanels;
std::vector<Panel*> mPanels;
// Log Files
std::ofstream mMasterLogFile;
@ -85,7 +85,7 @@ namespace lunarium
static InputManager& Input();
private: // HELPERS
uint32_t AddPanel(gui::Panel* p);
uint32_t AddPanel(Panel* p);
void FreePanel(uint32_t id);
private: // HIDDEN METHODS

@ -13,7 +13,7 @@
namespace lunarium
{
class CoreConsole : public gui::Console
class CoreConsole : public Console
{
public:
CoreConsole();

@ -15,8 +15,6 @@
#include <sstream>
#include <iostream>
namespace lunarium
{
namespace gui
{
////////////////////////////////////////////////////////////
// GUI LOG LISTENER
@ -46,7 +44,7 @@ namespace lunarium
// CONSOLE
////////////////////////////////////////////////////////////
Console::Console(const char* name)
: Panel(name, gui::PanelDockZone::DDZ_NONE, false),
: Panel(name, PanelDockZone::DDZ_NONE, false),
mbNewCommand(false), mRecalledCommand(-1), mIsFocused(false), mListener(nullptr),
mbOglDebug(false), mbInfoVerbose(false), mpListener(nullptr)
{
@ -222,4 +220,4 @@ namespace lunarium
return 0;
}
}}
}

@ -15,8 +15,6 @@
#include <vector>
namespace lunarium
{
namespace gui
{
class Console;
@ -69,7 +67,7 @@ namespace lunarium
void CheckFocus();
};
}}
}
#endif // CONSOLE_H_

@ -18,6 +18,7 @@
namespace lunarium
{
uint32_t GUI::LogCat = 0;
GUI* GUI::mpInstance = nullptr;
GUI::GUI()
: mbIsInit(false)//, mbShowDemo(false)
@ -48,6 +49,9 @@ namespace lunarium
return OpRes::Fail("GUI is already initialized!");
}
LogCat = Logger::RegisterCategory("GUI");
mNextWindowID = 0;
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
@ -146,6 +150,12 @@ namespace lunarium
}
u32 GUI::GetNextWindowID()
{
return mNextWindowID++;
}
void GUI::SetStyle(GuiStyle style)
{
// Reset the style

@ -9,6 +9,7 @@
#ifndef GUI_H_
#define GUI_H_
#include <core/common_defs.h>
#include <utils/op_res.h>
#include <map>
@ -41,6 +42,7 @@ namespace lunarium
class GUI
{
public:
static uint32_t LogCat;
static GUI& GetInstance();
static void FreeInstance();
OpRes Initialize(GLFWwindow* pWindow);
@ -55,6 +57,8 @@ namespace lunarium
void SetStyle(GuiStyle style);
ImFont* GetFont(GuiFont font);
u32 GetNextWindowID();
private:
GUI();
GUI(const GUI&) = delete;
@ -63,6 +67,7 @@ namespace lunarium
private:
static GUI* mpInstance;
bool mbIsInit;
u32 mNextWindowID;
ImGuiStyle* mpBaseStyle;
std::map<GuiFont, ImFont*> mFonts;
//bool mbShowDemo;

@ -11,8 +11,6 @@
#include "dearimgui/imgui.h"
namespace lunarium
{
namespace gui
{
Panel::Panel(std::string name, PanelDockZone dock_zone, bool isOpen)
: mIsOpen(isOpen), mPanelName(name), mDockZone(dock_zone)
@ -73,5 +71,5 @@ namespace gui
mWidth = s.x;
mHeight = s.y;
}
}
}

@ -1,5 +1,5 @@
/******************************************************************************
* File - iPanel.h
* File - panel.h
* Author - Joey Pollack
* Date - 2021/11/01 (y/m/d)
* Mod Date - 2021/11/01 (y/m/d)
@ -10,14 +10,13 @@
#define PANEL_H_
#include "panel_defs.h"
#include "panel_manager.h"
#include <string>
struct ImGuiInputTextCallbackData;
namespace lunarium
{
namespace gui
{
class Panel
{
@ -46,7 +45,10 @@ namespace gui
protected:
void UpdateMetaInfo();
private:
friend class PanelManager;
};
}}
}
#endif // PANEL_H_

@ -9,7 +9,7 @@
#ifndef PANEL_DEFS_H_
#define PANEL_DEFS_H_
namespace lunarium { namespace gui
namespace lunarium
{
enum PanelDockZone
{
@ -22,6 +22,6 @@ namespace lunarium { namespace gui
DDZ_NONE
};
}}
}
#endif // PANEL_DEFS_H_

@ -7,36 +7,30 @@
******************************************************************************/
#include "panel_manager.h"
#include "editor.h"
#include "gui.h"
#include <gui/panel.h>
#include <utils/logger.h>
#include <dearimgui/imgui_internal.h> // To use the DockWindowXXX methods
#include <filesystem>
// Panels
#include "panels/about.h"
#include "panels/asset_browser.h"
#include "panels/world_tree.h"
#include "panels/world_view.h"
#include "panels/properties_view.h"
using namespace lunarium::gui;
namespace lunarium { namespace editor
namespace lunarium
{
PanelManager::PanelManager()
: mpEditor(nullptr), mResetDockSpace(false), mDockSpaceID(0), mSplitBottom(false)
: mResetDockSpace(false), mDockSpaceID(0), mSplitBottom(false)
{
}
OpRes PanelManager::Initialize(Editor* editor, std::string name, bool split_bottom)
OpRes PanelManager::Initialize(std::string name, bool split_bottom)
{
mpEditor = editor;
mName = name;
mSplitBottom = split_bottom;
memset(&mWindowClass, 0, sizeof(ImGuiWindowClass));
mWindowClass.ClassId = mpEditor->GetNextWindowID();
mWindowClass.ClassId = GUI::GetInstance().GetNextWindowID();
if (!std::filesystem::exists("imgui.ini"))
{
@ -52,7 +46,7 @@ namespace lunarium { namespace editor
}
OpRes PanelManager::AddPanel(gui::Panel* panel, uint32_t& id)
OpRes PanelManager::AddPanel(Panel* panel, uint32_t& id)
{
if (mPanelsByName.find(panel->GetName()) != mPanelsByName.end())
{
@ -97,7 +91,7 @@ namespace lunarium { namespace editor
return mPanels[id];
}
Logger::Warn(mpEditor->GetLogCat(), "Requested panel not found: %d", id);
Logger::Warn(GUI::LogCat, "Requested panel not found: %d", id);
return nullptr;
}
@ -162,13 +156,13 @@ namespace lunarium { namespace editor
{
//ImGuiViewport* Viewport = ImGui::GetMainViewport();
ImGuiViewport* Viewport = ImGui::GetWindowViewport();
ImGuiID windowID = mpEditor->GetNextWindowID();
ImGuiID windowID = GUI::GetInstance().GetNextWindowID();
std::string dock_name = mName;
dock_name += " DockSpace";
mDockSpaceID = ImGui::DockSpace(ImGui::GetID(dock_name.c_str()), ImVec2(0, 0), 0, &mWindowClass);
if (!ImGui::DockBuilderGetNode(mDockSpaceID) || mResetDockSpace)
{
Logger::Trace(mpEditor->GetLogCat(), "Resetting Dockspace: %s", dock_name.c_str());
Logger::Trace(GUI::LogCat, "Resetting Dockspace: %s", dock_name.c_str());
mResetDockSpace = false;
ImGui::DockBuilderRemoveNode(mDockSpaceID);
@ -215,4 +209,4 @@ namespace lunarium { namespace editor
}
}
}}
}

@ -9,9 +9,9 @@
#ifndef PANEL_MANAGER_H_
#define PANEL_MANAGER_H_
#include "panel_defs.h"
#include <utils/op_res.h>
#include <dearimgui/imgui.h>
#include <gui/panel.h>
#include <map>
#include <vector>
@ -19,23 +19,22 @@ struct ImGuiWindowClass;
namespace lunarium{
class IGraphics;
namespace editor
{
class Editor;
class Panel;
class PanelManager
{
public:
PanelManager();
OpRes Initialize(Editor* editor, std::string name, bool split_bottom = false);
OpRes Initialize(std::string name, bool split_bottom = false);
void Shutdown();
// Panel interface
[[nodiscard]] OpRes AddPanel(gui::Panel* panel, uint32_t& id);
[[nodiscard]] OpRes AddPanel(Panel* panel, uint32_t& id);
void OpenPanel(uint32_t id);
void ClosePanel(uint32_t id);
bool IsOpen(uint32_t id);
gui::Panel* GetPanel(uint32_t id);
Panel* GetPanel(uint32_t id);
const ImGuiWindowClass* GetWindowClass() const;
// Docking
@ -48,21 +47,20 @@ namespace editor
void RenderPanels();
private:
Editor* mpEditor;
std::string mName;
bool mSplitBottom; // If true the bottom dock node will also be split into left/right
bool mResetDockSpace;
std::vector<gui::Panel*> mPanels;
std::map<const char*, gui::Panel*> mPanelsByName;
std::vector<Panel*> mPanels;
std::map<const char*, Panel*> mPanelsByName;
unsigned int mDockSpaceID;
ImGuiWindowClass mWindowClass;
std::map<gui::PanelDockZone, unsigned int> mDockZoneIDs;
std::map<PanelDockZone, unsigned int> mDockZoneIDs;
private:
void DestoryPanels();
};
}}
}
#endif // PANEL_MANAGER_H_

@ -3,7 +3,6 @@
set(EDITOR_SRC
"editor.cpp"
"editor_helpers.cpp"
"panel_manager.cpp"
"project.cpp"
"component_guis.cpp"
"panels/about.cpp"

@ -9,7 +9,7 @@
#include "editor.h"
#include <utils/helpers.h>
#include "panel_manager.h"
#include <gui/panel_manager.h>
#include <core/core.h>
#include <core/version.h>
#include <utils/logger.h>
@ -46,7 +46,7 @@ namespace editor
Editor::Editor()
: mDoNewProject(false), mDoOpenProject(false),
mDoSaveProject(false), mDoSaveAs(false), mNextWindowID(0), mpMapEditor(nullptr)
mDoSaveProject(false), mDoSaveAs(false), mpMapEditor(nullptr)
{
}
@ -62,7 +62,7 @@ namespace editor
// Init editor panels
mAboutPanel.SetOpen(false);
OpRes res = mPanelManager.Initialize(this, "Lunarium editor", true).LogIfFailed(LogCat);
OpRes res = mPanelManager.Initialize("Lunarium editor", true).LogIfFailed(LogCat);
if (Failed(res))
{
return res;
@ -124,12 +124,6 @@ namespace editor
return LogCat;
}
unsigned int Editor::GetNextWindowID()
{
return ++mNextWindowID;
}
bool Editor::IsToolOpen(ToolType type) const
{
switch (type)

@ -11,10 +11,10 @@
#include <core/run_mode.h>
#include <core/common_defs.h>
#include <gui/panel_manager.h>
#include <utils/op_res.h>
#include "project.h"
#include "panel_manager.h"
#include "panels/about.h"
#include <filesystem>
@ -49,7 +49,6 @@ namespace lunarium { namespace editor
uint32_t GetLogCat() const;
unsigned int GetNextWindowID();
bool IsToolOpen(ToolType type) const;
void ChangeWorld(lunarium::World* pWorld);
@ -67,7 +66,6 @@ namespace lunarium { namespace editor
Project mProject;
// Tools
unsigned int mNextWindowID;
MapEditor* mpMapEditor;
// Panels

@ -16,7 +16,7 @@ namespace lunarium
namespace editor
{
AboutPanel::AboutPanel()
: Panel("About", gui::PanelDockZone::DDZ_NONE)
: Panel("About", PanelDockZone::DDZ_NONE)
{
}

@ -16,7 +16,7 @@ namespace lunarium
namespace editor
{
class Editor;
class AboutPanel : public gui::Panel
class AboutPanel : public Panel
{
public:
AboutPanel();

@ -23,7 +23,7 @@ namespace lunarium
namespace editor
{
AssetBrowser::AssetBrowser(std::filesystem::path dir, Editor* pEditor)
: Panel("Asset Browser", gui::PanelDockZone::DDZ_BOTTOM, true),
: Panel("Asset Browser", PanelDockZone::DDZ_BOTTOM, true),
mAssetDirectory(dir), mpEditor(pEditor), mNewFolder(false), mSyncTree(false)
{
}

@ -19,7 +19,7 @@ namespace lunarium
{
namespace editor
{
class AssetBrowser : public gui::Panel
class AssetBrowser : public Panel
{
public:
AssetBrowser(std::filesystem::path dir, Editor* pEditor);

@ -17,7 +17,7 @@
namespace lunarium { namespace editor
{
PropertiesView::PropertiesView()
: Panel("Properties", gui::PanelDockZone::DDZ_RIGHT, true), mpSelectedAsset(nullptr), mpSelectedEntity(nullptr)
: Panel("Properties", PanelDockZone::DDZ_RIGHT, true), mpSelectedAsset(nullptr), mpSelectedEntity(nullptr)
{
}

@ -20,7 +20,7 @@ namespace editor
{
class CustromProperty;
class EditorAsset;
class PropertiesView : public gui::Panel
class PropertiesView : public Panel
{
public:

@ -20,7 +20,7 @@ namespace lunarium
namespace editor
{
WorldTree::WorldTree()
: Panel("World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(new lunarium::World), mDoNewEntity(false)
: Panel("World Tree", PanelDockZone::DDZ_LEFT, true), mpWorld(new lunarium::World), mDoNewEntity(false)
{
}

@ -17,7 +17,7 @@ namespace lunarium
namespace editor
{
class WorldTree : public gui::Panel
class WorldTree : public Panel
{
public:
WorldTree();

@ -11,14 +11,14 @@
#include <world/world.h>
#include <dearimgui/imgui.h>
#include <editor/editor.h>
#include "../panel_manager.h"
#include <gui/panel_manager.h>
namespace lunarium
{
namespace editor
{
WorldView::WorldView()
: Panel("World View", gui::PanelDockZone::DDZ_CENTER ,true), mpWorld(nullptr)
: Panel("World View", PanelDockZone::DDZ_CENTER ,true), mpWorld(nullptr)
{
}

@ -19,7 +19,7 @@ namespace lunarium
namespace editor
{
class Editor;
class WorldView : public gui::Panel
class WorldView : public Panel
{
public:
WorldView();

@ -43,7 +43,7 @@ namespace lunarium { namespace editor
}
mpEditor = editor;
if (Failed(mPanelManager.Initialize(mpEditor, "Map Editor").LogIfFailed(mpEditor->GetLogCat(), "Map Editor - ")))
if (Failed(mPanelManager.Initialize("Map Editor").LogIfFailed(mpEditor->GetLogCat(), "Map Editor - ")))
{
return OpRes::Fail("Could not initialize the panel manager!");
}

@ -13,7 +13,7 @@
#include <map>
#include <string>
#include <utils/op_res.h>
#include "../../panel_manager.h"
#include <gui/panel_manager.h>
#include <editor/contents/definitions.h>
namespace lunarium {

@ -21,7 +21,7 @@
namespace lunarium { namespace editor
{
MapCanvas::MapCanvas(MapEditor* editor)
: Panel("Map Canvas", gui::PanelDockZone::DDZ_CENTER, true),
: Panel("Map Canvas", PanelDockZone::DDZ_CENTER, true),
mpMapEditor(editor), mpCanvasImage(nullptr), mMap(nullptr), mSelectedTile({-1, -1}), mFrameBuffer(-1), mMapSizeChanged(false),
mZoomFactor(1.0f), mScrollDragged(false), mCurrentRegion({0, 0}), mRegionString("")
{

@ -20,7 +20,7 @@ namespace lunarium { namespace editor
class MapEditor;
class TileMap;
class MapCanvas : public gui::Panel
class MapCanvas : public Panel
{
public:
MapCanvas(MapEditor* editor);

@ -20,7 +20,7 @@
namespace lunarium { namespace editor
{
TileSetView::TileSetView(MapEditor* editor)
: Panel("Tile Set View", gui::PanelDockZone::DDZ_RIGHT, true),
: Panel("Tile Set View", PanelDockZone::DDZ_RIGHT, true),
mpEditor(editor), mpSelectedTileSet(nullptr), mpViewImage(nullptr), mFrameBuffer(-1),
mViewOffset({0, 0}), mViewZoom(1.0f), mMouseDown(false)
{

@ -20,7 +20,7 @@ namespace lunarium { namespace editor
{
class MapEditor;
class TileSet;
class TileSetView : public gui::Panel
class TileSetView : public Panel
{
public:
TileSetView(MapEditor* editor);

@ -9,7 +9,7 @@ target_include_directories(testbed
PUBLIC ../../../external/glad/include
PUBLIC ../../../external/glfw/include
PUBLIC ../../../external/box2d/include
PUBLIC ../../../external/dearimgui
PUBLIC ../../../external
)
target_link_libraries(testbed box2d dearimgui)
Loading…
Cancel
Save