Implement HideChildrenInTreeview

This commit is contained in:
Eric NGUYEN 2022-09-23 09:34:46 +02:00
parent e2da3142b5
commit 3e6204e917
6 changed files with 15 additions and 2 deletions

View file

@ -124,7 +124,7 @@ export function ElementsSidebar(props: IElementsSidebarProps): JSX.Element {
isOpenClasses = props.isHistoryOpen ? 'right-64' : 'right-0'; isOpenClasses = props.isHistoryOpen ? 'right-64' : 'right-0';
} }
const it = MakeIterator(props.mainContainer); const it = MakeIterator(props.mainContainer, true);
const containers = [...it]; const containers = [...it];
function Row({ function Row({
index, style index, style

View file

@ -96,6 +96,9 @@ export interface IAvailableContainer {
*/ */
Pattern?: string Pattern?: string
/** Hide the children in the treeview */
HideChildrenInTreeview?: boolean
/** if true, show the dimension of the container */ /** if true, show the dimension of the container */
ShowSelfDimensions?: boolean ShowSelfDimensions?: boolean

View file

@ -57,6 +57,9 @@ export interface IContainerProperties {
/** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */ /** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */
xPositionReference: XPositionReference xPositionReference: XPositionReference
/** Hide the children in the treeview */
hideChildrenInTreeview: boolean
/** if true, show the dimension of the container */ /** if true, show the dimension of the container */
showSelfDimensions: boolean showSelfDimensions: boolean

View file

@ -128,6 +128,7 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
isAnchor: false, isAnchor: false,
isFlex: false, isFlex: false,
xPositionReference: XPositionReference.Left, xPositionReference: XPositionReference.Left,
hideChildrenInTreeview: false,
showChildrenDimensions: true, // TODO: put the dimension at the top (see pdf) showChildrenDimensions: true, // TODO: put the dimension at the top (see pdf)
showSelfDimensions: true, // TODO: put the dimension at the bottom (see pdf) showSelfDimensions: true, // TODO: put the dimension at the bottom (see pdf)
isDimensionBorrower: true, // second dimensions from the bottom isDimensionBorrower: true, // second dimensions from the bottom
@ -173,6 +174,7 @@ export function GetDefaultContainerProps(type: string,
xPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left, xPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
minWidth: containerConfig.MinWidth ?? 1, minWidth: containerConfig.MinWidth ?? 1,
maxWidth: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER, maxWidth: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
hideChildrenInTreeview: containerConfig.HideChildrenInTreeview ?? false,
showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? false, showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? false,
showSelfDimensions: containerConfig.ShowSelfDimensions ?? false, showSelfDimensions: containerConfig.ShowSelfDimensions ?? false,
markPositionToDimensionBorrower: containerConfig.MarkPositionToDimensionBorrower ?? false, markPositionToDimensionBorrower: containerConfig.MarkPositionToDimensionBorrower ?? false,

View file

@ -3,7 +3,7 @@ import { IContainerModel } from '../Interfaces/IContainerModel';
/** /**
* Returns a Generator iterating of over the children depth-first * Returns a Generator iterating of over the children depth-first
*/ */
export function * MakeIterator(root: IContainerModel): Generator<IContainerModel, void, unknown> { export function * MakeIterator(root: IContainerModel, enableHideChildrenInTreeview = false): Generator<IContainerModel, void, unknown> {
const queue: IContainerModel[] = [root]; const queue: IContainerModel[] = [root];
const visited = new Set<IContainerModel>(queue); const visited = new Set<IContainerModel>(queue);
while (queue.length > 0) { while (queue.length > 0) {
@ -11,6 +11,10 @@ export function * MakeIterator(root: IContainerModel): Generator<IContainerModel
yield container; yield container;
if (enableHideChildrenInTreeview && container.properties.hideChildrenInTreeview) {
continue;
}
for (let i = container.children.length - 1; i >= 0; i--) { for (let i = container.children.length - 1; i >= 0; i--) {
const child = container.children[i]; const child = container.children[i];
if (visited.has(child)) { if (visited.has(child)) {

View file

@ -81,6 +81,7 @@ const GetSVGLayoutConfiguration = () => {
stroke: 'red', stroke: 'red',
fill: '#d3c9b7', fill: '#d3c9b7',
}, },
HideChildrenInTreeview: true,
ShowSelfDimensions: true, ShowSelfDimensions: true,
IsDimensionBorrower: true, IsDimensionBorrower: true,
Category: "Stuff" Category: "Stuff"