Skip to content

Commit 4aef3c6

Browse files
committed
Document the position gizmo and gizmos on non-shape nodes
1 parent 3eb2330 commit 4aef3c6

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

  • editor/src/messages/tool/common_functionality/gizmos

editor/src/messages/tool/common_functionality/gizmos/README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ gizmo_behaviors.rs the shape-specific half, and the only place node geometry b
1212
gizmo_manager.rs picks the right handler for the selected layer
1313
```
1414

15+
Three controls back the declarations:
16+
17+
| `GizmoType` | Parameter | Control |
18+
|---|---|---|
19+
| `Slider` | `f64` | a handle on a ray, dragged in and out |
20+
| `Dial` | `u32` | a count, stepped by horizontal drag distance |
21+
| `Position` | `DVec2` | a draggable point |
22+
| `Angle` | `f64` degrees | the slider's machinery with a drag of your own |
23+
1524
The generic layer always owns the hover/drag state machine, arbitration between overlapping gizmos,
1625
cursor feedback, and the write to the graph. You supply what is genuinely particular to your node, and
1726
often that is nothing at all.
@@ -138,8 +147,12 @@ transform is the one exception, and it moves the layer rather than the geometry.
138147
through, which is meaningless for a fraction-of-the-radius parameter.
139148
- **The transform cage sits on top of the obvious grab points.** Its corner and edge handles land where a
140149
circle's radius or an arc's endpoint invites the cursor, and it wins the press. Test away from them.
141-
- **The bounding-box `PositionHint` variants are inert.** Every migrated shape derives its handle from a
142-
parameter, so `BoundingBoxCenter` and friends currently fall through to the +X axis.
150+
- **The bounding-box `PositionHint` variants are inert.** Every declaration so far derives its handle from
151+
a parameter, so `BoundingBoxCenter` and friends still fall through to the +X axis. They are the natural
152+
place to start for a node whose parameter is not a length.
153+
- **A `Position` handle is placed by the *parent* transform, not the layer's own.** A translation is
154+
expressed in the space its transform is built from. Using the layer transform folds the value being
155+
edited into the handle's position, and the handle runs away from the cursor as you drag it.
143156
- **Two overlapping handles are not ranked by distance alone.** A gizmo grabbed along a region reports how
144157
far the cursor is from that region, which is near zero everywhere along it; a point handle reports its
145158
real distance. Comparing those two numbers gives the region every grab. Mark the region one
@@ -148,6 +161,37 @@ transform is the one exception, and it moves the layer rather than the geometry.
148161
- **Nothing is drawn at rest unless something asks for it.** A slider with no overlay marks its grab
149162
points; one that supplies an overlay is expected to draw its own resting state.
150163

164+
## Nodes that are not shapes
165+
166+
The registry has no notion of a shape, but the gizmo *manager* has to live in a tool, and for a long time
167+
that tool was only the Shape tool. A Blur or a Transform layer is selected with the Select tool, so a
168+
declaration for one of those rendered nothing at all until the manager was hosted there too.
169+
170+
Both tools now run it. If you add a gizmo to a node and see no handle, check which tool selects that kind
171+
of layer before you suspect the declaration.
172+
173+
Two things behave differently on the Select tool:
174+
175+
- **The transform cage gets first refusal on a press** everywhere except where a handle actually sits.
176+
A handle inside the bounding box is checked *before* the cage, or it could never be grabbed at all.
177+
- **There is no `ShapeType` to key off.** The manager looks up whichever node it finds upstream of the
178+
selected layer, which is exactly what makes a non-shape node work.
179+
180+
The smallest possible example is the Blur radius, which is a length in pixels and therefore needs no
181+
behaviour code whatsoever:
182+
183+
```rust
184+
const BLUR_GIZMOS: &[GizmoInfo] = &[GizmoInfo {
185+
parameter_index: blur::RadiusInput::INDEX,
186+
gizmo_type: GizmoType::Slider,
187+
name: "Radius",
188+
min: Some(0.),
189+
max: None,
190+
behavior: GizmoBehavior::NONE,
191+
position_hint: PositionHint::ParameterDerived,
192+
}];
193+
```
194+
151195
## Testing
152196

153197
Registry declarations are cheap to assert directly — see the tests at the bottom of `gizmo_registry.rs`,

0 commit comments

Comments
 (0)