Skip to content

Commit 810f6f0

Browse files
committed
feat: improve connection painter caching and theme handling, and fix path cache referencing current theme style
1 parent ced99e6 commit 810f6f0

File tree

12 files changed

+249
-386
lines changed

12 files changed

+249
-386
lines changed

packages/demo/lib/examples/annotations.dart

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -338,41 +338,45 @@ class _AnnotationExampleState extends State<AnnotationExample> {
338338
),
339339
const SectionTitle('Visibility'),
340340
SectionContent(
341-
child: Grid2Cols(
342-
buttons: [
343-
GridButton(
344-
label: 'Hide All',
345-
icon: Icons.visibility_off,
346-
onPressed: () {
347-
for (final node in controller.nodes.values) {
348-
if (node is CommentNode || node is GroupNode) {
349-
node.isVisible = false;
350-
}
351-
}
352-
},
341+
child: Column(
342+
crossAxisAlignment: CrossAxisAlignment.stretch,
343+
children: [
344+
Grid2Cols(
345+
buttons: [
346+
GridButton(
347+
label: 'Hide All',
348+
icon: Icons.visibility_off,
349+
onPressed: () {
350+
for (final node in controller.nodes.values) {
351+
if (node is CommentNode || node is GroupNode) {
352+
node.isVisible = false;
353+
}
354+
}
355+
},
356+
),
357+
GridButton(
358+
label: 'Show All',
359+
icon: Icons.visibility,
360+
onPressed: () {
361+
for (final node in controller.nodes.values) {
362+
if (node is CommentNode || node is GroupNode) {
363+
node.isVisible = true;
364+
}
365+
}
366+
},
367+
),
368+
],
353369
),
354-
GridButton(
355-
label: 'Show All',
356-
icon: Icons.visibility,
357-
onPressed: () {
358-
for (final node in controller.nodes.values) {
359-
if (node is CommentNode || node is GroupNode) {
360-
node.isVisible = true;
361-
}
362-
}
363-
},
370+
const SizedBox(height: 12),
371+
ControlButton(
372+
label: 'Clear All Comment/Group Nodes',
373+
icon: Icons.clear,
374+
isDestructive: true,
375+
onPressed: _clearAllCommentAndGroupNodes,
364376
),
365377
],
366378
),
367379
),
368-
SectionContent(
369-
child: ControlButton(
370-
label: 'Clear All Comment/Group Nodes',
371-
icon: Icons.clear,
372-
isDestructive: true,
373-
onPressed: _clearAllCommentAndGroupNodes,
374-
),
375-
),
376380
],
377381
);
378382
}

packages/demo/lib/examples/editable_connections.dart

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,27 @@ class _EditableConnectionsExampleState
265265
children: [
266266
const SectionTitle('About'),
267267
SectionContent(
268-
child: InfoCard(
269-
title: 'Instructions',
270-
content:
271-
'1. Enable editing mode to see control points\n'
272-
'2. Drag control points to modify connection paths\n'
273-
'3. Control points define waypoints for smooth step routing\n'
274-
'4. Connections without control points use automatic routing',
275-
),
276-
),
277-
SectionContent(
278-
child: InfoCard(
279-
title: 'Features',
280-
content:
281-
'• Drag control points to customize paths\n'
282-
'• Add/remove control points programmatically\n'
283-
'• Maintains orthogonal (90°) routing\n'
284-
'• Smooth rounded corners at bends',
268+
child: Column(
269+
crossAxisAlignment: CrossAxisAlignment.start,
270+
children: [
271+
InfoCard(
272+
title: 'Instructions',
273+
content:
274+
'1. Enable editing mode to see control points\n'
275+
'2. Drag control points to modify connection paths\n'
276+
'3. Control points define waypoints for smooth step routing\n'
277+
'4. Connections without control points use automatic routing',
278+
),
279+
const SizedBox(height: 12),
280+
InfoCard(
281+
title: 'Features',
282+
content:
283+
'• Drag control points to customize paths\n'
284+
'• Add/remove control points programmatically\n'
285+
'• Maintains orthogonal (90°) routing\n'
286+
'• Smooth rounded corners at bends',
287+
),
288+
],
285289
),
286290
),
287291
const SectionTitle('Actions'),

packages/demo/lib/examples/lod.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -762,33 +762,36 @@ class _LODExampleState extends State<LODExample> {
762762
children: [
763763
const SectionTitle('Quick Zoom'),
764764
SectionContent(
765-
child: Text(
766-
'Jump to specific zoom levels to see LOD changes',
767-
style: TextStyle(fontSize: 11, color: Colors.grey.shade600),
768-
),
769-
),
770-
SectionContent(
771-
child: Wrap(
772-
spacing: 8,
773-
runSpacing: 8,
765+
child: Column(
766+
crossAxisAlignment: CrossAxisAlignment.stretch,
774767
children: [
775-
_buildZoomButton('Min', _controller.config.minZoom.value),
776-
_buildZoomButton('25%', 0.25),
777-
_buildZoomButton('50%', 0.5),
778-
_buildZoomButton('75%', 0.75),
779-
_buildZoomButton('100%', 1.0),
780-
_buildZoomButton('150%', 1.5),
781-
_buildZoomButton('Max', _controller.config.maxZoom.value),
768+
Text(
769+
'Jump to specific zoom levels to see LOD changes',
770+
style: TextStyle(fontSize: 11, color: Colors.grey.shade600),
771+
),
772+
const SizedBox(height: 12),
773+
Wrap(
774+
spacing: 8,
775+
runSpacing: 8,
776+
children: [
777+
_buildZoomButton('Min', _controller.config.minZoom.value),
778+
_buildZoomButton('25%', 0.25),
779+
_buildZoomButton('50%', 0.5),
780+
_buildZoomButton('75%', 0.75),
781+
_buildZoomButton('100%', 1.0),
782+
_buildZoomButton('150%', 1.5),
783+
_buildZoomButton('Max', _controller.config.maxZoom.value),
784+
],
785+
),
786+
const SizedBox(height: 12),
787+
ControlButton(
788+
icon: Icons.fit_screen,
789+
label: 'Fit to View',
790+
onPressed: () => _controller.fitToView(),
791+
),
782792
],
783793
),
784794
),
785-
SectionContent(
786-
child: ControlButton(
787-
icon: Icons.fit_screen,
788-
label: 'Fit to View',
789-
onPressed: () => _controller.fitToView(),
790-
),
791-
),
792795
],
793796
);
794797
}

packages/demo/lib/examples/port_labels.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,7 @@ class _PortLabelsExampleState extends State<PortLabelsExample> {
320320
});
321321
},
322322
),
323-
],
324-
),
325-
),
326-
SectionContent(
327-
child: Column(
328-
crossAxisAlignment: CrossAxisAlignment.start,
329-
children: [
323+
const SizedBox(height: 12),
330324
Text(
331325
'Label Offset: ${_labelOffset.toStringAsFixed(0)}',
332326
style: theme.textTheme.bodyMedium,

packages/demo/lib/examples/ports.dart

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -458,68 +458,73 @@ class _PortCombinationsDemoState extends State<PortCombinationsDemo>
458458
// Animation Section
459459
const SectionTitle('Animation'),
460460
SectionContent(
461-
child: Observer(
462-
builder: (context) => SwitchListTile(
463-
contentPadding: EdgeInsets.zero,
464-
title: const Text(
465-
'Orbit Target Node',
466-
style: TextStyle(fontSize: 13),
467-
),
468-
subtitle: const Text(
469-
'Target node orbits around source node',
470-
style: TextStyle(fontSize: 11),
471-
),
472-
value: _themeControl._isRotating.value,
473-
onChanged: (value) {
474-
_themeControl.isRotating = value;
475-
},
476-
),
477-
),
478-
),
479-
SectionContent(
480-
child: Observer(
481-
builder: (context) => Column(
482-
crossAxisAlignment: CrossAxisAlignment.start,
483-
children: [
484-
Text(
485-
'Orbit Speed: ${_themeControl._rotationSpeed.value.toStringAsFixed(2)}',
486-
style: const TextStyle(fontSize: 13),
487-
),
488-
Slider(
489-
value: _themeControl._rotationSpeed.value,
490-
min: 0.1,
491-
max: 2.0,
492-
divisions: 19,
493-
label: _themeControl._rotationSpeed.value.toStringAsFixed(2),
461+
child: Column(
462+
crossAxisAlignment: CrossAxisAlignment.start,
463+
children: [
464+
Observer(
465+
builder: (context) => SwitchListTile(
466+
contentPadding: EdgeInsets.zero,
467+
title: const Text(
468+
'Orbit Target Node',
469+
style: TextStyle(fontSize: 13),
470+
),
471+
subtitle: const Text(
472+
'Target node orbits around source node',
473+
style: TextStyle(fontSize: 11),
474+
),
475+
value: _themeControl._isRotating.value,
494476
onChanged: (value) {
495-
_themeControl.rotationSpeed = value;
477+
_themeControl.isRotating = value;
496478
},
497479
),
498-
],
499-
),
500-
),
501-
),
502-
SectionContent(
503-
child: Observer(
504-
builder: (context) => Column(
505-
crossAxisAlignment: CrossAxisAlignment.start,
506-
children: [
507-
Text(
508-
'Orbit Radius: ${_themeControl._orbitRadius.value.toStringAsFixed(0)}',
509-
style: const TextStyle(fontSize: 13),
480+
),
481+
const SizedBox(height: 12),
482+
Observer(
483+
builder: (context) => Column(
484+
crossAxisAlignment: CrossAxisAlignment.start,
485+
children: [
486+
Text(
487+
'Orbit Speed: ${_themeControl._rotationSpeed.value.toStringAsFixed(2)}',
488+
style: const TextStyle(fontSize: 13),
489+
),
490+
Slider(
491+
value: _themeControl._rotationSpeed.value,
492+
min: 0.1,
493+
max: 2.0,
494+
divisions: 19,
495+
label: _themeControl._rotationSpeed.value.toStringAsFixed(
496+
2,
497+
),
498+
onChanged: (value) {
499+
_themeControl.rotationSpeed = value;
500+
},
501+
),
502+
],
510503
),
511-
Slider(
512-
value: _themeControl._orbitRadius.value,
513-
min: 50,
514-
max: 400,
515-
divisions: 35,
516-
label: _themeControl._orbitRadius.value.toStringAsFixed(0),
517-
onChanged: (value) {
518-
_themeControl.orbitRadius = value;
519-
},
504+
),
505+
const SizedBox(height: 12),
506+
Observer(
507+
builder: (context) => Column(
508+
crossAxisAlignment: CrossAxisAlignment.start,
509+
children: [
510+
Text(
511+
'Orbit Radius: ${_themeControl._orbitRadius.value.toStringAsFixed(0)}',
512+
style: const TextStyle(fontSize: 13),
513+
),
514+
Slider(
515+
value: _themeControl._orbitRadius.value,
516+
min: 50,
517+
max: 400,
518+
divisions: 35,
519+
label: _themeControl._orbitRadius.value.toStringAsFixed(0),
520+
onChanged: (value) {
521+
_themeControl.orbitRadius = value;
522+
},
523+
),
524+
],
520525
),
521-
],
522-
),
526+
),
527+
],
523528
),
524529
),
525530
// Connection Style Section

packages/demo/lib/examples/shortcuts.dart

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -185,35 +185,37 @@ class _ShortcutsExampleState extends State<ShortcutsExample> {
185185
return [
186186
const SectionTitle('Shortcuts'),
187187
SectionContent(
188-
child: _buildShortcutCategory('Selection', [
189-
_buildShortcutRow('Cmd/Ctrl + A', 'Select all nodes'),
190-
_buildShortcutRow('Cmd/Ctrl + I', 'Invert selection'),
191-
_buildShortcutRow('Escape', 'Clear selection'),
192-
_buildShortcutRow('Shift + Drag', 'Multi-select'),
193-
]),
194-
),
195-
SectionContent(
196-
child: _buildShortcutCategory('Editing', [
197-
_buildShortcutRow('Delete/Backspace', 'Delete selected'),
198-
_buildShortcutRow('Cmd/Ctrl + D', 'Duplicate'),
199-
_buildShortcutRow('Cmd/Ctrl + C', 'Copy'),
200-
_buildShortcutRow('Cmd/Ctrl + V', 'Paste'),
201-
]),
202-
),
203-
SectionContent(
204-
child: _buildShortcutCategory('Navigation', [
205-
_buildShortcutRow('F', 'Fit to view'),
206-
_buildShortcutRow('H', 'Fit selected'),
207-
_buildShortcutRow('Cmd/Ctrl + 0', 'Reset zoom'),
208-
_buildShortcutRow('Cmd/Ctrl + =', 'Zoom in'),
209-
_buildShortcutRow('Cmd/Ctrl + -', 'Zoom out'),
210-
]),
211-
),
212-
SectionContent(
213-
child: _buildShortcutCategory('Custom', [
214-
_buildShortcutRow('Cmd/Ctrl + S', 'Save workflow', custom: true),
215-
_buildShortcutRow('Cmd/Ctrl + E', 'Export graph', custom: true),
216-
]),
188+
child: Column(
189+
crossAxisAlignment: CrossAxisAlignment.stretch,
190+
children: [
191+
_buildShortcutCategory('Selection', [
192+
_buildShortcutRow('Cmd/Ctrl + A', 'Select all nodes'),
193+
_buildShortcutRow('Cmd/Ctrl + I', 'Invert selection'),
194+
_buildShortcutRow('Escape', 'Clear selection'),
195+
_buildShortcutRow('Shift + Drag', 'Multi-select'),
196+
]),
197+
const SizedBox(height: 12),
198+
_buildShortcutCategory('Editing', [
199+
_buildShortcutRow('Delete/Backspace', 'Delete selected'),
200+
_buildShortcutRow('Cmd/Ctrl + D', 'Duplicate'),
201+
_buildShortcutRow('Cmd/Ctrl + C', 'Copy'),
202+
_buildShortcutRow('Cmd/Ctrl + V', 'Paste'),
203+
]),
204+
const SizedBox(height: 12),
205+
_buildShortcutCategory('Navigation', [
206+
_buildShortcutRow('F', 'Fit to view'),
207+
_buildShortcutRow('H', 'Fit selected'),
208+
_buildShortcutRow('Cmd/Ctrl + 0', 'Reset zoom'),
209+
_buildShortcutRow('Cmd/Ctrl + =', 'Zoom in'),
210+
_buildShortcutRow('Cmd/Ctrl + -', 'Zoom out'),
211+
]),
212+
const SizedBox(height: 12),
213+
_buildShortcutCategory('Custom', [
214+
_buildShortcutRow('Cmd/Ctrl + S', 'Save workflow', custom: true),
215+
_buildShortcutRow('Cmd/Ctrl + E', 'Export graph', custom: true),
216+
]),
217+
],
218+
),
217219
),
218220
const SectionTitle('Actions'),
219221
SectionContent(

0 commit comments

Comments
 (0)