hudini 0.17.0 → 0.17.2
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 +34 -0
- package/dist/components/card/card.d.ts +9 -0
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +44 -8
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.spec.js +2 -7
- package/dist/components/card/card.spec.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/circular-progress.js +11 -2
- package/dist/components/circular-progress/circular-progress.js.map +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/panel/index.d.ts +2 -0
- package/dist/components/panel/index.d.ts.map +1 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/panel/index.js.map +1 -0
- package/dist/components/panel/panel.d.ts.map +1 -1
- package/dist/components/panel/panel.js +5 -2
- package/dist/components/panel/panel.js.map +1 -1
- package/dist/components/text-button/text-button.d.ts.map +1 -1
- package/dist/components/text-button/text-button.js +1 -1
- package/dist/components/text-button/text-button.js.map +1 -1
- package/dist/hudini.js +1078 -839
- package/dist/hudini.min.js +1 -1
- package/dist/test-setup.js +31 -2
- package/dist/test-setup.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/column/column.d.ts +0 -88
- package/dist/components/column/column.d.ts.map +0 -1
- package/dist/components/column/column.js +0 -143
- package/dist/components/column/column.js.map +0 -1
- package/dist/components/column/column.spec.d.ts +0 -2
- package/dist/components/column/column.spec.d.ts.map +0 -1
- package/dist/components/column/column.spec.js +0 -114
- package/dist/components/column/column.spec.js.map +0 -1
- package/dist/components/column/index.d.ts +0 -2
- package/dist/components/column/index.d.ts.map +0 -1
- package/dist/components/column/index.js +0 -2
- package/dist/components/column/index.js.map +0 -1
- package/dist/components/layout/layout-utils.d.ts +0 -13
- package/dist/components/layout/layout-utils.d.ts.map +0 -1
- package/dist/components/layout/layout-utils.js +0 -96
- package/dist/components/layout/layout-utils.js.map +0 -1
- package/dist/components/layout/layout-utils.spec.d.ts +0 -2
- package/dist/components/layout/layout-utils.spec.d.ts.map +0 -1
- package/dist/components/layout/layout-utils.spec.js +0 -70
- package/dist/components/layout/layout-utils.spec.js.map +0 -1
- package/dist/components/row/index.d.ts +0 -2
- package/dist/components/row/index.d.ts.map +0 -1
- package/dist/components/row/index.js +0 -2
- package/dist/components/row/index.js.map +0 -1
- package/dist/components/row/row.d.ts +0 -87
- package/dist/components/row/row.d.ts.map +0 -1
- package/dist/components/row/row.js +0 -146
- package/dist/components/row/row.js.map +0 -1
- package/dist/components/row/row.spec.d.ts +0 -2
- package/dist/components/row/row.spec.d.ts.map +0 -1
- package/dist/components/row/row.spec.js +0 -114
- package/dist/components/row/row.spec.js.map +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { DEFAULT_GAP, getDisplayHeightOf, getDisplayWidthOf, getNormalizedOriginOf, } from './layout-utils';
|
|
3
|
-
// Helper to satisfy typing without importing Phaser types in tests
|
|
4
|
-
const asGO = (o) => o;
|
|
5
|
-
describe('layout-utils', () => {
|
|
6
|
-
it('DEFAULT_GAP should be 8', () => {
|
|
7
|
-
expect(DEFAULT_GAP).toBe(8);
|
|
8
|
-
});
|
|
9
|
-
describe('getDisplayWidthOf', () => {
|
|
10
|
-
it('prefers displayWidth when present', () => {
|
|
11
|
-
const obj = asGO({ displayWidth: 120, width: 200, getBounds: () => ({ width: 300 }) });
|
|
12
|
-
expect(getDisplayWidthOf(obj)).toBe(120);
|
|
13
|
-
});
|
|
14
|
-
it('falls back to width when displayWidth is absent', () => {
|
|
15
|
-
const obj = asGO({ width: 200, getBounds: () => ({ width: 300 }) });
|
|
16
|
-
expect(getDisplayWidthOf(obj)).toBe(200);
|
|
17
|
-
});
|
|
18
|
-
it('falls back to getBounds().width when both displayWidth and width are absent', () => {
|
|
19
|
-
const obj = asGO({ getBounds: () => ({ width: 300 }) });
|
|
20
|
-
expect(getDisplayWidthOf(obj)).toBe(300);
|
|
21
|
-
});
|
|
22
|
-
it('returns 0 when nothing is available', () => {
|
|
23
|
-
const obj = asGO({});
|
|
24
|
-
expect(getDisplayWidthOf(obj)).toBe(0);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('getDisplayHeightOf', () => {
|
|
28
|
-
it('prefers displayHeight when present', () => {
|
|
29
|
-
const obj = asGO({ displayHeight: 110, height: 210, getBounds: () => ({ height: 310 }) });
|
|
30
|
-
expect(getDisplayHeightOf(obj)).toBe(110);
|
|
31
|
-
});
|
|
32
|
-
it('falls back to height when displayHeight is absent', () => {
|
|
33
|
-
const obj = asGO({ height: 210, getBounds: () => ({ height: 310 }) });
|
|
34
|
-
expect(getDisplayHeightOf(obj)).toBe(210);
|
|
35
|
-
});
|
|
36
|
-
it('falls back to getBounds().height when both displayHeight and height are absent', () => {
|
|
37
|
-
const obj = asGO({ getBounds: () => ({ height: 310 }) });
|
|
38
|
-
expect(getDisplayHeightOf(obj)).toBe(310);
|
|
39
|
-
});
|
|
40
|
-
it('returns 0 when nothing is available', () => {
|
|
41
|
-
const obj = asGO({});
|
|
42
|
-
expect(getDisplayHeightOf(obj)).toBe(0);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('getNormalizedOriginOf', () => {
|
|
46
|
-
it('returns originX/Y when provided', () => {
|
|
47
|
-
const obj = asGO({ originX: 0.2, originY: 0.8, displayWidth: 100, displayHeight: 100 });
|
|
48
|
-
expect(getNormalizedOriginOf(obj)).toEqual({ x: 0.2, y: 0.8 });
|
|
49
|
-
});
|
|
50
|
-
it('computes from displayOriginX/Y over displayWidth/Height when originX/Y absent', () => {
|
|
51
|
-
const obj = asGO({ displayOriginX: 25, displayOriginY: 50, displayWidth: 100, displayHeight: 200 });
|
|
52
|
-
// x = 25/100 = 0.25, y = 50/200 = 0.25
|
|
53
|
-
expect(getNormalizedOriginOf(obj)).toEqual({ x: 0.25, y: 0.25 });
|
|
54
|
-
});
|
|
55
|
-
it('defaults to 0.5 when origins are missing and size is zero', () => {
|
|
56
|
-
const obj = asGO({ displayOriginX: 10, displayOriginY: 10, displayWidth: 0, displayHeight: 0 });
|
|
57
|
-
expect(getNormalizedOriginOf(obj)).toEqual({ x: 0.5, y: 0.5 });
|
|
58
|
-
});
|
|
59
|
-
it('uses mixed fallbacks per axis independently', () => {
|
|
60
|
-
const obj = asGO({
|
|
61
|
-
originX: 0.1, // should take precedence on X
|
|
62
|
-
displayOriginY: 30,
|
|
63
|
-
displayHeight: 120, // Y should be 30/120 = 0.25
|
|
64
|
-
displayWidth: 400,
|
|
65
|
-
});
|
|
66
|
-
expect(getNormalizedOriginOf(obj)).toEqual({ x: 0.1, y: 0.25 });
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=layout-utils.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layout-utils.spec.js","sourceRoot":"","sources":["../../../src/components/layout/layout-utils.spec.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,mEAAmE;AACnE,MAAM,IAAI,GAAG,CAAC,CAAU,EAA0B,EAAE,CAAC,CAA2B,CAAC;AAEjF,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,mBAAm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EAAE,GAAG,EAAE,4BAA4B;gBAChD,YAAY,EAAE,GAAG;aAClB,CAAC,CAAC;YACH,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/row/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/row/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { GameObjects, Scene } from 'phaser';
|
|
2
|
-
/** Vertical alignment options for row items */
|
|
3
|
-
export type VerticalAlign = 'top' | 'center' | 'bottom';
|
|
4
|
-
/** Parameters for creating a Row container */
|
|
5
|
-
export type RowParams = {
|
|
6
|
-
/** The scene this row belongs to */
|
|
7
|
-
scene: Scene;
|
|
8
|
-
/** X coordinate of the row */
|
|
9
|
-
x: number;
|
|
10
|
-
/** Y coordinate of the row */
|
|
11
|
-
y: number;
|
|
12
|
-
/** Gap between elements in pixels */
|
|
13
|
-
gap?: number;
|
|
14
|
-
/** Vertical alignment of elements */
|
|
15
|
-
align?: VerticalAlign;
|
|
16
|
-
/** Initial child elements */
|
|
17
|
-
children?: GameObjects.GameObject[];
|
|
18
|
-
/** Horizontal origin point of the row */
|
|
19
|
-
horizontalOrigin?: 'left' | 'center' | 'right';
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Row is a layout container that arranges children horizontally with a gap.
|
|
23
|
-
* The container position (x, y) represents the center of the whole row.
|
|
24
|
-
*/
|
|
25
|
-
export declare class Row extends GameObjects.Container {
|
|
26
|
-
/** Gap between elements in pixels */
|
|
27
|
-
private gap;
|
|
28
|
-
/** Vertical alignment of elements */
|
|
29
|
-
private align;
|
|
30
|
-
/** Horizontal origin point of the row */
|
|
31
|
-
private horizontalOrigin;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new Row container
|
|
34
|
-
* @param params Configuration parameters for the row
|
|
35
|
-
*/
|
|
36
|
-
constructor({ scene, x, y, gap, align, children, horizontalOrigin, }: RowParams);
|
|
37
|
-
/**
|
|
38
|
-
* Sets the gap between elements and updates layout
|
|
39
|
-
* @param gap Gap size in pixels
|
|
40
|
-
*/
|
|
41
|
-
setGap(gap: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* Sets the vertical alignment and updates layout
|
|
44
|
-
* @param align New vertical alignment
|
|
45
|
-
*/
|
|
46
|
-
setAlign(align: VerticalAlign): void;
|
|
47
|
-
/**
|
|
48
|
-
* Adds a single child to the row
|
|
49
|
-
* @param child GameObject to add
|
|
50
|
-
* @param relayout Whether to update layout after adding
|
|
51
|
-
* @returns This row instance for chaining
|
|
52
|
-
*/
|
|
53
|
-
addChild(child: GameObjects.GameObject, relayout?: boolean): this;
|
|
54
|
-
/**
|
|
55
|
-
* Adds multiple children to the row
|
|
56
|
-
* @param children Array of GameObjects to add
|
|
57
|
-
* @param relayout Whether to update layout after adding
|
|
58
|
-
* @returns This row instance for chaining
|
|
59
|
-
*/
|
|
60
|
-
addChildren(children: GameObjects.GameObject[], relayout?: boolean): this;
|
|
61
|
-
/**
|
|
62
|
-
* Recomputes children's positions and updates this container size
|
|
63
|
-
*/
|
|
64
|
-
layout(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Gets the display width of a game object
|
|
67
|
-
* @param child GameObject to measure
|
|
68
|
-
* @returns Display width in pixels
|
|
69
|
-
*/
|
|
70
|
-
getDisplayWidth(child: GameObjects.GameObject): number;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the display height of a game object
|
|
73
|
-
* @param child GameObject to measure
|
|
74
|
-
* @returns Display height in pixels
|
|
75
|
-
*/
|
|
76
|
-
getDisplayHeight(child: GameObjects.GameObject): number;
|
|
77
|
-
/**
|
|
78
|
-
* Gets the normalized origin point of a game object
|
|
79
|
-
* @param child GameObject to get origin from
|
|
80
|
-
* @returns Object with normalized x,y coordinates of the origin point
|
|
81
|
-
*/
|
|
82
|
-
getNormalizedOrigin(child: GameObjects.GameObject): {
|
|
83
|
-
x: number;
|
|
84
|
-
y: number;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=row.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../../src/components/row/row.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAS5C,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG;IACtB,oCAAoC;IACpC,KAAK,EAAE,KAAK,CAAC;IACb,8BAA8B;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,8BAA8B;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC;IACpC,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CAChD,CAAC;AAEF;;;GAGG;AACH,qBAAa,GAAI,SAAQ,WAAW,CAAC,SAAS;IAC5C,qCAAqC;IACrC,OAAO,CAAC,GAAG,CAAS;IACpB,qCAAqC;IACrC,OAAO,CAAC,KAAK,CAAgB;IAC7B,yCAAyC;IACzC,OAAO,CAAC,gBAAgB,CAA8B;IAEtD;;;OAGG;gBACS,EACV,KAAK,EACL,CAAC,EACD,CAAC,EACD,GAAiB,EACjB,KAAgB,EAChB,QAAa,EACb,gBAA2B,GAC5B,EAAE,SAAS;IAcZ;;;OAGG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKhC;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAK3C;;;;;OAKG;IACI,QAAQ,CACb,KAAK,EAAE,WAAW,CAAC,UAAU,EAC7B,QAAQ,GAAE,OAAc,GACvB,IAAI;IAQP;;;;;OAKG;IACI,WAAW,CAChB,QAAQ,EAAE,WAAW,CAAC,UAAU,EAAE,EAClC,QAAQ,GAAE,OAAc,GACvB,IAAI;IAMP;;OAEG;IACI,MAAM,IAAI,IAAI;IAyDrB;;;;OAIG;IACI,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,GAAG,MAAM;IAI7D;;;;OAIG;IACI,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,GAAG,MAAM;IAI9D;;;;OAIG;IACI,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,GAAG;QACzD,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX;CAGF"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-lines-per-function */
|
|
2
|
-
/* eslint-disable complexity */
|
|
3
|
-
import { GameObjects } from 'phaser';
|
|
4
|
-
import { DEFAULT_GAP, getDisplayHeightOf, getDisplayWidthOf, getNormalizedOriginOf, } from '../layout/layout-utils';
|
|
5
|
-
/**
|
|
6
|
-
* Row is a layout container that arranges children horizontally with a gap.
|
|
7
|
-
* The container position (x, y) represents the center of the whole row.
|
|
8
|
-
*/
|
|
9
|
-
export class Row extends GameObjects.Container {
|
|
10
|
-
/** Gap between elements in pixels */
|
|
11
|
-
gap;
|
|
12
|
-
/** Vertical alignment of elements */
|
|
13
|
-
align;
|
|
14
|
-
/** Horizontal origin point of the row */
|
|
15
|
-
horizontalOrigin;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new Row container
|
|
18
|
-
* @param params Configuration parameters for the row
|
|
19
|
-
*/
|
|
20
|
-
constructor({ scene, x, y, gap = DEFAULT_GAP, align = 'center', children = [], horizontalOrigin = 'center', }) {
|
|
21
|
-
super(scene, x, y);
|
|
22
|
-
this.gap = gap;
|
|
23
|
-
this.align = align;
|
|
24
|
-
this.horizontalOrigin = horizontalOrigin;
|
|
25
|
-
if (children.length > 0) {
|
|
26
|
-
this.add(children);
|
|
27
|
-
}
|
|
28
|
-
this.layout();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sets the gap between elements and updates layout
|
|
32
|
-
* @param gap Gap size in pixels
|
|
33
|
-
*/
|
|
34
|
-
setGap(gap) {
|
|
35
|
-
this.gap = gap;
|
|
36
|
-
this.layout();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Sets the vertical alignment and updates layout
|
|
40
|
-
* @param align New vertical alignment
|
|
41
|
-
*/
|
|
42
|
-
setAlign(align) {
|
|
43
|
-
this.align = align;
|
|
44
|
-
this.layout();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Adds a single child to the row
|
|
48
|
-
* @param child GameObject to add
|
|
49
|
-
* @param relayout Whether to update layout after adding
|
|
50
|
-
* @returns This row instance for chaining
|
|
51
|
-
*/
|
|
52
|
-
addChild(child, relayout = true) {
|
|
53
|
-
this.add(child);
|
|
54
|
-
if (relayout) {
|
|
55
|
-
this.layout();
|
|
56
|
-
}
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Adds multiple children to the row
|
|
61
|
-
* @param children Array of GameObjects to add
|
|
62
|
-
* @param relayout Whether to update layout after adding
|
|
63
|
-
* @returns This row instance for chaining
|
|
64
|
-
*/
|
|
65
|
-
addChildren(children, relayout = true) {
|
|
66
|
-
if (children.length > 0)
|
|
67
|
-
this.add(children);
|
|
68
|
-
if (relayout)
|
|
69
|
-
this.layout();
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Recomputes children's positions and updates this container size
|
|
74
|
-
*/
|
|
75
|
-
layout() {
|
|
76
|
-
const children = this.list;
|
|
77
|
-
if (children.length === 0) {
|
|
78
|
-
this.setSize(0, 0);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Measure sizes and origins
|
|
82
|
-
const entries = children.map(child => ({
|
|
83
|
-
child,
|
|
84
|
-
width: this.getDisplayWidth(child),
|
|
85
|
-
height: this.getDisplayHeight(child),
|
|
86
|
-
origin: this.getNormalizedOrigin(child),
|
|
87
|
-
}));
|
|
88
|
-
const maxHeight = entries.reduce((m, s) => Math.max(m, s.height), 0);
|
|
89
|
-
const totalWidth = entries.reduce((sum, s) => sum + s.width, 0) +
|
|
90
|
-
this.gap * (entries.length - 1);
|
|
91
|
-
// Determine left of content based on horizontalOrigin
|
|
92
|
-
const contentLeftX = this.horizontalOrigin === 'left'
|
|
93
|
-
? 0
|
|
94
|
-
: this.horizontalOrigin === 'center'
|
|
95
|
-
? -totalWidth / 2
|
|
96
|
-
: -totalWidth;
|
|
97
|
-
// Walk left to right, aligning considering each child's origin
|
|
98
|
-
let cursorLeftX = contentLeftX;
|
|
99
|
-
for (const { child, width, height, origin } of entries) {
|
|
100
|
-
// Vertical alignment: align top/bottom edges or centers correctly using origin
|
|
101
|
-
let y = 0;
|
|
102
|
-
if (this.align === 'top') {
|
|
103
|
-
// place child's top edge at content top
|
|
104
|
-
y = -maxHeight / 2 + origin.y * height;
|
|
105
|
-
}
|
|
106
|
-
else if (this.align === 'bottom') {
|
|
107
|
-
// place child's bottom edge at content bottom
|
|
108
|
-
y = maxHeight / 2 - (1 - origin.y) * height;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// center alignment
|
|
112
|
-
y = (origin.y - 0.5) * height;
|
|
113
|
-
}
|
|
114
|
-
// Horizontal position so that child's left is at cursorLeftX
|
|
115
|
-
const x = cursorLeftX + origin.x * width;
|
|
116
|
-
child.setPosition(x, y);
|
|
117
|
-
cursorLeftX += width + this.gap;
|
|
118
|
-
}
|
|
119
|
-
this.setSize(totalWidth, maxHeight);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Gets the display width of a game object
|
|
123
|
-
* @param child GameObject to measure
|
|
124
|
-
* @returns Display width in pixels
|
|
125
|
-
*/
|
|
126
|
-
getDisplayWidth(child) {
|
|
127
|
-
return getDisplayWidthOf(child);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Gets the display height of a game object
|
|
131
|
-
* @param child GameObject to measure
|
|
132
|
-
* @returns Display height in pixels
|
|
133
|
-
*/
|
|
134
|
-
getDisplayHeight(child) {
|
|
135
|
-
return getDisplayHeightOf(child);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Gets the normalized origin point of a game object
|
|
139
|
-
* @param child GameObject to get origin from
|
|
140
|
-
* @returns Object with normalized x,y coordinates of the origin point
|
|
141
|
-
*/
|
|
142
|
-
getNormalizedOrigin(child) {
|
|
143
|
-
return getNormalizedOriginOf(child);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=row.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sourceRoot":"","sources":["../../../src/components/row/row.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,+BAA+B;AAC/B,OAAO,EAAE,WAAW,EAAS,MAAM,QAAQ,CAAC;AAE5C,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAuBhC;;;GAGG;AACH,MAAM,OAAO,GAAI,SAAQ,WAAW,CAAC,SAAS;IAC5C,qCAAqC;IAC7B,GAAG,CAAS;IACpB,qCAAqC;IAC7B,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
|
|
|
1
|
-
{"version":3,"file":"row.spec.d.ts","sourceRoot":"","sources":["../../../src/components/row/row.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
/* eslint-disable max-lines-per-function */
|
|
3
|
-
import { Scene } from 'phaser';
|
|
4
|
-
import { beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
-
import { Row } from './row';
|
|
6
|
-
class TestChild {
|
|
7
|
-
displayWidth;
|
|
8
|
-
width;
|
|
9
|
-
displayHeight;
|
|
10
|
-
height;
|
|
11
|
-
originX;
|
|
12
|
-
originY;
|
|
13
|
-
displayOriginX;
|
|
14
|
-
displayOriginY;
|
|
15
|
-
lastPosition = null;
|
|
16
|
-
constructor(params = {}) {
|
|
17
|
-
Object.assign(this, params);
|
|
18
|
-
}
|
|
19
|
-
setPosition(x, y) {
|
|
20
|
-
this.lastPosition = { x, y };
|
|
21
|
-
}
|
|
22
|
-
getBounds() {
|
|
23
|
-
return {
|
|
24
|
-
width: this.width ?? this.displayWidth ?? 0,
|
|
25
|
-
height: this.height ?? this.displayHeight ?? 0,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
let scene;
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
scene = new Scene();
|
|
32
|
-
});
|
|
33
|
-
describe('Row layout', () => {
|
|
34
|
-
it('centers children by default with horizontalOrigin center', () => {
|
|
35
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
36
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
37
|
-
const row = new Row({ scene, x: 0, y: 0, gap: 10, align: 'center', horizontalOrigin: 'center', children: [] });
|
|
38
|
-
row.addChildren([a, b]);
|
|
39
|
-
// totalWidth = 100 + 200 + 10 = 310; contentLeft = -155
|
|
40
|
-
expect(a.lastPosition).toEqual({ x: -155 + 0.5 * 100, y: 0 }); // -105, 0
|
|
41
|
-
expect(b.lastPosition).toEqual({ x: -45 + 0.5 * 200, y: 0 }); // 55, 0
|
|
42
|
-
// width = totalWidth; height = max child height
|
|
43
|
-
expect(row.width).toBe(310);
|
|
44
|
-
expect(row.height).toBe(100);
|
|
45
|
-
});
|
|
46
|
-
it('align top positions children at content top edge', () => {
|
|
47
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
48
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
49
|
-
const row = new Row({ scene, x: 0, y: 0, gap: 10, align: 'top', horizontalOrigin: 'center', children: [a, b] });
|
|
50
|
-
// maxHeight = 100
|
|
51
|
-
expect(a.lastPosition?.y).toBe(-50 + 0.5 * 50); // -25
|
|
52
|
-
expect(b.lastPosition?.y).toBe(-50 + 0.5 * 100); // 0
|
|
53
|
-
expect(row.width).toBe(310);
|
|
54
|
-
expect(row.height).toBe(100);
|
|
55
|
-
});
|
|
56
|
-
it('align bottom positions children at content bottom edge', () => {
|
|
57
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
58
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
59
|
-
new Row({ scene, x: 0, y: 0, gap: 10, align: 'bottom', horizontalOrigin: 'center', children: [a, b] });
|
|
60
|
-
expect(a.lastPosition?.y).toBe(50 - (1 - 0.5) * 50); // 25
|
|
61
|
-
expect(b.lastPosition?.y).toBe(50 - (1 - 0.5) * 100); // 0
|
|
62
|
-
});
|
|
63
|
-
it('horizontalOrigin left places content starting at x=0', () => {
|
|
64
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
65
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
66
|
-
const row = new Row({ scene, x: 0, y: 0, gap: 10, align: 'center', horizontalOrigin: 'left', children: [a, b] });
|
|
67
|
-
expect(a.lastPosition?.x).toBe(0 + 0.5 * 100); // 50
|
|
68
|
-
expect(b.lastPosition?.x).toBe(110 + 0.5 * 200); // 210
|
|
69
|
-
expect(row.width).toBe(310);
|
|
70
|
-
expect(row.height).toBe(100);
|
|
71
|
-
});
|
|
72
|
-
it('respects per-child origin when computing alignment and positions', () => {
|
|
73
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50, originX: 0.0, originY: 0.0 });
|
|
74
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100, originX: 1.0, originY: 1.0 });
|
|
75
|
-
// totalWidth = 310; left = 0 (horizontalOrigin left); maxHeight = 100
|
|
76
|
-
new Row({ scene, x: 0, y: 0, gap: 10, align: 'top', horizontalOrigin: 'left', children: [a, b] });
|
|
77
|
-
// a: x = 0 + 0*100 = 0; y = -50 + 0*50 = -50
|
|
78
|
-
expect(a.lastPosition).toEqual({ x: 0, y: -50 });
|
|
79
|
-
// cursor = 0 + 100 + 10 = 110; b: x = 110 + 1*200 = 310; y = -50 + 1*100 = 50
|
|
80
|
-
expect(b.lastPosition).toEqual({ x: 310, y: 50 });
|
|
81
|
-
});
|
|
82
|
-
it('setGap and setAlign trigger relayout', () => {
|
|
83
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
84
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
85
|
-
const row = new Row({ scene, x: 0, y: 0, children: [a, b] }); // default gap=8, align=center, horizontalOrigin=center
|
|
86
|
-
// Initial container width with gap=8
|
|
87
|
-
const initialWidth = row.width;
|
|
88
|
-
row.setGap(20); // triggers layout
|
|
89
|
-
const afterWidth = row.width;
|
|
90
|
-
expect(afterWidth).toBe(initialWidth + (20 - 8));
|
|
91
|
-
row.setAlign('top');
|
|
92
|
-
// For align top, y positions as computed earlier with maxHeight=100
|
|
93
|
-
expect(a.lastPosition?.y).toBe(-50 + 0.5 * 50); // -25
|
|
94
|
-
expect(b.lastPosition?.y).toBe(-50 + 0.5 * 100); // 0
|
|
95
|
-
});
|
|
96
|
-
it('addChild/addChildren optionally avoid relayout when requested', () => {
|
|
97
|
-
const a = new TestChild({ displayWidth: 100, displayHeight: 50 });
|
|
98
|
-
const b = new TestChild({ displayWidth: 200, displayHeight: 100 });
|
|
99
|
-
const row = new Row({ scene, x: 0, y: 0, children: [a] });
|
|
100
|
-
// b added without relayout
|
|
101
|
-
row.addChild(b, false);
|
|
102
|
-
const before = b.lastPosition;
|
|
103
|
-
expect(before).toBeNull();
|
|
104
|
-
// layout computes positions
|
|
105
|
-
row.layout();
|
|
106
|
-
expect(b.lastPosition).not.toBeNull();
|
|
107
|
-
});
|
|
108
|
-
it('empty row has size 0,0', () => {
|
|
109
|
-
const row = new Row({ scene, x: 0, y: 0, children: [] });
|
|
110
|
-
expect(row.width).toBe(0);
|
|
111
|
-
expect(row.height).toBe(0);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
//# sourceMappingURL=row.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row.spec.js","sourceRoot":"","sources":["../../../src/components/row/row.spec.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,2CAA2C;AAC3C,OAAO,EAAe,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,SAAS;IACN,YAAY,CAAU;IACtB,KAAK,CAAU;IACf,aAAa,CAAU;IACvB,MAAM,CAAU;IAChB,OAAO,CAAU;IACjB,OAAO,CAAU;IACjB,cAAc,CAAU;IACxB,cAAc,CAAU;IAExB,YAAY,GAAoC,IAAI,CAAC;IAE5D,YAAY,SAYR,EAAE;QACJ,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/B,CAA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