laymur 0.1.73 → 0.2.1
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 +367 -0
- package/dist/builders/UIConstraint2DBuilder.d.ts +130 -0
- 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/constraints/UIAspectConstraint.d.ts +60 -0
- package/dist/constraints/UIConstraint.d.ts +29 -0
- package/dist/constraints/UICoverConstraint.d.ts +0 -0
- package/dist/constraints/UICustomConstraint.d.ts +60 -0
- package/dist/constraints/UIFitConstraint.d.ts +0 -0
- package/dist/constraints/UIHeightConstraint.d.ts +49 -0
- package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +94 -0
- package/dist/constraints/UIHorizontalProportionConstraint.d.ts +67 -0
- package/dist/constraints/UISingleParameterConstraint.d.ts +108 -0
- package/dist/constraints/UIVerticalDistanceConstraint.d.ts +94 -0
- package/dist/constraints/UIVerticalProportionConstraint.d.ts +67 -0
- package/dist/constraints/UIWidthConstraint.d.ts +49 -0
- package/dist/elements/UIAnchor.d.ts +78 -0
- package/dist/elements/UIDummy.d.ts +72 -0
- package/dist/elements/UIElement.d.ts +121 -0
- package/dist/elements/UIImage.d.ts +88 -0
- package/dist/elements/UINineSline.d.ts +0 -0
- package/dist/elements/UIProgress.d.ts +39 -0
- package/dist/elements/UIScene.d.ts +199 -0
- package/dist/elements/UIText.d.ts +157 -0
- package/dist/index.d.ts +29 -31
- package/dist/index.js +3320 -3251
- 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 +112 -0
- package/dist/layers/UILayer.d.ts +144 -0
- package/dist/materials/UIInstancedMaterial.d.ts +0 -0
- package/dist/materials/UIMaterial.d.ts +13 -0
- package/dist/materials/UINineSliceMaterial.d.ts +0 -0
- package/dist/{Materials → materials}/UIProgressMaterial.d.ts +0 -4
- package/dist/miscellaneous/UIExpression.d.ts +117 -0
- package/dist/miscellaneous/UIMicro.d.ts +130 -0
- package/dist/{Miscellaneous → miscellaneous}/UIOrientation.d.ts +2 -9
- package/dist/miscellaneous/UIPriority.d.ts +56 -0
- package/dist/miscellaneous/UIRelation.d.ts +43 -0
- package/dist/miscellaneous/UITextPadding.d.ts +7 -0
- package/dist/miscellaneous/UITextSpan.d.ts +6 -0
- package/dist/miscellaneous/UITextStyle.d.ts +18 -0
- package/dist/miscellaneous/asserts.d.ts +112 -0
- package/dist/miscellaneous/textInterfaces.d.ts +19 -0
- package/dist/miscellaneous/textTools.d.ts +12 -0
- package/dist/scalable/UIScalableMesh.d.ts +16 -0
- package/dist/scalable/UIScalablePlaneMesh.d.ts +14 -0
- package/dist/wrappers/UISceneWrapper.d.ts +18 -0
- package/dist/wrappers/UISolverWrapper.d.ts +29 -0
- package/package.json +3 -3
- package/dist/Builders/UIConstraint2DBuilder.d.ts +0 -42
- package/dist/Builders/UIConstraintContainerBuilder.d.ts +0 -20
- package/dist/Builders/UIConstraintStackBuilder.d.ts +0 -24
- package/dist/Constraints/UIAspectConstraint.d.ts +0 -56
- package/dist/Constraints/UIConstraint.d.ts +0 -32
- package/dist/Constraints/UIConstraintPower.d.ts +0 -57
- package/dist/Constraints/UIConstraintRule.d.ts +0 -46
- package/dist/Constraints/UICoverConstraint.d.ts +0 -72
- package/dist/Constraints/UIFitConstraint.d.ts +0 -72
- package/dist/Constraints/UIHeightConstraint.d.ts +0 -55
- package/dist/Constraints/UIHorizontalDistanceConstraint.d.ts +0 -63
- package/dist/Constraints/UIHorizontalProportionConstraint.d.ts +0 -58
- package/dist/Constraints/UIVerticalDistanceConstraint.d.ts +0 -63
- package/dist/Constraints/UIVerticalProportionConstraint.d.ts +0 -58
- package/dist/Constraints/UIWidthConstraint.d.ts +0 -55
- package/dist/Elements/UIAnchor.d.ts +0 -66
- package/dist/Elements/UIDummy.d.ts +0 -21
- package/dist/Elements/UIElement.d.ts +0 -134
- package/dist/Elements/UIImage.d.ts +0 -57
- package/dist/Elements/UIProgress.d.ts +0 -127
- package/dist/Elements/UIScene.d.ts +0 -141
- package/dist/Elements/UIText.d.ts +0 -76
- package/dist/Layers/UIFullScreenLayer.d.ts +0 -13
- package/dist/Layers/UILayer.d.ts +0 -68
- package/dist/Materials/UIMaterial.d.ts +0 -13
- package/dist/Miscellaneous/UIBlending.d.ts +0 -7
- package/dist/Miscellaneous/UIMicro.d.ts +0 -176
- package/dist/Miscellaneous/UITextInterfaces.d.ts +0 -49
- package/dist/Miscellaneous/asserts.d.ts +0 -5
- package/dist/Miscellaneous/math.d.ts +0 -1
- package/dist/Miscellaneous/microTransformationTools.d.ts +0 -3
- package/dist/Miscellaneous/symbols.d.ts +0 -1
- package/dist/Miscellaneous/textTools.d.ts +0 -9
- package/dist/Passes/UIComposer.d.ts +0 -114
- package/dist/Passes/UIFullScreenQuad.d.ts +0 -51
- package/dist/Passes/UIPass.d.ts +0 -43
- /package/dist/{Miscellaneous → miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/threeInstances.d.ts +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
2
|
+
import { UILayer } from "./UILayer";
|
|
3
|
+
/**
|
|
4
|
+
* UI layer that manages fullscreen interfaces with optional fixed dimensions and automatic scaling.
|
|
5
|
+
*
|
|
6
|
+
* UIFullscreenLayer extends UILayer to provide automatic browser window integration,
|
|
7
|
+
* handling window resize events and pointer interactions. It supports optional fixed
|
|
8
|
+
* width or height constraints that enable responsive scaling while maintaining
|
|
9
|
+
* design proportions across different screen sizes.
|
|
10
|
+
*
|
|
11
|
+
* The layer automatically calculates scaling factors based on the orientation and
|
|
12
|
+
* fixed dimension constraints, ensuring consistent layout appearance regardless
|
|
13
|
+
* of the actual browser window size.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link UILayer} - Base layer functionality
|
|
16
|
+
* @see {@link UIOrientation} - Orientation-based scaling behavior
|
|
17
|
+
*/
|
|
18
|
+
export declare class UIFullscreenLayer extends UILayer {
|
|
19
|
+
/** Internal storage for the optional fixed width constraint. */
|
|
20
|
+
private fixedWidthInternal?;
|
|
21
|
+
/** Internal storage for the optional fixed height constraint. */
|
|
22
|
+
private fixedHeightInternal?;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new UIFullscreenLayer instance with optional fixed dimensions.
|
|
25
|
+
*
|
|
26
|
+
* The layer will automatically resize to match the browser window and set up
|
|
27
|
+
* event listeners for window resize and pointer events. Fixed dimensions
|
|
28
|
+
* enable proportional scaling while maintaining design aspect ratios.
|
|
29
|
+
*
|
|
30
|
+
* @param fixedWidth - Optional fixed width for proportional scaling
|
|
31
|
+
* @param fixedHeight - Optional fixed height for proportional scaling
|
|
32
|
+
* @throws Will throw an error if fixed dimensions are not valid positive numbers
|
|
33
|
+
* @see {@link assertValidPositiveNumber}
|
|
34
|
+
*/
|
|
35
|
+
constructor(fixedWidth: number | undefined, fixedHeight: number | undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Gets the current fixed width constraint.
|
|
38
|
+
* @returns The fixed width in pixels, or undefined if not set
|
|
39
|
+
*/
|
|
40
|
+
get fixedWidth(): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the current fixed height constraint.
|
|
43
|
+
* @returns The fixed height in pixels, or undefined if not set
|
|
44
|
+
*/
|
|
45
|
+
get fixedHeight(): number | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Sets a new fixed width constraint and triggers resize recalculation.
|
|
48
|
+
* @param value - The new fixed width in pixels, or undefined to remove constraint
|
|
49
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
50
|
+
* @see {@link assertValidPositiveNumber}
|
|
51
|
+
*/
|
|
52
|
+
set fixedWidth(value: number | undefined);
|
|
53
|
+
/**
|
|
54
|
+
* Sets a new fixed height constraint and triggers resize recalculation.
|
|
55
|
+
* @param value - The new fixed height in pixels, or undefined to remove constraint
|
|
56
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
57
|
+
* @see {@link assertValidPositiveNumber}
|
|
58
|
+
*/
|
|
59
|
+
set fixedHeight(value: number | undefined);
|
|
60
|
+
/**
|
|
61
|
+
* Destroys the fullscreen layer by removing all event listeners.
|
|
62
|
+
*
|
|
63
|
+
* This method cleans up window event listeners for resize and pointer events.
|
|
64
|
+
* After calling this method, the layer will no longer respond to window
|
|
65
|
+
* changes and should not be used anymore.
|
|
66
|
+
*/
|
|
67
|
+
destroy(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Renders the fullscreen layer and all its contained elements.
|
|
70
|
+
*
|
|
71
|
+
* Clears the depth and stencil buffers and delegates rendering to the
|
|
72
|
+
* parent layer's render method. This ensures proper rendering order
|
|
73
|
+
* and buffer management for fullscreen interfaces.
|
|
74
|
+
*
|
|
75
|
+
* @param renderer - The WebGL renderer instance
|
|
76
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
77
|
+
* @throws Will throw an error if deltaTime is not a valid number
|
|
78
|
+
* @see {@link assertValidNumber}
|
|
79
|
+
*/
|
|
80
|
+
render(renderer: WebGLRenderer, deltaTime: number): void;
|
|
81
|
+
/**
|
|
82
|
+
* Calculates the scaling factor based on orientation and fixed dimensions.
|
|
83
|
+
*
|
|
84
|
+
* The scaling factor is determined by the current orientation and which
|
|
85
|
+
* fixed dimension constraint is active. In horizontal orientation, fixed
|
|
86
|
+
* width takes precedence; in vertical orientation, fixed height takes precedence.
|
|
87
|
+
*
|
|
88
|
+
* @returns The scaling factor to apply to window dimensions
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
private calculateScale;
|
|
92
|
+
/**
|
|
93
|
+
* Event handler for window resize events.
|
|
94
|
+
*
|
|
95
|
+
* Recalculates the scaling factor and updates the layer dimensions
|
|
96
|
+
* based on the new window size and fixed dimension constraints.
|
|
97
|
+
*
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private readonly onResize;
|
|
101
|
+
/**
|
|
102
|
+
* Event handler for pointer down events.
|
|
103
|
+
*
|
|
104
|
+
* Converts browser pointer coordinates to layer coordinates by accounting
|
|
105
|
+
* for element positioning and applying the appropriate scaling factor.
|
|
106
|
+
* The y-coordinate is flipped to match the UI coordinate system.
|
|
107
|
+
*
|
|
108
|
+
* @param event - The pointer event from the browser
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private readonly onClick;
|
|
112
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Eventail } from "eventail";
|
|
2
|
+
import type { WebGLRenderer } from "three";
|
|
3
|
+
import { UIMode } from "../miscellaneous/UIMode";
|
|
4
|
+
import { UIOrientation } from "../miscellaneous/UIOrientation";
|
|
5
|
+
import { UISceneWrapper } from "../wrappers/UISceneWrapper";
|
|
6
|
+
import { UISolverWrapper } from "../wrappers/UISolverWrapper";
|
|
7
|
+
/**
|
|
8
|
+
* Events that can be emitted by UI layers.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum UILayerEvent {
|
|
11
|
+
/** Emitted when the layer's orientation changes between horizontal and vertical. */
|
|
12
|
+
ORIENTATION_CHANGE = "orientation_change",
|
|
13
|
+
/** Emitted when the layer's visibility/interaction mode changes. */
|
|
14
|
+
MODE_CHANGE = "mode_change"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Abstract base class for UI layout containers with constraint solving and rendering.
|
|
18
|
+
*
|
|
19
|
+
* UILayer serves as the fundamental container for UI elements, providing constraint-based
|
|
20
|
+
* layout solving, 3D scene management, and event handling. It manages the layer's
|
|
21
|
+
* dimensions through solver variables, handles orientation changes, and coordinates
|
|
22
|
+
* rendering and interaction for all contained elements.
|
|
23
|
+
*
|
|
24
|
+
* Each layer maintains its own constraint solver and scene graph, allowing for
|
|
25
|
+
* independent layout calculation and rendering optimization.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link UIElement} - Elements contained within layers
|
|
28
|
+
* @see {@link UISolverWrapper} - Constraint solving system
|
|
29
|
+
* @see {@link UISceneWrapper} - 3D scene management
|
|
30
|
+
* @see {@link UIOrientation} - Layer orientation states
|
|
31
|
+
*/
|
|
32
|
+
export declare abstract class UILayer extends Eventail {
|
|
33
|
+
/** Optional name identifier for the layer. */
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Solver variable descriptor for the x-coordinate position.
|
|
37
|
+
* This variable is managed by the constraint solver system.
|
|
38
|
+
*/
|
|
39
|
+
readonly xVariable: number;
|
|
40
|
+
/**
|
|
41
|
+
* Solver variable descriptor for the y-coordinate position.
|
|
42
|
+
* This variable is managed by the constraint solver system.
|
|
43
|
+
*/
|
|
44
|
+
readonly yVariable: number;
|
|
45
|
+
/**
|
|
46
|
+
* Solver variable descriptor for the width dimension.
|
|
47
|
+
* This variable is managed by the constraint solver system.
|
|
48
|
+
*/
|
|
49
|
+
readonly wVariable: number;
|
|
50
|
+
/**
|
|
51
|
+
* Solver variable descriptor for the height dimension.
|
|
52
|
+
* This variable is managed by the constraint solver system.
|
|
53
|
+
*/
|
|
54
|
+
readonly hVariable: number;
|
|
55
|
+
/**
|
|
56
|
+
* Constraint solver wrapper for managing layout calculations.
|
|
57
|
+
* @see {@link UISolverWrapper}
|
|
58
|
+
*/
|
|
59
|
+
protected readonly solverWrapper: UISolverWrapper;
|
|
60
|
+
/**
|
|
61
|
+
* 3D scene wrapper for managing rendering and element hierarchy.
|
|
62
|
+
* @see {@link UISceneWrapper}
|
|
63
|
+
*/
|
|
64
|
+
protected readonly sceneWrapper: UISceneWrapper;
|
|
65
|
+
/** Internal storage for the current visibility/interaction mode. */
|
|
66
|
+
protected modeInternal: UIMode;
|
|
67
|
+
/** Internal storage for the current orientation state. */
|
|
68
|
+
protected orientationInternal: UIOrientation;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new UILayer instance with specified dimensions.
|
|
71
|
+
*
|
|
72
|
+
* Initializes the constraint solver with position and dimension variables,
|
|
73
|
+
* sets up the 3D scene wrapper, and determines the initial orientation
|
|
74
|
+
* based on the width-to-height ratio.
|
|
75
|
+
*
|
|
76
|
+
* @param w - Initial width of the layer
|
|
77
|
+
* @param h - Initial height of the layer
|
|
78
|
+
*/
|
|
79
|
+
constructor(w: number, h: number);
|
|
80
|
+
/**
|
|
81
|
+
* Gets the current width value from the constraint solver.
|
|
82
|
+
* @returns The current layer width in pixels
|
|
83
|
+
*/
|
|
84
|
+
get width(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the current height value from the constraint solver.
|
|
87
|
+
* @returns The current layer height in pixels
|
|
88
|
+
*/
|
|
89
|
+
get height(): number;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the current visibility and interaction mode.
|
|
92
|
+
* @returns The current UIMode setting
|
|
93
|
+
* @see {@link UIMode}
|
|
94
|
+
*/
|
|
95
|
+
get mode(): UIMode;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the current orientation state.
|
|
98
|
+
* @returns The current orientation (horizontal or vertical)
|
|
99
|
+
* @see {@link UIOrientation}
|
|
100
|
+
*/
|
|
101
|
+
get orientation(): UIOrientation;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the visibility and interaction mode and emits change event.
|
|
104
|
+
* @param value - The new UIMode setting
|
|
105
|
+
* @see {@link UIMode}
|
|
106
|
+
*/
|
|
107
|
+
set mode(value: UIMode);
|
|
108
|
+
/**
|
|
109
|
+
* Internal method for resizing the layer and updating orientation.
|
|
110
|
+
*
|
|
111
|
+
* Updates the solver variables for width and height, resizes the scene wrapper,
|
|
112
|
+
* and determines if the orientation has changed based on the new dimensions.
|
|
113
|
+
* Emits an orientation change event if the orientation has changed.
|
|
114
|
+
*
|
|
115
|
+
* @param width - The new layer width
|
|
116
|
+
* @param height - The new layer height
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
protected resizeInternal(width: number, height: number): void;
|
|
120
|
+
/**
|
|
121
|
+
* Internal method for rendering the layer and its elements.
|
|
122
|
+
*
|
|
123
|
+
* Delegates rendering to the scene wrapper if the layer is not hidden.
|
|
124
|
+
* This method is called during the rendering loop to update and draw
|
|
125
|
+
* all elements contained within the layer.
|
|
126
|
+
*
|
|
127
|
+
* @param renderer - The WebGL renderer instance
|
|
128
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
129
|
+
* @protected
|
|
130
|
+
*/
|
|
131
|
+
protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* Internal method for handling click events on the layer.
|
|
134
|
+
*
|
|
135
|
+
* Processes click events by testing elements in reverse z-order (top to bottom)
|
|
136
|
+
* until one handles the click. Only processes clicks when the layer is in
|
|
137
|
+
* interactive mode.
|
|
138
|
+
*
|
|
139
|
+
* @param x - The x-coordinate of the click
|
|
140
|
+
* @param y - The y-coordinate of the click
|
|
141
|
+
* @protected
|
|
142
|
+
*/
|
|
143
|
+
protected clickInternal(x: number, y: number): void;
|
|
144
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Texture } from "three";
|
|
2
|
+
import { ShaderMaterial } from "three";
|
|
3
|
+
export declare class UIMaterial extends ShaderMaterial {
|
|
4
|
+
constructor(map?: Texture);
|
|
5
|
+
getTexture(): Texture;
|
|
6
|
+
getColor(): number;
|
|
7
|
+
getOpacity(): number;
|
|
8
|
+
getTransparency(): boolean;
|
|
9
|
+
setTexture(value: Texture): this;
|
|
10
|
+
setColor(value: number): this;
|
|
11
|
+
setOpacity(value: number): this;
|
|
12
|
+
setTransparency(value: boolean): this;
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -7,10 +7,8 @@ export declare class UIProgressMaterial extends ShaderMaterial {
|
|
|
7
7
|
getForegroundTexture(): Texture;
|
|
8
8
|
getBackgroundColor(): number;
|
|
9
9
|
getForegroundColor(): number;
|
|
10
|
-
getColor(): number;
|
|
11
10
|
getBackgroundOpacity(): number;
|
|
12
11
|
getForegroundOpacity(): number;
|
|
13
|
-
getOpacity(): number;
|
|
14
12
|
getAngle(): number;
|
|
15
13
|
getIsForwardDirection(): boolean;
|
|
16
14
|
setProgress(value: number): void;
|
|
@@ -18,10 +16,8 @@ export declare class UIProgressMaterial extends ShaderMaterial {
|
|
|
18
16
|
setForegroundTexture(value: Texture): void;
|
|
19
17
|
setBackgroundColor(value: number): void;
|
|
20
18
|
setForegroundColor(value: number): void;
|
|
21
|
-
setColor(value: number): void;
|
|
22
19
|
setBackgroundOpacity(value: number): void;
|
|
23
20
|
setForegroundOpacity(value: number): void;
|
|
24
|
-
setOpacity(value: number): void;
|
|
25
21
|
setAngle(value: number): void;
|
|
26
22
|
setIsForwardDirection(value: boolean): void;
|
|
27
23
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mathematical expression builder for constraint equations in the UI layout system.
|
|
3
|
+
*
|
|
4
|
+
* UIExpression represents linear mathematical expressions of the form:
|
|
5
|
+
* constant + coefficient₁ × variable₁ + coefficient₂ × variable₂ + ... + coefficientₙ × variableₙ
|
|
6
|
+
*
|
|
7
|
+
* These expressions are used to build constraint equations for the Kiwi solver,
|
|
8
|
+
* enabling complex mathematical relationships between UI element properties.
|
|
9
|
+
* Variables are referenced by their numeric descriptors from the solver system.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link UIConstraint} - Constraints that use expressions
|
|
12
|
+
* @see {@link UISolverWrapper} - Solver integration that creates variables
|
|
13
|
+
*/
|
|
14
|
+
export declare class UIExpression {
|
|
15
|
+
/** The constant term of the expression. */
|
|
16
|
+
constant: number;
|
|
17
|
+
/** Map of variable descriptors to their coefficients in the expression. */
|
|
18
|
+
private readonly terms;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new UIExpression instance.
|
|
21
|
+
*
|
|
22
|
+
* @param constant - The constant term of the expression (defaults to 0)
|
|
23
|
+
* @param terms - Optional array of [variableDescriptor, coefficient] pairs
|
|
24
|
+
*/
|
|
25
|
+
constructor(constant?: number, terms?: [number, number][]);
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new expression that represents the sum of two expressions.
|
|
28
|
+
*
|
|
29
|
+
* Performs mathematical addition: (a.constant + a.terms) + (b.constant + b.terms)
|
|
30
|
+
* Coefficients for the same variables are combined.
|
|
31
|
+
*
|
|
32
|
+
* @param a - The first expression
|
|
33
|
+
* @param b - The second expression
|
|
34
|
+
* @returns A new expression representing a + b
|
|
35
|
+
*/
|
|
36
|
+
static plus(a: UIExpression, b: UIExpression): UIExpression;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new expression that represents the difference of two expressions.
|
|
39
|
+
*
|
|
40
|
+
* Performs mathematical subtraction: (a.constant + a.terms) - (b.constant + b.terms)
|
|
41
|
+
* Coefficients for the same variables are combined with subtraction.
|
|
42
|
+
*
|
|
43
|
+
* @param a - The first expression (minuend)
|
|
44
|
+
* @param b - The second expression (subtrahend)
|
|
45
|
+
* @returns A new expression representing a - b
|
|
46
|
+
*/
|
|
47
|
+
static minus(a: UIExpression, b: UIExpression): UIExpression;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a variable term to this expression (mutating operation).
|
|
50
|
+
*
|
|
51
|
+
* If the variable already exists in the expression, its coefficient is
|
|
52
|
+
* increased by the specified amount. Otherwise, a new term is added.
|
|
53
|
+
*
|
|
54
|
+
* @param variableIndex - The variable descriptor from the solver
|
|
55
|
+
* @param coefficient - The coefficient to add for this variable
|
|
56
|
+
* @returns This expression instance for method chaining
|
|
57
|
+
*/
|
|
58
|
+
plus(variableIndex: number, coefficient: number): this;
|
|
59
|
+
/**
|
|
60
|
+
* Subtracts a variable term from this expression (mutating operation).
|
|
61
|
+
*
|
|
62
|
+
* If the variable already exists in the expression, its coefficient is
|
|
63
|
+
* decreased by the specified amount. Otherwise, a new term with negative
|
|
64
|
+
* coefficient is added.
|
|
65
|
+
*
|
|
66
|
+
* @param variableIndex - The variable descriptor from the solver
|
|
67
|
+
* @param coefficient - The coefficient to subtract for this variable
|
|
68
|
+
* @returns This expression instance for method chaining
|
|
69
|
+
*/
|
|
70
|
+
minus(variableIndex: number, coefficient: number): this;
|
|
71
|
+
/**
|
|
72
|
+
* Multiplies all terms in this expression by a scalar value (mutating operation).
|
|
73
|
+
*
|
|
74
|
+
* Both the constant term and all variable coefficients are multiplied
|
|
75
|
+
* by the specified value.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The scalar value to multiply by
|
|
78
|
+
* @returns This expression instance for method chaining
|
|
79
|
+
*/
|
|
80
|
+
multiply(value: number): this;
|
|
81
|
+
/**
|
|
82
|
+
* Divides all terms in this expression by a scalar value (mutating operation).
|
|
83
|
+
*
|
|
84
|
+
* Both the constant term and all variable coefficients are divided
|
|
85
|
+
* by the specified value.
|
|
86
|
+
*
|
|
87
|
+
* @param value - The scalar value to divide by (must not be zero)
|
|
88
|
+
* @returns This expression instance for method chaining
|
|
89
|
+
*/
|
|
90
|
+
divide(value: number): this;
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the expression contains a term for the specified variable.
|
|
93
|
+
*
|
|
94
|
+
* @param variableIndex - The variable descriptor to check for
|
|
95
|
+
* @returns True if the expression has a term for this variable, false otherwise
|
|
96
|
+
*/
|
|
97
|
+
hasTerm(variableIndex: number): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Copies the content of another expression into this expression (mutating operation).
|
|
100
|
+
*
|
|
101
|
+
* Replaces all terms and the constant of this expression with those
|
|
102
|
+
* from the source expression.
|
|
103
|
+
*
|
|
104
|
+
* @param expression - The source expression to copy from
|
|
105
|
+
* @returns This expression instance for method chaining
|
|
106
|
+
*/
|
|
107
|
+
copy(expression: UIExpression): this;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a deep copy of this expression.
|
|
110
|
+
*
|
|
111
|
+
* The returned expression is completely independent and can be modified
|
|
112
|
+
* without affecting the original.
|
|
113
|
+
*
|
|
114
|
+
* @returns A new UIExpression instance with the same content
|
|
115
|
+
*/
|
|
116
|
+
clone(): UIExpression;
|
|
117
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Micro-transformation system for non-constraint based UI element adjustments.
|
|
3
|
+
*
|
|
4
|
+
* UIMicro provides a lightweight transformation system that operates independently
|
|
5
|
+
* of the constraint solver. It manages position offsets, anchor points, scaling,
|
|
6
|
+
* and rotation transformations that can be applied to UI elements for animations,
|
|
7
|
+
* visual effects, or fine-tuned positioning without affecting the constraint-based
|
|
8
|
+
* layout system.
|
|
9
|
+
*
|
|
10
|
+
* All transformations are tracked with change detection to optimize rendering
|
|
11
|
+
* performance by only recalculating when properties have actually changed.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link UIElement} - Elements that use micro transformations
|
|
14
|
+
*/
|
|
15
|
+
export declare class UIMicro {
|
|
16
|
+
/** Internal storage for x-coordinate offset. */
|
|
17
|
+
private xInternal;
|
|
18
|
+
/** Internal storage for y-coordinate offset. */
|
|
19
|
+
private yInternal;
|
|
20
|
+
/** Internal storage for x-axis anchor point. */
|
|
21
|
+
private anchorXInternal;
|
|
22
|
+
/** Internal storage for y-axis anchor point. */
|
|
23
|
+
private anchorYInternal;
|
|
24
|
+
/** Internal storage for x-axis scale factor. */
|
|
25
|
+
private scaleXInternal;
|
|
26
|
+
/** Internal storage for y-axis scale factor. */
|
|
27
|
+
private scaleYInternal;
|
|
28
|
+
/** Internal storage for rotation in radians. */
|
|
29
|
+
private rotationInternal;
|
|
30
|
+
/** Flag indicating if any transformation properties have changed. */
|
|
31
|
+
private recalculationRequired;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the x-coordinate offset for micro positioning.
|
|
34
|
+
* @returns The x-offset value
|
|
35
|
+
*/
|
|
36
|
+
get x(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the y-coordinate offset for micro positioning.
|
|
39
|
+
* @returns The y-offset value
|
|
40
|
+
*/
|
|
41
|
+
get y(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the x-axis anchor point for transformations.
|
|
44
|
+
* @returns The anchor point (0.0 = left, 0.5 = center, 1.0 = right)
|
|
45
|
+
*/
|
|
46
|
+
get anchorX(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the y-axis anchor point for transformations.
|
|
49
|
+
* @returns The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
50
|
+
*/
|
|
51
|
+
get anchorY(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the x-axis scale factor.
|
|
54
|
+
* @returns The scale factor (1.0 = normal size)
|
|
55
|
+
*/
|
|
56
|
+
get scaleX(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the y-axis scale factor.
|
|
59
|
+
* @returns The scale factor (1.0 = normal size)
|
|
60
|
+
*/
|
|
61
|
+
get scaleY(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the uniform scale factor (maximum of scaleX and scaleY).
|
|
64
|
+
* @returns The larger of the two scale factors
|
|
65
|
+
*/
|
|
66
|
+
get size(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the rotation angle in degrees.
|
|
69
|
+
* @returns The rotation angle in degrees
|
|
70
|
+
*/
|
|
71
|
+
get angle(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the rotation angle in radians.
|
|
74
|
+
* @returns The rotation angle in radians
|
|
75
|
+
*/
|
|
76
|
+
get rotation(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Sets the x-coordinate offset for micro positioning.
|
|
79
|
+
* @param value - The new x-offset value
|
|
80
|
+
*/
|
|
81
|
+
set x(value: number);
|
|
82
|
+
/**
|
|
83
|
+
* Sets the y-coordinate offset for micro positioning.
|
|
84
|
+
* @param value - The new y-offset value
|
|
85
|
+
*/
|
|
86
|
+
set y(value: number);
|
|
87
|
+
/**
|
|
88
|
+
* Sets the x-axis anchor point for transformations.
|
|
89
|
+
* @param value - The anchor point (0.0 = left, 0.5 = center, 1.0 = right)
|
|
90
|
+
*/
|
|
91
|
+
set anchorX(value: number);
|
|
92
|
+
/**
|
|
93
|
+
* Sets the y-axis anchor point for transformations.
|
|
94
|
+
* @param value - The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)
|
|
95
|
+
*/
|
|
96
|
+
set anchorY(value: number);
|
|
97
|
+
/**
|
|
98
|
+
* Sets the x-axis scale factor.
|
|
99
|
+
* @param value - The scale factor (1.0 = normal size)
|
|
100
|
+
*/
|
|
101
|
+
set scaleX(value: number);
|
|
102
|
+
/**
|
|
103
|
+
* Sets the y-axis scale factor.
|
|
104
|
+
* @param value - The scale factor (1.0 = normal size)
|
|
105
|
+
*/
|
|
106
|
+
set scaleY(value: number);
|
|
107
|
+
/**
|
|
108
|
+
* Sets both scale factors to the same value for uniform scaling.
|
|
109
|
+
* @param value - The uniform scale factor (1.0 = normal size)
|
|
110
|
+
*/
|
|
111
|
+
set size(value: number);
|
|
112
|
+
/**
|
|
113
|
+
* Sets the rotation angle in degrees.
|
|
114
|
+
* @param value - The rotation angle in degrees
|
|
115
|
+
*/
|
|
116
|
+
set angle(value: number);
|
|
117
|
+
/**
|
|
118
|
+
* Sets the rotation angle in radians.
|
|
119
|
+
* @param value - The rotation angle in radians
|
|
120
|
+
*/
|
|
121
|
+
set rotation(value: number);
|
|
122
|
+
/**
|
|
123
|
+
* Resets all transformation properties to their default values.
|
|
124
|
+
*
|
|
125
|
+
* This method restores position (0,0), anchor (0,0), scale (1,1),
|
|
126
|
+
* and rotation (0) to their initial states. Only triggers recalculation
|
|
127
|
+
* if any values actually change.
|
|
128
|
+
*/
|
|
129
|
+
reset(): void;
|
|
130
|
+
}
|
|
@@ -9,25 +9,18 @@ export declare enum UIOrientation {
|
|
|
9
9
|
* Indicates a landscape orientation (width > height).
|
|
10
10
|
* Constraints using this value will only be active in landscape mode.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
HORIZONTAL = 0,
|
|
13
13
|
/**
|
|
14
14
|
* Indicates a portrait orientation (height > width).
|
|
15
15
|
* Constraints using this value will only be active in portrait mode.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
VERTICAL = 1,
|
|
18
18
|
/**
|
|
19
19
|
* Indicates that the constraint should always be active,
|
|
20
20
|
* regardless of screen orientation.
|
|
21
21
|
*/
|
|
22
22
|
ALWAYS = 2
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Type guard to check if a value is a valid UIOrientation.
|
|
26
|
-
*
|
|
27
|
-
* @param obj - The value to check
|
|
28
|
-
* @returns True if the value is a valid UIOrientation enum value
|
|
29
|
-
*/
|
|
30
|
-
export declare function isUIOrientation(obj: unknown): obj is UIOrientation;
|
|
31
24
|
/**
|
|
32
25
|
* Resolves an optional orientation to a definite value.
|
|
33
26
|
*
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority levels for UI layout constraints and variables.
|
|
3
|
+
*
|
|
4
|
+
* UIPriority defines a hierarchical system of priority levels used by the
|
|
5
|
+
* constraint solver to determine which constraints should take precedence
|
|
6
|
+
* when conflicts arise. Lower numeric values represent higher priority,
|
|
7
|
+
* with P0 being the highest priority and P7 being the lowest.
|
|
8
|
+
*
|
|
9
|
+
* The priority system maps to Kiwi solver strength values with different
|
|
10
|
+
* strength components (required, strong, medium, weak) to create a nuanced
|
|
11
|
+
* priority hierarchy for layout solving.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link convertPriority} - Converts to Kiwi solver strength values
|
|
14
|
+
*/
|
|
15
|
+
export declare enum UIPriority {
|
|
16
|
+
/** Highest priority - required constraints that must be satisfied. */
|
|
17
|
+
P0 = 0,
|
|
18
|
+
/** High priority - strong constraints with medium strength. */
|
|
19
|
+
P1 = 1,
|
|
20
|
+
/** Medium-high priority - strong constraints with low strength. */
|
|
21
|
+
P2 = 2,
|
|
22
|
+
/** Medium priority - medium strength constraints. */
|
|
23
|
+
P3 = 3,
|
|
24
|
+
/** Medium-low priority - medium strength constraints with low weight. */
|
|
25
|
+
P4 = 4,
|
|
26
|
+
/** Low priority - weak strength constraints with medium weight. */
|
|
27
|
+
P5 = 5,
|
|
28
|
+
/** Very low priority - weak strength constraints with low weight. */
|
|
29
|
+
P6 = 6,
|
|
30
|
+
/** Lowest priority - weak strength constraints with minimal weight. */
|
|
31
|
+
P7 = 7
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Converts UIPriority enum values to Kiwi solver strength values.
|
|
35
|
+
*
|
|
36
|
+
* This function maps the UI priority levels to the three-component strength
|
|
37
|
+
* system used by the Kiwi constraint solver (required, strong, medium, weak).
|
|
38
|
+
* Higher priority levels get stronger constraint strength values.
|
|
39
|
+
*
|
|
40
|
+
* @param priority - The UI priority level to convert
|
|
41
|
+
* @returns The corresponding Kiwi solver strength value
|
|
42
|
+
* @throws Will throw an error if an invalid priority is provided
|
|
43
|
+
* @see {@link UIPriority} - Priority level definitions
|
|
44
|
+
*/
|
|
45
|
+
export declare function convertPriority(priority: UIPriority): number;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves an optional priority value to a concrete UIPriority.
|
|
48
|
+
*
|
|
49
|
+
* If no priority is provided, returns the default highest priority (P0).
|
|
50
|
+
* This function is commonly used in constraint creation where priority
|
|
51
|
+
* is an optional parameter.
|
|
52
|
+
*
|
|
53
|
+
* @param priority - The optional priority value to resolve
|
|
54
|
+
* @returns The resolved priority, defaulting to P0 if undefined
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolvePriority(priority?: UIPriority): UIPriority;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Operator } from "@lume/kiwi";
|
|
2
|
+
/**
|
|
3
|
+
* Relational operators for UI layout constraints.
|
|
4
|
+
*
|
|
5
|
+
* UIRelation defines the mathematical relationship between the left-hand
|
|
6
|
+
* and right-hand sides of constraint equations. These relations are used
|
|
7
|
+
* by the constraint solver to determine how expressions should be compared
|
|
8
|
+
* when solving layout constraints.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link convertRelation} - Converts to Kiwi solver operators
|
|
11
|
+
*/
|
|
12
|
+
export declare enum UIRelation {
|
|
13
|
+
/** Equality relation: left-hand side equals right-hand side. */
|
|
14
|
+
EQUAL = 0,
|
|
15
|
+
/** Less than or equal relation: left-hand side ≤ right-hand side. */
|
|
16
|
+
LESS_THAN = 1,
|
|
17
|
+
/** Greater than or equal relation: left-hand side ≥ right-hand side. */
|
|
18
|
+
GREATER_THAN = 2
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts UIRelation enum values to Kiwi solver operator values.
|
|
22
|
+
*
|
|
23
|
+
* This function maps the UI relation types to the corresponding operators
|
|
24
|
+
* used by the Kiwi constraint solver for mathematical comparisons in
|
|
25
|
+
* constraint equations.
|
|
26
|
+
*
|
|
27
|
+
* @param relation - The UI relation type to convert
|
|
28
|
+
* @returns The corresponding Kiwi solver operator
|
|
29
|
+
* @throws Will throw an error if an invalid relation is provided
|
|
30
|
+
* @see {@link UIRelation} - Relation type definitions
|
|
31
|
+
*/
|
|
32
|
+
export declare function convertRelation(relation: UIRelation): Operator;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves an optional relation value to a concrete UIRelation.
|
|
35
|
+
*
|
|
36
|
+
* If no relation is provided, returns the default equality relation.
|
|
37
|
+
* This function is commonly used in constraint creation where relation
|
|
38
|
+
* is an optional parameter.
|
|
39
|
+
*
|
|
40
|
+
* @param relation - The optional relation value to resolve
|
|
41
|
+
* @returns The resolved relation, defaulting to EQUAL if undefined
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveRelation(relation?: UIRelation): UIRelation;
|