pict-section-flow 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/source/Pict-Section-Flow.js +20 -14
- package/source/providers/PictProvider-Flow-Background.js +303 -0
- package/source/providers/PictProvider-Flow-CSS.js +73 -7
- package/source/providers/PictProvider-Flow-Geometry.js +11 -421
- package/source/providers/PictProvider-Flow-Icons.js +12 -0
- package/source/providers/PictProvider-Flow-Layouts.js +107 -0
- package/source/services/PictService-Flow-ConnectionRenderer.js +1 -1
- package/source/services/PictService-Flow-CursorManager.js +113 -0
- package/source/services/PictService-Flow-InteractionManager.js +439 -59
- package/source/services/PictService-Flow-Layout.js +21 -16
- package/source/services/PictService-Flow-PathGenerator.js +30 -417
- package/source/services/PictService-Flow-RenderManager.js +9 -1
- package/source/services/PictService-Flow-ViewportManager.js +102 -0
- package/source/views/PictView-Flow-FloatingToolbar.js +5 -1
- package/source/views/PictView-Flow-Node.js +29 -0
- package/source/views/PictView-Flow-Toolbar.js +50 -3
- package/source/views/PictView-Flow.js +591 -2
- package/.claude/launch.json +0 -11
- package/docs/.nojekyll +0 -0
- package/docs/Architecture.md +0 -163
- package/docs/Custom-Styling.md +0 -275
- package/docs/Data_Model.md +0 -149
- package/docs/Event_System.md +0 -156
- package/docs/Getting_Started.md +0 -237
- package/docs/Implementation_Reference.md +0 -528
- package/docs/Layout_Persistence.md +0 -117
- package/docs/README.md +0 -103
- package/docs/Theme_Integration.md +0 -150
- package/docs/_brand.json +0 -18
- package/docs/_cover.md +0 -17
- package/docs/_playground.json +0 -24
- package/docs/_sidebar.md +0 -57
- package/docs/_topbar.md +0 -8
- package/docs/_version.json +0 -7
- package/docs/api/PictFlowCard.md +0 -216
- package/docs/api/PictFlowCardPropertiesPanel.md +0 -235
- package/docs/api/addConnection.md +0 -101
- package/docs/api/addNode.md +0 -137
- package/docs/api/autoLayout.md +0 -77
- package/docs/api/getFlowData.md +0 -112
- package/docs/api/marshalToView.md +0 -95
- package/docs/api/openPanel.md +0 -128
- package/docs/api/registerHandler.md +0 -174
- package/docs/api/registerNodeType.md +0 -142
- package/docs/api/removeConnection.md +0 -57
- package/docs/api/removeNode.md +0 -80
- package/docs/api/saveLayout.md +0 -152
- package/docs/api/screenToSVGCoords.md +0 -68
- package/docs/api/selectNode.md +0 -116
- package/docs/api/setTheme.md +0 -168
- package/docs/api/setZoom.md +0 -97
- package/docs/api/toggleFullscreen.md +0 -68
- package/docs/card-help/EACH.md +0 -19
- package/docs/card-help/FREAD.md +0 -24
- package/docs/card-help/FWRITE.md +0 -24
- package/docs/card-help/GET.md +0 -22
- package/docs/card-help/ITE.md +0 -23
- package/docs/card-help/LOG.md +0 -23
- package/docs/card-help/NOTE.md +0 -17
- package/docs/card-help/PREV.md +0 -18
- package/docs/card-help/SET.md +0 -27
- package/docs/card-help/SPKL.md +0 -22
- package/docs/card-help/STAT.md +0 -23
- package/docs/card-help/SW.md +0 -25
- package/docs/diagrams/architecture-at-a-glance.excalidraw +0 -4270
- package/docs/diagrams/architecture-at-a-glance.mmd +0 -30
- package/docs/diagrams/architecture-at-a-glance.svg +0 -2
- package/docs/diagrams/data-flow.excalidraw +0 -1451
- package/docs/diagrams/data-flow.mmd +0 -17
- package/docs/diagrams/data-flow.svg +0 -2
- package/docs/diagrams/high-level-design.excalidraw +0 -5767
- package/docs/diagrams/high-level-design.mmd +0 -86
- package/docs/diagrams/high-level-design.svg +0 -2
- package/docs/diagrams/relationships.excalidraw +0 -3852
- package/docs/diagrams/relationships.mmd +0 -9
- package/docs/diagrams/relationships.svg +0 -2
- package/docs/diagrams/service-initialization-sequence.excalidraw +0 -1466
- package/docs/diagrams/service-initialization-sequence.mmd +0 -19
- package/docs/diagrams/service-initialization-sequence.svg +0 -2
- package/docs/diagrams/svg-layer-structure.excalidraw +0 -1060
- package/docs/diagrams/svg-layer-structure.mmd +0 -18
- package/docs/diagrams/svg-layer-structure.svg +0 -2
- package/docs/examples/README.md +0 -9
- package/docs/examples/simple_cards/README.md +0 -677
- package/docs/examples/simple_cards/css/flowexample.css +0 -65
- package/docs/examples/simple_cards/index.html +0 -32
- package/docs/examples/simple_cards/js/pict.min.js +0 -12
- package/docs/examples/simple_cards/pict-section-flow-example-simple-cards.compatible.min.js +0 -1
- package/docs/index.html +0 -38
- package/docs/playground/app.json +0 -6
- package/docs/playground/appdata.json +0 -85
- package/docs/playground/application.js +0 -23
- package/docs/playground/pict.json +0 -17
- package/docs/playground/runtime/pict-application.min.js +0 -2
- package/docs/playground/runtime/pict-section-flow.min.js +0 -2
- package/docs/playground/runtime/pict-section-modal.min.js +0 -2
- package/docs/playground/runtime/pict.min.js +0 -12
- package/docs/retold-catalog.json +0 -244
- package/docs/retold-keyword-index.json +0 -26028
- package/example_applications/simple_cards/css/flowexample.css +0 -65
- package/example_applications/simple_cards/html/index.html +0 -32
- package/example_applications/simple_cards/package.json +0 -52
- package/example_applications/simple_cards/source/Pict-Application-FlowExample-Configuration.json +0 -15
- package/example_applications/simple_cards/source/Pict-Application-FlowExample.js +0 -539
- package/example_applications/simple_cards/source/card-help-content.js +0 -16
- package/example_applications/simple_cards/source/cards/FlowCard-Comment.js +0 -38
- package/example_applications/simple_cards/source/cards/FlowCard-DataPreview.js +0 -44
- package/example_applications/simple_cards/source/cards/FlowCard-Each.js +0 -38
- package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +0 -56
- package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +0 -50
- package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +0 -37
- package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +0 -49
- package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +0 -55
- package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +0 -97
- package/example_applications/simple_cards/source/cards/FlowCard-Sparkline.js +0 -100
- package/example_applications/simple_cards/source/cards/FlowCard-StatusMonitor.js +0 -46
- package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +0 -39
- package/example_applications/simple_cards/source/providers/PictRouter-FlowExample-Configuration.json +0 -22
- package/example_applications/simple_cards/source/sample-flows.js +0 -410
- package/example_applications/simple_cards/source/views/PictView-FlowExample-About.js +0 -184
- package/example_applications/simple_cards/source/views/PictView-FlowExample-BottomBar.js +0 -77
- package/example_applications/simple_cards/source/views/PictView-FlowExample-Documentation.js +0 -325
- package/example_applications/simple_cards/source/views/PictView-FlowExample-FileWriteInfo.js +0 -59
- package/example_applications/simple_cards/source/views/PictView-FlowExample-Layout.js +0 -90
- package/example_applications/simple_cards/source/views/PictView-FlowExample-MainWorkspace.js +0 -453
- package/example_applications/simple_cards/source/views/PictView-FlowExample-TopBar.js +0 -95
- package/scripts/generate-card-help.js +0 -214
- package/source/providers/edges/Edge-Bezier.js +0 -41
- package/source/providers/edges/Edge-Orthogonal.js +0 -37
- package/source/providers/edges/Edge-OrthogonalSnap.js +0 -72
- package/source/providers/edges/Edge-Perimeter-Linear.js +0 -31
- package/source/providers/edges/Edge-Perimeter-Orthogonal.js +0 -39
- package/source/providers/edges/Edge-Perimeter.js +0 -48
- package/source/providers/edges/Edge-PerimeterMath.js +0 -92
- package/source/providers/edges/Edge-Straight.js +0 -24
- package/source/providers/layouts/Layout-Circular.js +0 -203
- package/source/providers/layouts/Layout-Coerce.js +0 -40
- package/source/providers/layouts/Layout-Columnar.js +0 -134
- package/source/providers/layouts/Layout-Custom.js +0 -27
- package/source/providers/layouts/Layout-ForcedFromCenter.js +0 -256
- package/source/providers/layouts/Layout-Grid.js +0 -134
- package/source/providers/layouts/Layout-Layered.js +0 -155
- package/source/providers/layouts/Layout-Rank.js +0 -141
- package/source/providers/layouts/Layout-Staggered.js +0 -131
- package/source/providers/layouts/Layout-Tabular.js +0 -94
- package/test/CardPalette_tests.js +0 -43
- package/test/ConnectionHandleManager_tests.js +0 -717
- package/test/ConnectionRenderer_tests.js +0 -591
- package/test/ConnectionStyle_tests.js +0 -90
- package/test/DataManager_tests.js +0 -859
- package/test/Geometry_tests.js +0 -767
- package/test/InteractionManager_tests.js +0 -279
- package/test/Layout_tests.js +0 -1604
- package/test/NodeView_tests.js +0 -66
- package/test/PanelManager_tests.js +0 -172
- package/test/PathGenerator_tests.js +0 -978
- package/test/PortRenderer_tests.js +0 -376
- package/test/RenderManager_tests.js +0 -756
- package/test/Renderer_tests.js +0 -133
- package/test/SelectionManager_tests.js +0 -185
- package/test/StylePresets_tests.js +0 -153
- package/test/ToolbarExtraButtons_tests.js +0 -138
- package/test/UndirectedConnections_tests.js +0 -70
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
const libFable = require('fable');
|
|
2
|
-
const libChai = require('chai');
|
|
3
|
-
const libExpect = libChai.expect;
|
|
4
|
-
|
|
5
|
-
const libInteractionManager = require('../source/services/PictService-Flow-InteractionManager.js');
|
|
6
|
-
const STATES = libInteractionManager.INTERACTION_STATES;
|
|
7
|
-
|
|
8
|
-
// A minimal FlowView stand-in: just the surface the node-resize path touches.
|
|
9
|
-
function makeMockFlowView(pNode)
|
|
10
|
-
{
|
|
11
|
-
let tmpFired = [];
|
|
12
|
-
return {
|
|
13
|
-
options: { EnableNodeResizing: true, MinimumNodeWidth: 48, MinimumNodeHeight: 32 },
|
|
14
|
-
viewState: { Zoom: 1 },
|
|
15
|
-
flowData: {},
|
|
16
|
-
_nodes: (function () { let m = {}; m[pNode.Hash] = pNode; return m; })(),
|
|
17
|
-
getNode: function (pHash) { return this._nodes[pHash] || null; },
|
|
18
|
-
renderFlow: function () { this._rendered = (this._rendered || 0) + 1; },
|
|
19
|
-
marshalFromView: function () { this._marshaled = (this._marshaled || 0) + 1; },
|
|
20
|
-
_EventHandlerProvider: { fireEvent: function (pName) { tmpFired.push(pName); } },
|
|
21
|
-
_firedEvents: tmpFired
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function makeTarget(pHash)
|
|
26
|
-
{
|
|
27
|
-
return { getAttribute: function (pAttr) { return (pAttr === 'data-node-hash') ? pHash : null; } };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function makeManager(pFable, pNode)
|
|
31
|
-
{
|
|
32
|
-
let tmpFV = makeMockFlowView(pNode);
|
|
33
|
-
let tmpIM = new libInteractionManager(pFable, { FlowView: tmpFV }, 'IM-Test');
|
|
34
|
-
// initialize() would set this from the real SVG element; stub the class-list surface.
|
|
35
|
-
tmpIM._SVGElement = { classList: { add: function () {}, remove: function () {} } };
|
|
36
|
-
return { im: tmpIM, fv: tmpFV };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
suite('PictService-Flow-InteractionManager',
|
|
40
|
-
function ()
|
|
41
|
-
{
|
|
42
|
-
let _Fable;
|
|
43
|
-
setup(function () { _Fable = new libFable({}); });
|
|
44
|
-
|
|
45
|
-
suite('node resize',
|
|
46
|
-
function ()
|
|
47
|
-
{
|
|
48
|
-
test('resizes from the start size by the pointer delta divided by zoom',
|
|
49
|
-
function ()
|
|
50
|
-
{
|
|
51
|
-
let tmpNode = { Hash: 'n1', X: 0, Y: 0, Width: 100, Height: 80 };
|
|
52
|
-
let tmp = makeManager(_Fable, tmpNode);
|
|
53
|
-
tmp.fv.viewState.Zoom = 2;
|
|
54
|
-
|
|
55
|
-
tmp.im._startNodeResize({ clientX: 200, clientY: 100, stopPropagation: function () {} }, makeTarget('n1'));
|
|
56
|
-
libExpect(tmp.im._State).to.equal(STATES.RESIZING_NODE);
|
|
57
|
-
|
|
58
|
-
// +100px / +40px at zoom 2 -> +50 / +20 world units
|
|
59
|
-
tmp.im._onNodeResize({ clientX: 300, clientY: 140 });
|
|
60
|
-
libExpect(tmpNode.Width).to.equal(150);
|
|
61
|
-
libExpect(tmpNode.Height).to.equal(100);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('clamps to the minimum size',
|
|
65
|
-
function ()
|
|
66
|
-
{
|
|
67
|
-
let tmpNode = { Hash: 'n1', Width: 100, Height: 80 };
|
|
68
|
-
let tmp = makeManager(_Fable, tmpNode);
|
|
69
|
-
|
|
70
|
-
tmp.im._startNodeResize({ clientX: 0, clientY: 0, stopPropagation: function () {} }, makeTarget('n1'));
|
|
71
|
-
tmp.im._onNodeResize({ clientX: -1000, clientY: -1000 });
|
|
72
|
-
libExpect(tmpNode.Width).to.equal(48);
|
|
73
|
-
libExpect(tmpNode.Height).to.equal(32);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('end fires onNodeResized + onFlowChanged, marshals, and returns to idle',
|
|
77
|
-
function ()
|
|
78
|
-
{
|
|
79
|
-
let tmpNode = { Hash: 'n1', Width: 100, Height: 80 };
|
|
80
|
-
let tmp = makeManager(_Fable, tmpNode);
|
|
81
|
-
|
|
82
|
-
tmp.im._startNodeResize({ clientX: 0, clientY: 0, stopPropagation: function () {} }, makeTarget('n1'));
|
|
83
|
-
tmp.im._endNodeResize({});
|
|
84
|
-
|
|
85
|
-
libExpect(tmp.fv._firedEvents).to.include('onNodeResized');
|
|
86
|
-
libExpect(tmp.fv._firedEvents).to.include('onFlowChanged');
|
|
87
|
-
libExpect(tmp.fv._marshaled).to.be.greaterThan(0);
|
|
88
|
-
libExpect(tmp.im._State).to.equal(STATES.IDLE);
|
|
89
|
-
libExpect(tmp.im._ResizeNodeHash).to.equal(null);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('does not start when EnableNodeResizing is off',
|
|
93
|
-
function ()
|
|
94
|
-
{
|
|
95
|
-
let tmpNode = { Hash: 'n1', Width: 100, Height: 80 };
|
|
96
|
-
let tmp = makeManager(_Fable, tmpNode);
|
|
97
|
-
tmp.fv.options.EnableNodeResizing = false;
|
|
98
|
-
|
|
99
|
-
tmp.im._startNodeResize({ clientX: 0, clientY: 0, stopPropagation: function () {} }, makeTarget('n1'));
|
|
100
|
-
libExpect(tmp.im._State).to.equal(STATES.IDLE);
|
|
101
|
-
libExpect(tmp.im._ResizeNodeHash).to.equal(null);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
suite('grid snap',
|
|
106
|
-
function ()
|
|
107
|
-
{
|
|
108
|
-
test('snaps a value to the grid when EnableGridSnap is on',
|
|
109
|
-
function ()
|
|
110
|
-
{
|
|
111
|
-
let tmp = makeManager(_Fable, { Hash: 'n1' });
|
|
112
|
-
tmp.fv.options.EnableGridSnap = true;
|
|
113
|
-
tmp.fv.options.GridSnapSize = 10;
|
|
114
|
-
libExpect(tmp.im._snapToGrid(37)).to.equal(40);
|
|
115
|
-
libExpect(tmp.im._snapToGrid(53)).to.equal(50);
|
|
116
|
-
libExpect(tmp.im._snapToGrid(45)).to.equal(50);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('passes the value through when EnableGridSnap is off',
|
|
120
|
-
function ()
|
|
121
|
-
{
|
|
122
|
-
let tmp = makeManager(_Fable, { Hash: 'n1' });
|
|
123
|
-
tmp.fv.options.EnableGridSnap = false;
|
|
124
|
-
libExpect(tmp.im._snapToGrid(37)).to.equal(37);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('passes through when the grid size is zero or missing',
|
|
128
|
-
function ()
|
|
129
|
-
{
|
|
130
|
-
let tmp = makeManager(_Fable, { Hash: 'n1' });
|
|
131
|
-
tmp.fv.options.EnableGridSnap = true;
|
|
132
|
-
tmp.fv.options.GridSnapSize = 0;
|
|
133
|
-
libExpect(tmp.im._snapToGrid(37)).to.equal(37);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// ---- Multi-select ----
|
|
138
|
-
|
|
139
|
-
function makeMultiMockFlowView(pNodes)
|
|
140
|
-
{
|
|
141
|
-
let tmpSelected = [];
|
|
142
|
-
let tmpCalls = { selectNodes: [], deselectAll: 0, updateNodePosition: [] };
|
|
143
|
-
let tmpViewportChildren = [];
|
|
144
|
-
return {
|
|
145
|
-
options: { EnableMultiSelect: true, EnableNodeDragging: true, DefaultNodeWidth: 180, DefaultNodeHeight: 80 },
|
|
146
|
-
viewState: { Zoom: 1 },
|
|
147
|
-
_FlowData: { Nodes: pNodes.slice() },
|
|
148
|
-
_ViewportElement: { appendChild: function (e) { tmpViewportChildren.push(e); }, removeChild: function (e) { tmpViewportChildren = tmpViewportChildren.filter((c) => c !== e); } },
|
|
149
|
-
_NodesLayer: { querySelector: function () { return { classList: { add: function () {}, remove: function () {} } }; } },
|
|
150
|
-
_nodes: (function () { let m = {}; pNodes.forEach((n) => { m[n.Hash] = n; }); return m; })(),
|
|
151
|
-
getNode: function (pHash) { return this._nodes[pHash] || null; },
|
|
152
|
-
// Identity coordinate mapping so screen deltas equal world deltas in the test.
|
|
153
|
-
screenToSVGCoords: function (pX, pY) { return { x: pX, y: pY }; },
|
|
154
|
-
getSelectedNodeHashes: function () { return tmpSelected.slice(); },
|
|
155
|
-
selectNode: function (pHash) { tmpSelected = pHash ? [pHash] : []; },
|
|
156
|
-
selectNodes: function (pHashes) { tmpSelected = pHashes.slice(); tmpCalls.selectNodes.push(pHashes.slice()); },
|
|
157
|
-
deselectAll: function () { tmpSelected = []; tmpCalls.deselectAll++; },
|
|
158
|
-
updateNodePosition: function (pHash, pX, pY) { let n = this._nodes[pHash]; if (n) { n.X = pX; n.Y = pY; } tmpCalls.updateNodePosition.push({ Hash: pHash, X: pX, Y: pY }); },
|
|
159
|
-
renderFlow: function () {},
|
|
160
|
-
marshalFromView: function () {},
|
|
161
|
-
_EventHandlerProvider: { fireEvent: function () {} },
|
|
162
|
-
_calls: tmpCalls,
|
|
163
|
-
_setSelected: function (pArr) { tmpSelected = pArr.slice(); }
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function makeMultiManager(pFable, pNodes)
|
|
168
|
-
{
|
|
169
|
-
let tmpFV = makeMultiMockFlowView(pNodes);
|
|
170
|
-
let tmpIM = new libInteractionManager(pFable, { FlowView: tmpFV }, 'IM-Multi-Test');
|
|
171
|
-
tmpIM._SVGElement = { classList: { add: function () {}, remove: function () {} } };
|
|
172
|
-
return { im: tmpIM, fv: tmpFV };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
suite('marquee selection',
|
|
176
|
-
function ()
|
|
177
|
-
{
|
|
178
|
-
let _MNodes;
|
|
179
|
-
let _SavedDocument;
|
|
180
|
-
setup(function ()
|
|
181
|
-
{
|
|
182
|
-
_MNodes = [ { Hash: 'n1', X: 0, Y: 0, Width: 100, Height: 80 }, { Hash: 'n2', X: 200, Y: 0, Width: 100, Height: 80 }, { Hash: 'n3', X: 400, Y: 0, Width: 100, Height: 80 } ];
|
|
183
|
-
// The marquee draws a real SVG <rect>; stub the DOM factory for the headless test, restore after.
|
|
184
|
-
_SavedDocument = global.document;
|
|
185
|
-
global.document = { createElementNS: function () { let tmpEl = { setAttribute: function (pK, pV) { tmpEl[pK] = pV; } }; return tmpEl; } };
|
|
186
|
-
});
|
|
187
|
-
teardown(function () { global.document = _SavedDocument; });
|
|
188
|
-
|
|
189
|
-
test('a drag selects every node whose box intersects the rectangle',
|
|
190
|
-
function ()
|
|
191
|
-
{
|
|
192
|
-
let tmp = makeMultiManager(_Fable, _MNodes);
|
|
193
|
-
tmp.im._startMarquee({ clientX: 0, clientY: 0 });
|
|
194
|
-
libExpect(tmp.im._State).to.equal(STATES.MARQUEE);
|
|
195
|
-
tmp.im._onMarquee({ clientX: 250, clientY: 100 });
|
|
196
|
-
tmp.im._endMarquee({ clientX: 250, clientY: 100 });
|
|
197
|
-
libExpect(tmp.fv._calls.selectNodes.length).to.equal(1);
|
|
198
|
-
libExpect(tmp.fv._calls.selectNodes[0]).to.deep.equal(['n1', 'n2']);
|
|
199
|
-
libExpect(tmp.im._State).to.equal(STATES.IDLE);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test('a tiny rectangle (a click) clears the selection instead of selecting',
|
|
203
|
-
function ()
|
|
204
|
-
{
|
|
205
|
-
let tmp = makeMultiManager(_Fable, _MNodes);
|
|
206
|
-
tmp.im._startMarquee({ clientX: 10, clientY: 10 });
|
|
207
|
-
tmp.im._onMarquee({ clientX: 12, clientY: 11 });
|
|
208
|
-
tmp.im._endMarquee({ clientX: 12, clientY: 11 });
|
|
209
|
-
libExpect(tmp.fv._calls.deselectAll).to.equal(1);
|
|
210
|
-
libExpect(tmp.fv._calls.selectNodes.length).to.equal(0);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
suite('multi-drag',
|
|
215
|
-
function ()
|
|
216
|
-
{
|
|
217
|
-
let _MNodes;
|
|
218
|
-
setup(function () { _MNodes = [ { Hash: 'n1', X: 0, Y: 0, Width: 100, Height: 80 }, { Hash: 'n2', X: 200, Y: 50, Width: 100, Height: 80 } ]; });
|
|
219
|
-
|
|
220
|
-
test('dragging a node in the selection moves every selected node by the same delta',
|
|
221
|
-
function ()
|
|
222
|
-
{
|
|
223
|
-
let tmp = makeMultiManager(_Fable, _MNodes);
|
|
224
|
-
tmp.fv._setSelected(['n1', 'n2']);
|
|
225
|
-
tmp.im._startNodeDrag({ clientX: 0, clientY: 0 }, makeTarget('n1'));
|
|
226
|
-
libExpect(tmp.im._State).to.equal(STATES.DRAGGING_NODE);
|
|
227
|
-
libExpect(tmp.im._DragNodes.length).to.equal(2);
|
|
228
|
-
|
|
229
|
-
tmp.im._onNodeDrag({ clientX: 30, clientY: 20 });
|
|
230
|
-
libExpect(_MNodes[0].X).to.equal(30);
|
|
231
|
-
libExpect(_MNodes[0].Y).to.equal(20);
|
|
232
|
-
libExpect(_MNodes[1].X).to.equal(230);
|
|
233
|
-
libExpect(_MNodes[1].Y).to.equal(70);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('dragging a node outside the selection collapses to just that node',
|
|
237
|
-
function ()
|
|
238
|
-
{
|
|
239
|
-
let tmp = makeMultiManager(_Fable, _MNodes);
|
|
240
|
-
tmp.fv._setSelected(['n2']);
|
|
241
|
-
tmp.im._startNodeDrag({ clientX: 0, clientY: 0 }, makeTarget('n1'));
|
|
242
|
-
libExpect(tmp.im._DragNodes.length).to.equal(1);
|
|
243
|
-
libExpect(tmp.im._DragNodes[0].Hash).to.equal('n1');
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
suite('alignment guides',
|
|
248
|
-
function ()
|
|
249
|
-
{
|
|
250
|
-
test('snaps the dragged node so a near edge lines up, and reports guides',
|
|
251
|
-
function ()
|
|
252
|
-
{
|
|
253
|
-
let tmpNodes = [ { Hash: 'drag', X: 0, Y: 0, Width: 100, Height: 80 }, { Hash: 'other', X: 200, Y: 0, Width: 100, Height: 80 } ];
|
|
254
|
-
let tmp = makeMultiManager(_Fable, tmpNodes);
|
|
255
|
-
let tmpDrag = tmpNodes[0];
|
|
256
|
-
// Move the dragged node so its left edge (197) is 3px from the other node's left (200).
|
|
257
|
-
let tmpResult = tmp.im._alignmentFor(tmpDrag, 197, 0);
|
|
258
|
-
libExpect(tmpResult.X).to.equal(200); // snapped to align left edges
|
|
259
|
-
libExpect(tmpResult.Y).to.equal(0); // tops already aligned
|
|
260
|
-
let tmpVGuide = tmpResult.Guides.find(function (g) { return g.Type === 'v'; });
|
|
261
|
-
let tmpHGuide = tmpResult.Guides.find(function (g) { return g.Type === 'h'; });
|
|
262
|
-
libExpect(tmpVGuide).to.be.an('object');
|
|
263
|
-
libExpect(tmpVGuide.Pos).to.equal(200);
|
|
264
|
-
libExpect(tmpHGuide).to.be.an('object');
|
|
265
|
-
libExpect(tmpHGuide.Pos).to.equal(0);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
test('no snap or guides when nothing is within the threshold',
|
|
269
|
-
function ()
|
|
270
|
-
{
|
|
271
|
-
let tmpNodes = [ { Hash: 'drag', X: 0, Y: 0, Width: 100, Height: 80 }, { Hash: 'other', X: 200, Y: 0, Width: 100, Height: 80 } ];
|
|
272
|
-
let tmp = makeMultiManager(_Fable, tmpNodes);
|
|
273
|
-
let tmpResult = tmp.im._alignmentFor(tmpNodes[0], 500, 500);
|
|
274
|
-
libExpect(tmpResult.X).to.equal(500);
|
|
275
|
-
libExpect(tmpResult.Y).to.equal(500);
|
|
276
|
-
libExpect(tmpResult.Guides.length).to.equal(0);
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
});
|