@eclipse-glsp/client 1.0.0 → 1.1.0-next.7ff1b00.184
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/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/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/package.json +3 -3
- 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/vbox-layout.ts +22 -5
|
@@ -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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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,CAA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;YAChB,2CAA2C;YAC3C,SAAS,EAAE,IAAI;SAClB,CAAC;IACN,CAAC;IAES,sBAAsB,CAAC,gBAAsC;QACnE,kEAAkE;QAClE,wDAAwD;QACxD,2CAA2C;QAC3C,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,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,4BAA4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AAM,EAAE;YACR,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAChC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7D,OAAO,UAAU,CAAC,MAAM,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"}
|
|
@@ -36,6 +36,6 @@ export declare class VBoxLayouterExt extends VBoxLayouter {
|
|
|
36
36
|
protected getElementLayoutOptions(element: SModelElement): VBoxLayoutOptionsExt | undefined;
|
|
37
37
|
protected getFinalContainerBounds(container: SParentElement & LayoutContainer, lastOffset: Point, options: VBoxLayoutOptionsExt, maxWidth: number, maxHeight: number): Bounds;
|
|
38
38
|
protected getDefaultLayoutOptions(): VBoxLayoutOptionsExt;
|
|
39
|
-
protected
|
|
39
|
+
protected filterContainerOptions(containerOptions: VBoxLayoutOptionsExt): VBoxLayoutOptionsExt;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=vbox-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vbox-layout.d.ts","sourceRoot":"","sources":["../../../src/features/layout/vbox-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,iBAA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C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,GAC1B,KAAK;cA8BW,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,UAAU,CAAC,EAAE,MAAM,EACnB,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 VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
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 = (((_a = boundsData.bounds) === null || _a === void 0 ? void 0 : _a.width) || 0) - options.paddingLeft - options.paddingRight;
|
|
39
|
+
const currentHeight = (((_b = boundsData.bounds) === null || _b === void 0 ? void 0 : _b.height) || 0) - options.paddingTop - options.paddingBottom;
|
|
37
40
|
const maxWidth = options.paddingFactor *
|
|
38
41
|
(options.resizeContainer
|
|
39
42
|
? Math.max(fixedSize.width - options.paddingLeft - options.paddingRight, childrenSize.width)
|
|
@@ -42,8 +45,10 @@ let VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
|
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 vGrab option
|
|
46
|
-
const grabHeight =
|
|
51
|
+
const grabHeight = height - childrenSize.height;
|
|
47
52
|
// Number of children that request vGrab
|
|
48
53
|
// FIXME: This approach works fine when only 1 child uses VGrab, but may cause rounding issues
|
|
49
54
|
// when the grabHeight can't be equally shared by all children.
|
|
@@ -51,7 +56,7 @@ let VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
|
51
56
|
.map(child => this.getChildLayoutOptions(child, options))
|
|
52
57
|
.filter(opt => opt.vGrab).length;
|
|
53
58
|
if (maxWidth > 0 && maxHeight > 0) {
|
|
54
|
-
const offset = this.layoutChildren(container, layouter, options,
|
|
59
|
+
const offset = this.layoutChildren(container, layouter, options, width, height, grabHeight, grabbingChildren);
|
|
55
60
|
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, childrenSize.width, childrenSize.height);
|
|
56
61
|
boundsData.boundsChanged = true;
|
|
57
62
|
}
|
|
@@ -99,7 +104,10 @@ let VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
|
99
104
|
return currentOffset;
|
|
100
105
|
}
|
|
101
106
|
layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight, grabHeight, grabbingChildren) {
|
|
107
|
+
const hAlign = childOptions.hGrab ? 'left' : childOptions.hAlign;
|
|
108
|
+
const dx = this.getDx(hAlign, bounds, maxWidth);
|
|
102
109
|
let offset = super.layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight);
|
|
110
|
+
boundsData.bounds = Object.assign(Object.assign({}, boundsData.bounds), { x: currentOffset.x + dx, y: currentOffset.y });
|
|
103
111
|
if (childOptions.hGrab) {
|
|
104
112
|
boundsData.bounds = {
|
|
105
113
|
x: boundsData.bounds.x,
|
|
@@ -136,7 +144,7 @@ let VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
|
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 VBoxLayouterExt = class VBoxLayouterExt extends sprotty_1.VBoxLayouter {
|
|
|
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
|
VBoxLayouterExt.KIND = sprotty_1.VBoxLayouter.KIND;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vbox-layout.js","sourceRoot":"","sources":["../../../src/features/layout/vbox-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":"vbox-layout.js","sourceRoot":"","sources":["../../../src/features/layout/vbox-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,CAAC,CAAA,MAAA,UAAU,CAAC,MAAM,0CAAE,KAAK,KAAI,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;QA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EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-next.7ff1b00.184+7ff1b00",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"css"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@eclipse-glsp/protocol": "
|
|
37
|
+
"@eclipse-glsp/protocol": "1.1.0-next.7ff1b00.184+7ff1b00",
|
|
38
38
|
"autocompleter": "5.1.0",
|
|
39
39
|
"sprotty": "0.12.0"
|
|
40
40
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
},
|
|
58
58
|
"main": "lib/index",
|
|
59
59
|
"types": "lib/index",
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "7ff1b00a1575eb1979aa69e8e2873807883d9c6a"
|
|
61
61
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { ContainerModule } from 'inversify';
|
|
17
|
-
import { configureActionHandler, configureLayout, HBoxLayouter, VBoxLayouter } from 'sprotty';
|
|
17
|
+
import { configureActionHandler, configureLayout, HBoxLayouter, TYPES, VBoxLayouter } from 'sprotty';
|
|
18
18
|
import { FreeFormLayouter } from './freeform-layout';
|
|
19
19
|
import { HBoxLayouterExt } from './hbox-layout';
|
|
20
20
|
import {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
ResizeElementsAction,
|
|
24
24
|
ResizeElementsActionHandler
|
|
25
25
|
} from './layout-elements-action';
|
|
26
|
+
import { LayouterExt } from './layouter';
|
|
26
27
|
import { VBoxLayouterExt } from './vbox-layout';
|
|
27
28
|
|
|
28
29
|
const layoutModule = new ContainerModule((bind, _unbind, isBound, rebind) => {
|
|
@@ -32,6 +33,7 @@ const layoutModule = new ContainerModule((bind, _unbind, isBound, rebind) => {
|
|
|
32
33
|
|
|
33
34
|
rebind(VBoxLayouter).to(VBoxLayouterExt);
|
|
34
35
|
rebind(HBoxLayouter).to(HBoxLayouterExt);
|
|
36
|
+
rebind(TYPES.Layouter).to(LayouterExt);
|
|
35
37
|
configureLayout({ bind, isBound }, FreeFormLayouter.KIND, FreeFormLayouter);
|
|
36
38
|
});
|
|
37
39
|
|
|
@@ -49,6 +49,9 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
49
49
|
|
|
50
50
|
const fixedSize = this.getFixedContainerBounds(container, options, layouter);
|
|
51
51
|
|
|
52
|
+
const currentWidth = boundsData.bounds ? boundsData.bounds?.width - options.paddingLeft - options.paddingRight : 0;
|
|
53
|
+
const currentHeight = boundsData.bounds ? boundsData.bounds?.height - options.paddingTop - options.paddingBottom : 0;
|
|
54
|
+
|
|
52
55
|
const maxWidth =
|
|
53
56
|
options.paddingFactor *
|
|
54
57
|
(options.resizeContainer
|
|
@@ -60,8 +63,11 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
60
63
|
? Math.max(fixedSize.height - options.paddingTop - options.paddingBottom, childrenSize.height)
|
|
61
64
|
: Math.max(0, fixedSize.height - options.paddingTop - options.paddingBottom));
|
|
62
65
|
|
|
66
|
+
const width = Math.max(currentWidth, maxWidth);
|
|
67
|
+
const height = Math.max(currentHeight, maxHeight);
|
|
68
|
+
|
|
63
69
|
// Remaining size that can be grabbed by children with the hGrab option
|
|
64
|
-
const grabWidth
|
|
70
|
+
const grabWidth = width - childrenSize.width;
|
|
65
71
|
// Number of children that request hGrab
|
|
66
72
|
// FIXME: This approach works fine when only 1 child uses HGrab, but may cause rounding issues
|
|
67
73
|
// when the grabHeight can't be equally shared by all children.
|
|
@@ -69,8 +75,8 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
69
75
|
.map(child => this.getChildLayoutOptions(child, options))
|
|
70
76
|
.filter(opt => opt.hGrab).length;
|
|
71
77
|
|
|
72
|
-
if (
|
|
73
|
-
const offset = this.layoutChildren(container, layouter, options,
|
|
78
|
+
if (width > 0 && height > 0) {
|
|
79
|
+
const offset = this.layoutChildren(container, layouter, options, width, height, grabWidth, grabbingChildren);
|
|
74
80
|
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, childrenSize.width, childrenSize.height);
|
|
75
81
|
boundsData.boundsChanged = true;
|
|
76
82
|
}
|
|
@@ -155,8 +161,15 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
155
161
|
grabWidth?: number,
|
|
156
162
|
grabbingChildren?: number
|
|
157
163
|
): Point {
|
|
164
|
+
const vAlign = childOptions.vGrab ? 'top' : childOptions.vAlign;
|
|
165
|
+
const dy = this.getDy(vAlign, bounds, maxHeight);
|
|
158
166
|
let offset = super.layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight);
|
|
159
|
-
|
|
167
|
+
boundsData.bounds = {
|
|
168
|
+
...boundsData.bounds!,
|
|
169
|
+
x: currentOffset.x,
|
|
170
|
+
y: currentOffset.y + dy
|
|
171
|
+
};
|
|
172
|
+
if (childOptions.vGrab) {
|
|
160
173
|
boundsData.bounds = {
|
|
161
174
|
x: boundsData.bounds!.x,
|
|
162
175
|
y: boundsData.bounds!.y,
|
|
@@ -197,7 +210,7 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
protected override getChildLayoutOptions(child: SChildElement, containerOptions: HBoxLayoutOptionsExt): HBoxLayoutOptionsExt {
|
|
200
|
-
return super.getChildLayoutOptions(child, containerOptions) as HBoxLayoutOptionsExt;
|
|
213
|
+
return super.getChildLayoutOptions(child, this.filterContainerOptions(containerOptions)) as HBoxLayoutOptionsExt;
|
|
201
214
|
}
|
|
202
215
|
|
|
203
216
|
protected override getLayoutOptions(element: SModelElement): HBoxLayoutOptionsExt {
|
|
@@ -250,7 +263,11 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
250
263
|
};
|
|
251
264
|
}
|
|
252
265
|
|
|
253
|
-
protected
|
|
254
|
-
|
|
266
|
+
protected filterContainerOptions(containerOptions: HBoxLayoutOptionsExt): HBoxLayoutOptionsExt {
|
|
267
|
+
// Reset object-specific layout options to default before merging,
|
|
268
|
+
// to make sure they won't be inherited (grab, prefSize)
|
|
269
|
+
// eslint-disable-next-line no-null/no-null
|
|
270
|
+
const localOptions = { vGrab: false, hGrab: false, prefHeight: null, prefWidth: null };
|
|
271
|
+
return { ...containerOptions, ...localOptions };
|
|
255
272
|
}
|
|
256
273
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 {
|
|
17
|
+
BoundsData,
|
|
18
|
+
ILogger,
|
|
19
|
+
LayoutRegistry,
|
|
20
|
+
StatefulLayouter,
|
|
21
|
+
SModelElement,
|
|
22
|
+
Layouter,
|
|
23
|
+
SParentElement,
|
|
24
|
+
LayoutContainer,
|
|
25
|
+
isLayoutContainer
|
|
26
|
+
} from 'sprotty';
|
|
27
|
+
import { injectable } from 'inversify';
|
|
28
|
+
import { Bounds } from 'sprotty-protocol/lib/utils/geometry';
|
|
29
|
+
|
|
30
|
+
@injectable()
|
|
31
|
+
export class LayouterExt extends Layouter {
|
|
32
|
+
override layout(element2boundsData: Map<SModelElement, BoundsData>): void {
|
|
33
|
+
new StatefulLayouterExt(element2boundsData, this.layoutRegistry, this.logger).layout();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
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
|
+
|
|
44
|
+
export class StatefulLayouterExt extends StatefulLayouter {
|
|
45
|
+
protected toBeLayouted2: (SParentElement & LayoutContainer)[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param elementToBoundsData The map of element to bounds data. Bounds Data are computed from the hidden
|
|
50
|
+
* SVG rendering pass.
|
|
51
|
+
* @param layoutRegistry2 The registry of available layouts.
|
|
52
|
+
* @param log The log.
|
|
53
|
+
*/
|
|
54
|
+
constructor(
|
|
55
|
+
protected readonly elementToBoundsData: Map<SModelElement, BoundsData>,
|
|
56
|
+
protected readonly layoutRegistry2: LayoutRegistry,
|
|
57
|
+
log: ILogger
|
|
58
|
+
) {
|
|
59
|
+
super(elementToBoundsData, layoutRegistry2, log);
|
|
60
|
+
this.toBeLayouted2 = [];
|
|
61
|
+
elementToBoundsData.forEach((data, element) => {
|
|
62
|
+
if (isLayoutContainer(element)) {
|
|
63
|
+
this.toBeLayouted2.push(element);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
for (const element of this.toBeLayouted2) {
|
|
67
|
+
// Clear previous layout information for dynamic-layout objects
|
|
68
|
+
elementToBoundsData.delete(element);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override getBoundsData(element: SModelElement): BoundsData {
|
|
73
|
+
let boundsData = this.elementToBoundsData.get(element);
|
|
74
|
+
let bounds = (element as any).bounds;
|
|
75
|
+
if (isLayoutContainer(element) && this.toBeLayouted2.indexOf(element) >= 0) {
|
|
76
|
+
bounds = this.doLayout(element);
|
|
77
|
+
} else if (isLayoutContainer(element)) {
|
|
78
|
+
bounds = {
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0,
|
|
81
|
+
width: -1,
|
|
82
|
+
height: -1
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (!boundsData) {
|
|
86
|
+
boundsData = {
|
|
87
|
+
bounds: bounds,
|
|
88
|
+
boundsChanged: false,
|
|
89
|
+
alignmentChanged: false
|
|
90
|
+
};
|
|
91
|
+
this.elementToBoundsData.set(element, boundsData);
|
|
92
|
+
}
|
|
93
|
+
return boundsData;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override layout(): void {
|
|
97
|
+
// First pass: apply layout with cleared container data. Will get
|
|
98
|
+
// preferred size for all elements (Children first, then parents)
|
|
99
|
+
while (this.toBeLayouted2.length > 0) {
|
|
100
|
+
const element = this.toBeLayouted2[0];
|
|
101
|
+
this.doLayout(element);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.toBeLayouted2 = [];
|
|
105
|
+
this.elementToBoundsData.forEach((data, element) => {
|
|
106
|
+
if (isLayoutContainer(element)) {
|
|
107
|
+
this.toBeLayouted2.push(element);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Second pass: apply layout with initial size data for all
|
|
112
|
+
// nodes. Update the position/size of all elements, taking
|
|
113
|
+
// vGrab/hGrab into account (parent -> children).
|
|
114
|
+
while (this.toBeLayouted2.length > 0) {
|
|
115
|
+
const element = this.toBeLayouted2[0];
|
|
116
|
+
this.doLayout(element);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
protected override doLayout(element: SParentElement & LayoutContainer): Bounds {
|
|
121
|
+
const index = this.toBeLayouted2.indexOf(element);
|
|
122
|
+
if (index >= 0) {
|
|
123
|
+
this.toBeLayouted2.splice(index, 1);
|
|
124
|
+
}
|
|
125
|
+
const layout = this.layoutRegistry2.get(element.layout);
|
|
126
|
+
if (layout) {
|
|
127
|
+
layout.layout(element, this);
|
|
128
|
+
}
|
|
129
|
+
const boundsData = this.elementToBoundsData.get(element);
|
|
130
|
+
if (boundsData !== undefined && boundsData.bounds !== undefined) {
|
|
131
|
+
return boundsData.bounds;
|
|
132
|
+
} else {
|
|
133
|
+
this.log.error(element, 'Layout failed');
|
|
134
|
+
return Bounds.EMPTY;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -49,6 +49,9 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
49
49
|
|
|
50
50
|
const fixedSize = this.getFixedContainerBounds(container, options, layouter);
|
|
51
51
|
|
|
52
|
+
const currentWidth = (boundsData.bounds?.width || 0) - options.paddingLeft - options.paddingRight;
|
|
53
|
+
const currentHeight = (boundsData.bounds?.height || 0) - options.paddingTop - options.paddingBottom;
|
|
54
|
+
|
|
52
55
|
const maxWidth =
|
|
53
56
|
options.paddingFactor *
|
|
54
57
|
(options.resizeContainer
|
|
@@ -60,8 +63,11 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
60
63
|
? Math.max(fixedSize.height - options.paddingTop - options.paddingBottom, childrenSize.height)
|
|
61
64
|
: Math.max(0, fixedSize.height - options.paddingTop - options.paddingBottom));
|
|
62
65
|
|
|
66
|
+
const width = Math.max(currentWidth, maxWidth);
|
|
67
|
+
const height = Math.max(currentHeight, maxHeight);
|
|
68
|
+
|
|
63
69
|
// Remaining size that can be grabbed by children with the vGrab option
|
|
64
|
-
const grabHeight: number =
|
|
70
|
+
const grabHeight: number = height - childrenSize.height;
|
|
65
71
|
// Number of children that request vGrab
|
|
66
72
|
// FIXME: This approach works fine when only 1 child uses VGrab, but may cause rounding issues
|
|
67
73
|
// when the grabHeight can't be equally shared by all children.
|
|
@@ -70,7 +76,7 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
70
76
|
.filter(opt => opt.vGrab).length;
|
|
71
77
|
|
|
72
78
|
if (maxWidth > 0 && maxHeight > 0) {
|
|
73
|
-
const offset = this.layoutChildren(container, layouter, options,
|
|
79
|
+
const offset = this.layoutChildren(container, layouter, options, width, height, grabHeight, grabbingChildren);
|
|
74
80
|
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, childrenSize.width, childrenSize.height);
|
|
75
81
|
boundsData.boundsChanged = true;
|
|
76
82
|
}
|
|
@@ -155,7 +161,14 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
155
161
|
grabHeight?: number,
|
|
156
162
|
grabbingChildren?: number
|
|
157
163
|
): Point {
|
|
164
|
+
const hAlign = childOptions.hGrab ? 'left' : childOptions.hAlign;
|
|
165
|
+
const dx = this.getDx(hAlign, bounds, maxWidth);
|
|
158
166
|
let offset = super.layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight);
|
|
167
|
+
boundsData.bounds = {
|
|
168
|
+
...boundsData.bounds!,
|
|
169
|
+
x: currentOffset.x + dx,
|
|
170
|
+
y: currentOffset.y
|
|
171
|
+
};
|
|
159
172
|
if (childOptions.hGrab) {
|
|
160
173
|
boundsData.bounds = {
|
|
161
174
|
x: boundsData.bounds!.x,
|
|
@@ -197,7 +210,7 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
protected override getChildLayoutOptions(child: SChildElement, containerOptions: VBoxLayoutOptionsExt): VBoxLayoutOptionsExt {
|
|
200
|
-
return super.getChildLayoutOptions(child, containerOptions) as VBoxLayoutOptionsExt;
|
|
213
|
+
return super.getChildLayoutOptions(child, this.filterContainerOptions(containerOptions)) as VBoxLayoutOptionsExt;
|
|
201
214
|
}
|
|
202
215
|
|
|
203
216
|
protected override getLayoutOptions(element: SModelElement): VBoxLayoutOptionsExt {
|
|
@@ -250,7 +263,11 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
250
263
|
};
|
|
251
264
|
}
|
|
252
265
|
|
|
253
|
-
protected
|
|
254
|
-
|
|
266
|
+
protected filterContainerOptions(containerOptions: VBoxLayoutOptionsExt): VBoxLayoutOptionsExt {
|
|
267
|
+
// Reset object-specific layout options to default before merging,
|
|
268
|
+
// to make sure they won't be inherited (grab, prefSize)
|
|
269
|
+
// eslint-disable-next-line no-null/no-null
|
|
270
|
+
const localOptions = { vGrab: false, hGrab: false, prefHeight: null, prefWidth: null };
|
|
271
|
+
return { ...containerOptions, ...localOptions };
|
|
255
272
|
}
|
|
256
273
|
}
|