@energy8platform/game-engine 0.15.1 → 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 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
- if (resolvedLW !== undefined && resolvedLH !== undefined) {
2949
- return { w: resolvedLW, h: resolvedLH, ox: 0, oy: 0 };
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 extent and origin offset.
2961
- // This handles children with non-zero anchors (e.g. Button, Label with centered text).
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
- const w = resolvedLW ?? bounds.width;
2964
- const h = resolvedLH ?? bounds.height;
2965
- return { w, h, ox: bounds.x, oy: bounds.y };
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.