Merged PR 196: Implement Vertical orientation + Upgrade Heroicons to 2.0
Implémenter l'orientation verticale Modifier l'effet de append Implementer RigidBody Implementer Flex et simplex Implémenter Push Implémenter Swap Implement MinMaxHeight without behaviors Fix Margin for Height Implement PositionReference Fix dimension vertical position inside children Add orientation change in form Implement sortChildren Implement Anchor Fix warning message on overlapping Fix minimap when root container is vertical #7287 #7288 #7289 #7290 #7291 #7292 #7294 #7295 #7296 #7297 #7298 #7299 #7300 #7301 #7302
This commit is contained in:
parent
459e83a0c8
commit
18cbacaca1
45 changed files with 2112 additions and 1063 deletions
|
@ -3,7 +3,7 @@ import { IContainerModel } from '../Interfaces/IContainerModel';
|
|||
/**
|
||||
* Returns a Generator iterating of over the children depth-first
|
||||
*/
|
||||
export function * MakeIterator(root: IContainerModel, enableHideChildrenInTreeview = false): Generator<IContainerModel, void, unknown> {
|
||||
export function * MakeDFSIterator(root: IContainerModel, enableHideChildrenInTreeview = false): Generator<IContainerModel, void, unknown> {
|
||||
const queue: IContainerModel[] = [root];
|
||||
const visited = new Set<IContainerModel>(queue);
|
||||
while (queue.length > 0) {
|
||||
|
@ -30,6 +30,11 @@ export interface ContainerAndDepth {
|
|||
container: IContainerModel
|
||||
depth: number
|
||||
}
|
||||
|
||||
export interface ContainerAndDepthAndTransform extends ContainerAndDepth {
|
||||
currentTransform: [number, number]
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Generator iterating of over the children depth-first
|
||||
*/
|
||||
|
@ -54,9 +59,44 @@ export function * MakeBFSIterator(root: IContainerModel): Generator<ContainerAnd
|
|||
}
|
||||
}
|
||||
|
||||
export function * MakeRecursionDFSIterator(
|
||||
root: IContainerModel | null,
|
||||
depth: number,
|
||||
currentTransform: [number, number],
|
||||
enableHideChildrenInTreeview: boolean = false
|
||||
): Generator<ContainerAndDepthAndTransform, void, unknown> {
|
||||
if (root === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield {
|
||||
container: root,
|
||||
depth,
|
||||
currentTransform
|
||||
};
|
||||
|
||||
if (enableHideChildrenInTreeview && root.properties.hideChildrenInTreeview) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const container of root.children) {
|
||||
yield * MakeRecursionDFSIterator(
|
||||
container,
|
||||
depth + 1,
|
||||
[
|
||||
currentTransform[0] + root.properties.x,
|
||||
currentTransform[1] + root.properties.y
|
||||
],
|
||||
enableHideChildrenInTreeview
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the depth of the container
|
||||
* @returns The depth of the container
|
||||
* @deprecated Please avoid using this function inside an iterationl,
|
||||
* use recursive DFS or iterative BFS to get the depth
|
||||
*/
|
||||
export function GetDepth(parent: IContainerModel): number {
|
||||
let depth = 0;
|
||||
|
@ -80,6 +120,19 @@ export function GetAbsolutePosition(container: IContainerModel): [number, number
|
|||
return CancelParentTransform(container.parent, x, y);
|
||||
}
|
||||
|
||||
export function GetContainerLinkedList(container: IContainerModel, stop?: IContainerModel): IContainerModel[] {
|
||||
const it = MakeContainerLinkedListIterator(container, stop);
|
||||
return [...it];
|
||||
}
|
||||
|
||||
export function * MakeContainerLinkedListIterator(container: IContainerModel, stop?: IContainerModel): Generator<IContainerModel, void, unknown> {
|
||||
let current: IContainerModel | null = container;
|
||||
while (current !== stop && current != null) {
|
||||
yield current;
|
||||
current = current.parent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the hierarchic transformations to the given x, y
|
||||
* @param parent Parent of the container to remove its transform
|
||||
|
@ -93,34 +146,47 @@ export function CancelParentTransform(
|
|||
y: number,
|
||||
stop?: IContainerModel
|
||||
): [number, number] {
|
||||
let current = parent;
|
||||
while (current !== stop && current != null) {
|
||||
if (parent === null) {
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
const it = MakeContainerLinkedListIterator(parent, stop);
|
||||
for (const current of it) {
|
||||
x += current.properties.x;
|
||||
y += current.properties.y;
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the hierarchic transformations to the given x, y
|
||||
* Apply the hierarchic transformations to the given x, y
|
||||
* @param parent Parent of the container to remove its transform
|
||||
* @param x value to be restored
|
||||
* @param y value to be restored
|
||||
* @returns x and y such that the transformations of the parent are cancelled
|
||||
* @returns x and y such that the transformations of the parent are applied
|
||||
*/
|
||||
export function ApplyParentTransform(parent: IContainerModel | null, x: number, y: number): [number, number] {
|
||||
let current = parent;
|
||||
while (current != null) {
|
||||
export function ApplyParentTransform(
|
||||
parent: IContainerModel | null,
|
||||
x: number,
|
||||
y: number,
|
||||
stop?: IContainerModel
|
||||
): [number, number] {
|
||||
if (parent === null) {
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
const it = MakeContainerLinkedListIterator(parent, stop);
|
||||
for (const current of it) {
|
||||
x -= current.properties.x;
|
||||
y -= current.properties.y;
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
export function FindContainerById(root: IContainerModel, id: string): IContainerModel | undefined {
|
||||
const it = MakeIterator(root);
|
||||
const it = MakeDFSIterator(root);
|
||||
for (const container of it) {
|
||||
if (container.properties.id === id) {
|
||||
return container;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue