Skip to main content

EditorCreationController

EditorCreationController

Controller for unified editor creation and zone placement. More…

#include <EditorCreationController.hpp>

Inherits from QObject

Public Classes

Name
struct PlacedEditor
Result of creating and placing an editor.

Public Signals

Name
void editorPlaced(EditorLib::EditorInstanceId instance_id, EditorLib::EditorTypeId type_id)
Emitted when an editor is successfully created and placed.
void editorClosed(EditorLib::EditorInstanceId instance_id)
Emitted when an editor’s view dock is closed.

Public Functions

Name
EditorCreationController(EditorRegistry * registry, ZoneManager * zone_manager, ads::CDockManager * dock_manager, QObject * parent =[nullptr])
Construct an EditorCreationController.
~EditorCreationController() override =default
PlacedEditor createAndPlace(EditorLib::EditorTypeId const & type_id, bool raise_view =true)
Create an editor and place it in appropriate zones.
PlacedEditor createAndPlaceWithTitle(EditorLib::EditorTypeId const & type_id, QString const & view_title, bool raise_view =true)
Create an editor with a custom dock title.
int createdCount(EditorLib::EditorTypeId const & type_id) const
Get the number of editors created by this controller.
PlacedEditor placeExistingEditor(std::shared_ptr< EditorState > state, Zone view_zone, Zone properties_zone, QString const & view_title ={}, bool raise_view =false)
Create and place widgets for an already-registered EditorState.

Detailed Description

class EditorCreationController;

Controller for unified editor creation and zone placement.

EditorCreationController bridges EditorRegistry (which knows how to create editor components) with ZoneManager (which knows where to place them).

Zone Placement Logic

The controller reads EditorTypeInfo to determine:

  • preferred_zone: Where the view widget goes (typically Center)
  • properties_zone: Where the properties widget goes (typically Right)
  • properties_as_tab: Whether to add as tab (true) or replace content
  • auto_raise_properties: Whether to bring properties to front on creation

Ownership

  • The controller does NOT own the created widgets
  • Dock widgets are managed by the ADS dock manager
  • EditorState is registered with EditorRegistry
  • Callers can connect to dock widget signals for lifecycle events

Public Signals Documentation

signal editorPlaced

void editorPlaced(
    EditorLib::EditorInstanceId instance_id,
    EditorLib::EditorTypeId type_id
)

Emitted when an editor is successfully created and placed.

Parameters:

  • instance_id The instance ID of the created editor
  • type_id The type of the created editor

signal editorClosed

void editorClosed(
    EditorLib::EditorInstanceId instance_id
)

Emitted when an editor’s view dock is closed.

Parameters:

  • instance_id The instance ID of the closed editor

Public Functions Documentation

function EditorCreationController

explicit EditorCreationController(
    EditorRegistry * registry,
    ZoneManager * zone_manager,
    ads::CDockManager * dock_manager,
    QObject * parent =nullptr
)

Construct an EditorCreationController.

Parameters:

  • registry The EditorRegistry for type lookup and editor creation
  • zone_manager The ZoneManager for zone placement
  • dock_manager The ADS dock manager for creating dock widgets
  • parent Parent QObject (typically MainWindow)

function ~EditorCreationController

~EditorCreationController() override =default

function createAndPlace

PlacedEditor createAndPlace(
    EditorLib::EditorTypeId const & type_id,
    bool raise_view =true
)

Create an editor and place it in appropriate zones.

Parameters:

  • type_id The editor type to create
  • raise_view If true, make the view the active tab in its zone

Return: PlacedEditor containing the created components

This method:

  1. Creates the editor via EditorRegistry::createEditor()
  2. Wraps the view in a CDockWidget and adds to preferred_zone
  3. Wraps properties (if any) in a CDockWidget and adds to properties_zone
  4. Connects cleanup signals for state unregistration on close

The dock widget titles are derived from the editor’s display name. Properties dock titles are suffixed with ” Properties”.

function createAndPlaceWithTitle

PlacedEditor createAndPlaceWithTitle(
    EditorLib::EditorTypeId const & type_id,
    QString const & view_title,
    bool raise_view =true
)

Create an editor with a custom dock title.

Parameters:

  • type_id The editor type to create
  • view_title Custom title for the view dock widget
  • raise_view If true, make the view the active tab in its zone

Return: PlacedEditor containing the created components

Same as createAndPlace() but allows specifying custom titles for the dock widgets.

function createdCount

int createdCount(
    EditorLib::EditorTypeId const & type_id
) const

Get the number of editors created by this controller.

Useful for generating unique dock titles (e.g., “MediaWidget_1”).

function placeExistingEditor

PlacedEditor placeExistingEditor(
    std::shared_ptr< EditorState > state,
    Zone view_zone,
    Zone properties_zone,
    QString const & view_title ={},
    bool raise_view =false
)

Create and place widgets for an already-registered EditorState.

Parameters:

  • state An already-registered EditorState
  • view_zone Zone for the view widget
  • properties_zone Zone for the properties widget
  • view_title Custom title (empty → use display name from type info)
  • raise_view If true, make the view the active tab

Return: PlacedEditor containing the created dock widgets

Used during workspace restore: the state has been recreated via EditorRegistry::fromJson(), this method creates the view and properties widgets and places them in the requested zones.


Updated on 2026-11-13 at 20:25:40 +0000