Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Olympe::TabManager Class Reference

Singleton that owns and manages all open graph editor tabs. More...

#include <TabManager.h>

Public Member Functions

 ~TabManager ()
 
std::string CreateNewTab (const std::string &graphType)
 Creates a new empty tab of the given graph type.
 
std::string OpenFileInTab (const std::string &filePath)
 Opens a file in a new tab.
 
void SetActiveTab (const std::string &tabID)
 
std::string GetActiveTabID () const
 
EditorTabGetActiveTab ()
 
EditorTabGetTab (const std::string &tabID)
 
const std::vector< EditorTab > & GetAllTabs () const
 
bool CloseTab (const std::string &tabID)
 Closes the given tab.
 
bool CloseAllTabs ()
 Attempts to close all tabs.
 
bool SaveActiveTab ()
 Saves the active tab.
 
bool SaveActiveTabAs (const std::string &path)
 Saves the active tab to a specific path.
 
void RenderTabBar ()
 Renders the horizontal tab bar (call before RenderActiveCanvas).
 
void RenderActiveCanvas ()
 Renders the graph canvas of the active tab.
 
bool HasDirtyTabs () const
 Returns true when at least one tab has unsaved changes.
 
bool IsEmpty () const
 Returns true when there are no open tabs.
 

Static Public Member Functions

static TabManagerGet ()
 Returns the global singleton instance.
 

Private Member Functions

 TabManager ()
 
 TabManager (const TabManager &)
 
TabManageroperator= (const TabManager &)
 
int ShowUnsavedDialog (const EditorTab &tab)
 Shows a 3-button "Save / Don't Save / Cancel" modal dialog.
 
bool ShowSaveAsDialog (EditorTab *tab)
 Shows the "Save As" input dialog for a tab without a path.
 
std::string NextTabID ()
 Generates the next unique tabID.
 
void DestroyTab (size_t index)
 Deletes a renderer and removes its tab entry.
 

Static Private Member Functions

static std::string DetectGraphType (const std::string &filePath)
 Detects the graph type by inspecting the JSON contents.
 
static std::string DisplayNameFromPath (const std::string &filePath)
 Derives a display name from a file path (filename without dir).
 

Private Attributes

std::vector< EditorTabm_tabs
 
std::string m_activeTabID
 
int m_nextTabNum
 Counter for "Untitled-N" names.
 
int m_nextTabIDNum
 Counter for unique tab IDs.
 
std::string m_pendingSelectTabID
 
std::string m_pendingCloseTabID
 
bool m_showSaveAsDialog
 
char m_saveAsBuffer [512]
 
std::string m_saveAsTabID
 

Detailed Description

Singleton that owns and manages all open graph editor tabs.

Definition at line 64 of file TabManager.h.

Constructor & Destructor Documentation

◆ ~TabManager()

Olympe::TabManager::~TabManager ( )

Definition at line 48 of file TabManager.cpp.

References GetComponentTypeID_Static(), and m_tabs.

+ Here is the call graph for this function:

◆ TabManager() [1/2]

Olympe::TabManager::TabManager ( )
private

Definition at line 40 of file TabManager.cpp.

References m_saveAsBuffer.

◆ TabManager() [2/2]

Olympe::TabManager::TabManager ( const TabManager )
private

Member Function Documentation

◆ CloseAllTabs()

bool Olympe::TabManager::CloseAllTabs ( )

Attempts to close all tabs.

Returns
false if the user cancelled at any point.

Definition at line 421 of file TabManager.cpp.

References DestroyTab(), GetComponentTypeID_Static(), m_tabs, renderer, SaveActiveTabAs(), SetActiveTab(), and ShowUnsavedDialog().

Referenced by Olympe::BlueprintEditorGUI::HandleKeyboardShortcuts(), and Olympe::BlueprintEditorGUI::Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CloseTab()

bool Olympe::TabManager::CloseTab ( const std::string &  tabID)

Closes the given tab.

Shows an "unsaved changes" dialog when the tab is dirty.

Returns
false if the user chose Cancel.

Definition at line 395 of file TabManager.cpp.

References DestroyTab(), GetComponentTypeID_Static(), m_pendingCloseTabID, m_tabs, and renderer.

Referenced by Olympe::BlueprintEditorGUI::HandleKeyboardShortcuts(), and Olympe::BlueprintEditorGUI::Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateNewTab()

std::string Olympe::TabManager::CreateNewTab ( const std::string &  graphType)

Creates a new empty tab of the given graph type.

Parameters
graphType"VisualScript" or "BehaviorTree".
Returns
The new tab's tabID, or empty string on failure.

Definition at line 148 of file TabManager.cpp.

References GetComponentTypeID_Static(), Olympe::NodeGraphPanel::Initialize(), Olympe::PrefabCanvas::Initialize(), m_nextTabNum, m_tabs, NextTabID(), SetActiveTab(), and Olympe::EditorTab::tabID.

Referenced by Olympe::BlueprintEditorGUI::HandleKeyboardShortcuts(), Olympe::BlueprintEditorGUI::NewVisualScriptGraph(), Olympe::BlueprintEditorGUI::Render(), and RenderTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DestroyTab()

void Olympe::TabManager::DestroyTab ( size_t  index)
private

Deletes a renderer and removes its tab entry.

Definition at line 369 of file TabManager.cpp.

References GetComponentTypeID_Static(), m_activeTabID, m_tabs, and Olympe::EditorTab::tabID.

Referenced by CloseAllTabs(), CloseTab(), and RenderTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DetectGraphType()

std::string Olympe::TabManager::DetectGraphType ( const std::string &  filePath)
staticprivate

Detects the graph type by inspecting the JSON contents.

Returns
"VisualScript", "BehaviorTree", or "Unknown".

Definition at line 85 of file TabManager.cpp.

References GetComponentTypeID_Static().

Referenced by OpenFileInTab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DisplayNameFromPath()

std::string Olympe::TabManager::DisplayNameFromPath ( const std::string &  filePath)
staticprivate

Derives a display name from a file path (filename without dir).

Definition at line 69 of file TabManager.cpp.

References GetComponentTypeID_Static().

Referenced by OpenFileInTab(), RenderTabBar(), SaveActiveTab(), and SaveActiveTabAs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get()

TabManager & Olympe::TabManager::Get ( )
static

◆ GetActiveTab()

EditorTab * Olympe::TabManager::GetActiveTab ( )

Definition at line 345 of file TabManager.cpp.

References GetComponentTypeID_Static(), m_activeTabID, and m_tabs.

Referenced by RenderActiveCanvas(), SaveActiveTab(), SaveActiveTabAs(), and SetActiveTab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActiveTabID()

std::string Olympe::TabManager::GetActiveTabID ( ) const

Definition at line 340 of file TabManager.cpp.

References m_activeTabID.

◆ GetAllTabs()

const std::vector< EditorTab > & Olympe::TabManager::GetAllTabs ( ) const
inline

Definition at line 100 of file TabManager.h.

References m_tabs.

◆ GetTab()

EditorTab * Olympe::TabManager::GetTab ( const std::string &  tabID)

Definition at line 355 of file TabManager.cpp.

References GetComponentTypeID_Static(), and m_tabs.

Referenced by RenderTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasDirtyTabs()

bool Olympe::TabManager::HasDirtyTabs ( ) const

Returns true when at least one tab has unsaved changes.

Definition at line 515 of file TabManager.cpp.

References GetComponentTypeID_Static(), m_tabs, and renderer.

+ Here is the call graph for this function:

◆ IsEmpty()

bool Olympe::TabManager::IsEmpty ( ) const
inline

Returns true when there are no open tabs.

Definition at line 150 of file TabManager.h.

References m_tabs.

Referenced by Olympe::BlueprintEditorGUI::Render().

+ Here is the caller graph for this function:

◆ NextTabID()

std::string Olympe::TabManager::NextTabID ( )
private

Generates the next unique tabID.

Definition at line 62 of file TabManager.cpp.

References GetComponentTypeID_Static(), and m_nextTabIDNum.

Referenced by CreateNewTab(), and OpenFileInTab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenFileInTab()

std::string Olympe::TabManager::OpenFileInTab ( const std::string &  filePath)

Opens a file in a new tab.

If the file is already open, activates that tab instead.

Parameters
filePathFull path to the .ats / .json file.
Returns
The tab's tabID, or empty string on failure.

Definition at line 207 of file TabManager.cpp.

References DetectGraphType(), DisplayNameFromPath(), GetComponentTypeID_Static(), Olympe::NodeGraphPanel::Initialize(), Olympe::PrefabCanvas::Initialize(), m_tabs, NextTabID(), SetActiveTab(), and Olympe::EditorTab::tabID.

Referenced by Olympe::BlueprintEditorGUI::LoadBlueprint(), Olympe::VisualScriptEditorPanel::OnNodeDoubleClicked(), and Olympe::BlueprintEditor::OpenGraphInEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

TabManager & Olympe::TabManager::operator= ( const TabManager )
private

◆ RenderActiveCanvas()

void Olympe::TabManager::RenderActiveCanvas ( )

Renders the graph canvas of the active tab.

Definition at line 683 of file TabManager.cpp.

References GetActiveTab(), and GetComponentTypeID_Static().

Referenced by Olympe::BlueprintEditorGUI::RenderFixedLayout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RenderTabBar()

void Olympe::TabManager::RenderTabBar ( )

Renders the horizontal tab bar (call before RenderActiveCanvas).

Definition at line 531 of file TabManager.cpp.

References CreateNewTab(), DestroyTab(), DisplayNameFromPath(), GetComponentTypeID_Static(), GetTab(), Olympe::EditorTab::isDirty, m_activeTabID, m_pendingCloseTabID, m_pendingSelectTabID, m_tabs, SaveActiveTab(), and SetActiveTab().

Referenced by Olympe::BlueprintEditorGUI::RenderFixedLayout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveActiveTab()

bool Olympe::TabManager::SaveActiveTab ( )

Saves the active tab.

Opens "Save As" if no path is set.

Definition at line 453 of file TabManager.cpp.

References DisplayNameFromPath(), GetActiveTab(), GetComponentTypeID_Static(), m_saveAsBuffer, m_saveAsTabID, and m_showSaveAsDialog.

Referenced by Olympe::BlueprintEditorGUI::HandleKeyboardShortcuts(), Olympe::BlueprintEditorGUI::Render(), and RenderTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveActiveTabAs()

bool Olympe::TabManager::SaveActiveTabAs ( const std::string &  path)

Saves the active tab to a specific path.

Returns
true on success.

Definition at line 485 of file TabManager.cpp.

References DisplayNameFromPath(), GetActiveTab(), GetComponentTypeID_Static(), m_saveAsBuffer, m_saveAsTabID, and m_showSaveAsDialog.

Referenced by CloseAllTabs(), Olympe::BlueprintEditorGUI::HandleKeyboardShortcuts(), and Olympe::BlueprintEditorGUI::Render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetActiveTab()

void Olympe::TabManager::SetActiveTab ( const std::string &  tabID)

Definition at line 313 of file TabManager.cpp.

References GetActiveTab(), GetComponentTypeID_Static(), m_activeTabID, m_pendingSelectTabID, and m_tabs.

Referenced by CloseAllTabs(), CreateNewTab(), OpenFileInTab(), and RenderTabBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShowSaveAsDialog()

bool Olympe::TabManager::ShowSaveAsDialog ( EditorTab tab)
private

Shows the "Save As" input dialog for a tab without a path.

◆ ShowUnsavedDialog()

int Olympe::TabManager::ShowUnsavedDialog ( const EditorTab tab)
private

Shows a 3-button "Save / Don't Save / Cancel" modal dialog.

Parameters
tabTab whose unsaved state is being queried.
Returns
1 = Save, 0 = Don't Save, -1 = Cancel.

Definition at line 698 of file TabManager.cpp.

References GetComponentTypeID_Static().

Referenced by CloseAllTabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_activeTabID

std::string Olympe::TabManager::m_activeTabID
private

Definition at line 189 of file TabManager.h.

Referenced by DestroyTab(), GetActiveTab(), GetActiveTabID(), RenderTabBar(), and SetActiveTab().

◆ m_nextTabIDNum

int Olympe::TabManager::m_nextTabIDNum
private

Counter for unique tab IDs.

Definition at line 191 of file TabManager.h.

Referenced by NextTabID().

◆ m_nextTabNum

int Olympe::TabManager::m_nextTabNum
private

Counter for "Untitled-N" names.

Definition at line 190 of file TabManager.h.

Referenced by CreateNewTab().

◆ m_pendingCloseTabID

std::string Olympe::TabManager::m_pendingCloseTabID
private

Definition at line 199 of file TabManager.h.

Referenced by CloseTab(), and RenderTabBar().

◆ m_pendingSelectTabID

std::string Olympe::TabManager::m_pendingSelectTabID
private

Definition at line 196 of file TabManager.h.

Referenced by RenderTabBar(), and SetActiveTab().

◆ m_saveAsBuffer

char Olympe::TabManager::m_saveAsBuffer[512]
private

Definition at line 203 of file TabManager.h.

Referenced by SaveActiveTab(), SaveActiveTabAs(), and TabManager().

◆ m_saveAsTabID

std::string Olympe::TabManager::m_saveAsTabID
private

Definition at line 204 of file TabManager.h.

Referenced by SaveActiveTab(), and SaveActiveTabAs().

◆ m_showSaveAsDialog

bool Olympe::TabManager::m_showSaveAsDialog
private

Definition at line 202 of file TabManager.h.

Referenced by SaveActiveTab(), and SaveActiveTabAs().

◆ m_tabs

std::vector<EditorTab> Olympe::TabManager::m_tabs
private

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