From b09718d72df86ae47eb5df70c5c0ef34ca0466e6 Mon Sep 17 00:00:00 2001 From: Carl Fuchs Date: Fri, 10 Feb 2023 09:46:39 +0100 Subject: [PATCH] WIP2 --- .../Editor/Actions/SymbolOperations.ts | 17 +++++++++++------ .../Editor/Behaviors/SymbolBehaviors.ts | 2 +- src/Components/SymbolProperties/SymbolForm.tsx | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Components/Editor/Actions/SymbolOperations.ts b/src/Components/Editor/Actions/SymbolOperations.ts index 7464193..abff45f 100644 --- a/src/Components/Editor/Actions/SymbolOperations.ts +++ b/src/Components/Editor/Actions/SymbolOperations.ts @@ -1,10 +1,10 @@ -import { IConfiguration } from '../../../Interfaces/IConfiguration'; -import { IContainerModel } from '../../../Interfaces/IContainerModel'; -import { IHistoryState } from '../../../Interfaces/IHistoryState'; -import { ISymbolModel } from '../../../Interfaces/ISymbolModel'; +import { type IConfiguration } from '../../../Interfaces/IConfiguration'; +import { type IContainerModel } from '../../../Interfaces/IContainerModel'; +import { type IHistoryState } from '../../../Interfaces/IHistoryState'; +import { type ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { GetDefaultSymbolModel } from '../../../utils/default'; import { FindContainerById } from '../../../utils/itertools'; -import { RestoreX } from '../../../utils/svg'; +import {RestoreX, RestoreY} from '../../../utils/svg'; import { ApplyBehaviors, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors'; import { GetCurrentHistory, GetCurrentHistoryState, UpdateCounters } from '../Editor'; import { AddContainers } from './AddContainer'; @@ -32,7 +32,12 @@ export function AddSymbol( const newSymbols = structuredClone(current.symbols); const newSymbol: ISymbolModel = GetDefaultSymbolModel(name, typeCounters, type, symbolConfig); const containers = structuredClone(current.containers); - newSymbol.x = RestoreX(newSymbol.x, newSymbol.width, newSymbol.config.PositionReference); + + if (newSymbol.isVertical) { + newSymbol.offset = RestoreY(newSymbol.offset, newSymbol.height, newSymbol.config.PositionReference); + } else { + newSymbol.offset = RestoreX(newSymbol.offset, newSymbol.width, newSymbol.config.PositionReference); + } newSymbols.set(newSymbol.id, newSymbol); diff --git a/src/Components/Editor/Behaviors/SymbolBehaviors.ts b/src/Components/Editor/Behaviors/SymbolBehaviors.ts index 5efde19..7ece236 100644 --- a/src/Components/Editor/Behaviors/SymbolBehaviors.ts +++ b/src/Components/Editor/Behaviors/SymbolBehaviors.ts @@ -4,7 +4,7 @@ import { ApplyParentTransform, FindContainerById } from '../../../utils/itertool import { RestoreX, TransformX } from '../../../utils/svg'; export function ApplySymbol(containers: Map, container: IContainerModel, symbol: ISymbolModel): IContainerModel { - container.properties.x = TransformX(symbol.x, symbol.width, symbol.config.PositionReference); + container.properties.x = TransformX(symbol.offset, symbol.width, symbol.config.PositionReference); container.properties.x = RestoreX(container.properties.x, container.properties.width, container.properties.positionReference); const parent = FindContainerById(containers, container.properties.parentId); let x = 0; diff --git a/src/Components/SymbolProperties/SymbolForm.tsx b/src/Components/SymbolProperties/SymbolForm.tsx index fe0efeb..9b268fe 100644 --- a/src/Components/SymbolProperties/SymbolForm.tsx +++ b/src/Components/SymbolProperties/SymbolForm.tsx @@ -34,9 +34,9 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element { value={props.symbol.displayedText} onChange={(value) => { props.onChange('displayedText', value); }} />