![]() |
undoStudio
The IDE of the undoRT ecosystem
|
Manager class for Dear ImGui integration. More...
#include <ImGuiManager.hpp>

Classes | |
| struct | Panel |
| Panel structure. More... | |
Public Types | |
| using | PanelRenderFunc = std::function< void()> |
| Panel rendering function type. | |
Public Member Functions | |
| bool | initialize (void *window) |
| Initialize ImGui with the given window. | |
| void | shutdown () |
| Shutdown ImGui and release resources. | |
| void | newFrame () |
| Begin a new ImGui frame. | |
| void | render () |
| Render all registered panels. | |
| void | endFrame () |
| End the ImGui frame. | |
| void | reportDisplayIfChanged () |
| Write the display geometry to the log whenever it changes. | |
| void | addPanel (const std::string &name, PanelRenderFunc renderFunc) |
| Add a panel to the UI. | |
| void | removePanel (const std::string &name) |
| Remove a panel from the UI. | |
| void | showPanel (const std::string &name, bool show=true) |
| Show or hide a panel. | |
| bool | isPanelVisible (const std::string &name) const |
| Check if a panel is visible. | |
| void | setUndoRTTheme () |
| Set the UI theme to match undoRT website colors. | |
| void | setDarkTheme () |
| Set the UI theme to dark mode. | |
| void | setLightTheme () |
| Set the UI theme to light mode. | |
| void | setCustomTheme (const std::string &themePath) |
| Load a custom theme from file. | |
| bool | loadFont (const std::string &path, float size, const std::string &name="default") |
| Load a font for the UI. | |
| void | enableDocking (bool enable=true) |
| Enable or disable window docking. | |
| void | resetLayout () |
| Reset the docking layout to default. | |
| void | saveLayout (const std::string &filename="undoStudio_layout.ini") |
| Save the current layout to file. | |
| void | loadLayout (const std::string &filename="undoStudio_layout.ini") |
| Load a layout from file. | |
| void | openRecentProjects () |
| Ask for the recent projects list to be shown on the next frame. | |
| void | renderRecentProjects () |
| Draw the recent projects list, and set a request when one is picked. | |
| void | openRecentFiles () |
| Ask for the recent files list to be shown on the next frame. | |
| void | renderRecentFiles () |
| Draw the recent files list, and ask for the picked one to be opened. | |
| const std::string * | consumeOpenProjectRequest (std::string &projectPath) |
| Take the project a menu asked to open, if one was asked for. | |
| void | requestOpenProject (const std::string &projectPath) |
| Ask for a project to be opened. | |
| void | requestOpenFile (const std::string &filePath) |
| Ask for a file to be opened in the editor. | |
| const std::string * | consumeOpenFileRequest (std::string &filePath) |
| Take the next file that was asked to be opened. | |
| void | adoptShippedLayout () |
| Copy the layout shipped in resources/ into place when there is none. | |
| ImGuiIO & | getIO () |
| Get the ImGui IO structure. | |
Static Public Member Functions | |
| static ImGuiManager & | getInstance () |
| Get the singleton instance. | |
Static Public Attributes | |
| static constexpr const char * | kRecentProjectsPopup = "##recentProjects" |
| Name of the recent projects popup, shared by the ask and the draw. | |
| static constexpr const char * | kRecentFilesPopup = "##recentFiles" |
| Name of the recent files popup, shared by the ask and the draw. | |
Private Member Functions | |
| ImGuiManager ()=default | |
| ~ImGuiManager ()=default | |
| ImGuiManager (const ImGuiManager &)=delete | |
| ImGuiManager & | operator= (const ImGuiManager &)=delete |
| void | renderDockingLayout () |
| Render the docking layout. | |
| void | renderMenuBar () |
| Render the main menu bar. | |
| void | createDefaultLayout () |
| Create the default docking layout. | |
| ImTextureID | loadImageTexture (const std::string &path) |
| Load an image as an OpenGL texture for ImGui. | |
Private Attributes | |
| std::vector< Panel > | m_panels |
| bool | m_dockingEnabled = true |
| bool | m_layoutInitialized = false |
| bool | m_layoutResetRequested = false |
| ImGuiID | m_dockspaceID = 0 |
| std::string | m_iniFilename = "undoStudio_layout.ini" |
| Persistent storage for ImGuiIO::IniFilename. | |
| ImTextureID | m_logoTexture = 0 |
| bool | m_showAboutPopup = false |
| True once Help > About undoStudio was asked for. | |
| bool | m_showRecentsPopup = false |
| True while the recent projects list is open. | |
| std::string | m_pendingOpenProject |
| bool | m_showRecentFilesPopup = false |
| True while the recent files list is open, and cleared with it. | |
| std::deque< std::string > | m_pendingOpenFiles |
| Files asked to be opened, oldest first, by the command line or by a drop. | |
| std::string | m_lastDisplayReport |
| The last display geometry written to the log, so only a change is written. | |
Manager class for Dear ImGui integration.
ImGuiManager provides a high-level interface for managing the ImGui-based user interface. It handles panel registration, docking, theming, and font management.
| using undoStudio::ui::ImGuiManager::PanelRenderFunc = std::function<void()> |
Panel rendering function type.
This function type defines the signature for panel rendering functions. Each panel provides its own rendering logic.
|
privatedefault |
|
privatedefault |
|
privatedelete |
| void undoStudio::ui::ImGuiManager::addPanel | ( | const std::string & | name, |
| PanelRenderFunc | renderFunc | ||
| ) |
Add a panel to the UI.
| name | Unique panel name |
| renderFunc | Function that renders the panel content |
| void undoStudio::ui::ImGuiManager::adoptShippedLayout | ( | ) |
Copy the layout shipped in resources/ into place when there is none.
Copy the layout shipped with the project into place, if there is none yet.
A fresh install opens on the arrangement the project ships rather than on the one createDefaultLayout() builds, so the two cannot drift apart.
The arrangement the project opens with is a file in resources/, not a builder call: it is the one the dock layout is saved from, so what a new user gets is what the project settled on rather than a second description of it that can drift away from the first.
| const std::string * undoStudio::ui::ImGuiManager::consumeOpenFileRequest | ( | std::string & | filePath | ) |
Take the next file that was asked to be opened.
| filePath | Set to the path, valid until the next call |
| const std::string * undoStudio::ui::ImGuiManager::consumeOpenProjectRequest | ( | std::string & | projectPath | ) |
Take the project a menu asked to open, if one was asked for.
The menu bar is the core and the workspace that opens a project belongs to an undoApp, so the request crosses as a flag rather than as a call: one click leaves it, and the undoApp that owns the tree takes it on its next frame. The same shape the add-METHOD dialog uses.
| projectPath | Set when a project is wanted |
|
private |
Create the default docking layout.
| void undoStudio::ui::ImGuiManager::enableDocking | ( | bool | enable = true | ) |
Enable or disable window docking.
| enable | true to enable docking, false to disable |
| void undoStudio::ui::ImGuiManager::endFrame | ( | ) |
End the ImGui frame.
This method finalizes the frame and renders the ImGui draw data.
|
static |
Get the singleton instance.
| ImGuiIO & undoStudio::ui::ImGuiManager::getIO | ( | ) |
Get the ImGui IO structure.
| bool undoStudio::ui::ImGuiManager::initialize | ( | void * | window | ) |
Initialize ImGui with the given window.
| window | Native window handle |
| bool undoStudio::ui::ImGuiManager::isPanelVisible | ( | const std::string & | name | ) | const |
Check if a panel is visible.
| name | Name of the panel |
| bool undoStudio::ui::ImGuiManager::loadFont | ( | const std::string & | path, |
| float | size, | ||
| const std::string & | name = "default" |
||
| ) |
Load a font for the UI.
| path | Path to the font file (.ttf) |
| size | Font size in pixels |
| name | Optional name for the font |
|
private |
Load an image as an OpenGL texture for ImGui.
| path | Path to the image file (PNG recommended) |
| void undoStudio::ui::ImGuiManager::loadLayout | ( | const std::string & | filename = "undoStudio_layout.ini" | ) |
Load a layout from file.
| filename | Path to the layout file |
| void undoStudio::ui::ImGuiManager::newFrame | ( | ) |
Begin a new ImGui frame.
This method should be called at the beginning of each frame before any UI rendering.
| void undoStudio::ui::ImGuiManager::openRecentFiles | ( | ) |
Ask for the recent files list to be shown on the next frame.
| void undoStudio::ui::ImGuiManager::openRecentProjects | ( | ) |
Ask for the recent projects list to be shown on the next frame.
|
privatedelete |
| void undoStudio::ui::ImGuiManager::removePanel | ( | const std::string & | name | ) |
Remove a panel from the UI.
| name | Name of the panel to remove |
| void undoStudio::ui::ImGuiManager::render | ( | ) |
Render all registered panels.
This method renders all panels that have been registered with the manager.
|
private |
Render the docking layout.
This method renders the main docking space and manages the layout of docked panels.
|
private |
Render the main menu bar.
| void undoStudio::ui::ImGuiManager::renderRecentFiles | ( | ) |
Draw the recent files list, and ask for the picked one to be opened.
The pick goes through requestOpenFile rather than opening anything here, for the same reason the project list does not open a project: the editor that shows a file belongs to an undoApp, and the core asks rather than calls.
| void undoStudio::ui::ImGuiManager::renderRecentProjects | ( | ) |
Draw the recent projects list, and set a request when one is picked.
| void undoStudio::ui::ImGuiManager::reportDisplayIfChanged | ( | ) |
Write the display geometry to the log whenever it changes.
One line for the window, one per monitor and one per platform viewport, and nothing at all while none of them moves. A popup is a platform viewport of its own, and a mixed-DPI setup is invisible from here: the numbers that decide whether a popup is drawn once or redrawn every frame are the scale of the monitor the window is on and the scale ImGui gives the viewport, and both are only visible at run time.
A viewport that is created and destroyed every frame is what a log full of lines means, so the identifier is in the report: the same popup appearing under a new id on the next line is a popup being rebuilt, and one line per frame is the reading to take from it.
| void undoStudio::ui::ImGuiManager::requestOpenFile | ( | const std::string & | filePath | ) |
Ask for a file to be opened in the editor.
Where a path handed to the IDE on the command line, or dropped onto the window, is left until an undoApp takes it. Both of those arrive here and both are the core, while the editor that opens them belongs to an undoApp, so the request crosses the same way the recent-projects one does.
A file handed over while another is already open replaces it, which is what opening a file means everywhere else; the queue below holds one because a drop can carry several and they are opened in the order they were given, leaving the last one as the one on screen.
| filePath | The file to open, as the user wrote it |
| void undoStudio::ui::ImGuiManager::requestOpenProject | ( | const std::string & | projectPath | ) |
Ask for a project to be opened.
The counterpart of requestOpenFile, and the same crossing: the recent list and the keyboard shortcut already reach the Workspace this way, and a project named on the command line or dropped as a folder belongs with them.
| projectPath | The project directory, or its .undoProject folder |
| void undoStudio::ui::ImGuiManager::resetLayout | ( | ) |
Reset the docking layout to default.
| void undoStudio::ui::ImGuiManager::saveLayout | ( | const std::string & | filename = "undoStudio_layout.ini" | ) |
Save the current layout to file.
| filename | Path to the layout file |
| void undoStudio::ui::ImGuiManager::setCustomTheme | ( | const std::string & | themePath | ) |
Load a custom theme from file.
| themePath | Path to the theme file |
| void undoStudio::ui::ImGuiManager::setDarkTheme | ( | ) |
Set the UI theme to dark mode.
| void undoStudio::ui::ImGuiManager::setLightTheme | ( | ) |
Set the UI theme to light mode.
| void undoStudio::ui::ImGuiManager::setUndoRTTheme | ( | ) |
Set the UI theme to match undoRT website colors.
| void undoStudio::ui::ImGuiManager::showPanel | ( | const std::string & | name, |
| bool | show = true |
||
| ) |
Show or hide a panel.
| name | Name of the panel |
| show | true to show, false to hide |
| void undoStudio::ui::ImGuiManager::shutdown | ( | ) |
Shutdown ImGui and release resources.
|
staticconstexpr |
Name of the recent files popup, shared by the ask and the draw.
|
staticconstexpr |
Name of the recent projects popup, shared by the ask and the draw.
|
private |
|
private |
|
private |
Persistent storage for ImGuiIO::IniFilename.
|
private |
The last display geometry written to the log, so only a change is written.
|
private |
|
private |
|
private |
|
private |
|
private |
Files asked to be opened, oldest first, by the command line or by a drop.
|
private |
Set by the menu, taken by the undoApp
|
private |
True once Help > About undoStudio was asked for.
|
private |
True while the recent files list is open, and cleared with it.
|
private |
True while the recent projects list is open.