Add option to apply behaviors to children
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ff5c3d00da
commit
022ad38163
3 changed files with 17 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||||
|
import { APPLY_BEHAVIORS_ON_CHILDREN } from '../../../utils/default';
|
||||||
import { ImposePosition } from './AnchorBehaviors';
|
import { ImposePosition } from './AnchorBehaviors';
|
||||||
import { RecalculatePhysics } from './RigidBodyBehaviors';
|
import { RecalculatePhysics } from './RigidBodyBehaviors';
|
||||||
|
|
||||||
|
@ -17,5 +18,12 @@ export function ApplyBehaviors(container: IContainerModel): IContainerModel {
|
||||||
RecalculatePhysics(container);
|
RecalculatePhysics(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (APPLY_BEHAVIORS_ON_CHILDREN) {
|
||||||
|
// Apply DFS by recursion
|
||||||
|
for (const child of container.children) {
|
||||||
|
ApplyBehaviors(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,14 +231,15 @@ function getAvailableWidths(
|
||||||
const width = container.properties.width;
|
const width = container.properties.width;
|
||||||
let unallocatedSpaces: ISizePointer[] = [{ x, width }];
|
let unallocatedSpaces: ISizePointer[] = [{ x, width }];
|
||||||
|
|
||||||
// We will only uses containers that also are rigid or are anchors
|
for (const child of container.children) {
|
||||||
const solidBodies = container.children.filter(
|
if (unallocatedSpaces.length < 1) {
|
||||||
(child) => child.properties.isRigidBody || child.properties.isAnchor
|
return unallocatedSpaces;
|
||||||
);
|
}
|
||||||
|
|
||||||
for (const child of solidBodies) {
|
|
||||||
// Ignore the exception
|
// Ignore the exception
|
||||||
if (child === exception) {
|
// And we will also only uses containers that also are rigid or are anchors
|
||||||
|
if (child === exception ||
|
||||||
|
(!child.properties.isRigidBody && !child.properties.isAnchor)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const childX = child.properties.x;
|
const childX = child.properties.x;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { IConfiguration } from '../Interfaces/IConfiguration';
|
||||||
import { IContainerModel } from '../Interfaces/IContainerModel';
|
import { IContainerModel } from '../Interfaces/IContainerModel';
|
||||||
import IProperties from '../Interfaces/IProperties';
|
import IProperties from '../Interfaces/IProperties';
|
||||||
|
|
||||||
/// CONTAINRE DEFAULTS ///
|
/// CONTAINER DEFAULTS ///
|
||||||
|
|
||||||
export const SHOW_TEXT = true;
|
export const SHOW_TEXT = true;
|
||||||
export const DEFAULTCHILDTYPE_ALLOW_CYCLIC = false;
|
export const DEFAULTCHILDTYPE_ALLOW_CYCLIC = false;
|
||||||
|
@ -22,6 +22,7 @@ export const NOTCHES_LENGTH = 4;
|
||||||
|
|
||||||
export const ENABLE_SHORTCUTS = true;
|
export const ENABLE_SHORTCUTS = true;
|
||||||
export const MAX_HISTORY = 200;
|
export const MAX_HISTORY = 200;
|
||||||
|
export const APPLY_BEHAVIORS_ON_CHILDREN = true;
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: IConfiguration = {
|
export const DEFAULT_CONFIG: IConfiguration = {
|
||||||
AvailableContainers: [
|
AvailableContainers: [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue