xiaohongshu
xiaohongshu
editor-ui-infrastructure
Guide proper usage of Editor UI infrastructure including Drawers (ButtonDrawer, ModalDrawer, TableDrawer, etc.), Elements (drag-drop targets, ComponentSelector), FieldEditors, and EditorUIConstants. Use when implementing editor panels, component editors, or any ImGui UI code to ensure consistency...
Full skill instructions
The Editor UI infrastructure provides four layers of reusable UI components ensuring consistent styling and behavior across all editor panels and component editors.
Golden Rule: Never reimplement existing UI patterns. Always check if a Drawer, Element, or FieldEditor exists before writing custom ImGui code.
Benefits:
Invoke this skill when:
What: Static utility classes for common UI patterns with consistent styling.
When: Use for standard UI operations (buttons, modals, tables, spacing, text).
Available: ButtonDrawer, ModalDrawer, TableDrawer, TreeDrawer, LayoutDrawer, TextDrawer, DragDropDrawer
Key Example:
// ❌ WRONG - Raw ImGui
if (ImGui.Button("Save", new Vector2(120, 30)))
Save();
// ✅ CORRECT - Use ButtonDrawer
if (ButtonDrawer.DrawButton("Save", onClick: Save))
{
// Additional logic if needed
}
Features:
Common Methods:
ButtonDrawer.DrawButton() - Standard buttonButtonDrawer.DrawColoredButton() - Semantic colored button (red/green/yellow/blue)ModalDrawer.RenderConfirmationModal() - OK/Cancel dialogTableDrawer.BeginTable() - Consistent table renderingTreeDrawer.BeginTreeNode() - Expandable tree nodesLayoutDrawer.DrawSpacing() - Consistent vertical spacingTextDrawer.DrawText() - Colored text (Error/Warning/Success/Info)See references/drawers-api.md for complete API reference (15+ button variants, modal types, etc.).
What: Complex, stateful UI components for specific interactions.
When: Use for specialized interactions (drag-drop, component selection, context menus).
Available: TextureDropTarget, AudioDropTarget, MeshDropTarget, ComponentSelector, EntityContextMenu, PrefabManager
Key Example:
// ❌ WRONG - Custom drag-drop implementation
ImGui.Button("Texture");
if (ImGui.BeginDragDropTarget())
{
// Complex validation, error handling, visual feedback...
}
// ✅ CORRECT - Use specialized drop target
TextureDropTarget.Draw("Texture",
currentPath: component.TexturePath,
onTextureChanged: path => component.TexturePath = path,
assetsManager: _assetsManager
);
Features:
Common Elements:
TextureDropTarget - Texture files (.png, .jpg)AudioDropTarget - Audio files (.wav, .ogg)MeshDropTarget - Mesh files (.obj, .fbx)ComponentSelector - Searchable component list for "Add Component"EntityContextMenu - Right-click menu (duplicate, delete, rename)PrefabManager - Prefab creation/instantiationSee references/elements-api.md for complete API reference and usage patterns.
What: Generic type-safe editors for primitive types, used in component editors.
When: Use in component editors for properties (int, float, Vector3, string, bool).
Available: IFieldEditor<T> for bool, int, float, double, string, Vector2, Vector3, Vector4
Key Example:
// ❌ WRONG - Direct ImGui calls
public class MyComponentEditor : IComponentEditor<MyComponent>
{
public void DrawEditor(MyComponent component)
{
ImGui.DragFloat("Speed", ref component.Speed);
ImGui.Checkbox("Enabled", ref component.IsEnabled);
}
}
// ✅ CORRECT - Inject field editors
public class MyComponentEditor : IComponentEditor<MyComponent>
{
private readonly IFieldEditor<float> _floatEditor;
private readonly IFieldEditor<bool> _boolEditor;
private readonly IFieldEditor<Vector3> _vectorEditor;
public MyComponentEditor(
IFieldEditor<float> floatEditor,
IFieldEditor<bool> boolEditor,
IFieldEditor<Vector3> vectorEditor)
{
_floatEditor = floatEditor;
_boolEditor = boolEditor;
_vectorEditor = vectorEditor;
}
public void DrawEditor(MyComponent component)
{
_floatEditor.DrawField("Speed", ref component.Speed);
_boolEditor.DrawField("Enabled", ref component.IsEnabled);
_vectorEditor.DrawField("Offset", ref component.Offset);
}
}
Features:
Dependency Injection Pattern:
What: Centralized constants for consistent styling across all UI.
When: Use for ALL sizing, spacing, colors (never hardcode values).
Key Categories:
Key Example:
// ❌ WRONG - Magic numbers
ImGui.Button("Export", new Vector2(150, 35));
ImGui.Dummy(new Vector2(0, 10));
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 0, 0, 1));
// ✅ CORRECT - Use constants
ButtonDrawer.DrawButton("Export",
width: EditorUIConstants.WideButtonWidth,
height: EditorUIConstants.StandardButtonHeight);
LayoutDrawer.DrawSpacing();
ImGui.PushStyleColor(ImGuiCol.Text, EditorUIConstants.ErrorColor);
Golden Rule: EditorUIConstants is the ONLY static class allowed in the codebase (all other code uses DI).
See references/constants-catalog.md for complete catalog and design rationale.
Why: Ensures consistency, automatic sizing, proper callbacks.
// Use ButtonDrawer for all buttons
ButtonDrawer.DrawButton("Save");
ButtonDrawer.DrawColoredButton("Delete", MessageType.Error);
// Use ModalDrawer for confirmations
ModalDrawer.RenderConfirmationModal("Delete?", ref _show, "Sure?", () => Delete());
// Use LayoutDrawer for spacing
LayoutDrawer.DrawSpacing(); // Not ImGui.Dummy()
Why: Built-in validation, error handling, visual feedback.
// Use TextureDropTarget for textures
TextureDropTarget.Draw("Texture", onTextureChanged, assetsManager);
// Use AudioDropTarget for audio
AudioDropTarget.Draw("Audio Clip", onAudioChanged, assetsManager);
// Use MeshDropTarget for meshes
MeshDropTarget.Draw("Mesh", onMeshChanged, assetsManager);
Why: DI pattern, consistency, automatic layout ratios.
// Always inject field editors via primary constructor
public class MyComponentEditor(
IFieldEditor<float> floatEditor,
IFieldEditor<Vector3> vectorEditor) : IComponentEditor
{
// Use in DrawEditor - injected parameters are available as fields
public void DrawEditor()
{
floatEditor.DrawField("Speed", ref component.Speed);
vectorEditor.DrawField("Position", ref component.Position);
}
}
Why: Global style changes, visual consistency, no magic numbers.
// Always use constants
ButtonDrawer.DrawButton("Export",
width: EditorUIConstants.WideButtonWidth);
LayoutDrawer.DrawSpacing(EditorUIConstants.LargePadding);
ImGui.PushStyleColor(ImGuiCol.Text, EditorUIConstants.ErrorColor);
// NEVER hardcode
ImGui.Button("Export", new Vector2(150, 35)); // ❌ WRONG
ImGui.Dummy(new Vector2(0, 10)); // ❌ WRONG
Why: Visual consistency, user expectations (red=danger, green=success).
// Destructive actions = Error (red)
ButtonDrawer.DrawColoredButton("Delete", MessageType.Error);
TextDrawer.DrawText("Validation failed", MessageType.Error);
// Confirmations = Success (green)
ButtonDrawer.DrawColoredButton("Save", MessageType.Success);
TextDrawer.DrawText("Saved successfully!", MessageType.Success);
// Cautions = Warning (yellow)
TextDrawer.DrawText("Overwriting existing file", MessageType.Warning);
Why: Consistent UX, keyboard navigation, automatic component discovery.
// Use ComponentSelector for "Add Component"
private readonly ComponentSelector _selector = new();
if (ButtonDrawer.DrawButton("Add Component"))
_selector.Show(entity);
_selector.Draw(); // Call every frame
// Use EntityContextMenu for right-click
private readonly EntityContextMenu _contextMenu = new();
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
_contextMenu.Show(entity, scene);
_contextMenu.Draw(); // Call every frame
Problem: Inconsistent sizing, breaks global style changes, harder to maintain.
// ❌ WRONG - Raw ImGui
if (ImGui.Button("Save", new Vector2(120, 30)))
Save();
ImGui.SetNextItemWidth(200);
// ✅ CORRECT - Use infrastructure
if (ButtonDrawer.DrawButton("Save"))
Save();
ImGui.SetNextItemWidth(EditorUIConstants.DefaultColumnWidth);
Why It's Bad: Hardcoded values prevent global style updates, break visual consistency.
Problem: Complex validation, error handling, visual feedback must be reimplemented.
// ❌ WRONG - Manual implementation
if (ImGui.BeginDragDropTarget())
{
var payload = ImGui.AcceptDragDropPayload("CONTENT_BROWSER_ITEM");
if (payload.NativePtr != null)
{
// File extension validation
// Path validation
// Error messages
// Visual feedback
}
}
// ✅ CORRECT - Use specialized target
TextureDropTarget.Draw("Texture", onChange, assetsManager);
Why It's Bad: Drop targets handle validation, errors, and visual feedback automatically.
Problem: Breaks DI pattern, inconsistent layout ratios, no axis coloring.
// ❌ WRONG - Direct ImGui
ImGui.DragFloat("Speed", ref speed);
ImGui.DragFloat3("Position", ref position);
// ✅ CORRECT - Inject and use field editors
_floatEditor.DrawField("Speed", ref speed);
_vectorEditor.DrawField("Position", ref position); // Automatic X/Y/Z colors
Why It's Bad: Loses PropertyLabelRatio (33/67 split), axis color coding, reset buttons.
When implementing editor UI, ensure:
ImGui.Button)Detailed API documentation for each infrastructure layer:
references/drawers-api.md: Complete Drawer APIs
references/elements-api.md: Complete Element APIs
references/constants-catalog.md: EditorUIConstants Catalog
Editor/UI/Drawers/ - All drawer implementationsEditor/UI/Elements/ - All element implementationsEditor/UI/FieldEditors/ - All field editor implementationsEditor/UI/Constants/EditorUIConstants.cs - Constant definitionsThe Editor UI infrastructure provides four layers:
Key Principle: Never reimplement existing patterns. Check Drawers/Elements/FieldEditors first, then write custom ImGui code only if no match exists.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience