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
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
|
|
10
10
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
11
11
|
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
|
|
12
|
-
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js
|
|
12
|
+
<a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.175.0--0.179.0-green" alt="Three.js"></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
⚠️ **Early Alpha / Work in Progress** ⚠️
|
|
@@ -34,7 +34,7 @@ Originally built for mobile ad development scenarios where you need to keep the
|
|
|
34
34
|
npm install laymur
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Requires Three.js
|
|
37
|
+
Requires Three.js >=0.175.0 <0.180.0 as a peer dependency.
|
|
38
38
|
|
|
39
39
|
## Quick Example
|
|
40
40
|
|
|
@@ -70,17 +70,23 @@ animate();
|
|
|
70
70
|
|
|
71
71
|
### Elements
|
|
72
72
|
- **UIImage** - Display textures
|
|
73
|
-
- **
|
|
73
|
+
- **UIAnimatedImage** - Animated texture sequences
|
|
74
|
+
- **UIText** - Text rendering with word wrapping and styled spans
|
|
75
|
+
- **UIGraphics** - Vector graphics and shapes
|
|
74
76
|
- **UIScene** - Embed 3D scenes
|
|
75
77
|
- **UIProgress** - Progress bars
|
|
76
|
-
- **
|
|
78
|
+
- **UINineSlice** - Scalable UI panels with border preservation
|
|
77
79
|
- **UIAnchor** - Positioning points
|
|
80
|
+
- **UIDummy** - Invisible layout helpers
|
|
78
81
|
|
|
79
82
|
### Constraints
|
|
80
83
|
- **UIWidthConstraint** / **UIHeightConstraint** - Fixed sizes
|
|
81
84
|
- **UIAspectConstraint** - Maintain aspect ratios
|
|
82
|
-
- **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing
|
|
85
|
+
- **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing between elements
|
|
83
86
|
- **UIHorizontalProportionConstraint** / **UIVerticalProportionConstraint** - Proportional sizing
|
|
87
|
+
- **UICustomConstraint** - Custom constraint expressions
|
|
88
|
+
- **UIFitConstraintBuilder** - Fit element inside container (like CSS object-fit: contain)
|
|
89
|
+
- **UICoverConstraintBuilder** - Cover container with element (like CSS object-fit: cover)
|
|
84
90
|
|
|
85
91
|
## Constraint Layout
|
|
86
92
|
|
|
@@ -124,6 +130,8 @@ new UIWidthConstraint(sidebar, {
|
|
|
124
130
|
|
|
125
131
|
## Text Rendering
|
|
126
132
|
|
|
133
|
+
Text supports styled spans with different fonts, sizes, and colors:
|
|
134
|
+
|
|
127
135
|
```typescript
|
|
128
136
|
import { UIText } from 'laymur';
|
|
129
137
|
|
|
@@ -131,14 +139,15 @@ const text = new UIText(layer, [
|
|
|
131
139
|
{ text: 'Download ', style: { fontSize: 24, color: '#333333' } },
|
|
132
140
|
{ text: 'Now!', style: { fontSize: 32, color: '#ff0000', fontWeight: 'bold' } }
|
|
133
141
|
], {
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
x: 100,
|
|
143
|
+
y: 100,
|
|
144
|
+
maxLineWidth: 600,
|
|
136
145
|
});
|
|
137
146
|
```
|
|
138
147
|
|
|
139
|
-
##
|
|
148
|
+
## Transformations
|
|
140
149
|
|
|
141
|
-
Apply
|
|
150
|
+
Apply visual transformations without affecting the constraint layout:
|
|
142
151
|
|
|
143
152
|
```typescript
|
|
144
153
|
const element = new UIImage(layer, texture);
|
|
@@ -147,9 +156,9 @@ const element = new UIImage(layer, texture);
|
|
|
147
156
|
element.micro.x = 10;
|
|
148
157
|
element.micro.scaleX = 1.2;
|
|
149
158
|
element.micro.rotation = 0.1;
|
|
150
|
-
element.micro.anchorX = 0.5;
|
|
159
|
+
element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
|
|
151
160
|
|
|
152
|
-
// Reset transformations
|
|
161
|
+
// Reset all transformations
|
|
153
162
|
element.micro.reset();
|
|
154
163
|
```
|
|
155
164
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
/** Aspect constraint options */
|
|
3
|
+
export interface UIAspectConstraintOptions extends UISingleParameterConstraintOptions {
|
|
4
|
+
/** Target aspect ratio (width/height) */
|
|
5
|
+
aspect: number;
|
|
6
|
+
}
|
|
@@ -1,59 +1,22 @@
|
|
|
1
1
|
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UIAspectConstraintOptions } from "./UIAspectConstraint.Internal";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for UIAspectConstraint creation.
|
|
6
|
-
*/
|
|
7
|
-
export interface UIAspectConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The desired aspect ratio (width/height) for the element. */
|
|
9
|
-
aspect: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constraint that maintains a specific aspect ratio for UI elements.
|
|
13
|
-
*
|
|
14
|
-
* UIAspectConstraint enforces a mathematical relationship between an element's
|
|
15
|
-
* width and height to maintain a constant aspect ratio. The constraint equation
|
|
16
|
-
* is: width = height * aspect. This is useful for ensuring elements maintain
|
|
17
|
-
* their proportions during layout changes or for enforcing specific aspect
|
|
18
|
-
* ratios like 16:9 for video content.
|
|
19
|
-
*
|
|
20
|
-
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
21
|
-
* @see {@link UIPlaneElement} - Elements that can have aspect constraints applied
|
|
22
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
23
|
-
*/
|
|
4
|
+
/** Maintains element aspect ratio (width = height * aspect) */
|
|
24
5
|
export declare class UIAspectConstraint extends UISingleParameterConstraint {
|
|
25
6
|
private readonly element;
|
|
26
|
-
/**
|
|
7
|
+
/** Solver constraint descriptor */
|
|
27
8
|
protected readonly constraint: number;
|
|
28
|
-
/**
|
|
9
|
+
/** Current aspect ratio */
|
|
29
10
|
private aspectInternal;
|
|
30
11
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* If no aspect ratio is specified in options, the constraint will use the
|
|
34
|
-
* element's current width-to-height ratio as the target aspect ratio.
|
|
35
|
-
*
|
|
36
|
-
* @param element - The UI element to apply the aspect constraint to
|
|
37
|
-
* @param options - Configuration options for the constraint
|
|
12
|
+
* @param element Element to constrain
|
|
13
|
+
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
38
14
|
*/
|
|
39
15
|
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIAspectConstraintOptions>);
|
|
40
|
-
/**
|
|
41
|
-
* Gets the current aspect ratio being enforced.
|
|
42
|
-
* @returns The aspect ratio (width/height)
|
|
43
|
-
*/
|
|
16
|
+
/** Current aspect ratio (width/height) */
|
|
44
17
|
get aspect(): number;
|
|
45
|
-
/**
|
|
46
|
-
* Sets a new aspect ratio and updates the constraint equation.
|
|
47
|
-
* @param value - The new aspect ratio (width/height)
|
|
48
|
-
*/
|
|
18
|
+
/** Updates aspect ratio */
|
|
49
19
|
set aspect(value: number);
|
|
50
|
-
/**
|
|
51
|
-
* Builds the left-hand side expression for the constraint equation.
|
|
52
|
-
*
|
|
53
|
-
* Creates the expression: width - (height * aspect) = 0
|
|
54
|
-
* This enforces the relationship: width = height * aspect
|
|
55
|
-
*
|
|
56
|
-
* @returns The UIExpression representing the constraint equation
|
|
57
|
-
*/
|
|
20
|
+
/** Builds constraint expression: width - (height * aspect) = 0 */
|
|
58
21
|
private buildLHS;
|
|
59
22
|
}
|
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
/**
|
|
4
|
-
* Abstract base class for all UI layout constraints.
|
|
5
|
-
*
|
|
6
|
-
* UIConstraint serves as the fundamental building block for the constraint-based
|
|
7
|
-
* layout system. It provides access to the solver wrapper for creating and
|
|
8
|
-
* managing constraint relationships between UI elements. All concrete constraint
|
|
9
|
-
* implementations must extend this class to participate in the layout solving process.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link UILayer} - Container layer for constraints
|
|
12
|
-
* @see {@link UISolverWrapper} - Constraint solver integration
|
|
13
|
-
*/
|
|
1
|
+
import type { UILayer } from "../layers/UILayer";
|
|
2
|
+
import type { UISolverWrapperInterface } from "../wrappers/UISolverWrapper.Internal";
|
|
3
|
+
/** Base class for layout constraints */
|
|
14
4
|
export declare abstract class UIConstraint {
|
|
15
5
|
readonly layer: UILayer;
|
|
16
|
-
/** Optional name
|
|
6
|
+
/** Optional constraint name */
|
|
17
7
|
name: string;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
protected readonly solverWrapper: UISolverWrapper;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new UIConstraint instance.
|
|
25
|
-
*
|
|
26
|
-
* Automatically connects to the layer's constraint solver for managing
|
|
27
|
-
* layout relationships and constraint operations.
|
|
28
|
-
*
|
|
29
|
-
* @param layer - The UI layer that contains this constraint
|
|
30
|
-
*/
|
|
8
|
+
/** Constraint solver wrapper */
|
|
9
|
+
protected readonly solverWrapper: UISolverWrapperInterface;
|
|
10
|
+
/** @param layer Layer containing this constraint */
|
|
31
11
|
constructor(layer: UILayer);
|
|
32
12
|
}
|
|
@@ -1,60 +1,28 @@
|
|
|
1
1
|
import type { UILayer } from "../layers/UILayer";
|
|
2
2
|
import type { UIExpression } from "../miscellaneous/UIExpression";
|
|
3
|
-
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
4
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* UICustomConstraint provides maximum flexibility by allowing direct specification
|
|
9
|
-
* of the left-hand side (LHS) and right-hand side (RHS) expressions for constraint
|
|
10
|
-
* equations. This enables creation of complex mathematical relationships that may
|
|
11
|
-
* not be covered by the specialized constraint types. The constraint equation is:
|
|
12
|
-
* LHS relation RHS (e.g., LHS = RHS, LHS ≤ RHS, or LHS ≥ RHS)
|
|
13
|
-
*
|
|
14
|
-
* This is useful for implementing custom layout logic, complex mathematical
|
|
15
|
-
* relationships between multiple elements, or prototype new constraint types.
|
|
16
|
-
*
|
|
17
|
-
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
18
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
19
|
-
* @see {@link UILayer} - Container layer for constraints
|
|
20
|
-
*/
|
|
4
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
5
|
+
/** Constraint with custom LHS and RHS expressions */
|
|
21
6
|
export declare class UICustomConstraint extends UISingleParameterConstraint {
|
|
22
|
-
/**
|
|
7
|
+
/** Solver constraint descriptor */
|
|
23
8
|
protected readonly constraint: number;
|
|
24
|
-
/**
|
|
9
|
+
/** Left-hand side expression */
|
|
25
10
|
private lhsInternal;
|
|
26
|
-
/**
|
|
11
|
+
/** Right-hand side expression */
|
|
27
12
|
private rhsInternal;
|
|
28
13
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param layer - The UI layer that contains this constraint
|
|
35
|
-
* @param lhs - The left-hand side expression of the constraint equation
|
|
36
|
-
* @param rhs - The right-hand side expression of the constraint equation
|
|
37
|
-
* @param options - Configuration options for the constraint
|
|
14
|
+
* @param layer Layer containing this constraint
|
|
15
|
+
* @param lhs Left-hand side expression
|
|
16
|
+
* @param rhs Right-hand side expression
|
|
17
|
+
* @param options Constraint configuration
|
|
38
18
|
*/
|
|
39
19
|
constructor(layer: UILayer, lhs: UIExpression, rhs: UIExpression, options?: Partial<UISingleParameterConstraintOptions>);
|
|
40
|
-
/**
|
|
41
|
-
* Gets the current left-hand side expression.
|
|
42
|
-
* @returns The LHS expression of the constraint equation
|
|
43
|
-
*/
|
|
20
|
+
/** Left-hand side expression */
|
|
44
21
|
get lhs(): UIExpression;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the current right-hand side expression.
|
|
47
|
-
* @returns The RHS expression of the constraint equation
|
|
48
|
-
*/
|
|
22
|
+
/** Right-hand side expression */
|
|
49
23
|
get rhs(): UIExpression;
|
|
50
|
-
/**
|
|
51
|
-
* Sets a new left-hand side expression and updates the constraint.
|
|
52
|
-
* @param value - The new LHS expression for the constraint equation
|
|
53
|
-
*/
|
|
24
|
+
/** Updates left-hand side expression */
|
|
54
25
|
setLHS(value: UIExpression): void;
|
|
55
|
-
/**
|
|
56
|
-
* Sets a new right-hand side expression and updates the constraint.
|
|
57
|
-
* @param value - The new RHS expression for the constraint equation
|
|
58
|
-
*/
|
|
26
|
+
/** Updates right-hand side expression */
|
|
59
27
|
setRHS(value: UIExpression): void;
|
|
60
28
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
/** Height constraint options */
|
|
3
|
+
export interface UIHeightConstraintOptions extends UISingleParameterConstraintOptions {
|
|
4
|
+
/** Target height in world units */
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UIHeightConstraintOptions } from "./UIHeightConstraint.Internal";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for UIHeightConstraint creation.
|
|
6
|
-
*/
|
|
7
|
-
export interface UIHeightConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The desired height value for the element. */
|
|
9
|
-
height: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constraint that enforces a specific height value for UI elements.
|
|
13
|
-
*
|
|
14
|
-
* UIHeightConstraint creates a mathematical relationship that fixes an element's
|
|
15
|
-
* height to a constant value. The constraint equation is: element.height = height.
|
|
16
|
-
* This is useful for ensuring elements maintain a specific height 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 height constraints applied
|
|
21
|
-
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
22
|
-
*/
|
|
4
|
+
/** Fixes element height to constant value */
|
|
23
5
|
export declare class UIHeightConstraint extends UISingleParameterConstraint {
|
|
24
6
|
private readonly element;
|
|
25
|
-
/**
|
|
7
|
+
/** Solver constraint descriptor */
|
|
26
8
|
protected readonly constraint: number;
|
|
27
|
-
/**
|
|
9
|
+
/** Current height value */
|
|
28
10
|
private heightInternal;
|
|
29
11
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* If no height is specified in options, the constraint will use the
|
|
33
|
-
* element's current height as the target height value.
|
|
34
|
-
*
|
|
35
|
-
* @param element - The UI element to apply the height constraint to
|
|
36
|
-
* @param options - Configuration options for the constraint
|
|
12
|
+
* @param element Element to constrain
|
|
13
|
+
* @param options Height configuration. Defaults to element's current height.
|
|
37
14
|
*/
|
|
38
15
|
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIHeightConstraintOptions>);
|
|
39
|
-
/**
|
|
40
|
-
* Gets the current height value being enforced.
|
|
41
|
-
* @returns The height value in pixels
|
|
42
|
-
*/
|
|
16
|
+
/** Current height in world units */
|
|
43
17
|
get height(): number;
|
|
44
|
-
/**
|
|
45
|
-
* Sets a new height value and updates the constraint equation.
|
|
46
|
-
* @param value - The new height value in pixels
|
|
47
|
-
*/
|
|
18
|
+
/** Updates height */
|
|
48
19
|
set height(value: number);
|
|
49
20
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
export declare const DEFAULT_ANCHOR = 0.5;
|
|
3
|
+
/** Horizontal distance constraint options */
|
|
4
|
+
export interface UIHorizontalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
|
|
5
|
+
/** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
|
|
6
|
+
anchorA: number;
|
|
7
|
+
/** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
|
|
8
|
+
anchorB: number;
|
|
9
|
+
/** Distance in world units */
|
|
10
|
+
distance: number;
|
|
11
|
+
}
|
|
@@ -1,93 +1,36 @@
|
|
|
1
1
|
import type { UIPlaneElement, UIPointElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UIHorizontalDistanceConstraintOptions } from "./UIHorizontalDistanceConstraint.Internal";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for UIHorizontalDistanceConstraint creation.
|
|
6
|
-
*/
|
|
7
|
-
export interface UIHorizontalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** Anchor point for element A (0.0 = left edge, 0.5 = center, 1.0 = right edge). */
|
|
9
|
-
anchorA: number;
|
|
10
|
-
/** Anchor point for element B (0.0 = left edge, 0.5 = center, 1.0 = right edge). */
|
|
11
|
-
anchorB: number;
|
|
12
|
-
/** The desired horizontal distance between the elements. */
|
|
13
|
-
distance: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Constraint that enforces horizontal distance between two UI elements.
|
|
17
|
-
*
|
|
18
|
-
* UIHorizontalDistanceConstraint creates a mathematical relationship that maintains
|
|
19
|
-
* a specific horizontal distance between two elements using configurable anchor points.
|
|
20
|
-
* For plane elements, anchors determine the reference point (0.0 = left, 0.5 = center, 1.0 = right).
|
|
21
|
-
* For point elements, the anchor is always the element's position. The constraint equation is:
|
|
22
|
-
* (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * 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
|
-
*/
|
|
4
|
+
/** Maintains horizontal distance between elements with configurable anchors */
|
|
29
5
|
export declare class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
30
6
|
private readonly a;
|
|
31
7
|
private readonly b;
|
|
32
|
-
/**
|
|
8
|
+
/** Solver constraint descriptor */
|
|
33
9
|
protected readonly constraint: number;
|
|
34
|
-
/**
|
|
10
|
+
/** Anchor on element A */
|
|
35
11
|
private anchorAInternal;
|
|
36
|
-
/**
|
|
12
|
+
/** Anchor on element B */
|
|
37
13
|
private anchorBInternal;
|
|
38
|
-
/**
|
|
14
|
+
/** Current distance */
|
|
39
15
|
private distanceInternal;
|
|
40
16
|
/**
|
|
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}
|
|
17
|
+
* @param a First element
|
|
18
|
+
* @param b Second element
|
|
19
|
+
* @param options Distance configuration
|
|
51
20
|
*/
|
|
52
21
|
constructor(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIHorizontalDistanceConstraintOptions>);
|
|
53
|
-
/**
|
|
54
|
-
* Gets the current horizontal distance being enforced.
|
|
55
|
-
* @returns The horizontal distance in pixels
|
|
56
|
-
*/
|
|
22
|
+
/** Current distance in world units */
|
|
57
23
|
get distance(): number;
|
|
58
|
-
/**
|
|
59
|
-
* Gets the anchor point for element A.
|
|
60
|
-
* @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)
|
|
61
|
-
*/
|
|
24
|
+
/** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
|
|
62
25
|
get anchorA(): number;
|
|
63
|
-
/**
|
|
64
|
-
* Gets the anchor point for element B.
|
|
65
|
-
* @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)
|
|
66
|
-
*/
|
|
26
|
+
/** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
|
|
67
27
|
get anchorB(): number;
|
|
68
|
-
/**
|
|
69
|
-
* Sets a new horizontal distance and updates the constraint equation.
|
|
70
|
-
* @param value - The new horizontal distance in pixels
|
|
71
|
-
*/
|
|
28
|
+
/** Updates distance */
|
|
72
29
|
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 = left, 0.5 = center, 1.0 = right)
|
|
76
|
-
*/
|
|
30
|
+
/** Updates anchor on element A */
|
|
77
31
|
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 = left, 0.5 = center, 1.0 = right)
|
|
81
|
-
*/
|
|
32
|
+
/** Updates anchor on element B */
|
|
82
33
|
set anchorB(value: number);
|
|
83
|
-
/**
|
|
84
|
-
* Builds the left-hand side expression for the constraint equation.
|
|
85
|
-
*
|
|
86
|
-
* Creates the expression: (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA)
|
|
87
|
-
* For point elements, only the x position is used since they have no width.
|
|
88
|
-
* For plane elements, the anchor determines the reference point within the element's width.
|
|
89
|
-
*
|
|
90
|
-
* @returns The UIExpression representing the horizontal distance calculation
|
|
91
|
-
*/
|
|
34
|
+
/** Builds constraint expression for distance between anchored positions */
|
|
92
35
|
private buildLHS;
|
|
93
36
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint.Internal";
|
|
2
|
+
/** Horizontal proportion constraint options */
|
|
3
|
+
export interface UIHorizontalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
4
|
+
/** Proportion multiplier (A.width * proportion = B.width) */
|
|
5
|
+
proportion: number;
|
|
6
|
+
}
|
|
@@ -1,66 +1,22 @@
|
|
|
1
1
|
import type { UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UIHorizontalProportionConstraintOptions } from "./UIHorizontalProportionConstraint.Internal";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for UIHorizontalProportionConstraint creation.
|
|
6
|
-
*/
|
|
7
|
-
export interface UIHorizontalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The proportional relationship between element widths (elementA.width * proportion = elementB.width). */
|
|
9
|
-
proportion: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constraint that enforces proportional width relationships between two UI elements.
|
|
13
|
-
*
|
|
14
|
-
* UIHorizontalProportionConstraint creates a mathematical relationship that maintains
|
|
15
|
-
* a proportional ratio between the widths of two plane elements. The constraint equation is:
|
|
16
|
-
* elementA.width * proportion = elementB.width, which can be rearranged as:
|
|
17
|
-
* elementA.width * proportion - elementB.width = 0
|
|
18
|
-
*
|
|
19
|
-
* This is useful for creating responsive layouts where elements need to maintain
|
|
20
|
-
* specific width ratios, such as sidebar-to-content ratios or grid column 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
|
-
*/
|
|
4
|
+
/** Maintains proportional width relationship (A.width * proportion = B.width) */
|
|
26
5
|
export declare class UIHorizontalProportionConstraint 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 widths).
|
|
38
|
-
* Both elements must be from the same layer.
|
|
39
|
-
*
|
|
40
|
-
* @param a - The first UI plane element (whose width will be multiplied by proportion)
|
|
41
|
-
* @param b - The second UI plane element (target width 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<UIHorizontalProportionConstraintOptions>);
|
|
47
|
-
/**
|
|
48
|
-
* Gets the current proportion value being enforced.
|
|
49
|
-
* @returns The proportion ratio (elementA.width * proportion = elementB.width)
|
|
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.width * proportion) - elementB.width = 0
|
|
61
|
-
* This enforces the relationship: elementA.width * proportion = elementB.width
|
|
62
|
-
*
|
|
63
|
-
* @returns The UIExpression representing the proportional width relationship
|
|
64
|
-
*/
|
|
20
|
+
/** Builds constraint expression for proportional relationship */
|
|
65
21
|
private buildRHS;
|
|
66
22
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UIOrientation } from "../miscellaneous/UIOrientation";
|
|
2
|
+
import type { UIPriority } from "../miscellaneous/UIPriority";
|
|
3
|
+
import type { UIRelation } from "../miscellaneous/UIRelation";
|
|
4
|
+
/** Single parameter constraint options */
|
|
5
|
+
export interface UISingleParameterConstraintOptions {
|
|
6
|
+
/** Constraint priority */
|
|
7
|
+
priority: UIPriority;
|
|
8
|
+
/** Constraint relation */
|
|
9
|
+
relation: UIRelation;
|
|
10
|
+
/** When constraint is active */
|
|
11
|
+
orientation: UIOrientation;
|
|
12
|
+
}
|