You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/12/28 18:40:09 UTC

[royale-asjs] branch develop updated: styleduibase: override UIBase sizing properties to support NaN in JS platforms to reset style properties to browser defaults

This is an automated email from the ASF dual-hosted git repository.

carlosrovira 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 3d2f7ed  styleduibase: override UIBase sizing properties to support NaN in JS platforms to reset style properties to browser defaults
3d2f7ed is described below

commit 3d2f7eda9395bf15bca068798e605dad4cbd760e
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sat Dec 28 19:40:02 2019 +0100

    styleduibase: override UIBase sizing properties to support NaN in JS platforms to reset style properties to browser defaults
---
 .../royale/org/apache/royale/core/StyledUIBase.as  | 134 ++++++++++++++++++++-
 1 file changed, 132 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
index e9d98cc..02ca2ef 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
@@ -29,12 +29,16 @@ package org.apache.royale.core
 
     /**
      *  The StyledUIBase is the base class for UIBase components that makes
-     *  heavy use of styles
+     *  heavy use of styles through IClassSelectorListSupport, and supports emphasis property
+     *  through IEmphasis.
+     *  
+     *  For Javascript platform it allows to default size properties (like width and height)
+     *  to broswer defaults by removing the property. This is done through NaN value (that is the default)
      *  
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.0
+     *  @productversion Royale 0.9.3
      */
     public class StyledUIBase extends UIBase implements IClassSelectorListSupport, IEmphasis
     {
@@ -182,5 +186,131 @@ package org.apache.royale.core
 			addElementToWrapper(this,'div');
             return element;
         }
+
+        /**
+         *  @private
+         */
+		override public function set percentWidth(value:Number):void
+		{
+			COMPILE::SWF {
+				if (_percentWidth == value)
+					return;
+				
+				if (!isNaN(value))
+					_explicitWidth = NaN;
+				
+				_percentWidth = value;
+			}
+			COMPILE::JS {
+				this._percentWidth = value;
+				this.positioner.style.width = isNaN(value) ? null : value.toString() + '%';
+				if (!isNaN(value))
+					this._explicitWidth = NaN;
+			}
+			
+			dispatchEvent(new Event("percentWidthChanged"));
+		}
+
+        /**
+         *  @private
+         */
+		override public function set percentHeight(value:Number):void
+		{
+			COMPILE::SWF {
+				if (_percentHeight == value)
+					return;
+				
+				if (!isNaN(value))
+					_explicitHeight = NaN;
+				
+				_percentHeight = value;
+			}
+				
+			COMPILE::JS {
+				this._percentHeight = value;
+				this.positioner.style.height = isNaN(value) ? null : value.toString() + '%';
+				if (!isNaN(value))
+					this._explicitHeight = NaN;
+			}
+			
+			dispatchEvent(new Event("percentHeightChanged"));
+		}
+
+        /**
+         *  @copy org.apache.royale.core.ILayoutChild#setHeight
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.7
+         */
+        override public function setHeight(value:Number, noEvent:Boolean = false):void
+        {
+            if (_height !== value)
+            {
+                _height = value;
+                COMPILE::JS
+                {
+                    this.positioner.style.height = isNaN(value) ? null : value.toString() + 'px';        
+                }
+                if (!noEvent)
+                    dispatchEvent(new Event("heightChanged"));
+            }            
+        }
+
+        /**
+         *  @copy org.apache.royale.core.ILayoutChild#setWidth
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.7
+         */
+        override public function setWidth(value:Number, noEvent:Boolean = false):void
+        {
+            if (_width !== value)
+            {
+                _width = value;
+                COMPILE::JS
+                {
+                    this.positioner.style.width = isNaN(value) ? null : value.toString() + 'px';        
+                }
+                if (!noEvent)
+                    dispatchEvent(new Event("widthChanged"));
+            }
+        }
+
+        /**
+         *  @copy org.apache.royale.core.ILayoutChild#setWidthAndHeight
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.7
+         */
+        override public function setWidthAndHeight(newWidth:Number, newHeight:Number, noEvent:Boolean = false):void
+        {
+            if (_width !== newWidth)
+            {
+                _width = newWidth;
+                COMPILE::JS
+                {
+                    this.positioner.style.width = isNaN(newWidth) ? null : newWidth.toString() + 'px';        
+                }
+                if (!noEvent) 
+                    dispatchEvent(new Event("widthChanged"));
+            }
+            if (_height !== newHeight)
+            {
+                _height = newHeight;
+                COMPILE::JS
+                {
+                    this.positioner.style.height = isNaN(newHeight) ? null : newHeight.toString() + 'px';        
+                }
+                if (!noEvent)
+                    dispatchEvent(new Event("heightChanged"));
+            }            
+            dispatchEvent(new Event("sizeChanged"));
+        }
     }
 }
\ No newline at end of file