This is an automated email from the ASF dual-hosted git repository.
pushminakazi pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new f88ec51 Added validateSize() in UIComponent.as
f88ec51 is described below
commit f88ec51e5223860af2028fd323af37315f037e56
Author: pashminakazi <[email protected]>
AuthorDate: Wed Jun 23 06:16:55 2021 -0700
Added validateSize() in UIComponent.as
---
.../src/main/royale/mx/core/UIComponent.as | 232 ++++++++++++++++++++-
1 file changed, 231 insertions(+), 1 deletion(-)
diff --git
a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 653e4ed..2afadf7 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -4514,9 +4514,239 @@ COMPILE::JS
* @playerversion AIR 1.1
* @productversion Flex 3
*/
+ mx_internal var invalidateSizeFlag:Boolean = false;
public function validateSize(recursive:Boolean = false):void
{
- trace("validateSize not implemented");
+ //trace("validateSize not implemented");
+ if (recursive)
+ {
+ for (var i:int = 0; i < numChildren; i++)
+ {
+ //var child:DisplayObject = getChildAt(i);
+ var child:IUIComponent = getChildAt(i);
+ if (child is ILayoutManagerClient )
+ (child as ILayoutManagerClient ).validateSize(true);
+ }
+ }
+
+ if (invalidateSizeFlag)
+ {
+ var sizeChanging:Boolean = measureSizes();
+
+ if (sizeChanging && includeInLayout)
+ {
+ // TODO (egeorgie): we don't need this invalidateDisplayList()
here
+ // because we'll call it if the parent sets new actual size?
+ invalidateDisplayList();
+ invalidateParentSizeAndDisplayList();
+ }
+ }
+ }
+
+ protected function canSkipMeasurement():Boolean
+ {
+ // We can skip the measure function if the object's width and height
+ // have been explicitly specified (e.g.: the object's MXML tag has
+ // attributes like width="50" and height="100").
+ //
+ // If an object's width and height have been explicitly specified,
+ // then the explicitWidth and explicitHeight properties contain
+ // Numbers (as opposed to NaN)
+ return !isNaN(explicitWidth) && !isNaN(explicitHeight);
+ }
+
+ /**
+ * @private
+ * Holds the last recorded value of the scaleX property.
+ */
+ private var oldScaleX:Number = 1.0;
+
+ /**
+ * @private
+ * Holds the last recorded value of the scaleY property.
+ */
+ private var oldScaleY:Number = 1.0;
+
+ mx_internal function adjustSizesForScaleChanges():void
+ {
+ var xScale:Number = scaleX;
+ var yScale:Number = scaleY;
+
+ var scalingFactor:Number;
+
+ if (xScale != oldScaleX)
+ {
+ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+ {
+ scalingFactor = Math.abs(xScale / oldScaleX);
+
+ if (explicitMinWidth)
+ explicitMinWidth *= scalingFactor;
+
+ if (!isNaN(explicitWidth))
+ explicitWidth *= scalingFactor;
+
+ if (explicitMaxWidth)
+ explicitMaxWidth *= scalingFactor;
+ }
+
+ oldScaleX = xScale;
+ }
+
+ if (yScale != oldScaleY)
+ {
+ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+ {
+ scalingFactor = Math.abs(yScale / oldScaleY);
+
+ if (explicitMinHeight)
+ explicitMinHeight *= scalingFactor;
+
+ if (explicitHeight)
+ explicitHeight *= scalingFactor;
+
+ if (explicitMaxHeight)
+ explicitMaxHeight *= scalingFactor;
+ }
+
+ oldScaleY = yScale;
+ }
+ }
+
+ mx_internal function measureSizes():Boolean
+ {
+ var changed:Boolean = false;
+
+ if (!invalidateSizeFlag)
+ return changed;
+
+ var scalingFactor:Number;
+ var newValue:Number;
+
+ if (canSkipMeasurement())
+ {
+ invalidateSizeFlag = false;
+ _measuredMinWidth = 0;
+ _measuredMinHeight = 0;
+ }
+ else
+ {
+ var xScale:Number = Math.abs(scaleX);
+ var yScale:Number = Math.abs(scaleY);
+
+ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+ {
+ if (xScale != 1.0)
+ {
+ _measuredMinWidth /= xScale;
+ _measuredWidth /= xScale;
+ }
+
+ if (yScale != 1.0)
+ {
+ _measuredMinHeight /= yScale;
+ _measuredHeight /= yScale;
+ }
+ }
+
+ measure();
+
+ invalidateSizeFlag = false;
+
+ if (!isNaN(explicitMinWidth) && measuredWidth < explicitMinWidth)
+ measuredWidth = explicitMinWidth;
+
+ if (!isNaN(explicitMaxWidth) && measuredWidth > explicitMaxWidth)
+ measuredWidth = explicitMaxWidth;
+
+ if (!isNaN(explicitMinHeight) && measuredHeight <
explicitMinHeight)
+ measuredHeight = explicitMinHeight;
+
+ if (!isNaN(explicitMaxHeight) && measuredHeight >
explicitMaxHeight)
+ measuredHeight = explicitMaxHeight;
+
+ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+ {
+ if (xScale != 1.0)
+ {
+ _measuredMinWidth *= xScale;
+ _measuredWidth *= xScale;
+ }
+
+ if (yScale != 1.0)
+ {
+ _measuredMinHeight *= yScale;
+ _measuredHeight *= yScale;
+ }
+ }
+ }
+
+ adjustSizesForScaleChanges();
+
+ if (isNaN(oldMinWidth))
+ {
+ // This branch does the same thing as the else branch,
+ // but it is optimized for the first time that
+ // measureSizes() is called on this object.
+ oldMinWidth = !isNaN(explicitMinWidth) ?
+ explicitMinWidth :
+ measuredMinWidth;
+
+ oldMinHeight = !isNaN(explicitMinHeight) ?
+ explicitMinHeight :
+ measuredMinHeight;
+
+ oldExplicitWidth = !isNaN(explicitWidth) ?
+ explicitWidth :
+ measuredWidth;
+
+ oldExplicitHeight = !isNaN(explicitHeight) ?
+ explicitHeight :
+ measuredHeight;
+
+ changed = true;
+ }
+ else
+ {
+ newValue = !isNaN(explicitMinWidth) ?
+ explicitMinWidth :
+ measuredMinWidth;
+ if (newValue != oldMinWidth)
+ {
+ oldMinWidth = newValue;
+ changed = true;
+ }
+
+ newValue = !isNaN(explicitMinHeight) ?
+ explicitMinHeight :
+ measuredMinHeight;
+ if (newValue != oldMinHeight)
+ {
+ oldMinHeight = newValue;
+ changed = true;
+ }
+
+ newValue = !isNaN(explicitWidth) ?
+ explicitWidth :
+ measuredWidth;
+ if (newValue != oldExplicitWidth)
+ {
+ oldExplicitWidth = newValue;
+ changed = true;
+ }
+
+ newValue = !isNaN(explicitHeight) ?
+ explicitHeight :
+ measuredHeight;
+ if (newValue != oldExplicitHeight)
+ {
+ oldExplicitHeight = newValue;
+ changed = true;
+ }
+
+ }
+
+ return changed;
}
/**