This commit is contained in:
Carl Fuchs 2023-02-10 09:46:39 +01:00
parent 79caa5e9ab
commit b09718d72d
3 changed files with 14 additions and 9 deletions

View file

@ -1,10 +1,10 @@
import { IConfiguration } from '../../../Interfaces/IConfiguration'; import { type IConfiguration } from '../../../Interfaces/IConfiguration';
import { IContainerModel } from '../../../Interfaces/IContainerModel'; import { type IContainerModel } from '../../../Interfaces/IContainerModel';
import { IHistoryState } from '../../../Interfaces/IHistoryState'; import { type IHistoryState } from '../../../Interfaces/IHistoryState';
import { ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
import { GetDefaultSymbolModel } from '../../../utils/default'; import { GetDefaultSymbolModel } from '../../../utils/default';
import { FindContainerById } from '../../../utils/itertools'; import { FindContainerById } from '../../../utils/itertools';
import { RestoreX } from '../../../utils/svg'; import {RestoreX, RestoreY} from '../../../utils/svg';
import { ApplyBehaviors, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors'; import { ApplyBehaviors, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors';
import { GetCurrentHistory, GetCurrentHistoryState, UpdateCounters } from '../Editor'; import { GetCurrentHistory, GetCurrentHistoryState, UpdateCounters } from '../Editor';
import { AddContainers } from './AddContainer'; import { AddContainers } from './AddContainer';
@ -32,7 +32,12 @@ export function AddSymbol(
const newSymbols = structuredClone(current.symbols); const newSymbols = structuredClone(current.symbols);
const newSymbol: ISymbolModel = GetDefaultSymbolModel(name, typeCounters, type, symbolConfig); const newSymbol: ISymbolModel = GetDefaultSymbolModel(name, typeCounters, type, symbolConfig);
const containers = structuredClone(current.containers); 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); newSymbols.set(newSymbol.id, newSymbol);

View file

@ -4,7 +4,7 @@ import { ApplyParentTransform, FindContainerById } from '../../../utils/itertool
import { RestoreX, TransformX } from '../../../utils/svg'; import { RestoreX, TransformX } from '../../../utils/svg';
export function ApplySymbol(containers: Map<string, IContainerModel>, container: IContainerModel, symbol: ISymbolModel): IContainerModel { export function ApplySymbol(containers: Map<string, IContainerModel>, 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); container.properties.x = RestoreX(container.properties.x, container.properties.width, container.properties.positionReference);
const parent = FindContainerById(containers, container.properties.parentId); const parent = FindContainerById(containers, container.properties.parentId);
let x = 0; let x = 0;

View file

@ -34,9 +34,9 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
value={props.symbol.displayedText} value={props.symbol.displayedText}
onChange={(value) => { props.onChange('displayedText', value); }} /> onChange={(value) => { props.onChange('displayedText', value); }} />
<TextInputGroup <TextInputGroup
id='x' id='offset'
labelText={Text({ textId: '@SymbolOffset' })} labelText={Text({ textId: '@SymbolOffset' })}
inputKey='x' inputKey='offset'
labelClassName='' labelClassName=''
inputClassName='' inputClassName=''
type='number' type='number'