Skip to content

Commit d59ff63

Browse files
committed
Handle anchor adjustment.
1 parent 3c37bb3 commit d59ff63

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

newIDE/app/src/ObjectsRendering/Renderers/RenderedCustomObjectInstance.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ type AxeLayout = {
140140
anchorOrigin?: number,
141141
anchorTarget?: number,
142142
anchorTargetObject?: string,
143+
anchorDelta?: number,
143144
minSideAbsoluteMargin?: number,
144145
maxSideAbsoluteMargin?: number,
145146
minSideProportionalMargin?: number,
@@ -161,7 +162,9 @@ const layoutFields = [
161162
'HorizontalAnchorOrigin',
162163
'HorizontalAnchorTarget',
163164
'VerticalAnchorOrigin',
164-
'BarVerticalAnchorTarget',
165+
'VerticalAnchorTarget',
166+
'AnchorDeltaX',
167+
'AnchorDeltaY',
165168
];
166169

167170
const getHorizontalAnchorValue = (anchorName: string) => {
@@ -281,6 +284,10 @@ const getLayouts = (
281284
layout.verticalLayout.anchorTarget = anchorTarget;
282285
}
283286
layout.verticalLayout.anchorTargetObject = targetObjectName;
287+
} else if (layoutField === 'AnchorDeltaX') {
288+
layout.horizontalLayout.anchorDelta = propertyValueNumber;
289+
} else if (layoutField === 'AnchorDeltaY') {
290+
layout.verticalLayout.anchorDelta = propertyValueNumber;
284291
}
285292
}
286293
}
@@ -464,7 +471,7 @@ export default class RenderedCustomObjectInstance extends RenderedInstance {
464471
const anchorOrigin = childLayout.horizontalLayout.anchorOrigin || 0;
465472
const anchorTarget = childLayout.horizontalLayout.anchorTarget || 0;
466473
// TODO Use anchorTargetObject instead of defaulting on the background
467-
childInstance.x =
474+
childInstance.x = childLayout.horizontalLayout.anchorDelta || 0 +
468475
anchorTarget * width -
469476
anchorOrigin * renderedInstance.getDefaultWidth();
470477
}
@@ -475,7 +482,7 @@ export default class RenderedCustomObjectInstance extends RenderedInstance {
475482
const anchorOrigin = childLayout.verticalLayout.anchorOrigin || 0;
476483
const anchorTarget = childLayout.verticalLayout.anchorTarget || 0;
477484
// TODO Use anchorTargetObject instead of defaulting on the background
478-
childInstance.y =
485+
childInstance.y = childLayout.verticalLayout.anchorDelta || 0 +
479486
anchorTarget * height -
480487
anchorOrigin * renderedInstance.getDefaultHeight();
481488
}

0 commit comments

Comments
 (0)