The workspace UI¶
The Dear ImGui side of the editor (conjure::editor::ui, library conjure_editor_ui), drawn with the
widget kit: the layer that draws (conjure/editor/ui/editor_layer.h), the docking workspace with its
menus, dialogs and layout (conjure/editor/ui/editor_workspace.h), the start screen shown without a project
(conjure/editor/ui/start_screen.h), panels (conjure/editor/ui/editor_panel.h and conjure/editor/ui/panels/*.h),
the inspector's property drawers (conjure/editor/ui/property_drawer.h), the transform gizmo
(conjure/editor/ui/gizmo_controller.h), the hierarchy's row cache (conjure/editor/ui/hierarchy_cache.h) and the
frame scope the UI tests draw in (conjure/editor/ui/imgui_frame_scope.h). The UI is a client of the command model:
panels own only UI state and submit command_requests through the context's dispatcher, so every edit is validated,
undoable and announced like a protocol request. Selection, camera navigation, the gizmo operation and space, the
debug-draw toggles and the pins of play-mode persist are UI state the panels write directly; they are not commands.
| Name | The workspace UI |
| Module | Editor |
#include |
conjure/editor/ui/editor_icon.h, conjure/editor/ui/editor_layer.h, conjure/editor/ui/editor_panel.h, conjure/editor/ui/editor_workspace.h, conjure/editor/ui/gizmo_controller.h, conjure/editor/ui/hierarchy_cache.h, conjure/editor/ui/imgui_frame_scope.h, conjure/editor/ui/panels/*.h, conjure/editor/ui/panels/ai_session_panel.h, conjure/editor/ui/panels/asset_browser_panel.h, conjure/editor/ui/panels/console_panel.h, conjure/editor/ui/panels/export_dialog.h, conjure/editor/ui/panels/game_panel.h, conjure/editor/ui/panels/hierarchy_panel.h, conjure/editor/ui/panels/history_panel.h, conjure/editor/ui/panels/inspector_panel.h, conjure/editor/ui/panels/persist_panel.h, conjure/editor/ui/panels/profiler_panel.h, conjure/editor/ui/panels/project_settings_panel.h, conjure/editor/ui/panels/theme_editor_panel.h, conjure/editor/ui/panels/toolbar_panel.h, conjure/editor/ui/panels/viewport_panel.h, conjure/editor/ui/panels/widget_gallery_panel.h, conjure/editor/ui/property_drawer.h, conjure/editor/ui/start_screen.h, conjure/editor/ui/status_bar.h |
| Engineering Handbook | User Interface |
Syntax¶
Usage and complete examples are described in the reference sections below.
At a glance¶
| You want to... | Use |
|---|---|
| Put the editor UI on an application | create_editor_layer(context) as the layer_factory of editor_application::initialise |
| Add a panel from a module | a kit_panel_desc record that draws with the kit (The widget kit); the workspace lists it in the Window menu |
| Add a panel from C++ (the editor itself) | derive from editor_panel, register a panel_descriptor in the panel_registry |
| Put the panels back where they started | Window > Reset layout, the toolbar's Layout menu, editor_workspace::request_layout_reset(), or editor.layout.reset over the protocol |
| Open or create a project from the UI | the start screen, or File > Open project..., New project... and Recent projects (request_open_project, request_create_project) |
| Draw a field kind differently | property_drawer_registry::set(field_kind, drawer) |
| Keep a value tuned during play | its pin in the Inspector; the Persist panel lists the pins (Persist in the workspace) |
| Change the editor's look | Edit > Preferences > Themes... (Themes) |
| Draw panels in a test without the engine's ImGui layer | imgui_frame_scope around begin_frame()... end_frame() on the null device |
Variables and Properties¶
Types, fields, and state are described in the reference sections below.
The layer and the workspace¶
editor_layer is pushed after the engine's imgui_layer (which owns the one ImGuiContext): on_update
refreshes the panels' caches, on_imgui draws the workspace inside the frame the engine opened, on_event lets
ImGui consume input first. on_attach also gives the window the editor's icon through
conjure/editor/ui/editor_icon.h: editor_icon_images() decodes the official logo, compiled in as one PNG per
size from 16 to 256 px, and apply_editor_icon(window) hands it to window::set_icon (FEATURE_UNAVAILABLE on
macOS and Wayland, which is logged once at INFO and never fails the attach).
The layer owns the widget kit's context and a theme_applier, which shows the active theme
(Themes); each time it applies a theme it also sets the window's back-buffer clear to the theme's panel
colour. While attached, the layer is the context's editor_ui_host, so editor.layout.reset and
editor.theme.set from any client reach it
(User settings and the UI host). A project.open restarts
the engine, which brings a new ImGui context, a new layer and a new workspace.
editor_workspace is the full-window dockspace with a pass-through central node, the main menu bar, the toolbar
and the status bar, the start screen, the panel instances and the layout: create_default_panels(context),
sync_module_panels(context), update, draw, open_panel(name), show_panel(name), close_panel(name),
find_panel(name), open_panel_count() (open ones), instance_count(), menu_requests(). A loaded module's panels
follow the module: whenever a module loads, unloads or reloads, sync_module_panels removes every module panel's
descriptor and instance and makes them again from the loaded modules, so no panel draws through an unloaded
binary. A module panel keeps its open state for the module's next load and for the layout file.
Ctrl+Z, Ctrl+Y, Ctrl+S, F5 and Shift+F5 are handled by editor_workspace::draw, so they work whichever panels are
open. F5 plays the scene, or resumes a paused game, as Play > Play and the toolbar's Play do; Shift+F5 stops.
Ctrl+Z and Ctrl+Y do nothing while play freezes the undo stack. The shortcuts wait while one of the workspace's
dialogs is up, Save scene as included, and while the trust question is up: nothing changes the scene, saves it or
starts play behind a question that has not been answered.
File > Save scene and Ctrl+S call request_save_scene(context): scene.save when the scene has a path, otherwise
the Save scene as dialog, because a scene made with New scene has none yet. File > Save scene as... opens that
dialog directly (request_save_scene_as); its path is relative to assets:// and .scene.json is added, and its
Save button calls save_scene_as(context, path), which sends scene.save_as and keeps the error text on failure
(save_as_pending(), save_as_path(), save_as_error()). While playing or paused both menu items are disabled
and both requests do nothing: scene.save and scene.save_as are editing-state commands, because the scene then
holds the play session's state, which Stop discards.
The workspace also asks the one question the editor has about a project, in a dialog titled "Trust this project?".
It asks "Do you trust the authors of this project?", shows the folder an answer records, says that opening a
project runs its scripts and native modules with your rights, and says whether the answer is remembered or holds
until the editor exits. The dialog is up while editor_context::trust_prompt() names a project: when the editor was
started with --project on a project nobody answered for, or when a project.open for such a project was refused
(Project trust). It is drawn over the start screen or the panels, and over
any other dialog, which closes, so it is answered first.
- Trust and open calls
answer_trust_prompt(context, true): it sendsproject.trustand thenproject.open, the two requests a protocol client would send, and keeps the error text when the first fails (trust_prompt_error()). - Don't open, or Escape, calls
answer_trust_prompt(context, false): the dialog closes and nothing is recorded. - Enter presses neither: the answer lets the project's code run, so only a press of Trust and open trusts.
The dialog also closes by itself when a protocol client trusts the project meanwhile, or the project is opened.
The default layout and the menus¶
A project opened for the first time gets this layout, built with ImGui's DockBuilder:
menu bar File Edit Assets Entity Play Window Help
toolbar tools Pivot Snap|step Play Pause Step Stop Persist Layout
+---------------+----------------------------------+-------------------------------+
| Hierarchy | Scene | Game | Inspector | Project settings |
| 262 px wide | the central node | 340 px wide |
+---------------+----------------------------------+-------------------------------+
| Assets | Persist | Profiler | History | Console | AI session |
| 236 px tall; the two halves share the width 1.45 to 1 |
+----------------------------------------------------------------------------------+
status bar AI state scene pins AI port, clients build, GPU fps
- The first tab of each region is in front: Scene, Hierarchy, Inspector, Assets and Console.
- History, Profiler and AI session are closed by default and open in their region. Export, Themes and Widget gallery belong to no region and open floating, as do module panels.
- The sizes (
DEFAULT_LEFT_WIDTH,DEFAULT_RIGHT_WIDTH,DEFAULT_BOTTOM_HEIGHT,DEFAULT_BOTTOM_LEFT_SHARE) are for 100 % UI scale and grow with the kit's scale. In a small window a column never takes more than 40 % of the width, and the bottom row never more than 60 % of the height. - While the display is degenerate (the 1x1 of a window that has not reported its size) the layout waits
(
default_layout_pending()), and nothing is saved meanwhile.
Every panel window is identified by its registry name ("<title>###<name>" without the dock chrome), so a saved
layout survives a title change and two panels with the same title stay two windows; dockspace_id() is the
dockspace's ImGui id. Tabs have no close button: a right click on a tab opens its menu, with Close, Close others,
Undock and Reset layout, and the Window menu shows and hides panels too.
The layout lives in the project, in .conjure/editor_layout.ini (LAYOUT_FILE,
"project://.conjure/editor_layout.ini"), read and written through the project's file system, never by ImGui
itself. It holds ImGui's window and dock state and a section of the workspace's own, [ConjurePanels][Open], with
one name=0|1 line per panel, since ImGui's state does not say whether a window is open. The layer loads it when it
attaches (load_layout(context)). It is written atomically (save_layout(context)) when ImGui reports a change,
when the default is built and when the layer detaches, and only when its text changed. A missing file, or one
without the dockspace's dock state, gets the default layout; a file that cannot be read or written is one WARN,
never a failure.
Window > Reset layout, the toolbar's Layout menu, request_layout_reset() and editor.layout.reset rebuild the
default at the start of the next draw, before the dockspace is submitted: the default panels open, the others hide,
and the result is saved. Without a project there is no layout: the start screen is shown instead.
| Menu | Items |
|---|---|
| File | New project..., Open project..., Recent projects (the user's recent list, each with its folder), New scene, Open scene... (the scenes project.list_scenes finds), Save scene (Ctrl+S), Save scene as..., Save project, Export..., Quit |
| Edit | Undo (Ctrl+Z), Redo (Ctrl+Y), Create entity, Delete selection (Del), Preferences > Themes... (opens the Themes panel, Themes), Preferences > Code ligatures (editor.preferences.set {codeLigatures}, saved at once, Fonts and code ligatures) |
| Assets | Import... (asset.import), New folder... (asset.create_folder), New material... (asset.create_material) |
| Entity | Create empty, Create child (of the primary selection), Duplicate, Delete (Del), Focus (view.focus: the selection, or the whole scene when nothing is selected) |
| Play | Play (F5: starts the scene, or resumes a paused game), Pause, Resume, Step (one fixed update), Stop (Shift+F5) |
| Window | every registered panel with a check mark, built-in and module panels, then Reset layout |
| Help | About Conjure... (the version, the build configuration, the GPU and the AI protocol's port), then a line that names the AI protocol's port or says it is off |
An item that acts sends a command from the UI client. The Window menu, Export... and Edit > Preferences > Themes... only show and hide panels (UI state), and the other items whose label ends in "..." open a dialog first. A menu whose items are all disabled shows its title disabled: on the start screen that is true of Assets, Entity, Play and Window, while File, Edit and Help stay usable.
There is no native file dialog: the dialogs take a typed or pasted path and check it before anything is sent, so a
typo gets a sentence that says what to do (dialog_problem()). Open project takes the project's folder or its
project.json, with or without the quotes a file manager adds when it copies a path. New project takes a name,
which becomes the project's own folder, and the folder to create it in; a folder of that name may exist only when it
is empty. Import's Into names a folder under assets:// that the file is copied into under its own name.
Opening a project (request_open_project, request_create_project), opening a scene (request_open_scene, also a
scene the Assets panel opens), New scene (request_new_scene), Quit (request_quit) and closing the window (its
close button or Alt+F4: request_close, which the layer answers as the engine's layer::on_close_request) ask first
while the scene has unsaved changes. The Unsaved changes dialog offers Save, Discard and Cancel
(unsaved_prompt_pending(), resolve_unsaved_prompt(context, unsaved_choice)), and the window stays open meanwhile.
- Save while playing or paused stops play first (
play.stop, which keeps the pinned values), then saves. - Save on a scene that has no file yet goes through Save scene as, and the action follows that save; cancelling Save scene as drops the action.
- A save that fails keeps the dialog up with the reason.
- Nothing that replaces the scene is offered while playing or paused; Quit is.
Opening a project that nobody answered for meets the trust question instead of failing; see The start screen.
Note
A project.open that a protocol client sends does not ask about unsaved changes: it is the UI that asks before
it sends one.
The toolbar and the status bar¶
Two fixed bars frame the dockspace. They are not panels, so they cannot be closed, undocked or lost.
- The toolbar (
toolbar_panel,conjure/editor/ui/panels/toolbar_panel.h), under the menu bar, holds the gizmo's tools (Move, Rotate, Scale, All), Pivot (world or local axes), Snap and its step, the play controls (Play, Pause, Step, Stop), the Persist pill with the pin count and the pinned list, and Layout with Reset layout. - The status bar (
status_bar,conjure/editor/ui/status_bar.h), along the bottom, shows the AI state, the scene and its unsaved changes, the pins while playing, the AI port with its clients, the build, backend and GPU, and the frame rate.
Both are drawn with the widget kit. The status bar is drawn on the start screen too; the toolbar only while a project is open. Every control, segment and key is on 📘 The toolbar and the status bar.
The start screen¶
Without a project the workspace shows start_screen (conjure/editor/ui/start_screen.h) instead of the dockspace
and the panels, between the menu bar and the status bar.
- An editor started without
--projectshows it. - A windowed editor whose
--projectcould not be opened shows it instead of exiting with 2. Its Open problem then says why (editor_application::startup_problem()), until the next Open. - A windowed editor whose
--projectnobody answered for starts on it too, with the trust question over it (The startup order).
The screen is a column of kit widgets centred in the window: the version, Open (a folder), New (a name and the folder
to create it in), then the user's recent projects (editor_context::user_settings().recentProjects, kept in the user
configuration folder, not in a project), each with its folder, Open and Remove. A folder that no longer holds a
project.json is marked missing.
open_project(context, folder)andcreate_project(context, parentFolder, name)check what was typed as the File menu's dialogs do, then sendproject.open(andproject.createbefore it), and keep the sentence for the screen on failure (open_problem(),new_problem()).open_recent(context, index)opens a listed project (NOT_FOUND, withrecent_problem(), for a missing one);remove_recent(context, root)takes one off the list and out ofeditor_settings.jsonwith a read-modify-write, so other editors' changes stay.- The project opens at the end of the frame, when the engine restarts over it. The disk is read when the recent
list changes or on
refresh(), never every frame.
Edit > Preferences > Themes... works here too: themes belong to the user, not to a project.
Opening or creating a project, from the start screen or from the File menu, can meet the trust question:
project.open refuses a project nobody answered for with PROJECT_NOT_TRUSTED, and the window raises the question.
That is not a failure. No problem line appears, the Open project dialog closes, and Trust and open completes the
open. Where nobody can be asked (no window), the refusal stays as the problem line. A project created in a folder
that already existed (New accepts an empty one) is untrusted, so its open meets the question as well; a project
created in a new folder is trusted at once.
Panels¶
editor_panel is one ImGui window with an open flag, drawn every frame through a kit::panel_shell: the panel's
icon() and decorate() publish its tab's decoration (a badge, a status dot, the unsaved dot), and
draw_contents(context, shell) draws the body with the kit while it is visible; update(context) runs every frame,
open or not. The workspace gives every panel it creates its registry name (set_registry_name), which identifies
its window; a panel drawn on its own (a test) keeps its title. The built-in panels, in the Window menu's order:
| Panel (header) | Title | Shows and does |
|---|---|---|
viewport_panel (conjure/editor/ui/panels/viewport_panel.h) |
Scene | the scene through the editor camera, with picking, camera navigation, the gizmo and the editor's overlays (below) |
game_panel (conjure/editor/ui/panels/game_panel.h) |
Game | what the player sees, through the game camera; while playing it hands the mouse and the keyboard to the game (below) |
hierarchy_panel (conjure/editor/ui/panels/hierarchy_panel.h) |
Hierarchy | the scene tree from hierarchy_cache; click, Ctrl+click and Shift+click (range) selection; drag to reparent, or drop on the scene's row or below the rows to move to the root; inline rename with F2 or the context menu (begin_rename, is_renaming), committed by Enter or a click elsewhere and cancelled by Escape; a filter. A selection made elsewhere expands its ancestors and scrolls to its row. During play, the pin and change markers |
inspector_panel (conjure/editor/ui/panels/inspector_panel.h) |
Inspector | the entity block (enabled, name, layer; a prefab instance's root adds the prefab banner with Revert and Apply), then one component.get document per component of the primary selection, drawn through the property drawers; edits go back through component.set with one coalesce key per component, so a drag is one undo entry; Add component. During play, the pins and change dots |
project_settings_panel (conjure/editor/ui/panels/project_settings_panel.h) |
Project settings | the open project's project.json, each member edited through project.set_settings (below) |
asset_browser_panel (conjure/editor/ui/panels/asset_browser_panel.h) |
Assets | the database's assets as a table (path, type, status) with a filter and an import field; a double click opens a scene (as File > Open scene does) or instantiates a prefab, and a row's menu has Reimport, Open scene, Instantiate, Copy UUID and Delete. Deleting the file behind the open scene asks first: a "Delete open scene" dialog whose Close and delete closes the scene and deletes the file (request_delete, has_pending_delete, confirm_pending_delete, cancel_pending_delete). Close and delete is disabled while playing or paused, because asset.delete refuses to close the scene then; any other asset is deleted at once and comes back with undo |
persist_panel (conjure/editor/ui/panels/persist_panel.h) |
Persist | the pins of the play session, and after a stop what it kept and skipped (Persist in the workspace) |
console_panel (conjure/editor/ui/panels/console_panel.h) |
Console | the console_buffer ring with a level and a category filter, auto-scroll and clear; its tab counts the warnings and errors since the last clear |
history_panel (conjure/editor/ui/panels/history_panel.h) |
History | a Start row and the undo entries, oldest first, each with its label and who made it; a click steps the stack to that entry (history.undo or history.redo with a count); Clear. Closed by default |
profiler_panel (conjure/editor/ui/panels/profiler_panel.h) |
Profiler | the frame times from engine::frame_stats as a plot, the latest frame's phases, the world's entities and the frame memory's high water, and with a script runtime a Scripts section (the main thread's managed allocation, the heap size and the collections of the latest frame); Pause holds the plot. Closed by default |
ai_session_panel (conjure/editor/ui/panels/ai_session_panel.h) |
AI session | a request line sent through an in-process loopback client and the transcript of what was sent and what came back. When it connects, the transcript notes the paths of the token file, the inspect-only token file and the audit log as INFO lines (never a token), then the panel says session.hello, with the full-control token only when --ai-token or --ai-inspect-token set one. The footer shows the server's port, its agents and all its connections, whether a token is set, and the port file. Closed by default |
export_dialog (conjure/editor/ui/panels/export_dialog.h) |
Export | the output directory (a relative one is relative to the project root, as in the command), Export, a progress bar from the progress events and a status line (an export is always a Distribution export, so there is no configuration to pick). Closed by default |
theme_editor_panel (conjure/editor/ui/panels/theme_editor_panel.h) |
Themes | the themes, the active one and a working copy to edit, opened from Edit > Preferences > Themes... (Themes). Closed by default |
widget_gallery_panel (conjure/editor/ui/panels/widget_gallery_panel.h) |
Widget gallery | every widget of the kit in every state it derives, in the current theme, with a row that switches between the six built-in themes (show_theme(context, name), editor.theme.set). Closed by default |
#include "conjure/editor/kit/controls.h"
#include "conjure/editor/ui/editor_panel.h"
#include <format>
#include <string>
namespace kit = conjure::editor::kit;
class counter_panel final : public conjure::editor::ui::editor_panel {
public:
counter_panel() : editor_panel("Counter") {}
public:
void draw_contents(conjure::editor::editor_context &context, kit::panel_shell &shell) override {
CONJURE_UNUSED(shell);
const std::string count = std::format("{} entities", context.world().entity_count());
kit::label({.text = count});
if (kit::button("create", {.label = "Create one"})) {
conjure::editor::command_request request = {};
request.name = "entity.create";
request.args = conjure::core::json::object({{"name", "FromPanel"}});
CONJURE_UNUSED(context.dispatcher().execute(request)); // undoable like any other edit
}
}
};
Tip
A module's panel registers a kit_panel_desc record and draws with the kit in the shell it is handed, never with
the ImGui context. The older panel_desc, whose callback receives the raw ImGui context, still loads, but it is
drawn in a compatibility look and is deprecated (The widget kit).
The Scene, Game and Project settings panels¶
The default layout puts Scene and Game as tabs in the central node, and Project settings as a tab beside the Inspector; all three are open by default.
Pictures. The Scene and Game panels each draw a camera into a render target of their own, the size of their
picture, and show it with the kit. The Scene panel queues its view in update() every frame it is open, also while
its tab is behind another one; the Game panel queues while it draws, so only while it is visible. The editor camera
is therefore always the first view the renderer draws (after a view.screenshot's) and the game camera the second,
so the state the renderer keeps per view (auto-exposure history, among others) never passes from one camera to the
other when you switch tabs.
The Scene view keeps rendering behind a Game tab in front, so close the Scene panel when you measure the game's frame
time. Without a window there is no ImGui renderer: the views are still drawn when a renderer exists, and nothing is
shown (pictures_drawn() stays 0).
Scene panel (viewport_panel, registry name viewport). Under its options strip (2D, Orthographic, Shaded,
Grid, Bounds, Physics, Gizmos and Focus) it shows the scene through the editor camera. The Shaded menu, labelled
with the shading mode, picks Lit or Ambient occlusion (the ambient-occlusion term alone as grey, for tuning SSAO)
through view.set_debug_view, and the picture is drawn in that mode; its label takes the accent colour while the
mode is not Lit. The panel paints the theme's
viewport backdrop and the Grid first and draws the picture over them. The picture keeps the scene's coverage as
alpha (renderer::view_flags::KEEP_COVERAGE_ALPHA), so the backdrop and the Grid show only where the scene draws
nothing, and the scene covers the Grid. A view.screenshot of the "editor" camera keeps an opaque grey there
instead, so the screenshot and the panel differ where nothing drew. The 2D view mode keeps authored colours (no
post-processing).
The overlays stack in the options strip's order: the Grid under the scene, then over the picture the bounds, then the colliders over the bounds, so a collider as large as its entity's bounds still shows. The game camera's frame and the selection outline go over those. The overlays are the editor's own: no Game view, screenshot or exported game shows them.
The panel's input: orbit (right drag; in 2D it pans), pan (middle drag), zoom (wheel), Focus (F), picking (left
click, with Ctrl or Shift to add to the selection) and the gizmo, whose tools are the toolbar's (gizmo()). W, E and
R pick the gizmo's operation while the panel is focused or under the cursor, unless a text field has the keyboard
or a gizmo drag is open. Over a gizmo handle the left button is the gizmo's, while the wheel, F and a right or middle
drag still move the camera; a camera drag goes on from its press over the picture until its release, wherever the
cursor goes. When the panel is hidden in the middle of a gizmo drag, update() ends the drag and its undo
transaction. The picture, the pick ray and the gizmo use the same camera and rectangle, so what is clicked is what is
seen.
Game panel (game_panel, registry name game). It draws the camera the engine shows first, view.screenshot's
"game" (the camera engine::find_main_camera picks, as the runtime does: a main camera first, then the highest
priority), as the runtime presents it: with that camera's post-processing, its post_process overrides included,
and the debug lines the game draws. It has no gizmo, no picking and no editor
overlays. Where the game draws nothing it shows black, as a game window does; game pixels never take the theme's
colours. Playing or paused, the picture has the play border. Without a scene or an enabled camera the panel says why
on its own background (status(): game_view_status::NO_SCENE, NO_CAMERA or CAMERA).
While playing, the panel hands input to the game: the mouse while the cursor is over the picture (or a press that
began there is held), and the keyboard while the panel has focus. ImGui is told to leave those events to the engine
from the next frame on; routes_mouse_to_game() and routes_keyboard_to_game() report the last frame. The game
shares the editor's window, so a cursor mode it sets (hidden, captured or disabled) holds for the editor too. The
panel gives the cursor back (mode NORMAL) when play stops or pauses, and when the game stops getting the panel's
input (another panel takes the focus while the cursor is off the picture, or the panel is hidden), each time that
happens and not every frame.
Warning
Mouse positions reach the game in window coordinates, not relative to the Game panel: platform input knows nothing of where the panel sits in the editor window. Mouse positions a game reads in the editor therefore differ from the same game in the runtime unless the panel fills the window.
Project settings (project_settings_panel, registry name project_settings). The first section, Project, is
the project itself (its folder, name, version, engine version, startup scene, asset and cooked roots), under a note
that says when a change applies. Then comes one section per settings object of project.json (window, time,
physics, rendering, audio, assets, scripting, modules, extensions) and one for the scene's layer names.
- Rows read as people read them, in sentence words ("Max fixed steps per frame"). A unit symbol keeps its case:
time.fixed_hzreads "Fixed Hz", never "Fixed hz". - A label too long for its slot wraps between words onto lines of its own, and the row grows to fit it.
- A row's tooltip names its member in the file ("time.max_fixed_steps_per_frame in project.json").
Every edit is one project.set_settings request that merges the one member that changed, sent from the UI client:
the engine's own parser validates it, the file is saved, and Undo takes it back. Text and number fields send when the
edit is committed (Enter, the field losing focus, or the end of a number's drag), check boxes and choices at once; a
list of three numbers such as physics.gravity is a vector field whose components send on commit the same way. An
edit that leaves the value as it was sends nothing, and a refused value keeps the stored one and shows the error
under its row. The project folder, the schema and engine versions, the asset and cooked roots, cooked, every
nested object and every other list are shown read only. apply_setting(context, section, key, value) is what a
committed field calls.
The rendering section's Defaults are the exception, in a build with the renderer: one group per settings group
(Post process, Shadows, Ambient occlusion, Anti-aliasing) with a row for every field, whether the file has its key
or not, showing the value in effect. A row's tooltip names its key in the file and, while the file has no such key,
the engine default. Each edit sends one leaf of rendering.defaults (apply_render_default), which the renderer
checks and applies from the next frame, so the picture follows the edit and its undo. A row whose key is in the
file offers "Use engine default" on a right click over its value, which removes the key. FXAA subpixel shows only
while the post filter is FXAA or the file holds its key. Problems the editor found when it read the file's defaults
show under their row, their group or the Defaults header until the file is fixed. Each problem can be fixed on its
own while the others stay, because project.set_settings refuses an edit only for a problem the edit adds or
leaves in what it sets (Rendering settings).
The MSAA sample count is a choice of Off, 2x, 4x and 8x. The counts this machine's GPU cannot render are greyed and
cannot be picked; without a renderer only Off can be. While any count is greyed, the row's tooltip explains that
this machine cannot render it, and that project.json can still set it for GPUs that can. A count the file already
holds shows as the value even when it is greyed; the renderer then uses the largest supported count below it.
Property drawers, gizmo, hierarchy cache¶
property_drawer_registry maps every core::reflect::field_kind to a drawer that draws its value with the kit: the
inspector reads a component as JSON, hands each field to the drawer for its kind inside the property row the
registry opens for it, and writes the new value back through component.set when the drawer reports a change. The
constructor installs the built-in drawers; set(kind, drawer) replaces one, and an empty function restores the
built-in one.
The built-in drawers: a bool is a checkbox, an integer or a float a number field (dragged, or typed), a string a text field, a guid or an asset reference a field of its guid, an entity reference a field showing the entity's name, a vector a vector field with axis tags (a colour, by its name, a swatch), a rotation an angle field of its Euler angles in degrees, a matrix four rows of four numbers, a transform its position, rotation and scale on three lines, an enumeration an enum field (a flags enumeration a checkbox per flag), and anything else its value in short, read only. A nested struct, a list and a JSON object are groups of rows.
- Numbers are held to whichever of the field's
minandmaxattributes are set: a value typed or dragged outside them is clamped. Integers are edited in their own type's range. - A float field whose attributes carry a unit is shown as an angle: a
RADIANSfield in degrees (itsmin,maxand step converted with it), aDEGREESfield as stored. Both show the degree sign after the value (kit::ANGLE_UNIT, "90°"). The value is written back in the stored unit, and only when it was changed. - A rotation keeps the Euler angles it shows until the quaternion changes elsewhere, so an angle can be dragged past 90 degrees.
A float that is infinite or NaN ("inf", "-inf" and null in the component's JSON, see
Reflection) is shown as inf, -inf or nan, in a number field and in each component of
a vector, a matrix or a transform. It stays as it is while you edit the fields and components next to it, and a
number typed or dragged over it replaces it. The inspector never adds one: typing inf or nan into a field writes
nothing, so set an infinity with component.set and the string "inf". A colour with such a channel is edited as
numbers instead of a swatch until every channel is a number again, and a rotation with such a component shows nan
for its three angles; typing one angle repairs it, with the angles that are still not numbers taken as 0.
For tools of your own, draw_object(type, object, readOnly, section, walk) and draw_json(label, value, readOnly,
section, walk) draw a whole value into an open kit::property_section. The property_walk gives the base path and
pointer, and its property_marks ask the caller for each field's row marks (property_field { field, path, pointer,
container }) and report a pin press. The inspector's pins and change dots are drawn this way.
gizmo_controller drives ImGuizmo: the first manipulated frame opens an undo transaction and caches the selected
entities' world matrices, every frame with a delta dispatches component.set_many on the local transforms
(through the parents' inverse world matrices, pivoting at the centroid), the release ends the transaction. A
selected entity whose ancestor is also selected follows that ancestor instead of receiving the delta itself.
set_operation (translate, rotate, scale), set_space (world, local), set_snap(enabled, translate,
rotateDegrees, scale) (defaults 0.5, 15 and 0.1, off; the toolbar's Snap toggle and step field drive it,
snap_enabled() and the step getters read it back), is_over() (the mouse is over a handle of the gizmo the last
draw showed; false after a frame with nothing selected, so picking works again). end_drag closes the drag's undo
transaction; when the left button is still down (the Scene panel was hidden in the middle of the drag) the gizmo
stays hidden until the button is released, so that press cannot start a second drag.
hierarchy_cache is the hierarchy panel's flat row list. refresh_if_dirty(scene, selection, play) rebuilds the
rows, one pre-order walk, when the scene's structure, the expansion state, the filter or, given a play controller,
its marker_version() changed, and invalidate() forces the next rebuild. The expansion state (set_expanded(scene,
entity, expanded), is_expanded(scene, entity), reveal) is keyed by the entity's guid, so it survives play and
stop and never passes to an entity that reuses an index. set_filter is a name filter, and refresh_labels(scene,
selection, first, last) re-reads the names, enabled state and selection of rows already built, O(range) and without
a rebuild; the panel calls it for the visible rows. The rows are
hierarchy_row { entity, nameId, parent, children, pins, depth, flags }; in a play session the flags add PINNED,
PINNED_WHOLE, PINNED_WITH_CHILDREN and TOUCHED.
Persist in the workspace¶
While playing or paused the panels show and make the pins of play-mode persist: the values play.stop keeps instead
of discarding them. The commands are on The AI control protocol and the
C++ side on Headless mode and the command model. The panels pin and
unpin through play_controller directly, as the UI client (0): pins are UI state, like the selection, so drawing and
pinning never change the scene revision. The toolbar's Persist pill, the status bar and the Persist panel count the
same list; a row of the pill's pinned list selects its entity and brings the Inspector to the pin.
- Inspector. A pin on the Entity button, whose menu pins with the children, unpins the entity or unpins
everything on it; one on each component's header, beside a "changed in play" dot; and one on each field's row,
which also shows a change dot when play changed the value and the persisted mark when a pin keeps it. Of a script,
only its fields take a pin: the script entry's class and hash and its
startedandcreatedflags are not values, so they have no toggle. On an entity created during play any pin keeps the whole entity, and the entity block says so. - Changed in play. The dots compare the component with the scene of before play, for the selected entity only,
collapsed components included. A running script's
startedandcreatedflags, and the class defaults its edited form leaves out, do not count. - Hierarchy. A row shows the pins that name its entity ("entity" for an entity pinned whole, "2 pinned" for its values or components) and a change dot when an editor command changed the entity; their tooltips say what Stop keeps, or that Stop puts an unpinned edit back.
- Persist panel (
persist_panel,conjure/editor/ui/panels/persist_panel.h, open by default beside Assets). While playing or paused a tool row says what Stop does with the pins and offers Unpin all, and a table lists every pin in pin order. A row shows the entity, what the pin keeps in the inspector's names ("Transform > Position", "Sprite", "Whole entity"), the edit (the value when play started, an arrow and the value now), what Stop does otherwise than apply it (destroyed in play: skipped; created in play, or a component added in play: kept whole), who changed it last (the Inspector, a gizmo drag, the editor, an AI client or the game) and Unpin. A value is shown in short, never as JSON: an f32 in its shortest form,0.2rather than0.20000000298023224(value_summary). While editing the panel says how pins are made and shows what the last stop did: how many pins it applied, and a table of the skipped pins with their reasons, until the next play.
Testing the UI¶
imgui_frame_scope gives code without the engine's imgui_layer a frame to draw in: when a context exists it
only brackets begin_frame() / end_frame() on it, otherwise it creates one with a built font atlas and docking
enabled and destroys it later. set_mouse(position, leftDown) feeds input, and set_display_size(size) sets the
display size of the frames that follow (the 1x1 display of a window that has not reported its size, then a real
one). Nothing is rendered, so every panel can be drawn against the null device in a unit test.
Warning
ImGui has one context per process and the engine's imgui_layer owns it. Never call ImGui::CreateContext
or SetCurrentContext from a panel or a module; draw inside the frame the engine opened.
Functions¶
| Signature (short) | Purpose |
|---|---|
unique_ptr<engine::layer> create_editor_layer(editor_context &) |
the UI layer for editor_application::initialise |
result<std::vector<core::image>> editor_icon_images() / result<void> apply_editor_icon(platform::window &) |
the editor's window icon |
void editor_layer::request_layout_reset() / request_theme_refresh() / bool theme_refresh_pending() / theme_applier &themes() / editor_workspace *workspace() / bool on_close_request(engine::engine_context &) |
the UI host, its theme and workspace; a window close asks first |
class editor_panel { explicit editor_panel(std::string title, bool open = true); title(); is_open(); set_open(bool); draw(editor_context &); virtual draw_contents(editor_context &, kit::panel_shell &) } |
a panel |
void editor_panel::set_registry_name(string_view) / registry_name() / window_name() / static window_name_for(string_view title, string_view registryName) |
the panel's window identity |
void panel_registry::add(panel_descriptor) / add_module_panel(const module_panel_entry &) / bool remove(string_view) / usize remove_owned_by(string_view) / find(string_view) / descriptors() |
the panel list |
void editor_workspace::create_default_panels(editor_context &) / sync_module_panels / update / draw / bool open_panel(string_view) / show_panel / close_panel / find_panel |
the workspace |
result<void> editor_workspace::load_layout(editor_context &) / save_layout(editor_context &) / void set_layout_file(std::string) / request_layout_reset() / bool default_layout_pending() / static u32 dockspace_id() |
the layout and its file |
void editor_workspace::request_save_scene(editor_context &) / request_save_scene_as / bool save_scene_as(editor_context &, string_view) / save_as_pending() |
Save scene and Save scene as |
result<void> editor_workspace::request_open_project(editor_context &, string_view) / request_create_project(editor_context &, string_view, string_view) / request_open_scene / void request_new_scene / request_quit / bool request_close(editor_context &) / result<void> resolve_unsaved_prompt(editor_context &, unsaved_choice) |
switching projects and scenes, quitting |
bool editor_workspace::answer_trust_prompt(editor_context &, bool trust) / trust_prompt_error() |
the answer to the project trust question: Trust and open, or Don't open |
result<void> start_screen::open_project(editor_context &, string_view) / create_project(editor_context &, string_view, string_view) / open_recent(editor_context &, usize) / remove_recent(editor_context &, const path &) / void refresh(editor_context &) / entries() |
the start screen |
void property_drawer_registry::set(field_kind, draw_fn) / const draw_fn &drawer(field_kind) |
drawers per field kind |
bool property_drawer_registry::draw_object(const type_info &, json::document &, bool, kit::property_section &, const property_walk &) / draw_json(string_view, json::document &, bool, kit::property_section &, const property_walk &) |
a whole value with its paths, pointers and marks |
void gizmo_controller::apply_delta(editor_context &, const math::mat4 &) / end_drag / set_operation / set_space / set_snap / snap_enabled() / is_over() |
the gizmo |
gizmo_controller &viewport_panel::gizmo() / void pick_at(editor_context &, const math::vec2 &, bool) / pictures_drawn() / views_submitted() / is_shown() |
the Scene panel |
game_view_status game_panel::status() / pictures_drawn() / views_submitted() / routes_mouse_to_game() / routes_keyboard_to_game() |
the Game panel |
bool project_settings_panel::apply_setting(editor_context &, string_view section, string_view key, const json::document &) / last_error() |
Project settings |
bool project_settings_panel::apply_render_default(editor_context &, string_view group, string_view field, const json::document &value); DEFAULTS_KEY, ENGINE_DEFAULT_MENU_KEY, ENGINE_DEFAULT_ITEM |
one leaf of rendering.defaults (group its project key, field the reflected name, a null value for the engine default); the Defaults group's key, and the right-click menu's key and item |
static string persist_panel::value_summary(editor_context &, const persist_entry &, usize) / before_summary(...) / target_text(...) / rows_drawn() / skips_drawn() |
the Persist panel |
void inspector_panel::reveal_pin(const persist_entry &) / bool changed_in_play(string_view) |
the inspector's pins and markers |
bool hierarchy_cache::refresh_if_dirty(const scene::scene &, const selection_set &, const play_controller * = nullptr) / invalidate() / set_filter / set_expanded(const scene::scene &, entity, bool) / reveal / refresh_labels / rows() |
the hierarchy rows |
void hierarchy_panel::begin_rename(editor_context &, ecs::entity) / is_renaming() |
inline rename |
imgui_frame_scope::begin_frame() / end_frame() / set_mouse(const math::vec2 &, bool) / set_display_size(const math::vec2 &) |
a frame for tests |
See also:
- 📘 API: Headless mode and the command model, The AI control protocol
- 📘 API: The toolbar and the status bar, The widget kit, Themes, Fonts and code ligatures
- 📘 API: Rendering a frame (the ImGui backend), Writing a module
- 🛠Handbook: Editor Architecture
- 🛠Handbook: Branding and Application Icons