ofKitty runtime
README
ofxKit
Editor Shell for openFrameworks.ofKit is a composition-first, ECS-first runtime addon. It injects the Edit Inspector overlay into
ofBaseApp sketches with one explicit attach call in main.cpp.Press Cmd-E at runtime to toggle the overlay (
Ctrl-E is also registered as a fallback).ofKitty is an ECS edit-mode framework. Apps own anentt::registry; the
Runtime is the edit-mode shell over it, and domain features (paths, paint,
audio, …) ship as kit addons. ClassicofPath-in-ofApppatterns still work
as compatibility shims, but the entity-centric path is the architecture —
see docs/from-openframeworks.md for friendly
side-by-side translations.
ofKitty is a stack of addons, not a single package. ofxKit is the---
edit-mode shell; data, properties, and domain tools live in other addons. See
docs/supported-stack.md for the inventory and
docs/addon-boundaries.md for what each layer owns.
What it does
- Provides a default
entt::registry, or attaches to an app-owned registry - Registers itself with OF's event system so it draws after the app's
draw() - Provides a live ImGui inspector overlay (powered by
ofxEnTTInspector) in Edit Mode - Exposes entity selection state (
ofkitty::runtime().selected()) - Undo / redo — global command stack (
runtime().undoStack()), wired to Edit → Undo/Redo and Ctrl/Cmd+Z (seedocs/undo.md)
Registered ImGui windows
Sketches register dockable Inspector panels via
Runtime::registerWindow — either with a lambda or (when the window-class headers are present in your ofxKit checkout) by subclassing KitRegisteredWindow. See docs/windows.md for lambdas, KitPropertyBag / baseProp parity.Built-in windows (Scene, Properties, Toolbar, Shortcuts, Preferences, Code Editor) are opt-in by default — none are registered unless you ask for them. Call any of these before
ofRunApp():runtime().enableBuiltInWindows(); // Scene + Properties (standard set)
runtime().enableBuiltInWindow("Toolbar"); // one at a time (additive)
runtime().enableAllBuiltInWindows(); // all built-in panels
runtime().disableBuiltInWindows(); // reset to default (none)---
How attach works
The project template includes
ofxKit.h. In main.cpp it creates the app as a std::shared_ptr and attached it to the runtime, then we pass the app to ofRunApp(). Meaning we can push improvements up and run ofKitty from Addons in Vanilla OF.ofApp.h → #include "ofxKit.h"
main.cpp → ofkitty::Runtime::attach(window, app[, registry])
→ ofRunApp(window, std::move(app))main.cpp stays close to the standard openFrameworks shape:#include "ofMain.h"
include "ofApp.h"
int main() {
ofGLWindowSettings settings;
settings.setSize(1024, 768);
settings.title = "My App"; // also used as menu/status app name
auto window = ofCreateWindow(settings);
auto app = std::make_shared<ofApp>();
ofkitty::Runtime::attach(window, app);
ofRunApp(window, std::move(app));
ofRunMainLoop();
}---
Usage in a sketch
Runtime-owned registry
// ofApp.h (generated template — nothing to add)
pragma once
include "ofMain.h"
include "ofxKit.h" // already here from the template
class ofApp : public ofBaseApp { ... };// ofApp.cpp — access the registry anywhere
include "ofApp.h"
void ofApp::setup() {
auto& reg = ofkitty::runtime().registry();
auto e = reg.create();
reg.emplace<ecs::named_entity>(e, "My Node");
ecs::ensureSpatialComponents(reg, e);
// ...
}App-owned registry
When your app owns the ECS state, pass it to
attach so the Runtime's inspector, status bar, and Scene panel all see the same entities:// ofApp.h
class ofApp : public ofBaseApp {
public:
entt::registry& registry() { return m_registry; }
void setup() override;
private:
entt::registry m_registry;
};// main.cpp
auto app = std::make_shared<ofApp>();
ofkitty::Runtime::attach(window, app, app->registry());
ofRunApp(window, std::move(app));If you omit the registry argument,
runtime().registry() returns Runtime's own internal registry — only use that path if your app creates all entities via runtime().registry() directly.---
Runtime registries
ofxKit is the composition runtime for ofKitty. Core addons should stay small and headless where possible; optional kit addons can register the UI, ECS components, and systems that make sense for a specific app.The first concrete registry is the window registry:
ofkitty::runtime().registerWindow({
"Machine",
"View",
true,
[](bool& visible) {
if (ImGui::Begin("Machine", &visible)) {
ImGui::TextUnformatted("Machine status");
}
ImGui::End();
},
});Built-in windows such as
Properties, and Shortcuts use the same path. The View menu is generated from the registered windows, so addon-owned windows appear beside the built-in ones.Kit addon pattern
Use a companion kit addon when a core addon needs optional ofKitty integration.
ofx-X-Kit can contain windows, components, systems, and ofKitty registration helpers:ofx-X-Kit/src/windows/
ofx-X-Kit/src/components/
ofx-X-Kit/src/systems/
ofx-X-Kit/src/kit/Components and systems
The "+ Add Component" picker is driven by ofxEnTTKit (
ecs::componentMenuEntries()). ofxKit finalises the registry on attach; addons extend it via ecs::registerComponent<T>(). Component property panels stay type-driven via ofxEnTTInspector.#include "component_editor_registration.h"
// minimal — has / remove generated automatically from T
ecs::registerComponent<grbl::MachineStateComponent>(
"Machine State", "Machines");
// custom add — when default emplace<T>(entity) needs extra work
ecs::registerComponent<grbl::MachineStateComponent>(
"Machine State", "Machines",
[](entt::registry& r, entt::entity e) {
r.emplace<grbl::MachineStateComponent>(e).connect("/dev/ttyUSB0");
});See ofxEnTTKit/docs/component-registry.md for the full API. See docs/component-registry.md for how ofxKit consumes the registry.
Kit addons register lifecycle systems against the Runtime (beside the window registry). Systems implement
ecs::ISystem (ofxEnTTKit). Update runs automatically in Runtime::onUpdate; draw uses named phases:// Owned — Runtime constructs and owns the system:
runtime().registerSystem<grbl::MachineSystem>({.update = true, .drawPhase = {}});
// Non-owned — kit keeps a member (typical registerWith pattern):
runtime().registerSystem(m_system, {
.update = false,
.drawPhase = ofkitty::system_phase::canvas, // or "gui"
});
// Inside ofApp::draw(), under your pan/zoom transform:
runtime().drawSystems(); // defaults to "canvas"Built-in draw phases:
"canvas" (app-invoked) and "gui" (auto, inside drawOverlay while the ImGui frame is open). Kits may use any phase string. Enable/disable from the Debug window's Systems list.WindowRegistry UI panels and menu visibility (ofxKit)
ComponentRegistry picker rows — owned by ofxEnTTKit (ecs::)
SystemRegistry setup / update / named draw / cleanup (ofxKit)---
API reference
ofkitty::Runtime
| Member | Description |
|---|---|
Runtime::instance() | Returns the singleton |
runtime() | Free-function shorthand for Runtime::instance() |
runtime().registry() | The active entt::registry (owned by runtime or supplied by the app) |
runtime().selected() | Currently selected entity (entt::null if none) |
runtime().select(e) | Programmatically select an entity |
runtime().isEditMode() | Whether the overlay is currently visible |
runtime().toggleEditMode() | Toggle Edit mode on/off |
runtime().setAppName(name) | Menu/status bar name (else settings.title on attach, else exe stem) |
runtime().registerWindow(w) | Register a dockable UI panel (appears in the View menu) |
runtime().registerSystem(sys, opts) | Register an ecs::ISystem (update + named draw phase) |
runtime().registerSystem<T>(opts, …) | Construct and own a system |
runtime().drawSystems(phase) | Draw all systems for a phase ("canvas" default; "gui" auto) |
runtime().getSystem<T>() | Lookup a registered system by type |
runtime().unregisterSystem(sys) | Remove a system (calls cleanup) |
runtime().disableBuiltInWindows() | Reset to default: no built-in windows registered |
runtime().enableBuiltInWindow(nameOrId) | Opt in to one specific built-in window (additive) |
runtime().enableBuiltInWindows() | Register the standard set: Scene + Properties |
runtime().enableAllBuiltInWindows() | Register all built-in windows |
runtime().addMenuBarGroup(name, cb) | Add a top-level menu group to the main menu bar |
runtime().showRulers() | Whether pixel rulers are visible |
runtime().setShowRulers(bool) | Show/hide the pixel ruler overlay |
runtime().toggleRulers() | Toggle ruler visibility (also bound to F2) |
runtime().setViewportRenderer(fn) | Register the scene-draw callback for the secondary Viewport panel |
runtime().clearViewportRenderer() | Remove the viewport renderer (panel shows a placeholder) |
runtime().registerPreferencePage(page) | Add a page to the Preferences window (built-ins + addon pages) |
runtime().unregisterPreferencePage(id) | Remove a preference page by id |
runtime().registerStatusItem(item) | Push an item into the status bar (compact draw callback) |
runtime().unregisterStatusItem(id) | Remove a status bar item by id |
runtime().openFileDialog(key,title,flt,cb) | Open a file-open dialog; cb fires with the chosen path on confirm |
runtime().saveFileDialog(key,title,flt,fn,cb) | Open a file-save dialog; cb fires with the chosen path on confirm |
runtime().setSceneCamera(cam) | Provide the main-scene camera so the gizmo can be drawn on it |
runtime().clearSceneCamera() | Remove the scene camera reference |
runtime().setGizmoOperation(op) | Set gizmo mode: Translate / Rotate / Scale / Universal (W/E/R shortcuts) |
runtime().setGizmoMode(mode) | Set gizmo space: World / Local (X shortcut) |
runtime().codeEditorSetText(src) | Seed the Code Editor with a source string |
runtime().codeEditorGetText() | Read back the current Code Editor contents |
runtime().codeEditorSetLanguage(lang) | Set syntax-highlighting language (GLSL, C++, Lua, Python, …) |
ofkitty::Runtime::attach(window, app)
Call this once before
ofRunApp():auto app = std::make_shared<ofApp>();
ofkitty::Runtime::attach(window, app);
ofRunApp(window, std::move(app));ofkitty::Runtime::attach(window, app, registry)
Pass your app's registry when the app owns ECS state. The Runtime's inspector, status bar, and Scene panel all read from this registry:
ofkitty::Runtime::attach(window, app, app->registry());---
Dependencies
The spine below is the minimum. For the full stack (shell utilities, domain Kit addons, what each owns), see docs/supported-stack.md.
For a vanilla openFrameworks project using
addons.make, add:ofxEnTT
ofxImGui
ofxImGuiStyle
ofxEnTTKit
ofxEnTTInspector
ofxKit| Addon | Role |
|---|---|
ofxEnTT | EnTT ECS library |
ofxEnTTKit | ECS components for OF types + ofxNode + TransformSystem |
ofxEnTTInspector | ImGui inspector panels for ECS components |
ofxImGui | ImGui integration for openFrameworks |
ofxImGuiStyle | Theme registry (ImTheme) + bundled fonts/icons (ImFonts) |
In the ofKitty distribution, install/update these dependencies with:
./scripts/install_ofkitty_spine.sh---
Keyboard shortcuts
| Key | Action |
|---|---|
| Cmd-E | Toggle Edit mode overlay |
| Ctrl-E | Toggle Edit mode overlay |
| Ctrl/Cmd+Z | Undo (app stack; skipped while typing in ImGui fields) |
| Ctrl+Y / Cmd+Shift+Z | Redo |
| F2 | Toggle Rulers |
| TAB | Toggle Edit mode (built-in alias; suppressed when ImGui has keyboard focus) |
| W | Gizmo: Translate (while in Edit mode) |
| E | Gizmo: Rotate (while in Edit mode) |
| R | Gizmo: Scale (while in Edit mode) |
| X | Gizmo: Toggle World / Local space |
---
Examples
| Example | What it shows |
|---|---|
example-empty | Minimal ECS 2D sketch — author shapes with ecs::Painter (or layer.begin()/ecs::drawRect/end()), rendered via drawLayerContents(); Scene / Properties |
example-ui | Clickable glue — rectangle button + click_bind toggles a flag_component in play mode |
example-ofKitty | Full 3D ECS scene editor showcase — meshes authored with ecs::Painter (box/sphere/...), rendered via ecs::drawMeshes() |
ofxVectorKit and its example-pathEditor.Wrap normal OF draws to mirror them into the runtime registry (v1: rectangle + path):
void ofApp::draw() {
ofkitty::begin();
ofDrawRectangle(x, y, 200, 200);
myPath.draw(pathX, pathY);
ofkitty::end();
}Press Ctrl+E / Tab to toggle Edit mode, select captured entities in Scene, edit values in Properties.
---
Docs
| File | Topic |
|---|---|
CONTRIBUTING.md | Contributing — where new code belongs |
docs/supported-stack.md | ofKitty stack inventory — spine, utilities, Kit addons |
docs/addon-boundaries.md | Addon boundaries — four layers + Kit integration contract |
docs/dirty-state.md | Dirty state — dirty-only invalidate convention |
docs/source-map.md | Where the code lives — contributor index |
docs/component-registry.md | ComponentRegistry API, addon registration, picker |
docs/scene-window.md | Scene hierarchy tree, ofxNode traversal, selection |
docs/layers-panel.md | LayersPanel tree, ReorderDragDrop, LayerSystem |
docs/chain-editor.md | ChainEditor — re-orderable step lists (FX, pipeline) |
docs/status-bar.md | Status bar layout and implementation notes |
docs/preferences.md | App Preferences window — all OF settings |
docs/appearance.md | Theme/font integration with ofxImGuiStyle (ImTheme / ImFonts) |
docs/rulers.md | Rulers overlay — pixel coordinates + mouse tracking |
docs/viewport-window.md | Secondary Viewport panel — FBO, camera controls |
docs/from-openframeworks.md | From openFrameworks to ofKitty — friendly ECS translations |
docs/tools.md | File dialog, Gizmo, Code Editor |
docs/dockspace.md | Dockspace central node — passthrough vs opaque |
docs/undo.md | UndoStack — commands, snapshots, coalesced drags |
docs/shortcuts.md | ShortcutManager — named actions including edit.undo |
docs/menu-bar.md | Main menu bar — built-in Edit → Undo / Redo |
---
Architecture notes
ofkitty::Runtimeis a singleton that lives for the duration of the process- Implementation map (where to edit chrome code):
docs/source-map.md - The runtime creates a default registry, but can inspect an app-owned registry passed at attach time
- The overlay is rendered at
OF_EVENT_ORDER_AFTER_APPso it always draws on top ofxNode(inofxEnTTKit) is the ECS-native node handle;ecs::TransformSystempropagates global transforms once per frame
Architecture
ofxKit is intended to stay addon-owned rather than requiring openFrameworks core patches:openFrameworks app
├── main.cpp — calls ofkitty::Runtime::attach(...)
├── ofxEnTTKit — Relationship, LocalTransform, GlobalTransform, ofxNode, TransformSystem
├── ofxEnTTInspector — per-component ImGui panels
├── ofxImGui — ImGui window management
└── ofxKit — runtime singleton + Edit mode
ofxAddons