Shape behavior
What a person can do to a shape comes from its definition in pure Dart. The engine and the Flutter canvas read the same declaration; an overlay never decides on its own whether an operation is allowed. Part of it you declare as behavior; the rest follows from the shape's anatomy.
Declare behavior
dart
import 'package:vyuh_diagram_core/extension_api.dart';
import 'package:vyuh_diagram_core/vyuh_diagram_core.dart';
final note = ShapeDefinition(
type: 'app.note',
size: const DiagramSize(240, 120),
behavior: const ShapeBehavior(
rotatable: false,
textSizing: ShapeTextSizing.fitHeight,
),
body: const ShapeText('body', text: 'Height follows the text'),
);The note cannot rotate, and its height follows its text, so only its left and right resize handles show.
ShapeBehavior property | Default | Effect |
|---|---|---|
selectable | true | Whether the shape can be selected. |
deletable | true | Whether the shape can be deleted. |
movable | true | Whether the shape can be moved. |
resizable | true | Whether the shape can be resized; false shows no resize handles. |
rotatable | true | Whether the shape can be rotated, from a corner or the rotation handle. |
rotationHandle | false | Shows a stem-and-circle rotation control above a rotatable shape. |
textSizing | ShapeTextSizing.fixed | fixed keeps the authored frame; growHeight treats the authored height as a minimum and grows downward; fitHeight makes the height follow the content exactly. |
Resize handles follow from these: all eight when resizable, only the left and right sides when the height fits the content, and none when not resizable. behavior.resizeHandles lists them. Handle names describe the shape's local sides; their positions follow shape rotation. The rotation stem is presentation only: it cannot enable rotation when rotatable is false.
What follows from the anatomy
Editing is not declared with flags. It follows from what the shape is made of:
| The shape has | So a person can edit | Read it as |
|---|---|---|
An outline | Fill and stroke | definition.paintsSurface |
An outline that rounds its corners (rect(), regularPolygon(), editablePath(), or a path with cornerRadius: true) | Corner radius | definition.cornerRadiusEditable |
An editable ShapeText, or content such as a table | Text | definition.textEditable |
A PathValueField read by an editable path outline | Points | definition.pathValue |
| A regular polygon outline | Its number of sides | definition.sidesValue |
An ImageValueField | The image | definition.imageValue |
| Any other value | That value, with one control each | definition.customValues |
definition.propertyEditors lists the resulting inspector sections in order. To remove a control, change the anatomy: a shape with outline: null has no fill or stroke, ShapeOutline.rect(cornerRadius: false) has square corners, a ShapeText(..., editable: false) is text people cannot edit on the canvas, and body: null hosts no text.
Containers
A shape that owns child elements declares a container:
dart
import 'package:vyuh_diagram_core/extension_api.dart';
final lane = ShapeDefinition(
type: 'app.lane',
container: const ShapeContainer(clips: true, resizesChildren: false),
behavior: const ShapeBehavior(rotatable: false),
);ShapeContainer property | Default | Effect |
|---|---|---|
clips | false | Instances may clip their children to the outline with clipContent. A clipping container always shows its border, so its extent stays visible. |
resizesChildren | true | Whether resizing the container scales its children. Movement and rotation always carry them. |
A container may also declare collapse: ShapeCollapseDefinition(...) for a compact presentation. See frames and ownership.
Definition policy versus instance state
Behavior is fixed on each registered definition; there is no per-instance behavior callback. Locking an instance keeps it selectable but stops moving, resizing, rotating, deleting and editing it, while preserving its appearance. A collapsed container cannot resize or rotate, and its text does not size it. Content can narrow behavior too: a table whose controls disable resizeTable makes its shape not resizable. resolved.behavior on a resolved shape combines all of these. Command admission additionally checks the diagram's DiagramRules and operation preconditions.
For a different permanent behavior, register another shape definition. Do not replace a loaded registry definition or hide handles in an overlay as a substitute for engine policy.
See shape anatomy to package this definition in an extension and Canvas foundations to render it.