Merge branch 'dev'
This commit is contained in:
commit
58a881c813
11 changed files with 111 additions and 76 deletions
|
@ -93,27 +93,9 @@ namespace SVGLDLibs.Models
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public bool hideChildrenInTreeview;
|
public bool hideChildrenInTreeview;
|
||||||
|
|
||||||
/** if true, show the dimension of the container */
|
/** Dimension options */
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Position[] showSelfDimensions;
|
public Dimensions dimensionOptions;
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Position[] showChildrenDimensions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, allows a parent dimension borrower to borrow its x coordinate
|
|
||||||
* as a reference point for a dimension
|
|
||||||
*/
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Orientation[] markPosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, show a dimension from the edge of the container to end
|
|
||||||
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
|
||||||
*/
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Position[] showDimensionWithMarks;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warnings of a container
|
* Warnings of a container
|
||||||
|
|
32
csharp/SVGLDLibs/SVGLDLibs/Models/Dimensions.cs
Normal file
32
csharp/SVGLDLibs/SVGLDLibs/Models/Dimensions.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace SVGLDLibs.Models
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class Dimensions
|
||||||
|
{
|
||||||
|
|
||||||
|
/** if true, show the dimension of the container */
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public Position[] showSelfDimensions;
|
||||||
|
|
||||||
|
/** if true show the overall dimensions of its children */
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public Position[] showChildrenDimensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if true, allows a parent dimension borrower to borrow its x coordinate
|
||||||
|
* as a reference point for a dimension
|
||||||
|
*/
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public Orientation[] markPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if true, show a dimension from the edge of the container to end
|
||||||
|
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
||||||
|
*/
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public Position[] showDimensionWithMarks;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,11 +18,11 @@ export function AddDimensions(
|
||||||
depth: number
|
depth: number
|
||||||
): void {
|
): void {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if (SHOW_SELF_DIMENSIONS && container.properties.showSelfDimensions.length > 0) {
|
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.showSelfDimensions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showSelfDimensions,
|
container.properties.dimensionOptions.showSelfDimensions,
|
||||||
AddHorizontalSelfDimension,
|
AddHorizontalSelfDimension,
|
||||||
AddVerticalSelfDimension,
|
AddVerticalSelfDimension,
|
||||||
[
|
[
|
||||||
|
@ -32,11 +32,11 @@ export function AddDimensions(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_BORROWER_DIMENSIONS && container.properties.showDimensionWithMarks.length > 0) {
|
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.showDimensionWithMarks.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showDimensionWithMarks,
|
container.properties.dimensionOptions.showDimensionWithMarks,
|
||||||
AddHorizontalBorrowerDimension,
|
AddHorizontalBorrowerDimension,
|
||||||
AddVerticalBorrowerDimension,
|
AddVerticalBorrowerDimension,
|
||||||
[
|
[
|
||||||
|
@ -48,11 +48,11 @@ export function AddDimensions(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_CHILDREN_DIMENSIONS && container.properties.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showChildrenDimensions,
|
container.properties.dimensionOptions.showChildrenDimensions,
|
||||||
AddHorizontalChildrenDimension,
|
AddHorizontalChildrenDimension,
|
||||||
AddVerticalChildrenDimension,
|
AddVerticalChildrenDimension,
|
||||||
[
|
[
|
||||||
|
@ -238,7 +238,7 @@ function AddHorizontalBorrowerDimension(
|
||||||
for (const {
|
for (const {
|
||||||
container: childContainer, currentTransform: childCurrentTransform
|
container: childContainer, currentTransform: childCurrentTransform
|
||||||
} of it) {
|
} of it) {
|
||||||
const isHidden = !childContainer.properties.markPosition.includes(Orientation.Horizontal);
|
const isHidden = !childContainer.properties.dimensionOptions.markPosition.includes(Orientation.Horizontal);
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ function AddVerticalBorrowerDimension(
|
||||||
for (const {
|
for (const {
|
||||||
container: childContainer, currentTransform: childCurrentTransform
|
container: childContainer, currentTransform: childCurrentTransform
|
||||||
} of it) {
|
} of it) {
|
||||||
const isHidden = !childContainer.properties.markPosition.includes(Orientation.Vertical);
|
const isHidden = !childContainer.properties.dimensionOptions.markPosition.includes(Orientation.Vertical);
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,8 +339,8 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
id='showSelfDimensions'
|
id='showSelfDimensions'
|
||||||
name='ShowSelfDimensions'
|
name='ShowSelfDimensions'
|
||||||
labelText={Text({ textId: '@ContainerShowDimension' })}
|
labelText={Text({ textId: '@ContainerShowDimension' })}
|
||||||
value={props.properties.showSelfDimensions}
|
value={props.properties.dimensionOptions.showSelfDimensions}
|
||||||
onChange={props.onChange}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -351,8 +351,8 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
id='showChildrenDimensions'
|
id='showChildrenDimensions'
|
||||||
name='ShowChildrenDimensions'
|
name='ShowChildrenDimensions'
|
||||||
labelText={Text({ textId: '@ContainerShowChildrenDimension' })}
|
labelText={Text({ textId: '@ContainerShowChildrenDimension' })}
|
||||||
value={props.properties.showChildrenDimensions}
|
value={props.properties.dimensionOptions.showChildrenDimensions}
|
||||||
onChange={props.onChange}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -363,9 +363,9 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
<OrientationCheckboxes
|
<OrientationCheckboxes
|
||||||
id='markPosition'
|
id='markPosition'
|
||||||
name='MarkPosition'
|
name='MarkPosition'
|
||||||
value={props.properties.markPosition}
|
value={props.properties.dimensionOptions.markPosition}
|
||||||
labelText={Text({ textId: '@ContainerMarkPosition' })}
|
labelText={Text({ textId: '@ContainerMarkPosition' })}
|
||||||
onChange={props.onChange}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='grid grid-cols-1 gap-2'>
|
<div className='grid grid-cols-1 gap-2'>
|
||||||
|
@ -373,8 +373,8 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
id='showDimensionWithMarks'
|
id='showDimensionWithMarks'
|
||||||
name='ShowDimensionWithMarks'
|
name='ShowDimensionWithMarks'
|
||||||
labelText={Text({ textId: '@ContainerShowDimensionWithMarks' })}
|
labelText={Text({ textId: '@ContainerShowDimensionWithMarks' })}
|
||||||
value={props.properties.showDimensionWithMarks}
|
value={props.properties.dimensionOptions.showDimensionWithMarks}
|
||||||
onChange={props.onChange}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -42,10 +42,12 @@ describe.concurrent('Properties', () => {
|
||||||
isAnchor: false,
|
isAnchor: false,
|
||||||
warning: '',
|
warning: '',
|
||||||
hideChildrenInTreeview: false,
|
hideChildrenInTreeview: false,
|
||||||
|
dimensionOptions: {
|
||||||
showChildrenDimensions: [],
|
showChildrenDimensions: [],
|
||||||
showSelfDimensions: [],
|
showSelfDimensions: [],
|
||||||
showDimensionWithMarks: [],
|
showDimensionWithMarks: [],
|
||||||
markPosition: []
|
markPosition: []
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = vi.fn((key, value) => {
|
const handleChange = vi.fn((key, value) => {
|
||||||
|
|
|
@ -318,6 +318,9 @@ function AssignProperty(container: IContainerModel, key: string, value: string |
|
||||||
case PropertyType.Margin:
|
case PropertyType.Margin:
|
||||||
SetMargin();
|
SetMargin();
|
||||||
break;
|
break;
|
||||||
|
case PropertyType.DimensionOptions:
|
||||||
|
(container.properties.dimensionOptions as any)[key] = value;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
(container.properties as any)[key] = value;
|
(container.properties as any)[key] = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,10 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
const containerBottomDim = bottomDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const containerBottomDim = bottomDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
||||||
const containerRightDim = rightDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const containerRightDim = rightDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
||||||
const dimMapped = [containerLeftDim, containerBottomDim, containerTopDim, containerRightDim];
|
const dimMapped = [containerLeftDim, containerBottomDim, containerTopDim, containerRightDim];
|
||||||
if (SHOW_SELF_DIMENSIONS && container.properties.showSelfDimensions.length > 0) {
|
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.showSelfDimensions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showSelfDimensions,
|
container.properties.dimensionOptions.showSelfDimensions,
|
||||||
AddHorizontalSelfDimension,
|
AddHorizontalSelfDimension,
|
||||||
AddVerticalSelfDimension,
|
AddVerticalSelfDimension,
|
||||||
[
|
[
|
||||||
|
@ -86,10 +86,10 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_BORROWER_DIMENSIONS && container.properties.showDimensionWithMarks.length > 0) {
|
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.showDimensionWithMarks.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showDimensionWithMarks,
|
container.properties.dimensionOptions.showDimensionWithMarks,
|
||||||
AddHorizontalBorrowerDimension,
|
AddHorizontalBorrowerDimension,
|
||||||
AddVerticalBorrowerDimension,
|
AddVerticalBorrowerDimension,
|
||||||
[
|
[
|
||||||
|
@ -102,10 +102,10 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_CHILDREN_DIMENSIONS && container.properties.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.showChildrenDimensions,
|
container.properties.dimensionOptions.showChildrenDimensions,
|
||||||
AddHorizontalChildrenDimension,
|
AddHorizontalChildrenDimension,
|
||||||
AddVerticalChildrenDimension,
|
AddVerticalChildrenDimension,
|
||||||
[
|
[
|
||||||
|
@ -279,7 +279,7 @@ function AddHorizontalBorrowerDimension(
|
||||||
for (const {
|
for (const {
|
||||||
container: childContainer, currentTransform: childCurrentTransform
|
container: childContainer, currentTransform: childCurrentTransform
|
||||||
} of it) {
|
} of it) {
|
||||||
const isHidden = !childContainer.properties.markPosition.includes(Orientation.Horizontal);
|
const isHidden = !childContainer.properties.dimensionOptions.markPosition.includes(Orientation.Horizontal);
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ function AddVerticalBorrowerDimension(
|
||||||
for (const {
|
for (const {
|
||||||
container: childContainer, currentTransform: childCurrentTransform
|
container: childContainer, currentTransform: childCurrentTransform
|
||||||
} of it) {
|
} of it) {
|
||||||
const isHidden = !childContainer.properties.markPosition.includes(Orientation.Vertical);
|
const isHidden = !childContainer.properties.dimensionOptions.markPosition.includes(Orientation.Vertical);
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,9 @@ export enum PropertyType {
|
||||||
* Margin property: is inside the margin property: left, bottom, top, right...
|
* Margin property: is inside the margin property: left, bottom, top, right...
|
||||||
*/
|
*/
|
||||||
Margin,
|
Margin,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dimension options
|
||||||
|
*/
|
||||||
|
DimensionOptions,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PositionReference } from '../Enums/PositionReference';
|
import { PositionReference } from '../Enums/PositionReference';
|
||||||
import { IMargin } from './IMargin';
|
import { IMargin } from './IMargin';
|
||||||
import { Orientation } from '../Enums/Orientation';
|
import { Orientation } from '../Enums/Orientation';
|
||||||
import { Position } from '../Enums/Position';
|
|
||||||
import { IKeyValue } from './IKeyValue';
|
import { IKeyValue } from './IKeyValue';
|
||||||
import { IStyle } from './IStyle';
|
import { IStyle } from './IStyle';
|
||||||
|
import { IDimensions } from './IDimensions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties of a container
|
* Properties of a container
|
||||||
|
@ -78,24 +78,8 @@ export interface IContainerProperties {
|
||||||
/** Hide the children in the treeview */
|
/** Hide the children in the treeview */
|
||||||
hideChildrenInTreeview: boolean
|
hideChildrenInTreeview: boolean
|
||||||
|
|
||||||
// TODO: Refactor showSelf., showChildren., markPosition, showDimensionWithMarks in IDimensionOptions interface
|
/** Dimensions options */
|
||||||
/** if true, show the dimension of the container */
|
dimensionOptions: IDimensions
|
||||||
showSelfDimensions: Position[]
|
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
|
||||||
showChildrenDimensions: Position[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, allows a parent dimension borrower to borrow its x coordinate
|
|
||||||
* as a reference point for a dimension
|
|
||||||
*/
|
|
||||||
markPosition: Orientation[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, show a dimension from the edge of the container to end
|
|
||||||
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
|
||||||
*/
|
|
||||||
showDimensionWithMarks: Position[]
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warnings of a container
|
* Warnings of a container
|
||||||
|
|
23
src/Interfaces/IDimensions.ts
Normal file
23
src/Interfaces/IDimensions.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { Orientation } from '../Enums/Orientation';
|
||||||
|
import { Position } from '../Enums/Position';
|
||||||
|
|
||||||
|
export interface IDimensions {
|
||||||
|
// TODO: Refactor showSelf., showChildren., markPosition, showDimensionWithMarks in IDimensionOptions interface
|
||||||
|
/** if true, show the dimension of the container */
|
||||||
|
showSelfDimensions: Position[]
|
||||||
|
|
||||||
|
/** if true show the overall dimensions of its children */
|
||||||
|
showChildrenDimensions: Position[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if true, allows a parent dimension borrower to borrow its x coordinate
|
||||||
|
* as a reference point for a dimension
|
||||||
|
*/
|
||||||
|
markPosition: Orientation[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if true, show a dimension from the edge of the container to end
|
||||||
|
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
||||||
|
*/
|
||||||
|
showDimensionWithMarks: Position[]
|
||||||
|
}
|
|
@ -210,10 +210,12 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
|
||||||
isFlex: false,
|
isFlex: false,
|
||||||
positionReference: PositionReference.TopLeft,
|
positionReference: PositionReference.TopLeft,
|
||||||
hideChildrenInTreeview: false,
|
hideChildrenInTreeview: false,
|
||||||
|
dimensionOptions: {
|
||||||
showChildrenDimensions: [Position.Up, Position.Left],
|
showChildrenDimensions: [Position.Up, Position.Left],
|
||||||
showSelfDimensions: [Position.Up, Position.Left],
|
showSelfDimensions: [Position.Up, Position.Left],
|
||||||
showDimensionWithMarks: [Position.Down, Position.Right],
|
showDimensionWithMarks: [Position.Down, Position.Right],
|
||||||
markPosition: [],
|
markPosition: []
|
||||||
|
},
|
||||||
warning: '',
|
warning: '',
|
||||||
style: DEFAULT_CONTAINER_STYLE
|
style: DEFAULT_CONTAINER_STYLE
|
||||||
};
|
};
|
||||||
|
@ -257,10 +259,12 @@ export function GetDefaultContainerProps(type: string,
|
||||||
minHeight: containerConfig.MinWidth ?? 1,
|
minHeight: containerConfig.MinWidth ?? 1,
|
||||||
maxHeight: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
|
maxHeight: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
|
||||||
hideChildrenInTreeview: containerConfig.HideChildrenInTreeview ?? false,
|
hideChildrenInTreeview: containerConfig.HideChildrenInTreeview ?? false,
|
||||||
|
dimensionOptions: {
|
||||||
showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? [],
|
showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? [],
|
||||||
showSelfDimensions: containerConfig.ShowSelfDimensions ?? [],
|
showSelfDimensions: containerConfig.ShowSelfDimensions ?? [],
|
||||||
markPosition: containerConfig.MarkPosition ?? [],
|
markPosition: containerConfig.MarkPosition ?? [],
|
||||||
showDimensionWithMarks: containerConfig.ShowDimensionWithMarks ?? [],
|
showDimensionWithMarks: containerConfig.ShowDimensionWithMarks ?? []
|
||||||
|
},
|
||||||
warning: '',
|
warning: '',
|
||||||
customSVG: containerConfig.CustomSVG,
|
customSVG: containerConfig.CustomSVG,
|
||||||
style: Object.assign(structuredClone(DEFAULT_CONTAINER_STYLE), structuredClone(containerConfig.Style)),
|
style: Object.assign(structuredClone(DEFAULT_CONTAINER_STYLE), structuredClone(containerConfig.Style)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue