Skip to content

Commit c0f83d9

Browse files
Add root/viewport layout information to computed bounds for auto-layout (#458)
Relates to eclipse-glsp/glsp#1616
1 parent acbf000 commit c0f83d9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/client/src/features/bounds/glsp-hidden-bounds-updater.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
} from '@eclipse-glsp/sprotty';
3434
import { inject, injectable, optional } from 'inversify';
3535
import { VNode } from 'snabbdom';
36+
import { EditorContextService } from '../../base/editor-context-service';
3637
import { BoundsAwareModelElement, calcElementAndRoute, getDescendantIds, isRoutable } from '../../utils/gmodel-util';
3738
import { LayoutAware } from './layout-data';
3839
import { LocalComputedBoundsAction, LocalRequestBoundsAction } from './local-bounds';
@@ -49,6 +50,7 @@ export class BoundsDataExt extends BoundsData {
4950
@injectable()
5051
export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
5152
@inject(EdgeRouterRegistry) @optional() protected readonly edgeRouterRegistry?: EdgeRouterRegistry;
53+
@inject(EditorContextService) protected editorContext: EditorContextService;
5254

5355
protected element2route: ElementAndRoutingPoints[] = [];
5456

@@ -114,7 +116,17 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
114116
// prepare and dispatch action
115117
const responseId = (cause as RequestBoundsAction).requestId;
116118
const revision = this.root !== undefined ? this.root.revision : undefined;
117-
const computedBoundsAction = ComputedBoundsAction.create(resizes, { revision, alignments, layoutData, routes, responseId });
119+
const canvasBounds = this.editorContext.canvasBounds;
120+
const viewport = this.editorContext.viewportData;
121+
const computedBoundsAction = ComputedBoundsAction.create(resizes, {
122+
revision,
123+
alignments,
124+
layoutData,
125+
routes,
126+
responseId,
127+
canvasBounds,
128+
viewport
129+
});
118130
if (LocalRequestBoundsAction.is(cause)) {
119131
LocalComputedBoundsAction.mark(computedBoundsAction);
120132
}

packages/protocol/src/action-protocol/model-layout.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export interface ComputedBoundsAction extends ResponseAction, sprotty.ComputedBo
8585
* The layout data of hte model elements.
8686
*/
8787
layoutData?: ElementAndLayoutData[];
88+
89+
/**
90+
* The current bounds of the canvas at time of layout.
91+
*/
92+
canvasBounds?: Bounds;
93+
94+
/**
95+
* The current viewport information at time of layout.
96+
*/
97+
viewport?: Viewport;
8898
}
8999

90100
export namespace ComputedBoundsAction {
@@ -102,6 +112,8 @@ export namespace ComputedBoundsAction {
102112
alignments?: ElementAndAlignment[];
103113
routes?: ElementAndRoutingPoints[];
104114
layoutData?: ElementAndLayoutData[];
115+
canvasBounds?: Bounds;
116+
viewport?: Viewport;
105117
} = {}
106118
): ComputedBoundsAction {
107119
return {

0 commit comments

Comments
 (0)