Editor Window
Categories:
The MainWindow class provides a complete graph editor out of the box. Downstream editors subclass it and override virtual hooks to add domain-specific behavior.
Out-of-the-Box Features
Every MainWindow instance includes:
- Multi-document tabs — Each graph opens in its own tab with dirty tracking (asterisk
*in tab title) and close-with-save prompts - File menu — New, Open, Save, Save As, Open Recent (tracks last 10 files)
- Edit menu — Undo/Redo (Ctrl+Z / Ctrl+Y), Cut/Copy/Paste
- Node palette — Searchable list of available nodes with drag-drop creation
- Inspector panel — Auto-generated property editor from node EditContext reflection
- Variable panel — Variable declarations, type selection, and default value editing (when enabled)
Virtual Hooks
MainWindow provides virtual methods for downstream customization:
File Menu Overrides
virtual void AddFileNewAction();
virtual void AddFileOpenAction();
virtual void AddFileSaveAction();
virtual void AddFileSaveAsAction();
Override these to replace per-file behavior with container-level behavior (e.g., the Dialogue Editor overrides these to save the entire database instead of individual graphs).
Lifecycle Hooks
| Hook | Called When |
|---|---|
OnEditorOpened() | A graph tab is opened |
OnEditorClosing() | A graph tab is being closed |
OnActiveGraphChanged() | The user switches between graph tabs |
OnNewGraphRequested(QString& outTitle) | Before a new graph tab is created. Return false to cancel. |
OnNodeDoubleClicked(BaseNode* node) | A node is double-clicked. Used to open sub-graph editors. |
Full-Window Page System
The page system lets you add non-graph pages alongside the graph editor in the same window:
AddFullWindowPage("Performers", m_performersWidget);
AddFullWindowPage("System", m_systemWidget);
SetGraphPageTitle("Sequences"); // Rename the default graph tab
SetActivePage(index); // Switch between pages
The base class creates a tab bar on the first call. When switching to a non-graph page, the graph canvas and all docks are hidden; the page widget fills the entire window. Dock layout is preserved between switches.
Examples in practice:
- Dialogue Editor: Sequences (graph) + Performers + System
- Unit Action Editor: Layers (graph) + Layer Details
Container Editor Pattern
For editors where multiple graphs live inside a single file (like dialogue sequences in a database, or state machine layers in a unit action asset), MainWindow provides in-memory graph operations:
Opening Sub-Graphs
OpenGraphFromAsset(GraphDocumentAsset& asset, const QString& title, AZ::SerializeContext* sc);
Deserializes a graph from an asset’s byte buffer and opens it as a new tab.
Capturing Sub-Graphs
CaptureGraphToAsset(GraphModel::GraphId graphId, GraphDocumentAsset& outAsset, AZ::SerializeContext* sc);
Serializes an open graph back into the asset’s byte buffer. Used before saving the container.
Creating Empty Graphs
OpenNewGraphTab(const QString& title);
Opens a blank graph tab for a new sub-object.
Clearing Dirty State
ClearAllDocumentDirty();
Clears dirty markers on all open tabs. Called after a container-level save so that individual tab dirty states don’t linger.
Typical Container Save Flow
- Iterate all open graph tabs
- Call
CaptureGraphToAsset()for each to write graphs back to the container - Serialize the container to disk
- Call
ClearAllDocumentDirty()to clear all tab markers