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] - Added first measurement bead (for measuring width of text fields) in order to have the Alert size it correctly.
Date Wed, 05 Jun 2013 13:35:01 GMT
Updated Branches:
  refs/heads/develop 6f3bfc1fb -> 03b797f6e


Added first measurement bead (for measuring width of text fields) in order to have the Alert
size it correctly.


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

Branch: refs/heads/develop
Commit: 03b797f6ea4a32eb1d3c19e954fbc07749473a18
Parents: 6f3bfc1
Author: Peter Ent <pent@apache.org>
Authored: Wed Jun 5 09:34:52 2013 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Wed Jun 5 09:34:52 2013 -0400

----------------------------------------------------------------------
 frameworks/as/defaults.css                         |    1 +
 frameworks/as/src/FlexJSUIClasses.as               |    1 +
 .../src/org/apache/flex/core/IMeasurementBead.as   |   26 ++++++++
 .../org/apache/flex/html/staticControls/Label.as   |   16 ++++-
 .../html/staticControls/beads/SimpleAlertBead.as   |   10 +++-
 .../html/staticControls/beads/TextFieldBeadBase.as |    2 +-
 .../beads/TextFieldLabelMeasurementBead.as         |   51 +++++++++++++++
 7 files changed, 104 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index ccc280b..fadcab6 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -94,6 +94,7 @@ Label
 {
 	width: 95;
 	height: 18;
+	iMeasurementBead: ClassReference("org.apache.flex.html.staticControls.beads.TextFieldLabelMeasurementBead");
 }
 
 List

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as b/frameworks/as/src/FlexJSUIClasses.as
index a324460..f39654c 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -40,6 +40,7 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.staticControls.beads.ContainerBead; ContainerBead;
 	import org.apache.flex.html.staticControls.beads.PanelBead; PanelBead;
 	import org.apache.flex.html.staticControls.beads.SimpleAlertBead; SimpleAlertBead;
+	import org.apache.flex.html.staticControls.beads.TextFieldLabelMeasurementBead; TextFieldLabelMeasurementBead;
 	import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
 	import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
 	import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/org/apache/flex/core/IMeasurementBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IMeasurementBead.as b/frameworks/as/src/org/apache/flex/core/IMeasurementBead.as
new file mode 100644
index 0000000..3e294f4
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IMeasurementBead.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+	public interface IMeasurementBead extends IBead
+	{
+		function get measuredWidth():Number;
+		function get measuredHeight():Number;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/org/apache/flex/html/staticControls/Label.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Label.as b/frameworks/as/src/org/apache/flex/html/staticControls/Label.as
index 89c91cf..bb80171 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/Label.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Label.as
@@ -20,10 +20,12 @@ package org.apache.flex.html.staticControls
 {
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IInitSkin;
-	import org.apache.flex.core.ITextModel;
 	import org.apache.flex.core.ITextBead;
+	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;
 	
 	/**
 	 *  Label probably should extend TextField directly,
@@ -68,5 +70,17 @@ package org.apache.flex.html.staticControls
 			if (getBeadByType(ITextBead) == null)
 				addBead(new (ValuesManager.valuesImpl.getValue(this, "iTextBead")) as IBead);			
 		}
+		
+		override public function set width(value:Number):void
+		{
+			super.width = value;
+			IEventDispatcher(model).dispatchEvent( new Event("widthChanged") );
+		}
+		
+		override public function set height(value:Number):void
+		{
+			super.height = value;
+			IEventDispatcher(model).dispatchEvent( new Event("heightChanged") );
+		}
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
index 4c2ca4d..639f0b8 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertBead.as
@@ -22,13 +22,17 @@ package org.apache.flex.html.staticControls.beads
 	import flash.display.DisplayObjectContainer;
 	
 	import org.apache.flex.core.IAlertModel;
+	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IInitModel;
 	import org.apache.flex.core.IInitSkin;
+	import org.apache.flex.core.IMeasurementBead;
 	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ITextBead;
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.events.ValueChangeEvent;
 	import org.apache.flex.html.staticControls.Label;
 	import org.apache.flex.html.staticControls.TextButton;
 	
@@ -69,7 +73,11 @@ package org.apache.flex.html.staticControls.beads
 		
 		private function handleMessageChange(event:Event):void
 		{
-			var maxWidth:Number = Math.max(UIBase(_strand).width,messageLabel.width);
+			var ruler:IMeasurementBead = messageLabel.getBeadByType(IMeasurementBead) as IMeasurementBead;
+			if( ruler == null ) {
+				messageLabel.addBead(ruler = new (ValuesManager.valuesImpl.getValue(messageLabel, "iMeasurementBead"))
as IMeasurementBead);
+			}
+			var maxWidth:Number = Math.max(UIBase(_strand).width,ruler.measuredWidth);
 			
 			messageLabel.x = 0;
 			messageLabel.y = 0;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
index 1c4fb0a..b9a2ebf 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
@@ -37,7 +37,7 @@ package org.apache.flex.html.staticControls.beads
 		
 		private var _textField:CSSTextField;
 		
-		protected function get textField() : CSSTextField
+		public function get textField() : CSSTextField
 		{
 			return _textField;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/03b797f6/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldLabelMeasurementBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldLabelMeasurementBead.as
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldLabelMeasurementBead.as
new file mode 100644
index 0000000..f6ed3f0
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldLabelMeasurementBead.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.staticControls.beads
+{
+	import org.apache.flex.core.IMeasurementBead;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ITextBead;
+	
+	public class TextFieldLabelMeasurementBead implements IMeasurementBead
+	{
+		public function TextFieldLabelMeasurementBead()
+		{
+		}
+		
+		public function get measuredWidth():Number
+		{
+			var bead:TextFieldBead = _strand.getBeadByType(ITextBead) as TextFieldBead;
+			if( bead ) return bead.textField.textWidth;
+			else return 0;
+		}
+		
+		public function get measuredHeight():Number
+		{
+			var bead:TextFieldBead = _strand.getBeadByType(ITextBead) as TextFieldBead;
+			if( bead ) return bead.textField.textHeight;
+			else return 0;
+		}
+		
+		private var _strand:IStrand;
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+		}
+	}
+}
\ No newline at end of file


Mime
View raw message