Editor Toolbar
A thin chromeless MicroUI strip at the top of the viewport that acts as the visual control surface for SafiEditorState. Mode buttons on the left flip the engine between Play / Pause / Stop (Stop ≡ Edit mode); tool buttons on the right pick the manipulator the gizmo system draws for the currently selected entity.
The toolbar is drawn from inside safi_debug_ui_draw_panels when enable_debug_ui is set. Apps that roll their own top-of-frame chrome can skip the built-in call and use safi_editor_toolbar_draw directly.
Layout
The active button is darkened in-place — MicroUI has no toggle-button primitive, so the toolbar temporarily swaps MU_COLOR_BUTTON for the active entry.
API
Call between safi_debug_ui_begin_frame and safi_debug_ui_prepare. viewport_w is the logical (DPI-divided) width — the strip fills it edge-to-edge and is 36 px tall.
Mode transitions
The toolbar is the sole writer for the Play → Stop snapshot automation:
- Play clicked while Edit: captures a world snapshot (
safi_scene_snapshot_all) into a toolbar-owned cJSON blob, then sets mode to Play. The snapshot is distinct from the F6/F7 manual scratchpad in Editor Shortcuts — pressing F6 does not clobber the Play-start snapshot. - Play clicked while Paused: sets mode to Play without re-snapshotting.
- Pause clicked while Play: sets mode to Paused.
- Stop clicked (any mode): restores the Play-start snapshot if present, frees it, and sets mode to Edit. The snapshot restore is non-destructive — entity IDs stay stable across the round trip.
F1 still flips Edit ↔ Play and bypasses the snapshot logic entirely; it's kept as a raw keyboard alternative.
Tool transitions
The tool buttons write SafiEditorState.selected_tool directly — no side effects. The gizmo system reads the value each frame to decide what geometry to draw. Changing tools mid-drag doesn't hijack the drag: the gizmo finishes the in-flight manipulation on the tool it started with.
Keyboard shortcuts are Q / W / E / R for Select / Translate / Rotate / Scale, implemented by Editor Shortcuts and skipped while the right mouse button is held (RMB belongs to the fly-cam).
Install
Installed automatically by safi_app_init when enable_debug_ui is set. No separate install call is needed beyond the render system's safi_debug_ui_draw_panels invocation, which the engine handles.
See also
- Editor State — the singleton the toolbar writes
- Editor Shortcuts — F-keys + Q/W/E/R that mirror the buttons
- Editor Gizmo — what the tool buttons ultimately drive
- Scene Serialization — the snapshot / restore primitives Play ↔ Stop uses