[Update] Symbol alignement behavior + filtered Symbollist in ContainerForm.tsx
This commit is contained in:
parent
bf4f69a95f
commit
a476017d99
8 changed files with 148 additions and 32 deletions
|
@ -185,7 +185,7 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel,
|
|||
scale: number,
|
||||
depth: number
|
||||
): void {
|
||||
const width = symbol.offset + (symbol.width / 2);
|
||||
const width = TransformX(symbol.offset, symbol.width * 2, symbol.config.PositionReference);
|
||||
if (width != null && width > 0) {
|
||||
const id = `dim-y-margin-left${symbol.width.toFixed(0)}-${symbol.id}`;
|
||||
|
||||
|
@ -213,7 +213,7 @@ function AddVerticalSymbolDimension(symbol: ISymbolModel,
|
|||
scale: number,
|
||||
depth: number
|
||||
): void {
|
||||
const height = symbol.offset + (symbol.height / 2);
|
||||
const height = TransformY(symbol.offset, symbol.height * 2, symbol.config.PositionReference);
|
||||
if (height != null && height > 0) {
|
||||
const id = `dim-x-margin-left${symbol.height.toFixed(0)}-${symbol.id}`;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ import * as React from 'react';
|
|||
import { SYMBOL_MARGIN } from '../../../../utils/default';
|
||||
import { type ISymbolModel } from '../../../../Interfaces/ISymbolModel';
|
||||
import { Selector } from '../Selector/Selector';
|
||||
import { TransformX, TransformY } from '../../../../utils/svg';
|
||||
import { PositionReference } from '../../../../Enums/PositionReference';
|
||||
|
||||
interface ISelectorSymbolProps {
|
||||
symbols: Map<string, ISymbolModel>
|
||||
|
@ -19,20 +21,44 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
|||
}
|
||||
|
||||
const scale = (props.scale ?? 1);
|
||||
const [width, height] = [
|
||||
props.selected.width / scale,
|
||||
props.selected.height / scale
|
||||
];
|
||||
|
||||
let x, y: number;
|
||||
|
||||
const scaledHeight = props.selected.height / scale;
|
||||
const scaledWidth = props.selected.width / scale;
|
||||
|
||||
if (props.selected.isVertical) {
|
||||
x = -SYMBOL_MARGIN / scale - width;
|
||||
y = (props.selected.offset + props.selected.height / 2) - (props.selected.height / scale / 2);
|
||||
x = (-SYMBOL_MARGIN - props.selected.width) / scale;
|
||||
y = TransformY(props.selected.offset, props.selected.height * 2, props.selected.config.PositionReference);
|
||||
|
||||
switch (props.selected.config.PositionReference) {
|
||||
case PositionReference.CenterLeft:
|
||||
case PositionReference.CenterCenter:
|
||||
case PositionReference.CenterRight:
|
||||
y -= scaledHeight / 2;
|
||||
break;
|
||||
case PositionReference.BottomLeft:
|
||||
case PositionReference.BottomCenter:
|
||||
case PositionReference.BottomRight:
|
||||
y -= scaledHeight;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
[x, y] = [
|
||||
(props.selected.offset + props.selected.width / 2) - (props.selected.width / scale / 2),
|
||||
-SYMBOL_MARGIN / scale - height];
|
||||
x = TransformX(props.selected.offset, props.selected.width * 2, props.selected.config.PositionReference);
|
||||
|
||||
switch (props.selected.config.PositionReference) {
|
||||
case PositionReference.TopCenter:
|
||||
case PositionReference.CenterCenter:
|
||||
case PositionReference.BottomCenter:
|
||||
x -= scaledWidth / 2;
|
||||
break;
|
||||
case PositionReference.TopRight:
|
||||
case PositionReference.CenterRight:
|
||||
case PositionReference.BottomRight:
|
||||
x -= scaledWidth;
|
||||
break;
|
||||
}
|
||||
y = (-SYMBOL_MARGIN - props.selected.height) / scale;
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -40,8 +66,8 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
|||
text={props.selected.displayedText}
|
||||
x={x}
|
||||
y={y}
|
||||
width={width}
|
||||
height={height}
|
||||
width={scaledWidth}
|
||||
height={scaledHeight}
|
||||
scale={scale}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -2,6 +2,8 @@ import { Interweave } from 'interweave';
|
|||
import * as React from 'react';
|
||||
import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
||||
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../utils/default';
|
||||
import { TransformX, TransformY } from '../../../utils/svg';
|
||||
import { PositionReference } from '../../../Enums/PositionReference';
|
||||
|
||||
interface ISymbolProps {
|
||||
model: ISymbolModel
|
||||
|
@ -38,9 +40,36 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
|||
}
|
||||
if (props.model.isVertical) {
|
||||
x = (-SYMBOL_MARGIN - props.model.width) / props.scale;
|
||||
y = (props.model.offset + props.model.height / 2) - (props.model.height / props.scale / 2);
|
||||
y = TransformY(props.model.offset, props.model.height * 2, props.model.config.PositionReference);
|
||||
|
||||
switch (props.model.config.PositionReference) {
|
||||
case PositionReference.CenterLeft:
|
||||
case PositionReference.CenterCenter:
|
||||
case PositionReference.CenterRight:
|
||||
y -= props.model.height / props.scale / 2;
|
||||
break;
|
||||
case PositionReference.BottomLeft:
|
||||
case PositionReference.BottomCenter:
|
||||
case PositionReference.BottomRight:
|
||||
y -= props.model.height / props.scale;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
x = (props.model.offset + props.model.width / 2) - (props.model.width / props.scale / 2);
|
||||
x = TransformX(props.model.offset, props.model.width * 2, props.model.config.PositionReference);
|
||||
|
||||
switch (props.model.config.PositionReference) {
|
||||
case PositionReference.TopCenter:
|
||||
case PositionReference.CenterCenter:
|
||||
case PositionReference.BottomCenter:
|
||||
x -= props.model.width / props.scale / 2;
|
||||
break;
|
||||
case PositionReference.TopRight:
|
||||
case PositionReference.CenterRight:
|
||||
case PositionReference.BottomRight:
|
||||
x -= props.model.width / props.scale;
|
||||
break;
|
||||
}
|
||||
|
||||
y = (-SYMBOL_MARGIN - props.model.height) / props.scale;
|
||||
}
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue