import type { InterpreterContext, FullObject } from "@hylimo/core"; import type { Line, Point, Size } from "@hylimo/diagram-common"; import type { FontCollection } from "../font/fontCollection.js"; import type { LayoutElement, SizeConstraints } from "../layoutElement.js"; import type { LayoutEngine } from "./layoutEngine.js"; import type { Element } from "@hylimo/diagram-common"; import { CanvasLayoutEngine } from "./canvasLayoutEngine.js"; /** * Performs the layout, uses a layout engine to do so */ export declare class Layout { readonly engine: LayoutEngine; readonly styles: FullObject; readonly fonts: FontCollection; readonly defaultFontFamily: string; readonly context: InterpreterContext; /** * Lookup for layout elements */ readonly layoutElementLookup: Map; /** * Lookup for layouted elements */ readonly elementLookup: Record; /** * Lookop for element id based on syncscript object */ readonly elementIdLookup: Map; /** * Counter to provide child ids * Should be probed with `${parentId}_${idGroup}` */ private readonly elementIdCounter; /** * Canvas layout engine to layout all canvases */ readonly layoutEngine: CanvasLayoutEngine; /** * Style evaluator handling style matching and parsing */ private readonly styleEvaluator; /** * Creates a new layout * * @param engine the engine which provides fonts * @param styles styles to possibly apply to elements * @param fonts fonts to use * @param defaultFontFamily the default font to use * @param context the interpreter context to use for computing styles */ constructor(engine: LayoutEngine, styles: FullObject, fonts: FontCollection, defaultFontFamily: string, context: InterpreterContext); /** * Computes the styles based on the provided element * * @param layoutElement the layout element where the styles should be updated * @param matchingStyles the styles which match the element */ private applyStyles; /** * Sets the visibility of an element based on its styles and parent visibility * * @param layoutElement the element to set the visibility for */ private applyVisibility; /** * Computes the layout information based on styles * * @param style defines all required layout information * @returns the computed layout information */ private computeLayoutInformation; create(element: FullObject, parent: LayoutElement | undefined): LayoutElement; /** * Calls measure on the element and generates a LayoutElement for it. * computes the styles * * @param layoutElement the element to measure * @param constraints size constraitns required for measure * @returns the measured size */ measure(layoutElement: LayoutElement, constraints: SizeConstraints): Size; /** * Computes the size constraints for an element and the provided constraints. * Also uses the styles of the element to further limit the constraints. * * @param element the elements to compute the constraints for * @param constraints the constraints to use for the computation * @returns the computed size constraints */ computeSizeConstraints(element: LayoutElement, constraints: SizeConstraints): SizeConstraints; /** * Computes the size constraints for a visible (non-collapsed) element. * * @param element the elements to compute the constraints for * @param constraints the constraints to use for the computation * @returns the computed size constraints for the visible element */ private computeVisibleSizeConstraints; /** * Generates a new id based on the parent element * * @param layoutConfig the layout config of the element * @param parent the parent element * @returns the generated id */ private generateId; /** * Layouts an element, handles margin, alignment, min, max and absolute size * * @param element the element to layout * @param position the position of the element * @param size the size of the element * @returns the layouted element */ layout(element: LayoutElement, position: Point, size: Size): Element[]; /** * Layouts an element in the x direction. Computes the x coordinate and the width of the element. * * @param styles styles providing alignment, min/max width and absolute width * @param layoutInformation layout information providing margin * @param element the element to layout * @param size the size of the element * @param position the position of the element * @returns the computed x coordinate and width */ private layoutX; /** * Layouts an element in the y direction. Computes the y coordinate and the height of the element. * * @param styles styles providing alignment, min/max height and absolute height * @param layoutInformation layout information providing margin * @param element the element to layout * @param size the size of the element * @param position the position of the element * @returns the computed y coordinate and height */ private layoutY; /** * Create the outline of an element * Requires that the element has been measured and layouted * * @param element the element to get the outline of * @returns the outline of the element */ outline(element: LayoutElement): Line; /** * Gets the id of an element * * @param element the element to get the id of * @returns the id of the content element */ getElementId(element: FullObject): string; /** * Checks if an element is a child of another element * * @param parent the potential parent element * @param child the potential child element * @returns true if the child is a child of the parent, otherwise false */ isChildElement(parent: LayoutElement, child: LayoutElement): boolean; } //# sourceMappingURL=layout.d.ts.map