MCPcopy Create free account
hub / github.com/esengine/esengine / setSize

Method setSize

packages/fairygui/src/core/GObject.ts:251–291  ·  view source on GitHub ↗

* Set size * 设置尺寸

(wv: number, hv: number, bIgnorePivot: boolean = false)

Source from the content-addressed store, hash-verified

249 * 设置尺寸
250 */
251 public setSize(wv: number, hv: number, bIgnorePivot: boolean = false): void {
252 if (this._rawWidth !== wv || this._rawHeight !== hv) {
253 this._rawWidth = wv;
254 this._rawHeight = hv;
255
256 if (wv < this.minWidth) wv = this.minWidth;
257 if (hv < this.minHeight) hv = this.minHeight;
258 if (this.maxWidth > 0 && wv > this.maxWidth) wv = this.maxWidth;
259 if (this.maxHeight > 0 && hv > this.maxHeight) hv = this.maxHeight;
260
261 const dWidth = wv - this._width;
262 const dHeight = hv - this._height;
263 this._width = wv;
264 this._height = hv;
265
266 this.handleSizeChanged();
267
268 if (this._pivotX !== 0 || this._pivotY !== 0) {
269 if (!this._pivotAsAnchor) {
270 if (!bIgnorePivot) {
271 this.setXY(this.x - this._pivotX * dWidth, this.y - this._pivotY * dHeight);
272 }
273 this.updatePivotOffset();
274 } else {
275 this.applyPivot();
276 }
277 }
278
279 this.updateGear(2);
280
281 if (this._parent) {
282 this._relations?.onOwnerSizeChanged(dWidth, dHeight, this._pivotAsAnchor || !bIgnorePivot);
283 this._parent.setBoundsChangedFlag();
284 if (this._group) {
285 this._group.setBoundsChangedFlag();
286 }
287 }
288
289 this.emit(FGUIEvents.SIZE_CHANGED);
290 }
291 }
292
293 /**
294 * Ensure size is calculated correctly

Callers 15

widthMethod · 0.95
heightMethod · 0.95
makeFullScreenMethod · 0.95
setup_beforeAddMethod · 0.95
handleSizeChangedMethod · 0.45
constructorMethod · 0.45
onStageResizeMethod · 0.45
applyValueMethod · 0.45
resizeChildrenMethod · 0.45
constructorMethod · 0.45
applyMethod · 0.45

Calls 8

handleSizeChangedMethod · 0.95
setXYMethod · 0.95
updatePivotOffsetMethod · 0.95
applyPivotMethod · 0.95
updateGearMethod · 0.95
onOwnerSizeChangedMethod · 0.45
setBoundsChangedFlagMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected