@energy8platform/game-engine 0.15.0 → 0.15.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/dist/index.cjs.js +29 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +29 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/react-jsx.d.ts +68 -48
- package/dist/react.cjs.js +29 -19
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +600 -1
- package/dist/react.esm.js +29 -19
- package/dist/react.esm.js.map +1 -1
- package/dist/ui.cjs.js +29 -19
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +29 -19
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/react/index.ts +6 -0
- package/src/react/jsx-runtime.ts +102 -57
- package/src/ui/FlexContainer.ts +29 -19
package/dist/index.cjs.js
CHANGED
|
@@ -2945,24 +2945,29 @@ function measureChild(child, parentContentW = 0, parentContentH = 0) {
|
|
|
2945
2945
|
const cfg = child._flexConfig;
|
|
2946
2946
|
const resolvedLW = resolveDimension(cfg?.layoutWidth, parentContentW);
|
|
2947
2947
|
const resolvedLH = resolveDimension(cfg?.layoutHeight, parentContentH);
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
}
|
|
2951
|
-
// For FlexContainers, use their explicit or computed size
|
|
2948
|
+
// FlexContainer children are top-left origin by construction, so `ox/oy = 0`
|
|
2949
|
+
// is correct and we can skip the `getLocalBounds()` call entirely.
|
|
2952
2950
|
if (child instanceof FlexContainer) {
|
|
2953
2951
|
const fc = child;
|
|
2954
2952
|
const w = fc._explicitWidth > 0 ? fc._explicitWidth : (fc._computedWidth > 0 ? fc._computedWidth : undefined);
|
|
2955
2953
|
const h = fc._explicitHeight > 0 ? fc._explicitHeight : (fc._computedHeight > 0 ? fc._computedHeight : undefined);
|
|
2956
2954
|
if (w !== undefined && h !== undefined) {
|
|
2957
|
-
return { w, h, ox: 0, oy: 0 };
|
|
2955
|
+
return { w: resolvedLW ?? w, h: resolvedLH ?? h, ox: 0, oy: 0 };
|
|
2958
2956
|
}
|
|
2959
2957
|
}
|
|
2960
|
-
// Use localBounds to get the true visual
|
|
2961
|
-
//
|
|
2958
|
+
// Use localBounds to get the true visual origin offset.
|
|
2959
|
+
// We take `ox/oy` from bounds unconditionally — a user-supplied `layoutWidth/Height`
|
|
2960
|
+
// overrides the SIZE used by flex (protection against pre-paint bounds of 0), but
|
|
2961
|
+
// it must NOT erase the center-anchor compensation: Button/Label views are drawn at
|
|
2962
|
+
// `(-w/2..w/2)` and their bounds.x = -w/2 is what lets `layoutLine` place the
|
|
2963
|
+
// visible rectangle where the layout intends.
|
|
2962
2964
|
const bounds = child.getLocalBounds();
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2965
|
+
return {
|
|
2966
|
+
w: resolvedLW ?? bounds.width,
|
|
2967
|
+
h: resolvedLH ?? bounds.height,
|
|
2968
|
+
ox: bounds.x,
|
|
2969
|
+
oy: bounds.y,
|
|
2970
|
+
};
|
|
2966
2971
|
}
|
|
2967
2972
|
/**
|
|
2968
2973
|
* Set a child's main or cross dimension.
|
|
@@ -3451,30 +3456,35 @@ class FlexContainer extends pixi_js.Container {
|
|
|
3451
3456
|
this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
|
|
3452
3457
|
}
|
|
3453
3458
|
// Position flexExclude children (absolute positioning).
|
|
3454
|
-
// All position props describe the visual (bounds) rectangle
|
|
3455
|
-
//
|
|
3459
|
+
// All position props describe the visual (bounds) rectangle. We derive the
|
|
3460
|
+
// visual rectangle directly from `getLocalBounds()` rather than the
|
|
3461
|
+
// layout-config `w`/`h` returned by measureChild — those may differ from
|
|
3462
|
+
// actual bounds when the user pins `layoutWidth`/`layoutHeight` to a value
|
|
3463
|
+
// that doesn't match the child's real visual extent (e.g. a Button whose
|
|
3464
|
+
// text overflows its configured `width`). Mixing layout size with real
|
|
3465
|
+
// bounds-origin would shift the visual center off the requested point.
|
|
3456
3466
|
// `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
|
|
3457
3467
|
for (const child of this._layoutChildren) {
|
|
3458
3468
|
if (!child._flexConfig?.flexExclude)
|
|
3459
3469
|
continue;
|
|
3460
3470
|
const cfg = child._flexConfig;
|
|
3461
|
-
const
|
|
3471
|
+
const bounds = child.getLocalBounds();
|
|
3462
3472
|
const cw = this._computedWidth;
|
|
3463
3473
|
const ch = this._computedHeight;
|
|
3464
3474
|
const centerX = resolveDimension(cfg.centerX, pctRefW);
|
|
3465
3475
|
if (centerX !== undefined)
|
|
3466
|
-
child.x = centerX -
|
|
3476
|
+
child.x = centerX - bounds.x - bounds.width / 2;
|
|
3467
3477
|
else if (cfg.left !== undefined)
|
|
3468
|
-
child.x = cfg.left -
|
|
3478
|
+
child.x = cfg.left - bounds.x;
|
|
3469
3479
|
else if (cfg.right !== undefined)
|
|
3470
|
-
child.x = cw -
|
|
3480
|
+
child.x = cw - cfg.right - bounds.x - bounds.width;
|
|
3471
3481
|
const centerY = resolveDimension(cfg.centerY, pctRefH);
|
|
3472
3482
|
if (centerY !== undefined)
|
|
3473
|
-
child.y = centerY -
|
|
3483
|
+
child.y = centerY - bounds.y - bounds.height / 2;
|
|
3474
3484
|
else if (cfg.top !== undefined)
|
|
3475
|
-
child.y = cfg.top -
|
|
3485
|
+
child.y = cfg.top - bounds.y;
|
|
3476
3486
|
else if (cfg.bottom !== undefined)
|
|
3477
|
-
child.y = ch -
|
|
3487
|
+
child.y = ch - cfg.bottom - bounds.y - bounds.height;
|
|
3478
3488
|
}
|
|
3479
3489
|
}
|
|
3480
3490
|
/** Computed content size (after layout) */
|