feat(editor): right-click context menu + reset layout
Two operator-visible features filling concrete gaps the
jai_client editor exposed:
- Right-click on any step node opens a popup menu at the
cursor position with three actions:
* Duplicate — clones the step with a unique id
(<base>_2, <base>_3, …) and offsets its position so
the copy is visible next to the original.
* Disconnect all inputs — keeps every with-field key
but clears its expression value, so the step still
declares the same inputs but no longer wires them to
any upstream step.
* Delete — removes the step. Any dangling $refs in
downstream steps become run-time errors; we don't
silently rewrite their YAML because the surprise
would be worse than the explicit error.
- Floating "Reset layout" button on the canvas (next to
Fit to screen). Wipes the layout sidecar so AutoLayout
re-runs from scratch and the topological column
placement is restored. Auto-fits afterwards. Useful
when manual drags have drifted into spaghetti and the
operator wants a clean slate without losing the flow.
Implementation:
- FlowNode gains an `onContextMenu(Offset globalPos)`
parameter, wired to GestureDetector.onSecondaryTapDown.
- FlowEditorController.resetLayout() — clears layout,
re-seeds via AutoLayout, saves sidecar, notifies.
- The menu uses Flutter's showMenu() at the global
cursor position for native-feeling positioning.
Version bumped 0.2.2 -> 0.3.0 — first new operator-visible
feature set since the v0.2 WYSIWYG release.
Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
c15731fb1b
commit
296e5bfd01
4 changed files with 179 additions and 10 deletions
|
|
@ -67,6 +67,11 @@ class FlowNode extends StatelessWidget {
|
|||
final void Function(Offset delta)? onDrag;
|
||||
final VoidCallback? onDragEnd;
|
||||
|
||||
/// Right-click handler. Canvas wires this to a popup menu
|
||||
/// at the cursor position (Duplicate / Delete / Disconnect
|
||||
/// inputs etc.). `null` = no context menu offered.
|
||||
final void Function(Offset globalPos)? onContextMenu;
|
||||
|
||||
/// Live status from the most recent run, when this node is
|
||||
/// a step. Coloured dot in the header so the operator can
|
||||
/// glance at the canvas and see what's running.
|
||||
|
|
@ -84,6 +89,7 @@ class FlowNode extends StatelessWidget {
|
|||
this.onTap,
|
||||
this.onDrag,
|
||||
this.onDragEnd,
|
||||
this.onContextMenu,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -99,6 +105,9 @@ class FlowNode extends StatelessWidget {
|
|||
onTap: onTap,
|
||||
onPanUpdate: onDrag == null ? null : (d) => onDrag!(d.delta),
|
||||
onPanEnd: onDragEnd == null ? null : (_) => onDragEnd!(),
|
||||
onSecondaryTapDown: onContextMenu == null
|
||||
? null
|
||||
: (details) => onContextMenu!(details.globalPosition),
|
||||
child: Material(
|
||||
color: theme.colorScheme.surfaceContainerHigh,
|
||||
elevation: selected ? 6 : 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue