flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Label now supports top and bottom padding, plus the width adjusts based on the text. Buttons have better sizing with respect to padding.
Date Mon, 09 Jun 2014 20:46:42 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop c4a6440b9 -> d2f9ce253


Label now supports top and bottom padding, plus the width adjusts based on the text. Buttons
have better sizing with respect to padding.


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

Branch: refs/heads/develop
Commit: d2f9ce2532d4d28352ec5688bdc0a1a2b294e0ce
Parents: c4a6440
Author: Peter Ent <pent@apache.org>
Authored: Mon Jun 9 16:46:25 2014 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Mon Jun 9 16:46:25 2014 -0400

----------------------------------------------------------------------
 frameworks/as/projects/FlexJSUI/defaults.css    |   2 -
 .../src/org/apache/flex/core/CSSTextField.as    |  13 +-
 .../src/org/apache/flex/core/UIButtonBase.as    | 146 +++++++++++++++++++
 .../FlexJSUI/src/org/apache/flex/html/Button.as |  51 ++++++-
 .../FlexJSUI/src/org/apache/flex/html/Label.as  |  25 ++++
 .../apache/flex/html/beads/CSSTextButtonView.as |  22 ++-
 .../org/apache/flex/html/beads/TextFieldView.as |   1 +
 7 files changed, 246 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/defaults.css b/frameworks/as/projects/FlexJSUI/defaults.css
index 64a8ade..fa54d19 100644
--- a/frameworks/as/projects/FlexJSUI/defaults.css
+++ b/frameworks/as/projects/FlexJSUI/defaults.css
@@ -213,8 +213,6 @@ Image
 
 Label
 {
-	width: 95;
-	height: 18;
     IBeadModel: ClassReference("org.apache.flex.html.beads.models.TextModel");
     IBeadView: ClassReference("org.apache.flex.html.beads.TextFieldView");
 	iMeasurementBead: ClassReference("org.apache.flex.html.beads.TextFieldLabelMeasurementBead");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/CSSTextField.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/CSSTextField.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/CSSTextField.as
index dd74387..bc8cecf 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/CSSTextField.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/CSSTextField.as
@@ -75,11 +75,14 @@ package org.apache.flex.core
 			tf.bold = ValuesManager.valuesImpl.getValue(sp, "fontWeight") == "bold";
 			tf.color = ValuesManager.valuesImpl.getValue(sp, "color");
 			var padding:Object = ValuesManager.valuesImpl.getValue(sp, "padding");
-			if (padding != null)
-			{
-				tf.leftMargin = padding;
-				tf.rightMargin = padding;
-			}
+			if (padding == null) padding = 0;
+			var paddingLeft:Object = ValuesManager.valuesImpl.getValue(sp,"padding-left");
+			if (paddingLeft == null) paddingLeft = padding;
+			var paddingRight:Object = ValuesManager.valuesImpl.getValue(sp,"padding-right");
+			if (paddingRight == null) paddingRight = padding;
+			tf.leftMargin = paddingLeft;
+			tf.rightMargin = paddingRight;
+
 			defaultTextFormat = tf;
 			super.text = value;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
index b02ffd9..ea446d4 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
@@ -178,6 +178,142 @@ package org.apache.flex.core
 			return super.y;
 		}
 		
+		private var _explicitWidth:Number;
+		
+		/**
+		 *  The explicitly set width (as opposed to measured width
+		 *  or percentage width).
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get explicitWidth():Number
+		{
+			return _explicitWidth;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set explicitWidth(value:Number):void
+		{
+			if (_explicitWidth == value)
+				return;
+			
+			// width can be pixel or percent not both
+			if (!isNaN(value))
+				_percentWidth = NaN;
+			
+			_explicitWidth = value;
+			
+			dispatchEvent(new Event("explicitWidthChanged"));
+		}
+		
+		private var _explicitHeight:Number;
+		
+		/**
+		 *  The explicitly set width (as opposed to measured width
+		 *  or percentage width).
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get explicitHeight():Number
+		{
+			return _explicitHeight;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set explicitHeight(value:Number):void
+		{
+			if (_explicitHeight == value)
+				return;
+			
+			// height can be pixel or percent not both
+			if (!isNaN(value))
+				_percentHeight = NaN;
+			
+			_explicitHeight = value;
+			
+			dispatchEvent(new Event("explicitHeightChanged"));
+		}
+		
+		private var _percentWidth:Number;
+		
+		/**
+		 *  The requested percentage width this component
+		 *  should have in the parent container.  Note that
+		 *  the actual percentage may be different if the 
+		 *  total is more than 100% or if there are other
+		 *  components with explicitly set widths.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get percentWidth():Number
+		{
+			return _percentWidth;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set percentWidth(value:Number):void
+		{
+			if (_percentWidth == value)
+				return;
+			
+			if (!isNaN(value))
+				_explicitWidth = NaN;
+			
+			_percentWidth = value;
+			
+			dispatchEvent(new Event("percentWidthChanged"));
+		}
+		
+		private var _percentHeight:Number;
+		
+		/**
+		 *  The requested percentage height this component
+		 *  should have in the parent container.  Note that
+		 *  the actual percentage may be different if the 
+		 *  total is more than 100% or if there are other
+		 *  components with explicitly set heights.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get percentHeight():Number
+		{
+			return _percentHeight;
+		}
+		
+		/**
+		 *  @private
+		 */
+		public function set percentHeight(value:Number):void
+		{
+			if (_percentHeight == value)
+				return;
+			
+			if (!isNaN(value))
+				_explicitHeight = NaN;
+			
+			_percentHeight = value;
+			
+			dispatchEvent(new Event("percentHeightChanged"));
+		}
+		
 		private var _width:Number;
         
         /**
@@ -205,6 +341,11 @@ package org.apache.flex.core
          */
 		override public function set width(value:Number):void
 		{
+			if (explicitWidth != value)
+			{
+				explicitWidth = value;
+			}
+			
 			if (_width != value)
 			{
 				_width = value;
@@ -252,6 +393,11 @@ package org.apache.flex.core
          */
 		override public function set height(value:Number):void
 		{
+			if (explicitHeight != value)
+			{
+				explicitHeight = value;
+			}
+			
 			if (_height != value)
 			{
 				_height = value;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Button.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Button.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Button.as
index 4ef4bc8..b9e0ede 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Button.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Button.as
@@ -20,7 +20,8 @@ package org.apache.flex.html
 {
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
-    import org.apache.flex.core.UIButtonBase;
+	import org.apache.flex.core.UIButtonBase;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.IEventDispatcher;
 	
     //--------------------------------------
@@ -69,6 +70,52 @@ package org.apache.flex.html
 		public function Button()
 		{
 			super();
-		}		
+		}	
+		
+		/**
+		 * @private
+		 */
+		override public function get width():Number
+		{
+			var useWidth:Number;
+			if (isNaN(this.explicitWidth)) {
+				var padding:Object = ValuesManager.valuesImpl.getValue(this,"padding");
+				if (padding == null) padding = 0;
+				var borderThickness:Object = ValuesManager.valuesImpl.getValue(this,"border-thickness");
+				if (borderThickness == null) borderThickness = 0;
+				var paddingLeft:Object = ValuesManager.valuesImpl.getValue(this,"padding-left");
+				if (paddingLeft == null) paddingLeft = padding;
+				var paddingRight:Object = ValuesManager.valuesImpl.getValue(this,"padding-right");
+				if (paddingRight == null) paddingRight = padding;
+				useWidth = super.width + paddingLeft + paddingRight + 2*Number(borderThickness);
+			}
+			else {
+				useWidth = this.explicitWidth;
+			}
+			return useWidth;
+		}
+		
+		/**
+		 * @private
+		 */
+		override public function get height():Number
+		{
+			var useHeight:Number;
+			if (isNaN(this.explicitHeight)) {
+				var padding:Object = ValuesManager.valuesImpl.getValue(this,"padding");
+				if (padding == null) padding = 0;
+				var borderThickness:Object = ValuesManager.valuesImpl.getValue(this,"border-thickness");
+				if (borderThickness == null) borderThickness = 0;
+				var paddingTop:Object = ValuesManager.valuesImpl.getValue(this,"padding-top");
+				if (paddingTop == null) paddingTop = padding;
+				var paddingBottom:Object = ValuesManager.valuesImpl.getValue(this,"padding-bottom");
+				if (paddingBottom == null) paddingBottom = padding;
+				useHeight = super.height + paddingTop + paddingBottom + 2*Number(borderThickness);
+			}
+			else {
+				useHeight = this.explicitHeight;
+			}
+			return useHeight;
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Label.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Label.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Label.as
index a18b1d1..9ed74a2 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Label.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/Label.as
@@ -20,6 +20,7 @@ package org.apache.flex.html
 {
 	import org.apache.flex.core.ITextModel;
 	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	
@@ -114,5 +115,29 @@ package org.apache.flex.html
 			super.height = value;
 			IEventDispatcher(model).dispatchEvent( new Event("heightChanged") );
 		}
+		
+		/**
+		 *  @private
+		 *  Override height to provide top and bottom padding.
+		 */
+		override public function get height():Number
+		{
+			var useHeight:Number;
+			if (isNaN(this.explicitHeight)) {
+				var padding:Object = ValuesManager.valuesImpl.getValue(this,"padding");
+				if (padding == null) padding = 0;
+				var borderThickness:Object = ValuesManager.valuesImpl.getValue(this,"border-thickness");
+				if (borderThickness == null) borderThickness = 0;
+				var paddingTop:Object = ValuesManager.valuesImpl.getValue(this,"padding-top");
+				if (paddingTop == null) paddingTop = padding;
+				var paddingBottom:Object = ValuesManager.valuesImpl.getValue(this,"padding-bottom");
+				if (paddingBottom == null) paddingBottom = padding;
+				useHeight = super.height + paddingTop + paddingBottom + 2*Number(borderThickness);
+			}
+			else {
+				useHeight = this.explicitHeight;
+			}
+			return useHeight;
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
index 2d6bd10..45d0fa4 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/CSSTextButtonView.as
@@ -129,6 +129,9 @@ package org.apache.flex.html.beads
 			var sw:uint = DisplayObject(_strand).width;
 			var sh:uint = DisplayObject(_strand).height;
 			
+			textField.defaultTextFormat.leftMargin = 0;
+			textField.defaultTextFormat.rightMargin = 0;
+			
 			var borderColor:uint;
 			var borderThickness:uint;
 			var borderStyle:String;
@@ -256,12 +259,21 @@ package org.apache.flex.html.beads
 		{
 			var useWidth:uint = Math.max(DisplayObject(_strand).width, upTextField.textWidth);
 			var useHeight:uint = Math.max(DisplayObject(_strand).height, upTextField.textHeight);
+			var borderThickness:Object = ValuesManager.valuesImpl.getValue(_strand, "border-thickness");
+			if (borderThickness == null) borderThickness = 0;
 			var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding");
-			
-			if ((useWidth-2*Number(padding)) < upTextField.textWidth) 
-				useWidth = upTextField.textWidth+2*Number(padding);
-			if ((useHeight-2*Number(padding)) < upTextField.textHeight) 
-				useHeight = upTextField.textHeight+2*Number(padding);
+			if (padding == null) padding = 0;
+			var paddingLeft:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-left");
+			if (paddingLeft == null) paddingLeft = padding;
+			var paddingRight:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-right");
+			if (paddingRight == null) paddingRight = padding;
+			var paddingTop:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-top");
+			if (paddingTop == null) paddingTop = padding;
+			var paddingBottom:Object = ValuesManager.valuesImpl.getValue(_strand,"padding-bottom");
+			if (paddingBottom == null) paddingBottom = padding;
+
+			useWidth = paddingLeft + paddingRight + 2*Number(borderThickness) + upTextField.textWidth;
+			useHeight = paddingTop + paddingBottom + 2*Number(borderThickness) + upTextField.textHeight;
 			
 			shape.graphics.clear();
 			shape.graphics.beginFill(0xCCCCCC);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2f9ce25/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldView.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldView.as
index 2157490..61b6edb 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldView.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldView.as
@@ -48,6 +48,7 @@ package org.apache.flex.html.beads
 			textField.selectable = false;
 			textField.type = TextFieldType.DYNAMIC;
 			textField.mouseEnabled = false;
+			textField.autoSize = "left";
 		}
 	}
 }


Mime
View raw message