@eclipse-glsp/client 2.2.0-next.333 → 2.2.0-next.334
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/css/change-bounds.css +36 -2
- package/css/glsp-sprotty.css +18 -2
- package/css/helper-lines.css +3 -3
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +3 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/feedback/css-feedback.d.ts +7 -2
- package/lib/base/feedback/css-feedback.d.ts.map +1 -1
- package/lib/base/feedback/css-feedback.js +10 -2
- package/lib/base/feedback/css-feedback.js.map +1 -1
- package/lib/base/feedback/feeback-emitter.d.ts +2 -2
- package/lib/base/feedback/feeback-emitter.d.ts.map +1 -1
- package/lib/base/feedback/feeback-emitter.js +5 -2
- package/lib/base/feedback/feeback-emitter.js.map +1 -1
- package/lib/base/index.d.ts +1 -0
- package/lib/base/index.d.ts.map +1 -1
- package/lib/base/index.js +1 -0
- package/lib/base/index.js.map +1 -1
- package/lib/base/mouse-position-tracker.d.ts +22 -0
- package/lib/base/mouse-position-tracker.d.ts.map +1 -0
- package/lib/base/mouse-position-tracker.js +40 -0
- package/lib/base/mouse-position-tracker.js.map +1 -0
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +2 -0
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js +15 -7
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
- package/lib/features/bounds/bounds-module.d.ts.map +1 -1
- package/lib/features/bounds/bounds-module.js +2 -0
- package/lib/features/bounds/bounds-module.js.map +1 -1
- package/lib/features/bounds/freeform-layout.d.ts +17 -1
- package/lib/features/bounds/freeform-layout.d.ts.map +1 -1
- package/lib/features/bounds/freeform-layout.js +14 -5
- package/lib/features/bounds/freeform-layout.js.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +5 -4
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.js +51 -39
- package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
- package/lib/features/bounds/hbox-layout.d.ts +18 -2
- package/lib/features/bounds/hbox-layout.d.ts.map +1 -1
- package/lib/features/bounds/hbox-layout.js +14 -5
- package/lib/features/bounds/hbox-layout.js.map +1 -1
- package/lib/features/bounds/index.d.ts +1 -0
- package/lib/features/bounds/index.d.ts.map +1 -1
- package/lib/features/bounds/index.js +1 -0
- package/lib/features/bounds/index.js.map +1 -1
- package/lib/features/bounds/layout-data.d.ts +27 -0
- package/lib/features/bounds/layout-data.d.ts.map +1 -0
- package/lib/features/bounds/layout-data.js +48 -0
- package/lib/features/bounds/layout-data.js.map +1 -0
- package/lib/features/bounds/local-bounds.d.ts +3 -1
- package/lib/features/bounds/local-bounds.d.ts.map +1 -1
- package/lib/features/bounds/local-bounds.js +14 -0
- package/lib/features/bounds/local-bounds.js.map +1 -1
- package/lib/features/bounds/vbox-layout.d.ts +18 -2
- package/lib/features/bounds/vbox-layout.d.ts.map +1 -1
- package/lib/features/bounds/vbox-layout.js +14 -5
- package/lib/features/bounds/vbox-layout.js.map +1 -1
- package/lib/features/change-bounds/index.d.ts +1 -0
- package/lib/features/change-bounds/index.d.ts.map +1 -1
- package/lib/features/change-bounds/index.js +1 -0
- package/lib/features/change-bounds/index.js.map +1 -1
- package/lib/features/change-bounds/model.d.ts +19 -3
- package/lib/features/change-bounds/model.d.ts.map +1 -1
- package/lib/features/change-bounds/model.js +92 -4
- package/lib/features/change-bounds/model.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.d.ts +1 -0
- package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js +7 -1
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/change-bounds/point-position-updater.d.ts +3 -0
- package/lib/features/change-bounds/point-position-updater.d.ts.map +1 -1
- package/lib/features/change-bounds/point-position-updater.js +7 -2
- package/lib/features/change-bounds/point-position-updater.js.map +1 -1
- package/lib/features/change-bounds/position-snapper.d.ts +4 -0
- package/lib/features/change-bounds/position-snapper.d.ts.map +1 -1
- package/lib/features/change-bounds/position-snapper.js +4 -0
- package/lib/features/change-bounds/position-snapper.js.map +1 -1
- package/lib/features/change-bounds/snap.d.ts +6 -0
- package/lib/features/change-bounds/snap.d.ts.map +1 -1
- package/lib/features/change-bounds/snap.js +6 -0
- package/lib/features/change-bounds/snap.js.map +1 -1
- package/lib/features/change-bounds/tracker.d.ts +32 -0
- package/lib/features/change-bounds/tracker.d.ts.map +1 -0
- package/lib/features/change-bounds/tracker.js +60 -0
- package/lib/features/change-bounds/tracker.js.map +1 -0
- package/lib/features/debug/debug-bounds-decorator.d.ts +4 -1
- package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.js +14 -7
- package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +9 -22
- package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js +30 -46
- package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts +2 -2
- package/lib/features/helper-lines/helper-line-feedback.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +2 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +23 -0
- package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager.d.ts +10 -2
- package/lib/features/helper-lines/helper-line-manager.d.ts.map +1 -1
- package/lib/features/routing/edge-router.d.ts +4 -0
- package/lib/features/routing/edge-router.d.ts.map +1 -1
- package/lib/features/routing/edge-router.js +37 -0
- package/lib/features/routing/edge-router.js.map +1 -1
- package/lib/features/select/select-mouse-listener.d.ts +3 -0
- package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
- package/lib/features/select/select-mouse-listener.js +30 -2
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/tools/base-tools.d.ts +24 -15
- package/lib/features/tools/base-tools.d.ts.map +1 -1
- package/lib/features/tools/base-tools.js +0 -18
- package/lib/features/tools/base-tools.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-manager.d.ts +42 -0
- package/lib/features/tools/change-bounds/change-bounds-manager.d.ts.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-manager.js +136 -0
- package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts +6 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +14 -8
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.js +2 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-module.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +6 -15
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +24 -72
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +14 -25
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +63 -109
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts +136 -0
- package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tracker.js +301 -0
- package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -0
- package/lib/features/tools/change-bounds/index.d.ts +2 -0
- package/lib/features/tools/change-bounds/index.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/index.js +2 -0
- package/lib/features/tools/change-bounds/index.js.map +1 -1
- package/lib/features/tools/change-bounds/view.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/view.js +1 -16
- package/lib/features/tools/change-bounds/view.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +7 -9
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +27 -47
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +2 -2
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +5 -5
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts +1 -0
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +3 -0
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.d.ts +2 -4
- package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +8 -11
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/utils/gmodel-util.d.ts +20 -1
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +38 -16
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/utils/layout-utils.d.ts +1 -0
- package/lib/utils/layout-utils.d.ts.map +1 -1
- package/lib/utils/layout-utils.js +5 -1
- package/lib/utils/layout-utils.js.map +1 -1
- package/package.json +3 -3
- package/src/base/default.module.ts +4 -1
- package/src/base/feedback/css-feedback.ts +10 -2
- package/src/base/feedback/feeback-emitter.ts +6 -3
- package/src/base/index.ts +1 -0
- package/src/base/mouse-position-tracker.ts +25 -0
- package/src/features/accessibility/view-key-tools/movement-key-tool.ts +12 -7
- package/src/features/bounds/bounds-module.ts +2 -0
- package/src/features/bounds/freeform-layout.ts +16 -6
- package/src/features/bounds/glsp-hidden-bounds-updater.ts +63 -46
- package/src/features/bounds/hbox-layout.ts +18 -9
- package/src/features/bounds/index.ts +1 -0
- package/src/features/bounds/layout-data.ts +48 -0
- package/src/features/bounds/local-bounds.ts +20 -4
- package/src/features/bounds/vbox-layout.ts +18 -10
- package/src/features/change-bounds/index.ts +1 -0
- package/src/features/change-bounds/model.ts +104 -4
- package/src/features/change-bounds/movement-restrictor.ts +10 -0
- package/src/features/change-bounds/point-position-updater.spec.ts +2 -0
- package/src/features/change-bounds/point-position-updater.ts +6 -0
- package/src/features/change-bounds/position-snapper.ts +4 -0
- package/src/features/change-bounds/snap.ts +6 -0
- package/src/features/change-bounds/tracker.ts +63 -0
- package/src/features/debug/debug-bounds-decorator.tsx +17 -7
- package/src/features/element-template/mouse-tracking-element-position-listener.ts +49 -71
- package/src/features/helper-lines/helper-line-feedback.ts +2 -1
- package/src/features/helper-lines/helper-line-manager-default.ts +37 -2
- package/src/features/helper-lines/helper-line-manager.ts +11 -2
- package/src/features/routing/edge-router.ts +42 -0
- package/src/features/select/select-mouse-listener.ts +15 -1
- package/src/features/tools/base-tools.ts +31 -19
- package/src/features/tools/change-bounds/change-bounds-manager.ts +145 -0
- package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +17 -6
- package/src/features/tools/change-bounds/change-bounds-tool-module.ts +2 -0
- package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +31 -81
- package/src/features/tools/change-bounds/change-bounds-tool.ts +89 -148
- package/src/features/tools/change-bounds/change-bounds-tracker.ts +455 -0
- package/src/features/tools/change-bounds/index.ts +2 -0
- package/src/features/tools/change-bounds/view.tsx +2 -14
- package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +34 -52
- package/src/features/tools/edge-edit/edge-edit-tool.ts +4 -3
- package/src/features/tools/marquee-selection/marquee-mouse-tool.ts +4 -0
- package/src/features/tools/node-creation/node-creation-tool.ts +7 -7
- package/src/utils/gmodel-util.ts +41 -5
- package/src/utils/layout-utils.ts +4 -0
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
FeatureModule,
|
|
19
19
|
KeyTool,
|
|
20
20
|
LocationPostprocessor,
|
|
21
|
+
MousePositionTracker,
|
|
21
22
|
MouseTool,
|
|
22
23
|
MoveCommand,
|
|
23
24
|
SetDirtyStateAction,
|
|
@@ -47,6 +48,7 @@ import { DiagramLoader } from './model/diagram-loader';
|
|
|
47
48
|
import { GLSPModelSource } from './model/glsp-model-source';
|
|
48
49
|
import { DefaultModelInitializationConstraint, ModelInitializationConstraint } from './model/model-initialization-constraint';
|
|
49
50
|
import { GModelRegistry } from './model/model-registry';
|
|
51
|
+
import { GLSPMousePositionTracker } from './mouse-position-tracker';
|
|
50
52
|
import { SelectionClearingMouseListener } from './selection-clearing-mouse-listener';
|
|
51
53
|
import { SelectionService } from './selection-service';
|
|
52
54
|
import { EnableDefaultToolsAction, EnableToolsAction } from './tool-manager/tool';
|
|
@@ -85,7 +87,8 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
|
|
|
85
87
|
bind(GLSPMouseTool).toSelf().inSingletonScope();
|
|
86
88
|
bindOrRebind(context, MouseTool).toService(GLSPMouseTool);
|
|
87
89
|
bind(TYPES.IDiagramStartup).toService(GLSPMouseTool);
|
|
88
|
-
|
|
90
|
+
bind(GLSPMousePositionTracker).toSelf().inSingletonScope();
|
|
91
|
+
bindOrRebind(context, MousePositionTracker).toService(GLSPMousePositionTracker);
|
|
89
92
|
bind(GLSPKeyTool).toSelf().inSingletonScope();
|
|
90
93
|
bindOrRebind(context, KeyTool).toService(GLSPKeyTool);
|
|
91
94
|
bind(TYPES.IDiagramStartup).toService(GLSPKeyTool);
|
|
@@ -85,14 +85,18 @@ export enum CursorCSS {
|
|
|
85
85
|
RESIZE_NESW = 'resize-nesw-mode',
|
|
86
86
|
RESIZE_NWSE = 'resize-nwse-mode',
|
|
87
87
|
RESIZE_NW = 'resize-nw-mode',
|
|
88
|
+
RESIZE_N = 'resize-n-mode',
|
|
88
89
|
RESIZE_NE = 'resize-ne-mode',
|
|
89
|
-
|
|
90
|
+
RESIZE_E = 'resize-e-mode',
|
|
90
91
|
RESIZE_SE = 'resize-se-mode',
|
|
92
|
+
RESIZE_S = 'resize-s-mode',
|
|
93
|
+
RESIZE_SW = 'resize-sw-mode',
|
|
94
|
+
RESIZE_W = 'resize-w-mode',
|
|
91
95
|
MOVE = 'move-mode',
|
|
92
96
|
MARQUEE = 'marquee-mode'
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
export function cursorFeedbackAction(cursorCss?:
|
|
99
|
+
export function cursorFeedbackAction(cursorCss?: string): ModifyCSSFeedbackAction {
|
|
96
100
|
const add = [];
|
|
97
101
|
if (cursorCss) {
|
|
98
102
|
add.push(cursorCss);
|
|
@@ -107,3 +111,7 @@ export function applyCssClasses(element: GModelElement, ...add: string[]): Modif
|
|
|
107
111
|
export function deleteCssClasses(element: GModelElement, ...remove: string[]): ModifyCSSFeedbackAction {
|
|
108
112
|
return ModifyCSSFeedbackAction.create({ elements: [element], remove });
|
|
109
113
|
}
|
|
114
|
+
|
|
115
|
+
export function toggleCssClasses(element: GModelElement, add: boolean, ...cssClasses: string[]): ModifyCSSFeedbackAction {
|
|
116
|
+
return add ? applyCssClasses(element, ...cssClasses) : deleteCssClasses(element, ...cssClasses);
|
|
117
|
+
}
|
|
@@ -32,9 +32,12 @@ export class FeedbackEmitter implements IFeedbackEmitter, Disposable {
|
|
|
32
32
|
* once the {@link submit} method is called.
|
|
33
33
|
*
|
|
34
34
|
* @param action feedback action
|
|
35
|
-
* @param cleanupAction action that undoes the feedback action. This is only triggered when {@link revert} is called.
|
|
35
|
+
* @param cleanupAction action that undoes the feedback action. This is only triggered when {@link revert} or {@link dispose} is called.
|
|
36
36
|
*/
|
|
37
|
-
add(action
|
|
37
|
+
add(action?: Action, cleanupAction?: MaybeActions): this {
|
|
38
|
+
if (!action && !cleanupAction) {
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
38
41
|
const idx = this.feedbackActions.length;
|
|
39
42
|
this.feedbackActions[idx] = action;
|
|
40
43
|
if (cleanupAction) {
|
|
@@ -73,7 +76,7 @@ export class FeedbackEmitter implements IFeedbackEmitter, Disposable {
|
|
|
73
76
|
* Registers any pending actions as feedback. Any previously submitted feedback becomes invalid.
|
|
74
77
|
*/
|
|
75
78
|
submit(): this {
|
|
76
|
-
// with 'arrayOf' we skip undefined entries that are created for non-cleanup actions
|
|
79
|
+
// with 'arrayOf' we skip undefined entries that are created for non-cleanup actions or cleanup-only actions
|
|
77
80
|
const actions = arrayOf(...this.feedbackActions);
|
|
78
81
|
const cleanupActions = arrayOf(...this.cleanupActions);
|
|
79
82
|
this.deregistration = this.feedbackDispatcher.registerFeedback(this, actions, () => cleanupActions.flatMap(MaybeActions.asArray));
|
package/src/base/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './editor-context-service';
|
|
|
24
24
|
export * from './feedback';
|
|
25
25
|
export * from './focus';
|
|
26
26
|
export * from './model';
|
|
27
|
+
export * from './mouse-position-tracker';
|
|
27
28
|
export * from './ranked';
|
|
28
29
|
export * from './selection-clearing-mouse-listener';
|
|
29
30
|
export * from './selection-service';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 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
|
+
rank: number;
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
import { MousePositionTracker } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { injectable } from 'inversify';
|
|
19
|
+
import { Ranked } from './ranked';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class GLSPMousePositionTracker extends MousePositionTracker implements Ranked {
|
|
23
|
+
/* we want to be executed before all default mouse listeners since we are just tracking the position and others may need it */
|
|
24
|
+
rank = Ranked.DEFAULT_RANK - 200;
|
|
25
|
+
}
|
|
@@ -20,8 +20,8 @@ import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
|
|
|
20
20
|
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
|
|
21
21
|
import { SelectionService } from '../../../base/selection-service';
|
|
22
22
|
import { Tool } from '../../../base/tool-manager/tool';
|
|
23
|
-
import { unsnapModifier, useSnap } from '../../change-bounds/snap';
|
|
24
23
|
import { Grid } from '../../grid';
|
|
24
|
+
import { ChangeBoundsManager } from '../../tools';
|
|
25
25
|
import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
|
|
26
26
|
import { MoveElementAction, MoveViewportAction } from '../move-zoom/move-handler';
|
|
27
27
|
|
|
@@ -40,7 +40,8 @@ export class MovementKeyTool implements Tool {
|
|
|
40
40
|
@inject(SelectionService) selectionService: SelectionService;
|
|
41
41
|
@inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
|
|
42
42
|
@inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
|
|
43
|
-
@
|
|
43
|
+
@inject(TYPES.Grid) @optional() protected grid: Grid;
|
|
44
|
+
@inject(TYPES.IChangeBoundsManager) readonly changeBoundsManager: ChangeBoundsManager;
|
|
44
45
|
|
|
45
46
|
get id(): string {
|
|
46
47
|
return MovementKeyTool.ID;
|
|
@@ -86,7 +87,7 @@ export class MoveKeyListener extends KeyListener implements AccessibleKeyShortcu
|
|
|
86
87
|
|
|
87
88
|
override keyDown(_element: GModelElement, event: KeyboardEvent): Action[] {
|
|
88
89
|
const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
|
|
89
|
-
const snap =
|
|
90
|
+
const snap = this.tool.changeBoundsManager.usePositionSnap(event);
|
|
90
91
|
const offsetX = snap ? this.grid.x : 1;
|
|
91
92
|
const offsetY = snap ? this.grid.y : 1;
|
|
92
93
|
|
|
@@ -115,18 +116,22 @@ export class MoveKeyListener extends KeyListener implements AccessibleKeyShortcu
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
protected matchesMoveUpKeystroke(event: KeyboardEvent): boolean {
|
|
118
|
-
|
|
119
|
+
const unsnap = this.tool.changeBoundsManager.unsnapModifier();
|
|
120
|
+
return matchesKeystroke(event, 'ArrowUp') || (!!unsnap && matchesKeystroke(event, 'ArrowUp', unsnap));
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
protected matchesMoveDownKeystroke(event: KeyboardEvent): boolean {
|
|
122
|
-
|
|
124
|
+
const unsnap = this.tool.changeBoundsManager.unsnapModifier();
|
|
125
|
+
return matchesKeystroke(event, 'ArrowDown') || (!!unsnap && matchesKeystroke(event, 'ArrowDown', unsnap));
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
protected matchesMoveRightKeystroke(event: KeyboardEvent): boolean {
|
|
126
|
-
|
|
129
|
+
const unsnap = this.tool.changeBoundsManager.unsnapModifier();
|
|
130
|
+
return matchesKeystroke(event, 'ArrowRight') || (!!unsnap && matchesKeystroke(event, 'ArrowRight', unsnap));
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
protected matchesMoveLeftKeystroke(event: KeyboardEvent): boolean {
|
|
130
|
-
|
|
134
|
+
const unsnap = this.tool.changeBoundsManager.unsnapModifier();
|
|
135
|
+
return matchesKeystroke(event, 'ArrowLeft') || (!!unsnap && matchesKeystroke(event, 'ArrowLeft', unsnap));
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -52,5 +52,7 @@ export const boundsModule = new FeatureModule((bind, _unbind, isBound, _rebind)
|
|
|
52
52
|
configureLayout(context, HBoxLayouter.KIND, HBoxLayouterExt);
|
|
53
53
|
configureLayout(context, FreeFormLayouter.KIND, FreeFormLayouter);
|
|
54
54
|
|
|
55
|
+
// backwards compatibility
|
|
56
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
55
57
|
bind(PositionSnapper).toSelf();
|
|
56
58
|
});
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { injectable } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
AbstractLayout,
|
|
19
18
|
AbstractLayoutOptions,
|
|
@@ -21,11 +20,13 @@ import {
|
|
|
21
20
|
BoundsData,
|
|
22
21
|
Dimension,
|
|
23
22
|
GChildElement,
|
|
23
|
+
GParentElement,
|
|
24
24
|
LayoutContainer,
|
|
25
25
|
Point,
|
|
26
|
-
GParentElement,
|
|
27
26
|
StatefulLayouter
|
|
28
27
|
} from '@eclipse-glsp/sprotty';
|
|
28
|
+
import { injectable } from 'inversify';
|
|
29
|
+
import { LayoutAware } from './layout-data';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Layouts children of a container with explicit X/Y positions
|
|
@@ -44,9 +45,11 @@ export class FreeFormLayouter extends AbstractLayout<AbstractLayoutOptions> {
|
|
|
44
45
|
|
|
45
46
|
const maxWidth = childrenSize.width > 0 ? childrenSize.width + options.paddingLeft + options.paddingRight : 0;
|
|
46
47
|
const maxHeight = childrenSize.height > 0 ? childrenSize.height + options.paddingTop + options.paddingBottom : 0;
|
|
47
|
-
if (
|
|
48
|
+
if (childrenSize.width > 0 && childrenSize.height > 0) {
|
|
48
49
|
const offset = this.layoutChildren(container, layouter, options, maxWidth, maxHeight);
|
|
49
|
-
|
|
50
|
+
const computed = this.getComputedContainerDimensions(options, childrenSize.width, childrenSize.height);
|
|
51
|
+
LayoutAware.setComputedDimensions(boundsData, computed);
|
|
52
|
+
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, computed.width, computed.height);
|
|
50
53
|
boundsData.boundsChanged = true;
|
|
51
54
|
} else {
|
|
52
55
|
boundsData.bounds = { x: boundsData.bounds!.x, y: boundsData.bounds!.y, width: 0, height: 0 };
|
|
@@ -96,6 +99,13 @@ export class FreeFormLayouter extends AbstractLayout<AbstractLayoutOptions> {
|
|
|
96
99
|
return currentOffset;
|
|
97
100
|
}
|
|
98
101
|
|
|
102
|
+
protected getComputedContainerDimensions(options: AbstractLayoutOptions, maxWidth: number, maxHeight: number): Dimension {
|
|
103
|
+
return {
|
|
104
|
+
width: maxWidth + options.paddingLeft + options.paddingRight,
|
|
105
|
+
height: maxHeight + options.paddingTop + options.paddingBottom
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
99
109
|
protected override getFinalContainerBounds(
|
|
100
110
|
container: GParentElement & LayoutContainer,
|
|
101
111
|
lastOffset: Point,
|
|
@@ -106,8 +116,8 @@ export class FreeFormLayouter extends AbstractLayout<AbstractLayoutOptions> {
|
|
|
106
116
|
const result = {
|
|
107
117
|
x: container.bounds.x,
|
|
108
118
|
y: container.bounds.y,
|
|
109
|
-
width: Math.max(options.minWidth, maxWidth
|
|
110
|
-
height: Math.max(options.minHeight, maxHeight
|
|
119
|
+
width: Math.max(options.minWidth, maxWidth),
|
|
120
|
+
height: Math.max(options.minHeight, maxHeight)
|
|
111
121
|
};
|
|
112
122
|
|
|
113
123
|
return result;
|
|
@@ -18,21 +18,29 @@ import {
|
|
|
18
18
|
Action,
|
|
19
19
|
BoundsData,
|
|
20
20
|
ComputedBoundsAction,
|
|
21
|
-
Deferred,
|
|
22
21
|
EdgeRouterRegistry,
|
|
22
|
+
ElementAndAlignment,
|
|
23
|
+
ElementAndBounds,
|
|
24
|
+
ElementAndLayoutData,
|
|
23
25
|
ElementAndRoutingPoints,
|
|
26
|
+
GChildElement,
|
|
24
27
|
GModelElement,
|
|
25
28
|
HiddenBoundsUpdater,
|
|
26
|
-
|
|
29
|
+
LayoutData,
|
|
27
30
|
ModelIndexImpl,
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
RequestBoundsAction,
|
|
32
|
+
isLayoutContainer
|
|
30
33
|
} from '@eclipse-glsp/sprotty';
|
|
31
34
|
import { inject, injectable, optional } from 'inversify';
|
|
32
35
|
import { VNode } from 'snabbdom';
|
|
33
36
|
import { BoundsAwareModelElement, calcElementAndRoute, getDescendantIds, isRoutable } from '../../utils/gmodel-util';
|
|
37
|
+
import { LayoutAware } from './layout-data';
|
|
34
38
|
import { LocalComputedBoundsAction, LocalRequestBoundsAction } from './local-bounds';
|
|
35
39
|
|
|
40
|
+
export class BoundsDataExt extends BoundsData {
|
|
41
|
+
layoutData?: LayoutData;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
/**
|
|
37
45
|
* Grabs the bounds from hidden SVG DOM elements, applies layouts, collects routes and fires {@link ComputedBoundsAction}s.
|
|
38
46
|
*
|
|
@@ -44,7 +52,7 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
44
52
|
|
|
45
53
|
protected element2route: ElementAndRoutingPoints[] = [];
|
|
46
54
|
|
|
47
|
-
protected getElement2BoundsData(): Map<BoundsAwareModelElement,
|
|
55
|
+
protected getElement2BoundsData(): Map<BoundsAwareModelElement, BoundsDataExt> {
|
|
48
56
|
return this['element2boundsData'];
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -60,10 +68,56 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
60
68
|
if (LocalRequestBoundsAction.is(cause) && cause.elementIDs) {
|
|
61
69
|
this.focusOnElements(cause.elementIDs);
|
|
62
70
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
|
|
72
|
+
// collect bounds and layout data in element2BoundsData
|
|
73
|
+
this.getBoundsFromDOM();
|
|
74
|
+
this.layouter.layout(this.getElement2BoundsData());
|
|
75
|
+
|
|
76
|
+
// prepare data for action
|
|
77
|
+
const resizes: ElementAndBounds[] = [];
|
|
78
|
+
const alignments: ElementAndAlignment[] = [];
|
|
79
|
+
const layoutData: ElementAndLayoutData[] = [];
|
|
80
|
+
this.getElement2BoundsData().forEach((boundsData, element) => {
|
|
81
|
+
if (boundsData.boundsChanged && boundsData.bounds !== undefined) {
|
|
82
|
+
const resize: ElementAndBounds = {
|
|
83
|
+
elementId: element.id,
|
|
84
|
+
newSize: {
|
|
85
|
+
width: boundsData.bounds.width,
|
|
86
|
+
height: boundsData.bounds.height
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// don't copy position if the element is layouted by the server
|
|
90
|
+
if (element instanceof GChildElement && isLayoutContainer(element.parent)) {
|
|
91
|
+
resize.newPosition = {
|
|
92
|
+
x: boundsData.bounds.x,
|
|
93
|
+
y: boundsData.bounds.y
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
resizes.push(resize);
|
|
97
|
+
}
|
|
98
|
+
if (boundsData.alignmentChanged && boundsData.alignment !== undefined) {
|
|
99
|
+
alignments.push({
|
|
100
|
+
elementId: element.id,
|
|
101
|
+
newAlignment: boundsData.alignment
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (LayoutAware.is(boundsData)) {
|
|
105
|
+
layoutData.push({ elementId: element.id, layoutData: boundsData.layoutData });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const routes = this.element2route.length === 0 ? undefined : this.element2route;
|
|
109
|
+
|
|
110
|
+
// prepare and dispatch action
|
|
111
|
+
const responseId = (cause as RequestBoundsAction).requestId;
|
|
112
|
+
const revision = this.root !== undefined ? this.root.revision : undefined;
|
|
113
|
+
const computedBoundsAction = ComputedBoundsAction.create(resizes, { revision, alignments, layoutData, routes, responseId });
|
|
114
|
+
if (LocalRequestBoundsAction.is(cause)) {
|
|
115
|
+
LocalComputedBoundsAction.mark(computedBoundsAction);
|
|
116
|
+
}
|
|
117
|
+
this.actionDispatcher.dispatch(computedBoundsAction);
|
|
118
|
+
|
|
119
|
+
// cleanup
|
|
120
|
+
this.getElement2BoundsData().clear();
|
|
67
121
|
this.element2route = [];
|
|
68
122
|
}
|
|
69
123
|
|
|
@@ -82,41 +136,4 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
82
136
|
protected expandElementId(id: string, index: ModelIndexImpl, elementIDs: string[]): string[] {
|
|
83
137
|
return getDescendantIds(index.getById(id));
|
|
84
138
|
}
|
|
85
|
-
|
|
86
|
-
protected captureActions(call: () => void): Action[] {
|
|
87
|
-
const capturingActionDispatcher = new CapturingActionDispatcher();
|
|
88
|
-
const actualActionDispatcher = this.actionDispatcher;
|
|
89
|
-
this.actionDispatcher = capturingActionDispatcher;
|
|
90
|
-
try {
|
|
91
|
-
call();
|
|
92
|
-
return capturingActionDispatcher.actions;
|
|
93
|
-
} finally {
|
|
94
|
-
this.actionDispatcher = actualActionDispatcher;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
protected enhanceAction(action: ComputedBoundsAction, cause?: Action): ComputedBoundsAction {
|
|
99
|
-
if (LocalRequestBoundsAction.is(cause)) {
|
|
100
|
-
LocalComputedBoundsAction.mark(action);
|
|
101
|
-
}
|
|
102
|
-
action.routes = this.element2route.length === 0 ? undefined : this.element2route;
|
|
103
|
-
return action;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
class CapturingActionDispatcher implements IActionDispatcher {
|
|
108
|
-
readonly actions: Action[] = [];
|
|
109
|
-
|
|
110
|
-
async dispatch(action: Action): Promise<void> {
|
|
111
|
-
this.actions.push(action);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async dispatchAll(actions: Action[]): Promise<void> {
|
|
115
|
-
this.actions.push(...actions);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async request<Res extends ResponseAction>(action: RequestAction<Res>): Promise<Res> {
|
|
119
|
-
// ignore, not needed for our purposes
|
|
120
|
-
return new Deferred<Res>().promise;
|
|
121
|
-
}
|
|
122
139
|
}
|
|
@@ -13,22 +13,23 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { injectable } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
Bounds,
|
|
19
18
|
BoundsData,
|
|
20
19
|
Dimension,
|
|
21
20
|
GChildElement,
|
|
21
|
+
GModelElement,
|
|
22
|
+
GParentElement,
|
|
22
23
|
HBoxLayoutOptions,
|
|
23
24
|
HBoxLayouter,
|
|
24
25
|
LayoutContainer,
|
|
25
26
|
Point,
|
|
26
|
-
GModelElement,
|
|
27
|
-
GParentElement,
|
|
28
27
|
StatefulLayouter,
|
|
29
28
|
isBoundsAware,
|
|
30
29
|
isLayoutableChild
|
|
31
30
|
} from '@eclipse-glsp/sprotty';
|
|
31
|
+
import { injectable } from 'inversify';
|
|
32
|
+
import { LayoutAware } from './layout-data';
|
|
32
33
|
|
|
33
34
|
export interface HBoxLayoutOptionsExt extends HBoxLayoutOptions {
|
|
34
35
|
hGrab: boolean;
|
|
@@ -79,7 +80,9 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
79
80
|
|
|
80
81
|
if (width > 0 && height > 0) {
|
|
81
82
|
const offset = this.layoutChildren(container, layouter, options, width, height, grabWidth, grabbingChildren);
|
|
82
|
-
|
|
83
|
+
const computed = this.getComputedContainerDimensions(options, childrenSize.width, childrenSize.height);
|
|
84
|
+
LayoutAware.setComputedDimensions(boundsData, computed);
|
|
85
|
+
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, computed.width, computed.height);
|
|
83
86
|
boundsData.boundsChanged = true;
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -223,22 +226,28 @@ export class HBoxLayouterExt extends HBoxLayouter {
|
|
|
223
226
|
return (element as any).layoutOptions;
|
|
224
227
|
}
|
|
225
228
|
|
|
229
|
+
protected getComputedContainerDimensions(options: HBoxLayoutOptionsExt, maxWidth: number, maxHeight: number): Dimension {
|
|
230
|
+
return {
|
|
231
|
+
width: maxWidth + options.paddingLeft + options.paddingRight,
|
|
232
|
+
height: maxHeight + options.paddingTop + options.paddingBottom
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
226
236
|
protected override getFinalContainerBounds(
|
|
227
237
|
container: GParentElement & LayoutContainer,
|
|
228
238
|
lastOffset: Point,
|
|
229
239
|
options: HBoxLayoutOptionsExt,
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
computedWidth: number,
|
|
241
|
+
computedHeight: number
|
|
232
242
|
): Bounds {
|
|
233
243
|
const elementOptions = this.getElementLayoutOptions(container);
|
|
234
244
|
const width = elementOptions?.prefWidth ?? options.minWidth;
|
|
235
245
|
const height = elementOptions?.prefHeight ?? options.minHeight;
|
|
236
|
-
|
|
237
246
|
const result = {
|
|
238
247
|
x: container.bounds.x,
|
|
239
248
|
y: container.bounds.y,
|
|
240
|
-
width: Math.max(width,
|
|
241
|
-
height: Math.max(height,
|
|
249
|
+
width: Math.max(width, computedWidth),
|
|
250
|
+
height: Math.max(height, computedHeight)
|
|
242
251
|
};
|
|
243
252
|
|
|
244
253
|
return result;
|
|
@@ -17,6 +17,7 @@ export * from './bounds-module';
|
|
|
17
17
|
export * from './freeform-layout';
|
|
18
18
|
export * from './glsp-hidden-bounds-updater';
|
|
19
19
|
export * from './hbox-layout';
|
|
20
|
+
export * from './layout-data';
|
|
20
21
|
export * from './layouter';
|
|
21
22
|
export * from './local-bounds';
|
|
22
23
|
export * from './set-bounds-feedback-command';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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
|
+
|
|
17
|
+
import { Dimension, LayoutData } from '@eclipse-glsp/sprotty';
|
|
18
|
+
|
|
19
|
+
export interface LayoutAware {
|
|
20
|
+
layoutData: LayoutData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export namespace LayoutAware {
|
|
24
|
+
export function is<T extends object>(element: T): element is T & LayoutAware {
|
|
25
|
+
return 'layoutData' in element;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getLayoutData<T extends object>(element: T): LayoutData | undefined {
|
|
29
|
+
return is(element) ? element.layoutData : undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function setLayoutData<T extends object>(element: T, data: LayoutData): void {
|
|
33
|
+
(element as LayoutAware).layoutData = data;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function setComputedDimensions<T extends object>(element: T, computedDimensions: Dimension): void {
|
|
37
|
+
ensureLayoutAware(element).layoutData.computedDimensions = computedDimensions;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getComputedDimensions<T extends object>(element: T): Dimension | undefined {
|
|
41
|
+
return getLayoutData(element)?.computedDimensions;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ensureLayoutAware<T extends object>(element: T): T & LayoutAware {
|
|
45
|
+
(element as LayoutAware).layoutData = (element as LayoutAware).layoutData ?? {};
|
|
46
|
+
return element as T & LayoutAware;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '@eclipse-glsp/sprotty';
|
|
32
32
|
import { inject, injectable } from 'inversify';
|
|
33
33
|
import { ServerAction } from '../../base/model/glsp-model-source';
|
|
34
|
+
import { LayoutAware } from './layout-data';
|
|
34
35
|
|
|
35
36
|
export interface LocalRequestBoundsAction extends RequestBoundsAction {
|
|
36
37
|
elementIDs?: string[];
|
|
@@ -41,9 +42,11 @@ export namespace LocalRequestBoundsAction {
|
|
|
41
42
|
return RequestBoundsAction.is(object) && !ServerAction.is(object) && hasArrayProp(object, 'elementIDs', true);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export function create(newRoot:
|
|
45
|
+
export function create(newRoot: GModelRoot, elementIDs?: string[]): LocalRequestBoundsAction;
|
|
46
|
+
export function create(newRoot: GModelRootSchema, elementIDs?: string[]): LocalRequestBoundsAction;
|
|
47
|
+
export function create(newRoot: GModelRoot | GModelRootSchema, elementIDs?: string[]): LocalRequestBoundsAction {
|
|
45
48
|
return {
|
|
46
|
-
...RequestBoundsAction.create(newRoot),
|
|
49
|
+
...RequestBoundsAction.create(newRoot as unknown as GModelRootSchema),
|
|
47
50
|
elementIDs
|
|
48
51
|
};
|
|
49
52
|
}
|
|
@@ -55,7 +58,7 @@ export namespace LocalRequestBoundsAction {
|
|
|
55
58
|
elementIDs?: string[]
|
|
56
59
|
): CommandResult {
|
|
57
60
|
// do not modify the main model (modelChanged = false) but request local bounds calculation on hidden model
|
|
58
|
-
actionDispatcher.dispatch(LocalRequestBoundsAction.create(root
|
|
61
|
+
actionDispatcher.dispatch(LocalRequestBoundsAction.create(root, elementIDs));
|
|
59
62
|
return {
|
|
60
63
|
model: root,
|
|
61
64
|
modelChanged: false,
|
|
@@ -65,7 +68,7 @@ export namespace LocalRequestBoundsAction {
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
export namespace LocalComputedBoundsAction {
|
|
68
|
-
export function is(object: unknown): object is
|
|
71
|
+
export function is(object: unknown): object is ComputedBoundsAction & ServerAction {
|
|
69
72
|
return ComputedBoundsAction.is(object) && ServerAction.is(object);
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -94,9 +97,22 @@ export class LocalComputedBoundsCommand extends Command {
|
|
|
94
97
|
}
|
|
95
98
|
// apply computed bounds from the hidden model and return updated model to render new main model
|
|
96
99
|
this.computedBoundsApplicator.apply(context.root as unknown as GModelRootSchema, this.action);
|
|
100
|
+
this.action.layoutData?.forEach(({ elementId, layoutData }) => {
|
|
101
|
+
const element = context.root.index.getById(elementId);
|
|
102
|
+
if (element !== undefined) {
|
|
103
|
+
LayoutAware.setLayoutData(element, layoutData);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
97
106
|
return context.root;
|
|
98
107
|
}
|
|
99
108
|
|
|
109
|
+
this.action.layoutData?.forEach(({ elementId, layoutData }) => {
|
|
110
|
+
const element = context.root.index.getById(elementId);
|
|
111
|
+
if (element !== undefined) {
|
|
112
|
+
LayoutAware.setLayoutData(element, layoutData);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
100
116
|
// computed bounds action from server -> we do not care and do not trigger any update of the main model
|
|
101
117
|
return {
|
|
102
118
|
model: context.root,
|
|
@@ -13,22 +13,23 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { injectable } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
Bounds,
|
|
19
18
|
BoundsData,
|
|
20
19
|
Dimension,
|
|
21
20
|
GChildElement,
|
|
22
|
-
LayoutContainer,
|
|
23
|
-
Point,
|
|
24
21
|
GModelElement,
|
|
25
22
|
GParentElement,
|
|
23
|
+
LayoutContainer,
|
|
24
|
+
Point,
|
|
26
25
|
StatefulLayouter,
|
|
27
26
|
VBoxLayoutOptions,
|
|
28
27
|
VBoxLayouter,
|
|
29
28
|
isBoundsAware,
|
|
30
29
|
isLayoutableChild
|
|
31
30
|
} from '@eclipse-glsp/sprotty';
|
|
31
|
+
import { injectable } from 'inversify';
|
|
32
|
+
import { LayoutAware } from './layout-data';
|
|
32
33
|
|
|
33
34
|
export interface VBoxLayoutOptionsExt extends VBoxLayoutOptions {
|
|
34
35
|
hGrab: boolean;
|
|
@@ -79,7 +80,9 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
79
80
|
|
|
80
81
|
if (maxWidth > 0 && maxHeight > 0) {
|
|
81
82
|
const offset = this.layoutChildren(container, layouter, options, width, height, grabHeight, grabbingChildren);
|
|
82
|
-
|
|
83
|
+
const computed = this.getComputedContainerDimensions(options, childrenSize.width, childrenSize.height);
|
|
84
|
+
LayoutAware.setComputedDimensions(boundsData, computed);
|
|
85
|
+
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, computed.width, computed.height);
|
|
83
86
|
boundsData.boundsChanged = true;
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -223,24 +226,29 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
223
226
|
return (element as any).layoutOptions;
|
|
224
227
|
}
|
|
225
228
|
|
|
229
|
+
protected getComputedContainerDimensions(options: VBoxLayoutOptionsExt, maxWidth: number, maxHeight: number): Dimension {
|
|
230
|
+
return {
|
|
231
|
+
width: maxWidth + options.paddingLeft + options.paddingRight,
|
|
232
|
+
height: maxHeight + options.paddingTop + options.paddingBottom
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
226
236
|
protected override getFinalContainerBounds(
|
|
227
237
|
container: GParentElement & LayoutContainer,
|
|
228
238
|
lastOffset: Point,
|
|
229
239
|
options: VBoxLayoutOptionsExt,
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
computedWidth: number,
|
|
241
|
+
computedHeight: number
|
|
232
242
|
): Bounds {
|
|
233
243
|
const elementOptions = this.getElementLayoutOptions(container);
|
|
234
244
|
const width = elementOptions?.prefWidth ?? options.minWidth;
|
|
235
245
|
const height = elementOptions?.prefHeight ?? options.minHeight;
|
|
236
|
-
|
|
237
246
|
const result = {
|
|
238
247
|
x: container.bounds.x,
|
|
239
248
|
y: container.bounds.y,
|
|
240
|
-
width: Math.max(width,
|
|
241
|
-
height: Math.max(height,
|
|
249
|
+
width: Math.max(width, computedWidth),
|
|
250
|
+
height: Math.max(height, computedHeight)
|
|
242
251
|
};
|
|
243
|
-
|
|
244
252
|
return result;
|
|
245
253
|
}
|
|
246
254
|
|