@eclipse-glsp/client 1.0.0 → 1.1.0-RC02
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/lib/base/types.d.ts +2 -0
- package/lib/base/types.d.ts.map +1 -1
- package/lib/features/export/glsp-svg-exporter.d.ts +22 -0
- package/lib/features/export/glsp-svg-exporter.d.ts.map +1 -0
- package/lib/features/export/glsp-svg-exporter.js +45 -0
- package/lib/features/export/glsp-svg-exporter.js.map +1 -0
- package/lib/features/layout/di.config.d.ts.map +1 -1
- package/lib/features/layout/di.config.js +2 -0
- package/lib/features/layout/di.config.js.map +1 -1
- package/lib/features/layout/hbox-layout.d.ts +1 -1
- package/lib/features/layout/hbox-layout.d.ts.map +1 -1
- package/lib/features/layout/hbox-layout.js +19 -7
- package/lib/features/layout/hbox-layout.js.map +1 -1
- package/lib/features/layout/layouter.d.ts +37 -0
- package/lib/features/layout/layouter.d.ts.map +1 -0
- package/lib/features/layout/layouter.js +131 -0
- package/lib/features/layout/layouter.js.map +1 -0
- package/lib/features/layout/tests/freeform-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/freeform-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/freeform-layout.spec.js +201 -0
- package/lib/features/layout/tests/freeform-layout.spec.js.map +1 -0
- package/lib/features/layout/tests/hbox-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/hbox-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/hbox-layout.spec.js +161 -0
- package/lib/features/layout/tests/hbox-layout.spec.js.map +1 -0
- package/lib/features/layout/tests/layouter-test-util.d.ts +34 -0
- package/lib/features/layout/tests/layouter-test-util.d.ts.map +1 -0
- package/lib/features/layout/tests/layouter-test-util.js +96 -0
- package/lib/features/layout/tests/layouter-test-util.js.map +1 -0
- package/lib/features/layout/tests/vbox-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/vbox-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/vbox-layout.spec.js +161 -0
- package/lib/features/layout/tests/vbox-layout.spec.js.map +1 -0
- package/lib/features/layout/vbox-layout.d.ts +1 -1
- package/lib/features/layout/vbox-layout.d.ts.map +1 -1
- package/lib/features/layout/vbox-layout.js +17 -5
- package/lib/features/layout/vbox-layout.js.map +1 -1
- package/lib/features/tools/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds-tool.js +13 -10
- package/lib/features/tools/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/di.config.d.ts.map +1 -1
- package/lib/features/tools/di.config.js +4 -1
- package/lib/features/tools/di.config.js.map +1 -1
- package/lib/features/tools/edge-edit-tool.d.ts +2 -2
- package/lib/features/tools/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit-tool.js +3 -2
- package/lib/features/tools/edge-edit-tool.js.map +1 -1
- package/lib/sprotty-reexport.d.ts +1 -1
- package/lib/sprotty-reexport.d.ts.map +1 -1
- package/lib/sprotty-reexport.js +6 -4
- package/lib/sprotty-reexport.js.map +1 -1
- package/lib/utils/smodel-util.d.ts +11 -2
- package/lib/utils/smodel-util.d.ts.map +1 -1
- package/lib/utils/smodel-util.js +17 -2
- package/lib/utils/smodel-util.js.map +1 -1
- package/lib/views/glsp-projection-view.d.ts.map +1 -1
- package/lib/views/glsp-projection-view.js +8 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +6 -5
- package/src/features/export/glsp-svg-exporter.ts +50 -0
- package/src/features/layout/di.config.ts +3 -1
- package/src/features/layout/hbox-layout.ts +24 -7
- package/src/features/layout/layouter.ts +137 -0
- package/src/features/layout/tests/freeform-layout.spec.ts +216 -0
- package/src/features/layout/tests/hbox-layout.spec.ts +171 -0
- package/src/features/layout/tests/layouter-test-util.ts +122 -0
- package/src/features/layout/tests/vbox-layout.spec.ts +171 -0
- package/src/features/layout/vbox-layout.ts +22 -5
- package/src/features/tools/change-bounds-tool.ts +16 -13
- package/src/features/tools/di.config.ts +5 -1
- package/src/features/tools/edge-edit-tool.ts +5 -6
- package/src/sprotty-reexport.ts +6 -1
- package/src/utils/smodel-util.ts +20 -1
- package/src/views/glsp-projection-view.tsx +10 -3
package/lib/base/types.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const TYPES: {
|
|
|
28
28
|
IAnchorComputer: symbol;
|
|
29
29
|
AnimationFrameSyncer: symbol;
|
|
30
30
|
IButtonHandler: symbol;
|
|
31
|
+
IButtonHandlerRegistration: symbol;
|
|
31
32
|
ICommandPaletteActionProvider: symbol;
|
|
32
33
|
ICommandPaletteActionProviderRegistry: symbol;
|
|
33
34
|
CommandRegistration: symbol;
|
|
@@ -110,6 +111,7 @@ export declare const GLSP_TYPES: {
|
|
|
110
111
|
IAnchorComputer: symbol;
|
|
111
112
|
AnimationFrameSyncer: symbol;
|
|
112
113
|
IButtonHandler: symbol;
|
|
114
|
+
IButtonHandlerRegistration: symbol;
|
|
113
115
|
ICommandPaletteActionProvider: symbol;
|
|
114
116
|
ICommandPaletteActionProviderRegistry: symbol;
|
|
115
117
|
CommandRegistration: symbol;
|
package/lib/base/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,eAAO,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAQ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { RequestAction } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { ExportSvgAction, SModelRoot, SvgExporter } from 'sprotty';
|
|
18
|
+
export declare class GLSPSvgExporter extends SvgExporter {
|
|
19
|
+
export(root: SModelRoot, _request?: RequestAction<ExportSvgAction>): void;
|
|
20
|
+
protected findSvgElement(): SVGSVGElement | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=glsp-svg-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-svg-exporter.d.ts","sourceRoot":"","sources":["../../../src/features/export/glsp-svg-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGlE,qBACa,eAAgB,SAAQ,WAAW;IACpC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,IAAI;IAsBlF,SAAS,CAAC,cAAc,IAAI,aAAa,GAAG,IAAI;CAKlD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GLSPSvgExporter = void 0;
|
|
10
|
+
const inversify_1 = require("inversify");
|
|
11
|
+
const sprotty_1 = require("sprotty");
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
13
|
+
let GLSPSvgExporter = class GLSPSvgExporter extends sprotty_1.SvgExporter {
|
|
14
|
+
export(root, _request) {
|
|
15
|
+
if (typeof document !== 'undefined') {
|
|
16
|
+
const svgElement = this.findSvgElement();
|
|
17
|
+
if (svgElement) {
|
|
18
|
+
// createSvg requires the svg to have a non-empty id, so we generate one if necessary
|
|
19
|
+
const originalId = svgElement.id;
|
|
20
|
+
try {
|
|
21
|
+
svgElement.id = originalId || (0, uuid_1.v4)();
|
|
22
|
+
// provide generated svg code with respective sizing for proper viewing in browser and remove undesired border
|
|
23
|
+
const bounds = this.getBounds(root);
|
|
24
|
+
const svg = this.createSvg(svgElement, root)
|
|
25
|
+
.replace('style="', `style="width: ${bounds.width}px !important;height: ${bounds.height}px !important;border: none !important;`);
|
|
26
|
+
// do not give request/response id here as otherwise the action is treated as an unrequested response
|
|
27
|
+
this.actionDispatcher.dispatch(sprotty_1.ExportSvgAction.create(svg, ''));
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
svgElement.id = originalId;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
findSvgElement() {
|
|
36
|
+
const div = document.getElementById(this.options.hiddenDiv);
|
|
37
|
+
// search for first svg element as hierarchy within Sprotty might change
|
|
38
|
+
return div && div.querySelector('svg');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
GLSPSvgExporter = __decorate([
|
|
42
|
+
(0, inversify_1.injectable)()
|
|
43
|
+
], GLSPSvgExporter);
|
|
44
|
+
exports.GLSPSvgExporter = GLSPSvgExporter;
|
|
45
|
+
//# sourceMappingURL=glsp-svg-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-svg-exporter.js","sourceRoot":"","sources":["../../../src/features/export/glsp-svg-exporter.ts"],"names":[],"mappings":";;;;;;;;;AAgBA,yCAAuC;AACvC,qCAAmE;AACnE,+BAAkC;AAGjC,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,qBAAW;IACpC,MAAM,CAAC,IAAgB,EAAE,QAAyC;QACvE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YACzC,IAAI,UAAU,EAAE;gBACZ,qFAAqF;gBACrF,MAAM,UAAU,GAAG,UAAU,CAAC,EAAE,CAAC;gBACjC,IAAI;oBACA,UAAU,CAAC,EAAE,GAAG,UAAU,IAAI,IAAA,SAAI,GAAE,CAAC;oBACrC,8GAA8G;oBAC9G,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBACpC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC;yBACvC,OAAO,CAAC,SAAS,EACd,iBAAiB,MAAM,CAAC,KAAK,yBAAyB,MAAM,CAAC,MAAM,wCAAwC,CAAC,CAAC;oBACrH,qGAAqG;oBACrG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,yBAAe,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;iBACnE;wBAAS;oBACN,UAAU,CAAC,EAAE,GAAG,UAAU,CAAC;iBAC9B;aACJ;SACJ;IACL,CAAC;IAES,cAAc;QACpB,MAAM,GAAG,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5D,wEAAwE;QACxE,OAAO,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACH,CAAA;AA5BY,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CA4B3B;AA5BY,0CAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../../../src/features/layout/di.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../../../src/features/layout/di.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAa5C,QAAA,MAAM,YAAY,iBAShB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -20,6 +20,7 @@ const sprotty_1 = require("sprotty");
|
|
|
20
20
|
const freeform_layout_1 = require("./freeform-layout");
|
|
21
21
|
const hbox_layout_1 = require("./hbox-layout");
|
|
22
22
|
const layout_elements_action_1 = require("./layout-elements-action");
|
|
23
|
+
const layouter_1 = require("./layouter");
|
|
23
24
|
const vbox_layout_1 = require("./vbox-layout");
|
|
24
25
|
const layoutModule = new inversify_1.ContainerModule((bind, _unbind, isBound, rebind) => {
|
|
25
26
|
const context = { bind, isBound };
|
|
@@ -27,6 +28,7 @@ const layoutModule = new inversify_1.ContainerModule((bind, _unbind, isBound, re
|
|
|
27
28
|
(0, sprotty_1.configureActionHandler)(context, layout_elements_action_1.AlignElementsAction.KIND, layout_elements_action_1.AlignElementsActionHandler);
|
|
28
29
|
rebind(sprotty_1.VBoxLayouter).to(vbox_layout_1.VBoxLayouterExt);
|
|
29
30
|
rebind(sprotty_1.HBoxLayouter).to(hbox_layout_1.HBoxLayouterExt);
|
|
31
|
+
rebind(sprotty_1.TYPES.Layouter).to(layouter_1.LayouterExt);
|
|
30
32
|
(0, sprotty_1.configureLayout)({ bind, isBound }, freeform_layout_1.FreeFormLayouter.KIND, freeform_layout_1.FreeFormLayouter);
|
|
31
33
|
});
|
|
32
34
|
exports.default = layoutModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../../../src/features/layout/di.config.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../../../src/features/layout/di.config.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA4C;AAC5C,qCAAqG;AACrG,uDAAqD;AACrD,+CAAgD;AAChD,qEAKkC;AAClC,yCAAyC;AACzC,+CAAgD;AAEhD,MAAM,YAAY,GAAG,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IACxE,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAClC,IAAA,gCAAsB,EAAC,OAAO,EAAE,6CAAoB,CAAC,IAAI,EAAE,oDAA2B,CAAC,CAAC;IACxF,IAAA,gCAAsB,EAAC,OAAO,EAAE,4CAAmB,CAAC,IAAI,EAAE,mDAA0B,CAAC,CAAC;IAEtF,MAAM,CAAC,sBAAY,CAAC,CAAC,EAAE,CAAC,6BAAe,CAAC,CAAC;IACzC,MAAM,CAAC,sBAAY,CAAC,CAAC,EAAE,CAAC,6BAAe,CAAC,CAAC;IACzC,MAAM,CAAC,eAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,sBAAW,CAAC,CAAC;IACvC,IAAA,yBAAe,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kCAAgB,CAAC,IAAI,EAAE,kCAAgB,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC"}
|
|
@@ -36,6 +36,6 @@ export declare class HBoxLayouterExt extends HBoxLayouter {
|
|
|
36
36
|
protected getElementLayoutOptions(element: SModelElement): HBoxLayoutOptionsExt | undefined;
|
|
37
37
|
protected getFinalContainerBounds(container: SParentElement & LayoutContainer, lastOffset: Point, options: HBoxLayoutOptionsExt, maxWidth: number, maxHeight: number): Bounds;
|
|
38
38
|
protected getDefaultLayoutOptions(): HBoxLayoutOptionsExt;
|
|
39
|
-
protected
|
|
39
|
+
protected filterContainerOptions(containerOptions: HBoxLayoutOptionsExt): HBoxLayoutOptionsExt;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=hbox-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hbox-layout.d.ts","sourceRoot":"","sources":["../../../src/features/layout/hbox-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EACH,UAAU,EAGV,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,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A8BW,WAAW,CAC1B,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,oBAAoB,EAClC,gBAAgB,EAAE,oBAAoB,EACtC,aAAa,EAAE,KAAK,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,MAAM,GAC1B,KAAK;cAgCW,uBAAuB,CACtC,SAAS,EAAE,aAAa,EACxB,aAAa,EAAE,oBAAoB,EACnC,QAAQ,EAAE,gBAAgB,GAC3B,MAAM;cAaU,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,GAAG,oBAAoB;cAIzG,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,oBAAoB;IAIjF,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,oBAAoB,GAAG,SAAS;cAIxE,uBAAuB,CACtC,SAAS,EAAE,cAAc,GAAG,eAAe,EAC3C,UAAU,EAAE,KAAK,EACjB,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB,MAAM;cAeU,uBAAuB,IAAI,oBAAoB;IAqBlE,SAAS,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,oBAAoB,GAAG,oBAAoB;CAOjG"}
|
|
@@ -30,10 +30,13 @@ const sprotty_1 = require("sprotty");
|
|
|
30
30
|
*/
|
|
31
31
|
let HBoxLayouterExt = class HBoxLayouterExt extends sprotty_1.HBoxLayouter {
|
|
32
32
|
layout(container, layouter) {
|
|
33
|
+
var _a, _b;
|
|
33
34
|
const boundsData = layouter.getBoundsData(container);
|
|
34
35
|
const options = this.getLayoutOptions(container);
|
|
35
36
|
const childrenSize = this.getChildrenSize(container, options, layouter);
|
|
36
37
|
const fixedSize = this.getFixedContainerBounds(container, options, layouter);
|
|
38
|
+
const currentWidth = boundsData.bounds ? ((_a = boundsData.bounds) === null || _a === void 0 ? void 0 : _a.width) - options.paddingLeft - options.paddingRight : 0;
|
|
39
|
+
const currentHeight = boundsData.bounds ? ((_b = boundsData.bounds) === null || _b === void 0 ? void 0 : _b.height) - options.paddingTop - options.paddingBottom : 0;
|
|
37
40
|
const maxWidth = options.paddingFactor *
|
|
38
41
|
(options.resizeContainer
|
|
39
42
|
? Math.max(fixedSize.width - options.paddingLeft - options.paddingRight, childrenSize.width)
|
|
@@ -42,16 +45,18 @@ let HBoxLayouterExt = class HBoxLayouterExt extends sprotty_1.HBoxLayouter {
|
|
|
42
45
|
(options.resizeContainer
|
|
43
46
|
? Math.max(fixedSize.height - options.paddingTop - options.paddingBottom, childrenSize.height)
|
|
44
47
|
: Math.max(0, fixedSize.height - options.paddingTop - options.paddingBottom));
|
|
48
|
+
const width = Math.max(currentWidth, maxWidth);
|
|
49
|
+
const height = Math.max(currentHeight, maxHeight);
|
|
45
50
|
// Remaining size that can be grabbed by children with the hGrab option
|
|
46
|
-
const grabWidth =
|
|
51
|
+
const grabWidth = width - childrenSize.width;
|
|
47
52
|
// Number of children that request hGrab
|
|
48
53
|
// FIXME: This approach works fine when only 1 child uses HGrab, but may cause rounding issues
|
|
49
54
|
// when the grabHeight can't be equally shared by all children.
|
|
50
55
|
const grabbingChildren = container.children
|
|
51
56
|
.map(child => this.getChildLayoutOptions(child, options))
|
|
52
57
|
.filter(opt => opt.hGrab).length;
|
|
53
|
-
if (
|
|
54
|
-
const offset = this.layoutChildren(container, layouter, options,
|
|
58
|
+
if (width > 0 && height > 0) {
|
|
59
|
+
const offset = this.layoutChildren(container, layouter, options, width, height, grabWidth, grabbingChildren);
|
|
55
60
|
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, childrenSize.width, childrenSize.height);
|
|
56
61
|
boundsData.boundsChanged = true;
|
|
57
62
|
}
|
|
@@ -99,8 +104,11 @@ let HBoxLayouterExt = class HBoxLayouterExt extends sprotty_1.HBoxLayouter {
|
|
|
99
104
|
return currentOffset;
|
|
100
105
|
}
|
|
101
106
|
layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight, grabWidth, grabbingChildren) {
|
|
107
|
+
const vAlign = childOptions.vGrab ? 'top' : childOptions.vAlign;
|
|
108
|
+
const dy = this.getDy(vAlign, bounds, maxHeight);
|
|
102
109
|
let offset = super.layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight);
|
|
103
|
-
|
|
110
|
+
boundsData.bounds = Object.assign(Object.assign({}, boundsData.bounds), { x: currentOffset.x, y: currentOffset.y + dy });
|
|
111
|
+
if (childOptions.vGrab) {
|
|
104
112
|
boundsData.bounds = {
|
|
105
113
|
x: boundsData.bounds.x,
|
|
106
114
|
y: boundsData.bounds.y,
|
|
@@ -136,7 +144,7 @@ let HBoxLayouterExt = class HBoxLayouterExt extends sprotty_1.HBoxLayouter {
|
|
|
136
144
|
return protocol_1.Bounds.EMPTY;
|
|
137
145
|
}
|
|
138
146
|
getChildLayoutOptions(child, containerOptions) {
|
|
139
|
-
return super.getChildLayoutOptions(child, containerOptions);
|
|
147
|
+
return super.getChildLayoutOptions(child, this.filterContainerOptions(containerOptions));
|
|
140
148
|
}
|
|
141
149
|
getLayoutOptions(element) {
|
|
142
150
|
return super.getLayoutOptions(element);
|
|
@@ -177,8 +185,12 @@ let HBoxLayouterExt = class HBoxLayouterExt extends sprotty_1.HBoxLayouter {
|
|
|
177
185
|
prefWidth: null
|
|
178
186
|
};
|
|
179
187
|
}
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
filterContainerOptions(containerOptions) {
|
|
189
|
+
// Reset object-specific layout options to default before merging,
|
|
190
|
+
// to make sure they won't be inherited (grab, prefSize)
|
|
191
|
+
// eslint-disable-next-line no-null/no-null
|
|
192
|
+
const localOptions = { vGrab: false, hGrab: false, prefHeight: null, prefWidth: null };
|
|
193
|
+
return Object.assign(Object.assign({}, containerOptions), localOptions);
|
|
182
194
|
}
|
|
183
195
|
};
|
|
184
196
|
HBoxLayouterExt.KIND = sprotty_1.HBoxLayouter.KIND;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hbox-layout.js","sourceRoot":"","sources":["../../../src/features/layout/hbox-layout.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAAkE;AAClE,yCAAuC;AACvC,qCAWiB;AASjB;;GAEG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,sBAAY;IAGpC,MAAM,CAAC,SAA2C,EAAE,QAA0B
|
|
1
|
+
{"version":3,"file":"hbox-layout.js","sourceRoot":"","sources":["../../../src/features/layout/hbox-layout.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAAkE;AAClE,yCAAuC;AACvC,qCAWiB;AASjB;;GAEG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,sBAAY;IAGpC,MAAM,CAAC,SAA2C,EAAE,QAA0B;;QACnF,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAExE,MAAM,SAAS,GAAG,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAE7E,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA,MAAA,UAAU,CAAC,MAAM,0CAAE,KAAK,IAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACnH,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA,MAA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,EAAE,CAAC;QACvF,uCAAY,gBAAgB,GAAK,YAAY,EAAG;IACpD,CAAC;CACJ,CAAA;AAtOmB,oBAAI,GAAG,sBAAY,CAAC,IAAK,CAAA;AADhC,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CAuO3B;AAvOY,0CAAe"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { BoundsData, ILogger, LayoutRegistry, StatefulLayouter, SModelElement, Layouter, SParentElement, LayoutContainer } from 'sprotty';
|
|
17
|
+
import { Bounds } from 'sprotty-protocol/lib/utils/geometry';
|
|
18
|
+
export declare class LayouterExt extends Layouter {
|
|
19
|
+
layout(element2boundsData: Map<SModelElement, BoundsData>): void;
|
|
20
|
+
}
|
|
21
|
+
export declare class StatefulLayouterExt extends StatefulLayouter {
|
|
22
|
+
protected readonly elementToBoundsData: Map<SModelElement, BoundsData>;
|
|
23
|
+
protected readonly layoutRegistry2: LayoutRegistry;
|
|
24
|
+
protected toBeLayouted2: (SParentElement & LayoutContainer)[];
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param elementToBoundsData The map of element to bounds data. Bounds Data are computed from the hidden
|
|
28
|
+
* SVG rendering pass.
|
|
29
|
+
* @param layoutRegistry2 The registry of available layouts.
|
|
30
|
+
* @param log The log.
|
|
31
|
+
*/
|
|
32
|
+
constructor(elementToBoundsData: Map<SModelElement, BoundsData>, layoutRegistry2: LayoutRegistry, log: ILogger);
|
|
33
|
+
getBoundsData(element: SModelElement): BoundsData;
|
|
34
|
+
layout(): void;
|
|
35
|
+
protected doLayout(element: SParentElement & LayoutContainer): Bounds;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=layouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layouter.d.ts","sourceRoot":"","sources":["../../../src/features/layout/layouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,UAAU,EACV,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,eAAe,EAElB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,qBACa,WAAY,SAAQ,QAAQ;IAC5B,MAAM,CAAC,kBAAkB,EAAE,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,IAAI;CAG5E;AASD,qBAAa,mBAAoB,SAAQ,gBAAgB;IAWjD,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC;IACtE,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,cAAc;IAXtD,SAAS,CAAC,aAAa,EAAE,CAAC,cAAc,GAAG,eAAe,CAAC,EAAE,CAAC;IAE9D;;;;;;OAMG;gBAEoB,mBAAmB,EAAE,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,EACnD,eAAe,EAAE,cAAc,EAClD,GAAG,EAAE,OAAO;IAeP,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,UAAU;IAwBjD,MAAM,IAAI,IAAI;cAwBJ,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,eAAe,GAAG,MAAM;CAiBjF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.StatefulLayouterExt = exports.LayouterExt = void 0;
|
|
10
|
+
/********************************************************************************
|
|
11
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
12
|
+
*
|
|
13
|
+
* This program and the accompanying materials are made available under the
|
|
14
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
15
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
16
|
+
*
|
|
17
|
+
* This Source Code may also be made available under the following Secondary
|
|
18
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
19
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
20
|
+
* with the GNU Classpath Exception which is available at
|
|
21
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
24
|
+
********************************************************************************/
|
|
25
|
+
const sprotty_1 = require("sprotty");
|
|
26
|
+
const inversify_1 = require("inversify");
|
|
27
|
+
const geometry_1 = require("sprotty-protocol/lib/utils/geometry");
|
|
28
|
+
let LayouterExt = class LayouterExt extends sprotty_1.Layouter {
|
|
29
|
+
layout(element2boundsData) {
|
|
30
|
+
new StatefulLayouterExt(element2boundsData, this.layoutRegistry, this.logger).layout();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
LayouterExt = __decorate([
|
|
34
|
+
(0, inversify_1.injectable)()
|
|
35
|
+
], LayouterExt);
|
|
36
|
+
exports.LayouterExt = LayouterExt;
|
|
37
|
+
// 2-pass layout:
|
|
38
|
+
// Step 1: Find "rendered size" of each element (may take resizeContainer into account)
|
|
39
|
+
// Child-to-parent layout
|
|
40
|
+
// Step 2: Extend parents as necessary, then use the adjusted parent size to properly
|
|
41
|
+
// align children (center/end alignments, hGrab/vGrab)
|
|
42
|
+
// Parent-to-children layout
|
|
43
|
+
class StatefulLayouterExt extends sprotty_1.StatefulLayouter {
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param elementToBoundsData The map of element to bounds data. Bounds Data are computed from the hidden
|
|
47
|
+
* SVG rendering pass.
|
|
48
|
+
* @param layoutRegistry2 The registry of available layouts.
|
|
49
|
+
* @param log The log.
|
|
50
|
+
*/
|
|
51
|
+
constructor(elementToBoundsData, layoutRegistry2, log) {
|
|
52
|
+
super(elementToBoundsData, layoutRegistry2, log);
|
|
53
|
+
this.elementToBoundsData = elementToBoundsData;
|
|
54
|
+
this.layoutRegistry2 = layoutRegistry2;
|
|
55
|
+
this.toBeLayouted2 = [];
|
|
56
|
+
elementToBoundsData.forEach((data, element) => {
|
|
57
|
+
if ((0, sprotty_1.isLayoutContainer)(element)) {
|
|
58
|
+
this.toBeLayouted2.push(element);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
for (const element of this.toBeLayouted2) {
|
|
62
|
+
// Clear previous layout information for dynamic-layout objects
|
|
63
|
+
elementToBoundsData.delete(element);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getBoundsData(element) {
|
|
67
|
+
let boundsData = this.elementToBoundsData.get(element);
|
|
68
|
+
let bounds = element.bounds;
|
|
69
|
+
if ((0, sprotty_1.isLayoutContainer)(element) && this.toBeLayouted2.indexOf(element) >= 0) {
|
|
70
|
+
bounds = this.doLayout(element);
|
|
71
|
+
}
|
|
72
|
+
else if ((0, sprotty_1.isLayoutContainer)(element)) {
|
|
73
|
+
bounds = {
|
|
74
|
+
x: 0,
|
|
75
|
+
y: 0,
|
|
76
|
+
width: -1,
|
|
77
|
+
height: -1
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (!boundsData) {
|
|
81
|
+
boundsData = {
|
|
82
|
+
bounds: bounds,
|
|
83
|
+
boundsChanged: false,
|
|
84
|
+
alignmentChanged: false
|
|
85
|
+
};
|
|
86
|
+
this.elementToBoundsData.set(element, boundsData);
|
|
87
|
+
}
|
|
88
|
+
return boundsData;
|
|
89
|
+
}
|
|
90
|
+
layout() {
|
|
91
|
+
// First pass: apply layout with cleared container data. Will get
|
|
92
|
+
// preferred size for all elements (Children first, then parents)
|
|
93
|
+
while (this.toBeLayouted2.length > 0) {
|
|
94
|
+
const element = this.toBeLayouted2[0];
|
|
95
|
+
this.doLayout(element);
|
|
96
|
+
}
|
|
97
|
+
this.toBeLayouted2 = [];
|
|
98
|
+
this.elementToBoundsData.forEach((data, element) => {
|
|
99
|
+
if ((0, sprotty_1.isLayoutContainer)(element)) {
|
|
100
|
+
this.toBeLayouted2.push(element);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
// Second pass: apply layout with initial size data for all
|
|
104
|
+
// nodes. Update the position/size of all elements, taking
|
|
105
|
+
// vGrab/hGrab into account (parent -> children).
|
|
106
|
+
while (this.toBeLayouted2.length > 0) {
|
|
107
|
+
const element = this.toBeLayouted2[0];
|
|
108
|
+
this.doLayout(element);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
doLayout(element) {
|
|
112
|
+
const index = this.toBeLayouted2.indexOf(element);
|
|
113
|
+
if (index >= 0) {
|
|
114
|
+
this.toBeLayouted2.splice(index, 1);
|
|
115
|
+
}
|
|
116
|
+
const layout = this.layoutRegistry2.get(element.layout);
|
|
117
|
+
if (layout) {
|
|
118
|
+
layout.layout(element, this);
|
|
119
|
+
}
|
|
120
|
+
const boundsData = this.elementToBoundsData.get(element);
|
|
121
|
+
if (boundsData !== undefined && boundsData.bounds !== undefined) {
|
|
122
|
+
return boundsData.bounds;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.log.error(element, 'Layout failed');
|
|
126
|
+
return geometry_1.Bounds.EMPTY;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.StatefulLayouterExt = StatefulLayouterExt;
|
|
131
|
+
//# sourceMappingURL=layouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layouter.js","sourceRoot":"","sources":["../../../src/features/layout/layouter.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qCAUiB;AACjB,yCAAuC;AACvC,kEAA6D;AAG7D,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,kBAAQ;IAC5B,MAAM,CAAC,kBAAkD;QAC9D,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3F,CAAC;CACJ,CAAA;AAJY,WAAW;IADvB,IAAA,sBAAU,GAAE;GACA,WAAW,CAIvB;AAJY,kCAAW;AAMxB,iBAAiB;AACjB,uFAAuF;AACvF,yBAAyB;AACzB,qFAAqF;AACrF,sDAAsD;AACtD,4BAA4B;AAE5B,MAAa,mBAAoB,SAAQ,0BAAgB;IAGrD;;;;;;OAMG;IACH,YACuB,mBAAmD,EACnD,eAA+B,EAClD,GAAY;QAEZ,KAAK,CAAC,mBAAmB,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC;QAJ9B,wBAAmB,GAAnB,mBAAmB,CAAgC;QACnD,oBAAe,GAAf,eAAe,CAAgB;QAIlD,IAAI,CA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AM,CAAC;SAC5B;aAAM;YACH,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YACzC,OAAO,iBAAM,CAAC,KAAK,CAAC;SACvB;IACL,CAAC;CACJ;AA7FD,kDA6FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freeform-layout.spec.d.ts","sourceRoot":"","sources":["../../../../src/features/layout/tests/freeform-layout.spec.ts"],"names":[],"mappings":"AAgBA,OAAO,OAAO,CAAC;AACf,OAAO,kBAAkB,CAAC"}
|