You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2015/01/15 12:44:58 UTC

[08/19] git commit: [flex-sdk] [refs/heads/develop] - fix the visuals of BusyIndicator to it matches old visuals

fix the visuals of BusyIndicator to it matches old visuals


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/73c27465
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/73c27465
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/73c27465

Branch: refs/heads/develop
Commit: 73c274653807e09a80ab9dc46601cd1258fcaad7
Parents: 59f6130
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jan 13 16:44:28 2015 -0800
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Jan 15 12:44:15 2015 +0100

----------------------------------------------------------------------
 .../src/spark/skins/mobile/BusyIndicatorSkin.as |  91 ++++++++--------
 .../src/spark/skins/spark/BusyIndicatorSkin.as  | 109 +++++++++++++++++--
 2 files changed, 143 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/73c27465/frameworks/projects/mobiletheme/src/spark/skins/mobile/BusyIndicatorSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/BusyIndicatorSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/BusyIndicatorSkin.as
index 130ac97..d56f6bd 100644
--- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/BusyIndicatorSkin.as
+++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/BusyIndicatorSkin.as
@@ -60,47 +60,6 @@ package spark.skins.mobile
 		{
 			super();
 			alpha = 0.60;       // default alpha
-			
-			// Set the default measured size depending on the
-			// applicationDPI
-			if (applicationDPI == DPIClassification.DPI_640)
-			{
-				measuredWidth = 104;
-				measuredHeight = 104;
-			}
-			else if (applicationDPI == DPIClassification.DPI_480)
-			{
-				measuredWidth = 80;
-				measuredHeight = 80;
-			}
-			else if (applicationDPI == DPIClassification.DPI_320)
-			{
-				measuredWidth = 52;
-				measuredHeight = 52;
-			}
-			else if (applicationDPI == DPIClassification.DPI_240)
-			{
-				measuredWidth = 40;
-				measuredHeight = 40;
-			}
-			else if (applicationDPI == DPIClassification.DPI_160)
-			{
-				measuredWidth = 26;
-				measuredHeight = 26;
-			}
-			else if (applicationDPI == DPIClassification.DPI_120)
-			{
-				measuredWidth = 20;
-				measuredHeight = 20;
-			}
-			else
-			{
-				measuredWidth = DEFAULT_MINIMUM_SIZE;
-				measuredHeight = DEFAULT_MINIMUM_SIZE;
-			}
-			
-			measuredMinWidth = DEFAULT_MINIMUM_SIZE;
-			measuredMinHeight = DEFAULT_MINIMUM_SIZE;
 		}
 		
 		private var _hostComponent:spark.components.BusyIndicator;
@@ -155,13 +114,13 @@ package spark.skins.mobile
 		{
 			super.styleChanged(styleProp);
 			
-			var allStyles:Boolean = !styleName || styleName == "styleName";
+			var allStyles:Boolean = !styleProp || styleProp == "styleName";
 			
 			// Check for skin/icon changes here.
 			// We could only throw out any skins that change,
 			// but since dynamic re-skinning is uncommon, we'll take
 			// the simpler approach of throwing out all skins.
-			if (allStyles || styleName == "rotationInterval")
+			if (allStyles || styleProp == "rotationInterval")
 			{
 				// Update the timer if the rotation interval has changed.
 				if (isRotating())
@@ -171,7 +130,7 @@ package spark.skins.mobile
 				}
 			}
 			
-			if (allStyles || styleName == "symbolColor")
+			if (allStyles || styleProp == "symbolColor")
 			{
 				updateSpinner(spinnerDiameter);
 			}
@@ -179,8 +138,46 @@ package spark.skins.mobile
 		
 		override protected function measure():void
 		{
-			measuredHeight = hostComponent.height;
-			measuredWidth = hostComponent.width;
+            // Set the default measured size depending on the
+            // applicationDPI
+            if (applicationDPI == DPIClassification.DPI_640)
+            {
+                measuredWidth = 104;
+                measuredHeight = 104;
+            }
+            else if (applicationDPI == DPIClassification.DPI_480)
+            {
+                measuredWidth = 80;
+                measuredHeight = 80;
+            }
+            else if (applicationDPI == DPIClassification.DPI_320)
+            {
+                measuredWidth = 52;
+                measuredHeight = 52;
+            }
+            else if (applicationDPI == DPIClassification.DPI_240)
+            {
+                measuredWidth = 40;
+                measuredHeight = 40;
+            }
+            else if (applicationDPI == DPIClassification.DPI_160)
+            {
+                measuredWidth = 26;
+                measuredHeight = 26;
+            }
+            else if (applicationDPI == DPIClassification.DPI_120)
+            {
+                measuredWidth = 20;
+                measuredHeight = 20;
+            }
+            else
+            {
+                measuredWidth = DEFAULT_MINIMUM_SIZE;
+                measuredHeight = DEFAULT_MINIMUM_SIZE;
+            }
+            
+            measuredMinWidth = DEFAULT_MINIMUM_SIZE;
+            measuredMinHeight = DEFAULT_MINIMUM_SIZE;
 		}
 		
 		override protected function commitCurrentState():void
@@ -204,7 +201,7 @@ package spark.skins.mobile
 		override protected function updateDisplayList(unscaledWidth:Number,
 													  unscaledHeight:Number):void
 		{
-			super.updateDisplayList(unscaledWidth, unscaledHeight);
+			//super.updateDisplayList(unscaledWidth, unscaledHeight);
 			
 			// If the size changed, then create a new spinner.
 			if (oldUnscaledWidth != unscaledWidth ||

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/73c27465/frameworks/projects/spark/src/spark/skins/spark/BusyIndicatorSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/skins/spark/BusyIndicatorSkin.as b/frameworks/projects/spark/src/spark/skins/spark/BusyIndicatorSkin.as
index 41e7b87..eafe2bc 100644
--- a/frameworks/projects/spark/src/spark/skins/spark/BusyIndicatorSkin.as
+++ b/frameworks/projects/spark/src/spark/skins/spark/BusyIndicatorSkin.as
@@ -33,6 +33,11 @@ package spark.skins.spark
 	public class BusyIndicatorSkin extends ActionScriptSkinBase
 	{
 		static private const DEFAULT_ROTATION_INTERVAL:Number = 30;
+        /**
+         *  @private
+         */ 
+        static private const DEFAULT_MINIMUM_SIZE:Number = 20;
+        
 		private var busyIndicatorClass:Class;
 		private var busyIndicator:DisplayObject;
 		private var busyIndicatorBackground:DisplayObject;
@@ -40,6 +45,16 @@ package spark.skins.spark
 		private var rotationTimer:Timer;
 		private var rotationInterval:Number;
 		private var rotationSpeed:Number;
+        /**
+         *  @private
+         */   
+        private var oldUnscaledHeight:Number;
+        
+        /**
+         *  @private
+         */   
+        private var oldUnscaledWidth:Number;
+        
 		/**
 		 *  @private
 		 * 
@@ -112,23 +127,63 @@ package spark.skins.spark
 		{
 			//This layer stays still in the background
 			busyIndicatorBackground = new busyIndicatorClass();
-			busyIndicatorBackground.width = busyIndicatorBackground.height = busyIndicatorDiameter;
+			//busyIndicatorBackground.width = busyIndicatorBackground.height = busyIndicatorDiameter;
 			addChild(busyIndicatorBackground);
 			//This layer rotates in the foreground to give the required effect
 			busyIndicator = new busyIndicatorClass();
 			busyIndicator.alpha = 0.3;
-			busyIndicator.width = busyIndicator.height = busyIndicatorDiameter;
+			//busyIndicator.width = busyIndicator.height = busyIndicatorDiameter;
 			addChild(busyIndicator);
 		}
 		
-		override protected function measure():void
-		{
-			measuredWidth = busyIndicatorDiameter;
-			measuredHeight = busyIndicatorDiameter;
-			
-			measuredMinHeight = busyIndicatorDiameter;
-			measuredMinWidth = busyIndicatorDiameter
-		}
+        /**
+         *  @private
+         */
+        override protected function measure():void
+        {
+            super.measure();
+            
+            // Set the default measured size depending on the
+            // applicationDPI
+            if (applicationDPI == DPIClassification.DPI_640)
+            {
+                measuredWidth = 104;
+                measuredHeight = 104;
+            }
+            else if (applicationDPI == DPIClassification.DPI_480)
+            {
+                measuredWidth = 80;
+                measuredHeight = 80;
+            }
+            else if (applicationDPI == DPIClassification.DPI_320)
+            {
+                measuredWidth = 52;
+                measuredHeight = 52;
+            }
+            else if (applicationDPI == DPIClassification.DPI_240)
+            {
+                measuredWidth = 40;
+                measuredHeight = 40;
+            }
+            else if (applicationDPI == DPIClassification.DPI_160)
+            {
+                measuredWidth = 26;
+                measuredHeight = 26;
+            }
+            else if (applicationDPI == DPIClassification.DPI_120)
+            {
+                measuredWidth = 20;
+                measuredHeight = 20;
+            }
+            else
+            {
+                measuredWidth = DEFAULT_MINIMUM_SIZE;
+                measuredHeight = DEFAULT_MINIMUM_SIZE;
+            }
+            
+            measuredMinWidth = DEFAULT_MINIMUM_SIZE;
+            measuredMinHeight = DEFAULT_MINIMUM_SIZE;
+        }
 		
 		override protected function commitCurrentState():void
 		{
@@ -164,8 +219,42 @@ package spark.skins.spark
 				colorizeSymbol();	
 				symbolColorChanged = false;
 			}
+            // If the size changed, then create a new spinner.
+            if (oldUnscaledWidth != unscaledWidth ||
+                oldUnscaledHeight != unscaledHeight)
+            {
+                var newDiameter:Number;
+                
+                newDiameter = calculateSpinnerDiameter(unscaledWidth, unscaledHeight);
+                busyIndicatorBackground.width = busyIndicatorBackground.height = newDiameter;
+                busyIndicator.width = busyIndicator.height = newDiameter;
+                
+                oldUnscaledWidth = unscaledWidth;
+                oldUnscaledHeight = unscaledHeight;
+            }
 		}
 		
+        /**
+         *   @private
+         *
+         *   Apply the rules to calculate the spinner diameter from the width
+         *   and height.
+         *  
+         *   @param width new width of this component
+         *   @param height new height of this component
+         *    
+         *   @return true if the spinner's diameter changes, false otherwise.
+         */
+        private function calculateSpinnerDiameter(width:Number, height:Number):Number
+        {
+            var diameter:Number = Math.min(width, height);
+            diameter = Math.max(DEFAULT_MINIMUM_SIZE, diameter);
+            if (diameter % 2 != 0)
+                diameter--;
+            
+            return diameter;
+        }
+        
 		private function colorizeSymbol():void
 		{
 			super.applyColorTransform(this.busyIndicator, 0x000000, symbolColor);