From 387e1035011fd35543f8c43791189d0552481fd6 Mon Sep 17 00:00:00 2001 From: Carl Fuchs Date: Mon, 20 Feb 2023 15:32:06 +0100 Subject: [PATCH] [WIP] Height --- src/Components/Editor/Behaviors/SymbolBehaviors.ts | 14 ++++++++++---- .../SVG/Elements/SelectorSymbol/SelectorSymbol.tsx | 11 ++++------- src/Components/SVG/Elements/Symbol.tsx | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Components/Editor/Behaviors/SymbolBehaviors.ts b/src/Components/Editor/Behaviors/SymbolBehaviors.ts index 939b1f6..e73350f 100644 --- a/src/Components/Editor/Behaviors/SymbolBehaviors.ts +++ b/src/Components/Editor/Behaviors/SymbolBehaviors.ts @@ -3,10 +3,14 @@ import { type ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { ApplyParentTransform, FindContainerById } from '../../../utils/itertools'; import { RestoreX, RestoreY, TransformX, TransformY } from '../../../utils/svg'; -export function ApplySymbol(containers: Map, container: IContainerModel, symbol: ISymbolModel): IContainerModel { +export function ApplySymbol(containers: Map, + container: IContainerModel, + symbol: ISymbolModel): IContainerModel { if (symbol.isVertical) { - container.properties.y = TransformY(symbol.offset, symbol.height, symbol.config.PositionReference); - container.properties.y = RestoreY(container.properties.y, container.properties.height, container.properties.positionReference); + container.properties.y = TransformY(symbol.offset, 0, symbol.config.PositionReference); + container.properties.y = RestoreY(container.properties.y, + container.properties.height, + container.properties.positionReference); const parent = FindContainerById(containers, container.properties.parentId); let y = 0; if (parent !== undefined && parent !== null) { @@ -16,7 +20,9 @@ export function ApplySymbol(containers: Map, container: return container; } else { container.properties.x = TransformX(symbol.offset, symbol.width, symbol.config.PositionReference); - container.properties.x = RestoreX(container.properties.x, container.properties.width, container.properties.positionReference); + container.properties.x = RestoreX(container.properties.x, + container.properties.width, + container.properties.positionReference); const parent = FindContainerById(containers, container.properties.parentId); let x = 0; if (parent !== undefined && parent !== null) { diff --git a/src/Components/SVG/Elements/SelectorSymbol/SelectorSymbol.tsx b/src/Components/SVG/Elements/SelectorSymbol/SelectorSymbol.tsx index a420e40..7941731 100644 --- a/src/Components/SVG/Elements/SelectorSymbol/SelectorSymbol.tsx +++ b/src/Components/SVG/Elements/SelectorSymbol/SelectorSymbol.tsx @@ -28,16 +28,13 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element { if (props.selected.isVertical) { x = -SYMBOL_MARGIN; - y = props.selected.offset; + y = (props.selected.offset + props.selected.height / 2) - height; } else { - [x,y] = [ - props.selected.offset + props.selected.width / 2, - -SYMBOL_MARGIN - height] + [x, y] = [ + props.selected.offset + props.selected.width / 2, + -SYMBOL_MARGIN - height]; } - const xText = x + width / 2; - const yText = y + height / 2; - const style: React.CSSProperties = { transform: 'translateX(-50%)', transformBox: 'fill-box' diff --git a/src/Components/SVG/Elements/Symbol.tsx b/src/Components/SVG/Elements/Symbol.tsx index 9595e8c..41f6c88 100644 --- a/src/Components/SVG/Elements/Symbol.tsx +++ b/src/Components/SVG/Elements/Symbol.tsx @@ -38,7 +38,7 @@ export function Symbol(props: ISymbolProps): JSX.Element { } if (props.model.isVertical) { x = -SYMBOL_MARGIN; - y = props.model.offset + props.model.width / 2; + y = props.model.offset + props.model.height / 2; } else { x = props.model.offset + props.model.width / 2; y = -SYMBOL_MARGIN;