docs: add Editor API documentation

This commit is contained in:
2026-03-27 14:40:29 +08:00
parent 3e2608a802
commit 94c56dd279
87 changed files with 3795 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
# ScalarControls
**命名空间**: `XCEngine::Editor::UI`
**类型**: `header-helper`
**源文件**: `editor/src/UI/ScalarControls.h`
**描述**: 提供基于双列表格布局的标量属性控件,如 float、int、bool、颜色和下拉框。
## 概述
`ScalarControls.h` 封装的是 Inspector 最基础的输入部件:
- `DrawFloat`
- `DrawInt`
- `DrawBool`
- `DrawColor3`
- `DrawColor4`
- `DrawSliderFloat`
- `DrawSliderInt`
- `DrawCombo`
## 当前实现
- 所有控件都建立在 [`DrawControlRow`](../Core/Core.md) 之上
- 默认列宽来自 `DefaultControlLabelWidth()`
- 每个控件都统一使用 `##value` 作为内部 item id 后缀,并通过外层 `PushID(label)` 隔离
## 设计说明
这层的价值在于把“输入控件长什么样”从组件编辑器里抽出来。
否则每个组件 editor 都会重复写:
- 两列表格
- 标签列宽
- `SetNextItemWidth`
- 不同控件的 ImGui 参数模板
`ScalarControls` 让上层代码只保留业务字段名和少量范围参数。
## 相关文档
- [UI](../UI.md)
- [Core](../Core/Core.md)
- [PropertyGrid](../PropertyGrid/PropertyGrid.md)