Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiEditor::EditorWindow Class Referenceabstract

Base class for standalone editor windows. More...

#include <EditorWindow.h>

Public Member Functions

virtual ~EditorWindow ()=default
virtual const char * GetTitle ()=0
 Get the window title.
virtual const char * GetMenuPath ()
 Get the menu path for the Tools menu.
virtual const char * GetShortcut ()
 Get optional keyboard shortcut.
virtual void OnOpen ()
 Called when the window is first opened.
virtual void OnClose ()
 Called when the window is closed.
virtual void OnGUI ()=0
 Called each frame to draw the window UI.
virtual void OnUpdate (float deltaTime)
 Called each frame for non-UI updates.
virtual bool CanOpenFile (const char *extension)
 Check if this window can open a file type.
virtual bool CanOpenAssetType (const char *assetType)
 Check if this window can open a .asset file by its type field.
virtual void OpenFile (const char *filePath, const char *cachePath)
 Open a file in this window.
virtual bool SaveSession (std::string &)
 Serialize window state to JSON.
virtual void RestoreSession (const std::string &)
 Rebuild state from SaveSession's JSON (after DLLs reloaded).
bool IsOpen () const
void SetOpen (bool open)

Protected Attributes

bool m_IsOpen = false

Detailed Description

Base class for standalone editor windows.

Replaces IEditorTool. Use EditorApplication::Get() for project info.

Usage:

class SpritesheetEditorWindow : public EditorWindow
{
public:
const char* GetTitle() override { return "Spritesheet Editor"; }
const char* GetMenuPath() override { return "2D/Spritesheet Editor"; }
void OnOpen() override
{
auto& app = EditorApplication::Get();
m_ProjectPath = app.GetProjectPath();
}
void OnGUI() override
{
ImGui::Begin(GetTitle(), &m_IsOpen);
// ... draw UI
ImGui::End();
}
};
REGISTER_EDITOR_WINDOW(SpritesheetEditorWindow, "Spritesheet Editor", "2D/Spritesheet Editor")
#define REGISTER_EDITOR_WINDOW(WindowClass, WindowTitle, MenuPath)
Register an editor window.
Definition EditorWindow.h:193
static EditorApplication & Get()
Get singleton instance.
Base class for standalone editor windows.
Definition EditorWindow.h:44
bool m_IsOpen
Definition EditorWindow.h:161
virtual const char * GetTitle()=0
Get the window title.
virtual const char * GetMenuPath()
Get the menu path for the Tools menu.
Definition EditorWindow.h:62
virtual void OnOpen()
Called when the window is first opened.
Definition EditorWindow.h:87
virtual void OnGUI()=0
Called each frame to draw the window UI.

Constructor & Destructor Documentation

◆ ~EditorWindow()

virtual DekiEditor::EditorWindow::~EditorWindow ( )
virtualdefault

Member Function Documentation

◆ GetTitle()

virtual const char * DekiEditor::EditorWindow::GetTitle ( )
pure virtual

Get the window title.

Returns
Human-readable window title

◆ GetMenuPath()

virtual const char * DekiEditor::EditorWindow::GetMenuPath ( )
inlinevirtual

Get the menu path for the Tools menu.

Returns
Menu path (e.g., "2D/Spritesheet Editor") or nullptr

◆ GetShortcut()

virtual const char * DekiEditor::EditorWindow::GetShortcut ( )
inlinevirtual

Get optional keyboard shortcut.

Returns
Shortcut string (e.g., "Ctrl+Shift+S") or nullptr

◆ OnOpen()

virtual void DekiEditor::EditorWindow::OnOpen ( )
inlinevirtual

Called when the window is first opened.

Use EditorApplication::Get() to access project paths:

void OnOpen() override
{
auto& app = EditorApplication::Get();
m_ProjectPath = app.GetProjectPath();
m_AssetsPath = app.GetAssetsPath();
}

◆ OnClose()

virtual void DekiEditor::EditorWindow::OnClose ( )
inlinevirtual

Called when the window is closed.

◆ OnGUI()

virtual void DekiEditor::EditorWindow::OnGUI ( )
pure virtual

Called each frame to draw the window UI.

Use ImGui directly. Call ImGui::Begin() with &m_IsOpen.

◆ OnUpdate()

virtual void DekiEditor::EditorWindow::OnUpdate ( float deltaTime)
inlinevirtual

Called each frame for non-UI updates.

Parameters
deltaTimeTime since last frame in seconds

◆ CanOpenFile()

virtual bool DekiEditor::EditorWindow::CanOpenFile ( const char * extension)
inlinevirtual

Check if this window can open a file type.

Parameters
extensionFile extension (e.g., ".png", ".anim")
Returns
True if window can handle this file type

◆ CanOpenAssetType()

virtual bool DekiEditor::EditorWindow::CanOpenAssetType ( const char * assetType)
inlinevirtual

Check if this window can open a .asset file by its type field.

Parameters
assetTypeThe "type" value from the .asset JSON (e.g., "iconexport")
Returns
True if window can handle this asset type

◆ OpenFile()

virtual void DekiEditor::EditorWindow::OpenFile ( const char * filePath,
const char * cachePath )
inlinevirtual

Open a file in this window.

Parameters
filePathFull path to the file
cachePathFull path to the cached file

◆ SaveSession()

virtual bool DekiEditor::EditorWindow::SaveSession ( std::string & )
inlinevirtual

Serialize window state to JSON.

Return false to skip persistence.

◆ RestoreSession()

virtual void DekiEditor::EditorWindow::RestoreSession ( const std::string & )
inlinevirtual

Rebuild state from SaveSession's JSON (after DLLs reloaded).

◆ IsOpen()

bool DekiEditor::EditorWindow::IsOpen ( ) const
inline

◆ SetOpen()

void DekiEditor::EditorWindow::SetOpen ( bool open)
inline

Member Data Documentation

◆ m_IsOpen

bool DekiEditor::EditorWindow::m_IsOpen = false
protected

The documentation for this class was generated from the following file: