Skip to content

Commit 6af4e74

Browse files
committed
wip: (hardcode) when node-type sidebar is active have better centering of canvas
1 parent 3a6a5a6 commit 6af4e74

File tree

7 files changed

+51
-9
lines changed

7 files changed

+51
-9
lines changed

libs/app-canvas/src/app/app.element.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
showHTMLElement,
5757
} from './utils/show-hide-element';
5858
import { createInputDialog } from './utils/create-input-dialog';
59+
import { APPFlowOptions } from './interfaces/app-flow-options';
5960

6061
export class AppElement<T extends BaseNodeInfo> {
6162
public static observedAttributes = [];
@@ -105,7 +106,8 @@ export class AppElement<T extends BaseNodeInfo> {
105106
_isReadOnly?: boolean,
106107
heightSpaceForHeaderFooterToolbars?: number,
107108
widthSpaceForSideToobars?: number,
108-
getNodeTaskFactory?: GetNodeTaskFactory<T>
109+
getNodeTaskFactory?: GetNodeTaskFactory<T>,
110+
options?: APPFlowOptions
109111
) {
110112
// NOTE : on http instead of https, crypto is not available...
111113
// so uuid's cannot be created and the app will not work
@@ -157,7 +159,11 @@ export class AppElement<T extends BaseNodeInfo> {
157159
undefined,
158160
undefined,
159161
undefined,
160-
getNodeTaskFactory
162+
getNodeTaskFactory,
163+
{
164+
hasNodeTypeSideBar: options?.hasNodeTypeSideBar,
165+
nodeTypeSideBarSelector: options?.nodeTypeSideBarSelector,
166+
}
161167
);
162168
this.canvas = canvasApp.canvas;
163169
this.canvasApp = canvasApp;

libs/app-canvas/src/app/flow-app.element.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ export class FlowAppElement extends AppElement<NodeInfo> {
272272
isReadOnly,
273273
heightSpaceForHeaderFooterToolbars,
274274
widthSpaceForSideToobars,
275-
getNodeTaskFactory
275+
getNodeTaskFactory,
276+
{
277+
hasNodeTypeSideBar: true,
278+
nodeTypeSideBarSelector: '.taskbar-container',
279+
}
276280
);
277281
if (!this.rootElement) {
278282
return;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface APPFlowOptions {
2+
hasNodeTypeSideBar?: boolean;
3+
nodeTypeSideBarSelector?: string;
4+
}

libs/visual-programming-system/src/canvas-app/base-flow.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export interface IBaseFlow<T extends BaseNodeInfo> {
3333
isContextOnly: boolean;
3434
isComposition: boolean;
3535
theme: Theme;
36+
37+
hasNodeTypeSideBar?: boolean;
38+
nodeTypeSideBarSelector?: string;
39+
3640
setOnAddcomposition: (
3741
_onAddComposition: (
3842
composition: Composition<T>,

libs/visual-programming-system/src/canvas-app/index.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { IFlowCanvasBase } from './flow-canvas';
4848
import { FlowCore } from './flow-core';
4949
import { GetNodeTaskFactory } from '../interfaces/node-task-registry';
5050
import { LayoutProperties } from '../interfaces/layout-properties';
51+
import { FlowCanvasOptions } from '../interfaces/flow-canvas';
5152

5253
export const createFlowCanvas = <T extends BaseNodeInfo>(
5354
rootElement: HTMLElement,
@@ -71,7 +72,8 @@ export const createFlowCanvas = <T extends BaseNodeInfo>(
7172
isCancelling: boolean
7273
) => void,
7374
rootFlowCanvas?: IFlowCanvasBase<T>,
74-
getNodeTaskFactory?: GetNodeTaskFactory<T>
75+
getNodeTaskFactory?: GetNodeTaskFactory<T>,
76+
options?: FlowCanvasOptions
7577
): IFlowCanvasBase<T> => {
7678
return new FlowCanvas(
7779
rootElement,
@@ -88,7 +90,8 @@ export const createFlowCanvas = <T extends BaseNodeInfo>(
8890
onDroppedOnNode,
8991
onDraggingOverNode,
9092
rootFlowCanvas,
91-
getNodeTaskFactory
93+
getNodeTaskFactory,
94+
options
9295
);
9396
};
9497

@@ -107,6 +110,9 @@ export class FlowCanvas<T extends BaseNodeInfo>
107110
public isContextOnly = false;
108111
public isComposition = false;
109112

113+
public hasNodeTypeSideBar?: boolean;
114+
public nodeTypeSideBarSelector?: string;
115+
110116
private rectInstanceList: Record<string, Rect<T>>;
111117
private CanvasClickEvent: Event;
112118
private animationFunctions: undefined | AnimatePathFunctions<T>;
@@ -179,6 +185,7 @@ export class FlowCanvas<T extends BaseNodeInfo>
179185
| undefined;
180186

181187
private rootFlowCanvas: IFlowCanvasBase<T> | undefined;
188+
182189
public getRootFlowCanvas = () => this.rootFlowCanvas;
183190
constructor(
184191
rootElement: HTMLElement,
@@ -202,7 +209,8 @@ export class FlowCanvas<T extends BaseNodeInfo>
202209
isCancelling: boolean
203210
) => void,
204211
rootFlowCanvas?: IFlowCanvasBase<T>,
205-
getNodeTaskFactory?: GetNodeTaskFactory<T>
212+
getNodeTaskFactory?: GetNodeTaskFactory<T>,
213+
options?: FlowCanvasOptions
206214
) {
207215
super();
208216
this.rootFlowCanvas = rootFlowCanvas;
@@ -212,6 +220,9 @@ export class FlowCanvas<T extends BaseNodeInfo>
212220
heightSpaceForHeaderFooterToolbars;
213221
this.widthSpaceForSideToobars = widthSpaceForSideToobars;
214222

223+
this.hasNodeTypeSideBar = options?.hasNodeTypeSideBar;
224+
this.nodeTypeSideBarSelector = options?.nodeTypeSideBarSelector;
225+
215226
this.rootElement = rootElement;
216227
this.theme = customTheme ?? standardTheme;
217228
this.interactionStateMachine =
@@ -1193,8 +1204,11 @@ export class FlowCanvas<T extends BaseNodeInfo>
11931204
const helperScale = rootWidth / helperWidth;
11941205
const helperHeight = maxY - minY;
11951206
const helperScaleHeight = rootHeight / helperHeight;
1196-
1197-
const width = maxX - minX + 120 / helperScale;
1207+
let offsetNodesidebar = 0;
1208+
if (this.hasNodeTypeSideBar) {
1209+
offsetNodesidebar = 280;
1210+
}
1211+
const width = maxX - minX + (120 + offsetNodesidebar) / helperScale;
11981212
const height = maxY - minY + 240 / helperScaleHeight;
11991213

12001214
let scale = rootWidth / width;
@@ -1242,11 +1256,16 @@ export class FlowCanvas<T extends BaseNodeInfo>
12421256
this.heightSpaceForHeaderFooterToolbars ?? 0
12431257
); // 100; //-150 //-boundingBox.y; // -500; //boundingBox.y;
12441258

1259+
let xOffsetNodesidebar = 0;
1260+
if (this.hasNodeTypeSideBar) {
1261+
xOffsetNodesidebar = 200;
1262+
}
12451263
this.xCamera =
12461264
rootWidth / 2 -
12471265
(scale * width) / 2 -
12481266
scale * (minX + (-60 + 60) / helperScale) -
1249-
boudingBoxCorrectionX;
1267+
boudingBoxCorrectionX +
1268+
xOffsetNodesidebar;
12501269
this.yCamera =
12511270
rootHeight / 2 -
12521271
(scale * height) / 2 -

libs/visual-programming-system/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ export * from './canvas-app/composition-runtime-flow-context';
6161
export * from './interfaces/run-counter';
6262
export * from './utils/pointer-pos';
6363
export * from './components/events/pointer-events';
64+
export * from './interfaces/layout-properties';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface FlowCanvasOptions {
2+
hasNodeTypeSideBar?: boolean;
3+
nodeTypeSideBarSelector?: string;
4+
}

0 commit comments

Comments
 (0)