laymur 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -11
- package/dist/constraints/UIAspectConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIAspectConstraint.d.ts +9 -46
- package/dist/constraints/UIConstraint.d.ts +7 -27
- package/dist/constraints/UICustomConstraint.d.ts +13 -45
- package/dist/constraints/UIHeightConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIHeightConstraint.d.ts +8 -37
- package/dist/constraints/UIHorizontalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +16 -73
- package/dist/constraints/UIHorizontalProportionConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIHorizontalProportionConstraint.d.ts +8 -52
- package/dist/constraints/UISingleParameterConstraint.Internal.d.ts +12 -0
- package/dist/constraints/UISingleParameterConstraint.d.ts +24 -87
- package/dist/constraints/UIVerticalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/constraints/UIVerticalDistanceConstraint.d.ts +12 -73
- package/dist/constraints/UIVerticalProportionConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIVerticalProportionConstraint.d.ts +8 -52
- package/dist/constraints/UIWidthConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIWidthConstraint.d.ts +8 -37
- package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +45 -0
- package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +35 -0
- package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +13 -0
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +29 -0
- package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +13 -0
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +29 -0
- package/dist/elements/UIAnchor.Internal.d.ts +9 -0
- package/dist/elements/UIAnchor.d.ts +17 -62
- package/dist/elements/UIAnimatedImage.Internal.d.ts +24 -0
- package/dist/elements/UIAnimatedImage.d.ts +38 -100
- package/dist/elements/UIDummy.Internal.d.ts +18 -0
- package/dist/elements/UIDummy.d.ts +51 -63
- package/dist/elements/UIElement.Internal.d.ts +11 -0
- package/dist/elements/UIElement.d.ts +28 -168
- package/dist/elements/UIGraphics.Internal.d.ts +7 -0
- package/dist/elements/UIGraphics.d.ts +29 -99
- package/dist/elements/UIImage.Internal.d.ts +7 -0
- package/dist/elements/UIImage.d.ts +18 -73
- package/dist/elements/UINineSlice.Internal.d.ts +23 -0
- package/dist/elements/UINineSlice.d.ts +45 -0
- package/dist/elements/UIProgress.Internal.d.ts +14 -0
- package/dist/elements/UIProgress.d.ts +26 -152
- package/dist/elements/UIScene.Internal.d.ts +43 -0
- package/dist/elements/UIScene.d.ts +29 -171
- package/dist/elements/UIText/UIText.Interfaces.d.ts +32 -0
- package/dist/elements/UIText/UIText.Internal.d.ts +26 -0
- package/dist/elements/UIText/UIText.Measuring.d.ts +49 -0
- package/dist/elements/UIText/UIText.Rendering.d.ts +19 -0
- package/dist/elements/UIText/UIText.d.ts +63 -0
- package/dist/index.d.ts +46 -46
- package/dist/index.js +4180 -4006
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UIFullscreenLayer.d.ts +33 -43
- package/dist/layers/UILayer.Internal.d.ts +15 -0
- package/dist/layers/UILayer.d.ts +29 -184
- package/dist/miscellaneous/UIExpression.d.ts +35 -83
- package/dist/miscellaneous/UIInputEvent.d.ts +11 -8
- package/dist/miscellaneous/UIMode.d.ts +19 -21
- package/dist/miscellaneous/UIOrientation.d.ts +7 -22
- package/dist/miscellaneous/UIPriority.d.ts +16 -40
- package/dist/miscellaneous/UIRelation.d.ts +11 -31
- package/dist/miscellaneous/UITransparencyMode.d.ts +4 -21
- package/dist/miscellaneous/area/UIArea.d.ts +3 -0
- package/dist/miscellaneous/area/UIAreaCircle.d.ts +15 -0
- package/dist/miscellaneous/area/UIAreaPolygon.d.ts +12 -0
- package/dist/miscellaneous/area/UIAreaRectangle.d.ts +17 -0
- package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +21 -0
- package/dist/miscellaneous/asserts.d.ts +39 -82
- package/dist/miscellaneous/color/UIColor.Internal.d.ts +7 -0
- package/dist/miscellaneous/color/UIColor.d.ts +197 -0
- package/dist/miscellaneous/computeTransform.d.ts +18 -0
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.Internal.d.ts +10 -0
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.d.ts +36 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlane.Internal.d.ts +5 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlane.d.ts +23 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.Internal.d.ts +6 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.d.ts +27 -0
- package/dist/miscellaneous/generic-plane/shared.d.ts +22 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +9 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +21 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +16 -0
- package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +31 -0
- package/dist/miscellaneous/micro/UIMicro.d.ts +59 -0
- package/dist/miscellaneous/padding/UIPadding.Internal.d.ts +11 -0
- package/dist/miscellaneous/padding/UIPadding.d.ts +46 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +3 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +5 -0
- package/dist/miscellaneous/text-span/UITextSpan.Internal.d.ts +8 -0
- package/dist/miscellaneous/text-span/UITextSpan.d.ts +14 -0
- package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +48 -0
- package/dist/miscellaneous/text-style/UITextStyle.d.ts +85 -0
- package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +54 -0
- package/dist/miscellaneous/texture/UITextureView.d.ts +61 -0
- package/dist/wrappers/UIInputWrapper.Internal.d.ts +17 -0
- package/dist/wrappers/UIInputWrapper.d.ts +13 -0
- package/dist/wrappers/UISceneWrapper.Internal.d.ts +13 -0
- package/dist/wrappers/UISceneWrapper.d.ts +12 -19
- package/dist/wrappers/UISolverWrapper.Internal.d.ts +49 -0
- package/dist/wrappers/UISolverWrapper.d.ts +2 -1
- package/package.json +3 -1
- package/dist/builders/UIConstraint2DBuilder.d.ts +0 -130
- package/dist/builders/UICoverConstraintBuilder.d.ts +0 -56
- package/dist/builders/UIFitConstraintBuilder.d.ts +0 -56
- package/dist/composer/UIComposer.d.ts +0 -0
- package/dist/composer/UIFullscreenQuad.d.ts +0 -0
- package/dist/composer/UIPass.d.ts +0 -0
- package/dist/elements/UINineSline.d.ts +0 -139
- package/dist/elements/UISpine.d.ts +0 -54
- package/dist/elements/UIText.d.ts +0 -149
- package/dist/miscellaneous/UIColor.d.ts +0 -245
- package/dist/miscellaneous/UIGenericInstancedPlane.d.ts +0 -32
- package/dist/miscellaneous/UIMicro.d.ts +0 -148
- package/dist/miscellaneous/UIMicroAnchorMode.d.ts +0 -9
- package/dist/miscellaneous/UINineSliceBorder.d.ts +0 -21
- package/dist/miscellaneous/UIResizePolicy.d.ts +0 -21
- package/dist/miscellaneous/UIResizePolicyCross.d.ts +0 -14
- package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +0 -14
- package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +0 -24
- package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +0 -27
- package/dist/miscellaneous/UIResizePolicyNone.d.ts +0 -7
- package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +0 -12
- package/dist/miscellaneous/UITextPadding.d.ts +0 -7
- package/dist/miscellaneous/UITextSpan.d.ts +0 -6
- package/dist/miscellaneous/UITextStyle.d.ts +0 -20
- package/dist/miscellaneous/textInterfaces.d.ts +0 -19
- package/dist/miscellaneous/textTools.d.ts +0 -12
|
@@ -1,106 +1,43 @@
|
|
|
1
1
|
import type { UILayer } from "../layers/UILayer";
|
|
2
2
|
import { UIOrientation } from "../miscellaneous/UIOrientation";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { UIPriority } from "../miscellaneous/UIPriority";
|
|
4
|
+
import type { UIRelation } from "../miscellaneous/UIRelation";
|
|
5
5
|
import { UIConstraint } from "./UIConstraint";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export interface UISingleParameterConstraintOptions {
|
|
10
|
-
/** Priority level for the constraint in the solver hierarchy. */
|
|
11
|
-
priority: UIPriority;
|
|
12
|
-
/** Mathematical relation type for the constraint equation. */
|
|
13
|
-
relation: UIRelation;
|
|
14
|
-
/** Orientation context for when the constraint should be active. */
|
|
15
|
-
orientation: UIOrientation;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Abstract base class for constraints that operate with configurable parameters.
|
|
19
|
-
*
|
|
20
|
-
* UISingleParameterConstraint extends UIConstraint with common functionality
|
|
21
|
-
* for constraints that need priority, relation, and orientation configuration.
|
|
22
|
-
* It provides automatic orientation-based enabling/disabling of constraints
|
|
23
|
-
* and manages the lifecycle of solver constraint descriptors.
|
|
24
|
-
*
|
|
25
|
-
* @see {@link UIConstraint} - Base constraint class
|
|
26
|
-
* @see {@link UIPriority} - Priority level configuration
|
|
27
|
-
* @see {@link UIRelation} - Mathematical relation types
|
|
28
|
-
* @see {@link UIOrientation} - Orientation-based activation
|
|
29
|
-
*/
|
|
6
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
7
|
+
/** Base class for constraints with priority, relation, and orientation */
|
|
30
8
|
export declare abstract class UISingleParameterConstraint extends UIConstraint {
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
/**
|
|
9
|
+
/** Constraint priority */
|
|
10
|
+
private priorityInternal;
|
|
11
|
+
/** Constraint relation */
|
|
12
|
+
private relationInternal;
|
|
13
|
+
/** Constraint orientation */
|
|
14
|
+
private orientationInternal;
|
|
15
|
+
/** Solver constraint descriptor */
|
|
38
16
|
protected abstract readonly constraint: number;
|
|
39
17
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Initializes the constraint with resolved default values and sets up
|
|
43
|
-
* orientation change event handling for dynamic constraint activation.
|
|
44
|
-
*
|
|
45
|
-
* @param layer - The UI layer that contains this constraint
|
|
46
|
-
* @param priority - Optional priority level (defaults to P0)
|
|
47
|
-
* @param relation - Optional relation type (defaults to EQUAL)
|
|
48
|
-
* @param orientation - Optional orientation setting (defaults to ALWAYS)
|
|
49
|
-
*/
|
|
50
|
-
constructor(layer: UILayer, priority?: UIPriority, relation?: UIRelation, orientation?: UIOrientation);
|
|
51
|
-
/**
|
|
52
|
-
* Gets the current priority level of the constraint.
|
|
53
|
-
* @returns The constraint priority level
|
|
18
|
+
* @param layer Layer containing this constraint
|
|
19
|
+
* @param options Constraint configuration
|
|
54
20
|
*/
|
|
21
|
+
constructor(layer: UILayer, options?: Partial<UISingleParameterConstraintOptions>);
|
|
22
|
+
/** Constraint priority */
|
|
55
23
|
get priority(): UIPriority;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the current mathematical relation type of the constraint.
|
|
58
|
-
* @returns The constraint relation type
|
|
59
|
-
*/
|
|
24
|
+
/** Constraint relation */
|
|
60
25
|
get relation(): UIRelation;
|
|
61
|
-
/**
|
|
62
|
-
* Gets the current orientation setting of the constraint.
|
|
63
|
-
* @returns The constraint orientation setting
|
|
64
|
-
*/
|
|
26
|
+
/** When constraint is active */
|
|
65
27
|
get orientation(): UIOrientation;
|
|
66
|
-
/**
|
|
67
|
-
* Sets a new priority level for the constraint.
|
|
68
|
-
* @param value - The new priority level
|
|
69
|
-
*/
|
|
28
|
+
/** Updates constraint priority */
|
|
70
29
|
set priority(value: UIPriority);
|
|
71
|
-
/**
|
|
72
|
-
* Sets a new mathematical relation type for the constraint.
|
|
73
|
-
* @param value - The new relation type
|
|
74
|
-
*/
|
|
30
|
+
/** Updates constraint relation */
|
|
75
31
|
set relation(value: UIRelation);
|
|
76
|
-
/**
|
|
77
|
-
* Sets a new orientation setting for the constraint.
|
|
78
|
-
* @param value - The new orientation setting
|
|
79
|
-
*/
|
|
32
|
+
/** Updates when constraint is active */
|
|
80
33
|
set orientation(value: UIOrientation);
|
|
81
|
-
/**
|
|
82
|
-
* Destroys the constraint by cleaning up event listeners and solver resources.
|
|
83
|
-
*
|
|
84
|
-
* This method removes the orientation change event listener and removes
|
|
85
|
-
* the constraint from the solver system. After calling this method,
|
|
86
|
-
* the constraint should not be used anymore.
|
|
87
|
-
*/
|
|
34
|
+
/** Removes constraint from solver and cleans up listeners */
|
|
88
35
|
destroy(): void;
|
|
89
36
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* The constraint is enabled if its orientation is set to ALWAYS or if
|
|
93
|
-
* it matches the current layer orientation.
|
|
94
|
-
*
|
|
95
|
-
* @returns True if the constraint should be enabled, false otherwise
|
|
96
|
-
* @protected
|
|
37
|
+
* Checks if constraint should be active for current orientation.
|
|
38
|
+
* @returns True if orientation is ALWAYS or matches layer orientation
|
|
97
39
|
*/
|
|
98
40
|
protected isConstraintEnabled(): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Event handler for layer orientation changes.
|
|
101
|
-
*
|
|
102
|
-
* Updates the constraint's enabled state in the solver based on the
|
|
103
|
-
* current orientation and the constraint's orientation setting.
|
|
104
|
-
*/
|
|
41
|
+
/** Updates constraint enabled state when layer orientation changes */
|
|
105
42
|
private readonly onOrientationChange;
|
|
106
43
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
export declare const DEFAULT_ANCHOR = 0.5;
|
|
3
|
+
/** Vertical distance constraint options */
|
|
4
|
+
export interface UIVerticalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
|
|
5
|
+
/** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */
|
|
6
|
+
anchorA: number;
|
|
7
|
+
/** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */
|
|
8
|
+
anchorB: number;
|
|
9
|
+
/** Distance in world units */
|
|
10
|
+
distance: number;
|
|
11
|
+
}
|
|
@@ -1,93 +1,32 @@
|
|
|
1
1
|
import type { UIPlaneElement, UIPointElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
2
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export interface UIVerticalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** Anchor point for element A (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */
|
|
9
|
-
anchorA: number;
|
|
10
|
-
/** Anchor point for element B (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */
|
|
11
|
-
anchorB: number;
|
|
12
|
-
/** The desired vertical distance between the elements. */
|
|
13
|
-
distance: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Constraint that enforces vertical distance between two UI elements.
|
|
17
|
-
*
|
|
18
|
-
* UIVerticalDistanceConstraint creates a mathematical relationship that maintains
|
|
19
|
-
* a specific vertical distance between two elements using configurable anchor points.
|
|
20
|
-
* For plane elements, anchors determine the reference point (0.0 = top, 0.5 = center, 1.0 = bottom).
|
|
21
|
-
* For point elements, the anchor is always the element's position. The constraint equation is:
|
|
22
|
-
* (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA) = distance
|
|
23
|
-
*
|
|
24
|
-
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
25
|
-
* @see {@link UIPointElement} - Point elements that can be constrained
|
|
26
|
-
* @see {@link UIPlaneElement} - Plane elements that can be constrained
|
|
27
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
28
|
-
*/
|
|
3
|
+
import type { UIVerticalDistanceConstraintOptions } from "./UIVerticalDistanceConstraint.Internal";
|
|
4
|
+
/** Maintains vertical distance between elements with configurable anchors */
|
|
29
5
|
export declare class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
30
6
|
private readonly a;
|
|
31
7
|
private readonly b;
|
|
32
|
-
/** The constraint descriptor managed by the solver system. */
|
|
33
8
|
protected readonly constraint: number;
|
|
34
|
-
/** Internal storage for element A's anchor point. */
|
|
35
9
|
private anchorAInternal;
|
|
36
|
-
/** Internal storage for element B's anchor point. */
|
|
37
10
|
private anchorBInternal;
|
|
38
|
-
/** Internal storage for the vertical distance value. */
|
|
39
11
|
private distanceInternal;
|
|
40
12
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* if not specified in options. Both elements must be from the same layer.
|
|
45
|
-
*
|
|
46
|
-
* @param a - The first UI element (point or plane element)
|
|
47
|
-
* @param b - The second UI element (point or plane element)
|
|
48
|
-
* @param options - Configuration options for the constraint
|
|
49
|
-
* @throws Will throw an error if elements are not from the same layer
|
|
50
|
-
* @see {@link assertValidConstraintSubjects}
|
|
13
|
+
* @param a First element
|
|
14
|
+
* @param b Second element
|
|
15
|
+
* @param options Distance configuration
|
|
51
16
|
*/
|
|
52
17
|
constructor(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIVerticalDistanceConstraintOptions>);
|
|
53
|
-
/**
|
|
54
|
-
* Gets the current vertical distance being enforced.
|
|
55
|
-
* @returns The vertical distance in pixels
|
|
56
|
-
*/
|
|
18
|
+
/** Current distance in world units */
|
|
57
19
|
get distance(): number;
|
|
58
|
-
/**
|
|
59
|
-
* Gets the anchor point for element A.
|
|
60
|
-
* @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
61
|
-
*/
|
|
20
|
+
/** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */
|
|
62
21
|
get anchorA(): number;
|
|
63
|
-
/**
|
|
64
|
-
* Gets the anchor point for element B.
|
|
65
|
-
* @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
66
|
-
*/
|
|
22
|
+
/** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */
|
|
67
23
|
get anchorB(): number;
|
|
68
|
-
/**
|
|
69
|
-
* Sets a new vertical distance and updates the constraint equation.
|
|
70
|
-
* @param value - The new vertical distance in pixels
|
|
71
|
-
*/
|
|
24
|
+
/** Updates distance */
|
|
72
25
|
set distance(value: number);
|
|
73
|
-
/**
|
|
74
|
-
* Sets a new anchor point for element A and updates the constraint equation.
|
|
75
|
-
* @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
76
|
-
*/
|
|
26
|
+
/** Updates anchor on element A */
|
|
77
27
|
set anchorA(value: number);
|
|
78
|
-
/**
|
|
79
|
-
* Sets a new anchor point for element B and updates the constraint equation.
|
|
80
|
-
* @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
81
|
-
*/
|
|
28
|
+
/** Updates anchor on element B */
|
|
82
29
|
set anchorB(value: number);
|
|
83
|
-
/**
|
|
84
|
-
* Builds the left-hand side expression for the constraint equation.
|
|
85
|
-
*
|
|
86
|
-
* Creates the expression: (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA)
|
|
87
|
-
* For point elements, only the y position is used since they have no height.
|
|
88
|
-
* For plane elements, the anchor determines the reference point within the element's height.
|
|
89
|
-
*
|
|
90
|
-
* @returns The UIExpression representing the vertical distance calculation
|
|
91
|
-
*/
|
|
30
|
+
/** Builds constraint expression for distance between anchored positions */
|
|
92
31
|
private buildLHS;
|
|
93
32
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
/** Vertical proportion constraint options */
|
|
3
|
+
export interface UIVerticalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
4
|
+
/** Proportion multiplier (A.height * proportion = B.height) */
|
|
5
|
+
proportion: number;
|
|
6
|
+
}
|
|
@@ -1,66 +1,22 @@
|
|
|
1
1
|
import type { UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
2
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export interface UIVerticalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The proportional relationship between element heights (elementA.height * proportion = elementB.height). */
|
|
9
|
-
proportion: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constraint that enforces proportional height relationships between two UI elements.
|
|
13
|
-
*
|
|
14
|
-
* UIVerticalProportionConstraint creates a mathematical relationship that maintains
|
|
15
|
-
* a proportional ratio between the heights of two plane elements. The constraint equation is:
|
|
16
|
-
* elementA.height * proportion = elementB.height, which can be rearranged as:
|
|
17
|
-
* elementA.height * proportion - elementB.height = 0
|
|
18
|
-
*
|
|
19
|
-
* This is useful for creating responsive layouts where elements need to maintain
|
|
20
|
-
* specific height ratios, such as header-to-content ratios or row height proportions.
|
|
21
|
-
*
|
|
22
|
-
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
23
|
-
* @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied
|
|
24
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
25
|
-
*/
|
|
3
|
+
import type { UIVerticalProportionConstraintOptions } from "./UIVerticalProportionConstraint.Internal";
|
|
4
|
+
/** Maintains proportional height relationship (A.height * proportion = B.height) */
|
|
26
5
|
export declare class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
27
6
|
private readonly a;
|
|
28
7
|
private readonly b;
|
|
29
|
-
/** The constraint descriptor managed by the solver system. */
|
|
30
8
|
protected readonly constraint: number;
|
|
31
|
-
/** Internal storage for the current proportion value. */
|
|
32
9
|
private proportionInternal;
|
|
33
10
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* If no proportion is specified, it defaults to 1.0 (equal heights).
|
|
38
|
-
* Both elements must be from the same layer.
|
|
39
|
-
*
|
|
40
|
-
* @param a - The first UI plane element (whose height will be multiplied by proportion)
|
|
41
|
-
* @param b - The second UI plane element (target height for the proportion)
|
|
42
|
-
* @param options - Configuration options for the constraint
|
|
43
|
-
* @throws Will throw an error if elements are not from the same layer
|
|
44
|
-
* @see {@link assertValidConstraintSubjects}
|
|
11
|
+
* @param a First element
|
|
12
|
+
* @param b Second element
|
|
13
|
+
* @param options Proportion configuration
|
|
45
14
|
*/
|
|
46
15
|
constructor(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIVerticalProportionConstraintOptions>);
|
|
47
|
-
/**
|
|
48
|
-
* Gets the current proportion value being enforced.
|
|
49
|
-
* @returns The proportion ratio (elementA.height * proportion = elementB.height)
|
|
50
|
-
*/
|
|
16
|
+
/** Current proportion multiplier */
|
|
51
17
|
get proportion(): number;
|
|
52
|
-
/**
|
|
53
|
-
* Sets a new proportion value and updates the constraint equation.
|
|
54
|
-
* @param value - The new proportion ratio
|
|
55
|
-
*/
|
|
18
|
+
/** Updates proportion multiplier */
|
|
56
19
|
set proportion(value: number);
|
|
57
|
-
/**
|
|
58
|
-
* Builds the right-hand side expression for the constraint equation.
|
|
59
|
-
*
|
|
60
|
-
* Creates the expression: (elementA.height * proportion) - elementB.height = 0
|
|
61
|
-
* This enforces the relationship: elementA.height * proportion = elementB.height
|
|
62
|
-
*
|
|
63
|
-
* @returns The UIExpression representing the proportional height relationship
|
|
64
|
-
*/
|
|
20
|
+
/** Builds constraint expression for proportional relationship */
|
|
65
21
|
private buildRHS;
|
|
66
22
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
/** Width constraint options */
|
|
3
|
+
export interface UIWidthConstraintOptions extends UISingleParameterConstraintOptions {
|
|
4
|
+
/** Target width in world units */
|
|
5
|
+
width: number;
|
|
6
|
+
}
|
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
2
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export interface UIWidthConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The desired width value for the element. */
|
|
9
|
-
width: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constraint that enforces a specific width value for UI elements.
|
|
13
|
-
*
|
|
14
|
-
* UIWidthConstraint creates a mathematical relationship that fixes an element's
|
|
15
|
-
* width to a constant value. The constraint equation is: element.width = width.
|
|
16
|
-
* This is useful for ensuring elements maintain a specific width regardless of
|
|
17
|
-
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
18
|
-
*
|
|
19
|
-
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
20
|
-
* @see {@link UIPlaneElement} - Elements that can have width constraints applied
|
|
21
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
22
|
-
*/
|
|
3
|
+
import type { UIWidthConstraintOptions } from "./UIWidthConstraint.Internal";
|
|
4
|
+
/** Fixes element width to constant value */
|
|
23
5
|
export declare class UIWidthConstraint extends UISingleParameterConstraint {
|
|
24
6
|
private readonly element;
|
|
25
|
-
/**
|
|
7
|
+
/** Solver constraint descriptor */
|
|
26
8
|
protected readonly constraint: number;
|
|
27
|
-
/**
|
|
9
|
+
/** Current width value */
|
|
28
10
|
private widthInternal;
|
|
29
11
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* If no width is specified in options, the constraint will use the
|
|
33
|
-
* element's current width as the target width value.
|
|
34
|
-
*
|
|
35
|
-
* @param element - The UI element to apply the width constraint to
|
|
36
|
-
* @param options - Configuration options for the constraint
|
|
12
|
+
* @param element Element to constrain
|
|
13
|
+
* @param options Width configuration. Defaults to element's current width.
|
|
37
14
|
*/
|
|
38
15
|
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIWidthConstraintOptions>);
|
|
39
|
-
/**
|
|
40
|
-
* Gets the current width value being enforced.
|
|
41
|
-
* @returns The width value in pixels
|
|
42
|
-
*/
|
|
16
|
+
/** Current width in world units */
|
|
43
17
|
get width(): number;
|
|
44
|
-
/**
|
|
45
|
-
* Sets a new width value and updates the constraint equation.
|
|
46
|
-
* @param value - The new width value in pixels
|
|
47
|
-
*/
|
|
18
|
+
/** Updates width */
|
|
48
19
|
set width(value: number);
|
|
49
20
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { UIOrientation } from "../../miscellaneous/UIOrientation";
|
|
2
|
+
import type { UIPriority } from "../../miscellaneous/UIPriority";
|
|
3
|
+
import type { UIRelation } from "../../miscellaneous/UIRelation";
|
|
4
|
+
/** Horizontal and vertical values */
|
|
5
|
+
export interface UIType2D<T> {
|
|
6
|
+
/** Horizontal value */
|
|
7
|
+
h?: T;
|
|
8
|
+
/** Vertical value */
|
|
9
|
+
v?: T;
|
|
10
|
+
}
|
|
11
|
+
/** Base 2D constraint options */
|
|
12
|
+
export interface UIConstraint2DOptions {
|
|
13
|
+
/** Priority for each axis */
|
|
14
|
+
priority: UIType2D<UIPriority>;
|
|
15
|
+
/** Relation for each axis */
|
|
16
|
+
relation: UIType2D<UIRelation>;
|
|
17
|
+
/** Orientation for each axis */
|
|
18
|
+
orientation: UIType2D<UIOrientation>;
|
|
19
|
+
}
|
|
20
|
+
/** 2D size constraint options */
|
|
21
|
+
export interface UIConstraintSize2DOptions extends UIConstraint2DOptions {
|
|
22
|
+
/** Width and height */
|
|
23
|
+
size: UIType2D<number>;
|
|
24
|
+
}
|
|
25
|
+
/** 2D distance constraint options */
|
|
26
|
+
export interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {
|
|
27
|
+
/** Anchor on element A for each axis */
|
|
28
|
+
anchorA: UIType2D<number>;
|
|
29
|
+
/** Anchor on element B for each axis */
|
|
30
|
+
anchorB: UIType2D<number>;
|
|
31
|
+
/** Distance for each axis */
|
|
32
|
+
distance: UIType2D<number>;
|
|
33
|
+
}
|
|
34
|
+
/** 2D proportion constraint options */
|
|
35
|
+
export interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {
|
|
36
|
+
/** Proportion for each axis */
|
|
37
|
+
proportion: UIType2D<number>;
|
|
38
|
+
}
|
|
39
|
+
/** Horizontal and vertical constraint pair */
|
|
40
|
+
export interface UIConstraint2DResult<TH, TV> {
|
|
41
|
+
/** Horizontal constraint */
|
|
42
|
+
h: TH;
|
|
43
|
+
/** Vertical constraint */
|
|
44
|
+
v: TV;
|
|
45
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UIHeightConstraint } from "../../constraints/UIHeightConstraint";
|
|
2
|
+
import { UIHorizontalDistanceConstraint } from "../../constraints/UIHorizontalDistanceConstraint";
|
|
3
|
+
import { UIHorizontalProportionConstraint } from "../../constraints/UIHorizontalProportionConstraint";
|
|
4
|
+
import { UIVerticalDistanceConstraint } from "../../constraints/UIVerticalDistanceConstraint";
|
|
5
|
+
import { UIVerticalProportionConstraint } from "../../constraints/UIVerticalProportionConstraint";
|
|
6
|
+
import { UIWidthConstraint } from "../../constraints/UIWidthConstraint";
|
|
7
|
+
import type { UIElement } from "../../elements/UIElement";
|
|
8
|
+
import type { UIPlaneElement, UIPointElement } from "../../miscellaneous/asserts";
|
|
9
|
+
import type { UIConstraint2DResult, UIConstraintDistance2DOptions, UIConstraintProportion2DOptions, UIConstraintSize2DOptions } from "./UIConstraint2DBuilder.Internal";
|
|
10
|
+
/** Builder for paired horizontal and vertical constraints */
|
|
11
|
+
export declare class UIConstraint2DBuilder {
|
|
12
|
+
/**
|
|
13
|
+
* Creates width and height constraints.
|
|
14
|
+
* @param element Element to constrain
|
|
15
|
+
* @param options Size configuration for both axes
|
|
16
|
+
* @returns Width and height constraints
|
|
17
|
+
*/
|
|
18
|
+
static size(element: UIElement, options?: Partial<UIConstraintSize2DOptions>): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates horizontal and vertical distance constraints.
|
|
21
|
+
* @param a First element
|
|
22
|
+
* @param b Second element
|
|
23
|
+
* @param options Distance configuration for both axes
|
|
24
|
+
* @returns Horizontal and vertical distance constraints
|
|
25
|
+
*/
|
|
26
|
+
static distance(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIConstraintDistance2DOptions>): UIConstraint2DResult<UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates horizontal and vertical proportion constraints.
|
|
29
|
+
* @param a Element with proportional dimensions
|
|
30
|
+
* @param b Target element
|
|
31
|
+
* @param options Proportion configuration for both axes
|
|
32
|
+
* @returns Horizontal and vertical proportion constraints
|
|
33
|
+
*/
|
|
34
|
+
static proportion(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIConstraintProportion2DOptions>): UIConstraint2DResult<UIHorizontalProportionConstraint, UIVerticalProportionConstraint>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UIOrientation } from "../../miscellaneous/UIOrientation";
|
|
2
|
+
export declare const COVER_CONSTRAINT_DEFAULT_ANCHOR = 0.5;
|
|
3
|
+
/** Cover constraint builder options */
|
|
4
|
+
export interface UICoverConstraintBuilderOptions {
|
|
5
|
+
/** Whether to maintain active element aspect ratio */
|
|
6
|
+
keepActiveAspect: boolean;
|
|
7
|
+
/** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */
|
|
8
|
+
anchorH: number;
|
|
9
|
+
/** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */
|
|
10
|
+
anchorV: number;
|
|
11
|
+
/** Orientation for constraints */
|
|
12
|
+
orientation: UIOrientation;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UIHorizontalDistanceConstraint } from "../../constraints/UIHorizontalDistanceConstraint";
|
|
2
|
+
import { UIHorizontalProportionConstraint } from "../../constraints/UIHorizontalProportionConstraint";
|
|
3
|
+
import { UIVerticalDistanceConstraint } from "../../constraints/UIVerticalDistanceConstraint";
|
|
4
|
+
import { UIVerticalProportionConstraint } from "../../constraints/UIVerticalProportionConstraint";
|
|
5
|
+
import type { UILayerElement, UIPlaneElement } from "../../miscellaneous/asserts";
|
|
6
|
+
import { UIAspectConstraint } from "../UIAspectConstraint";
|
|
7
|
+
import type { UICoverConstraintBuilderOptions } from "./UICoverConstraintBuilder.Internal";
|
|
8
|
+
/** Builder for cover layout (like CSS object-fit: cover) */
|
|
9
|
+
export declare class UICoverConstraintBuilder {
|
|
10
|
+
/**
|
|
11
|
+
* Creates cover layout constraints.
|
|
12
|
+
* @param passive Container element
|
|
13
|
+
* @param active Content element that covers container
|
|
14
|
+
* @param options Cover configuration
|
|
15
|
+
* @returns Created constraints
|
|
16
|
+
*/
|
|
17
|
+
static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UICoverConstraintBuilderOptions>): {
|
|
18
|
+
/** Aspect constraint if keepActiveAspect is true */
|
|
19
|
+
activeAspectConstraint?: UIAspectConstraint;
|
|
20
|
+
/** Horizontal position constraint */
|
|
21
|
+
xConstraint: UIHorizontalDistanceConstraint;
|
|
22
|
+
/** Vertical position constraint */
|
|
23
|
+
yConstraint: UIVerticalDistanceConstraint;
|
|
24
|
+
/** Width constraint (ensures coverage) */
|
|
25
|
+
widthConstraint: UIHorizontalProportionConstraint;
|
|
26
|
+
/** Height constraint (ensures coverage) */
|
|
27
|
+
heightConstraint: UIVerticalProportionConstraint;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UIOrientation } from "../../miscellaneous/UIOrientation";
|
|
2
|
+
export declare const DEFAULT_ANCHOR = 0.5;
|
|
3
|
+
/** Fit constraint builder options */
|
|
4
|
+
export interface UIFitConstraintBuilderOptions {
|
|
5
|
+
/** Whether to maintain active element aspect ratio */
|
|
6
|
+
keepActiveAspect: boolean;
|
|
7
|
+
/** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */
|
|
8
|
+
anchorH: number;
|
|
9
|
+
/** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */
|
|
10
|
+
anchorV: number;
|
|
11
|
+
/** Orientation for constraints */
|
|
12
|
+
orientation: UIOrientation;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UIHorizontalDistanceConstraint } from "../../constraints/UIHorizontalDistanceConstraint";
|
|
2
|
+
import { UIHorizontalProportionConstraint } from "../../constraints/UIHorizontalProportionConstraint";
|
|
3
|
+
import { UIVerticalDistanceConstraint } from "../../constraints/UIVerticalDistanceConstraint";
|
|
4
|
+
import { UIVerticalProportionConstraint } from "../../constraints/UIVerticalProportionConstraint";
|
|
5
|
+
import type { UILayerElement, UIPlaneElement } from "../../miscellaneous/asserts";
|
|
6
|
+
import { UIAspectConstraint } from "../UIAspectConstraint";
|
|
7
|
+
import type { UIFitConstraintBuilderOptions } from "./UIFitConstraintBuilder.Internal";
|
|
8
|
+
/** Builder for fit layout (like CSS object-fit: contain) */
|
|
9
|
+
export declare class UIFitConstraintBuilder {
|
|
10
|
+
/**
|
|
11
|
+
* Creates fit layout constraints.
|
|
12
|
+
* @param passive Container element
|
|
13
|
+
* @param active Content element that fits within container
|
|
14
|
+
* @param options Fit configuration
|
|
15
|
+
* @returns Created constraints
|
|
16
|
+
*/
|
|
17
|
+
static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UIFitConstraintBuilderOptions>): {
|
|
18
|
+
/** Aspect constraint if keepActiveAspect is true */
|
|
19
|
+
activeAspectConstraint?: UIAspectConstraint;
|
|
20
|
+
/** Horizontal position constraint */
|
|
21
|
+
xConstraint: UIHorizontalDistanceConstraint;
|
|
22
|
+
/** Vertical position constraint */
|
|
23
|
+
yConstraint: UIVerticalDistanceConstraint;
|
|
24
|
+
/** Width constraint (ensures fitting) */
|
|
25
|
+
widthConstraint: UIHorizontalProportionConstraint;
|
|
26
|
+
/** Height constraint (ensures fitting) */
|
|
27
|
+
heightConstraint: UIVerticalProportionConstraint;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Configuration options for UIAnchor */
|
|
2
|
+
export interface UIAnchorOptions {
|
|
3
|
+
/** X coordinate in world units */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Y coordinate in world units */
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const ANCHOR_DEFAULT_X = 0;
|
|
9
|
+
export declare const ANCHOR_DEFAULT_Y = 0;
|