You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/06/18 21:58:25 UTC

git commit: [flex-asjs] [refs/heads/develop] - Created IGraphicsDrawing interface that some beads implement if they draw into their strands' graphic context. Alert and SimpleAlert now have proper background and border beads. Border bead now picks up bord

Updated Branches:
  refs/heads/develop 7a18c74ad -> 53b1bfcd0


Created IGraphicsDrawing interface that some beads implement if they draw into their strands' graphic context. Alert and SimpleAlert now have proper background and border beads. Border bead now picks up border-color and border-thickness from CSS. Background bead now includes opacity.


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

Branch: refs/heads/develop
Commit: 53b1bfcd0c04c951cf01bfb86a9dde1e3c0f6ff9
Parents: 7a18c74
Author: Peter Ent <pe...@apache.org>
Authored: Tue Jun 18 15:58:14 2013 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Tue Jun 18 15:58:14 2013 -0400

----------------------------------------------------------------------
 frameworks/as/defaults.css                      | 26 +++++++----
 .../apache/flex/html/staticControls/Alert.as    | 10 +++++
 .../flex/html/staticControls/SimpleAlert.as     | 10 +++++
 .../flex/html/staticControls/beads/AlertBead.as | 46 +++++++++-----------
 .../staticControls/beads/IGraphicsDrawing.as    | 25 +++++++++++
 .../staticControls/beads/SimpleAlertBead.as     | 33 ++++++--------
 .../beads/SingleLineBorderBead.as               | 22 +++++++---
 .../staticControls/beads/SolidBackgroundBead.as | 28 ++++++++++--
 8 files changed, 140 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index 04c0492..8577021 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -142,18 +142,28 @@ Panel
 
 SimpleAlert
 {
-    IAlertModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");
-    IAlertBead:  ClassReference("org.apache.flex.html.staticControls.beads.SimpleAlertBead");
+    iAlertModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");
+    iAlertBead:  ClassReference("org.apache.flex.html.staticControls.beads.SimpleAlertBead");
+    iBorderBead: ClassReference("org.apache.flex.html.staticControls.beads.SingleLineBorderBead");
+    iBackgroundBead: ClassReference("org.apache.flex.html.staticControls.beads.SolidBackgroundBead");
+
+    background-color: #FFFFFF;
+    border-style: solid;
+    border-color: #000000;
+    border-thickness: 1;
 }
 
 Alert
 {
-    IAlertModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");
-    IAlertBead:  ClassReference("org.apache.flex.html.staticControls.beads.AlertBead");
-	background-color: #FFFFFF;
-	border-style: solid;
-	border-color: #000000;
-	border-thickness: 2;
+    iAlertModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");
+    iAlertBead:  ClassReference("org.apache.flex.html.staticControls.beads.AlertBead");
+    iBackgroundBead: ClassReference("org.apache.flex.html.staticControls.beads.SolidBackgroundBead");
+    iBorderBead: ClassReference("org.apache.flex.html.staticControls.beads.SingleLineBorderBead");
+
+    background-color: #FFFFFF;
+    border-style: solid;
+    border-color: #000000;
+    border-thickness: 1;
 }
 
 /* HTML5 */

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
index b74c444..4da5fef 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
@@ -26,6 +26,8 @@ package org.apache.flex.html.staticControls
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.html.staticControls.beads.IAlertBead;
+	import org.apache.flex.html.staticControls.beads.IBackgroundBead;
+	import org.apache.flex.html.staticControls.beads.IBorderBead;
 	
 	public class Alert extends UIBase implements IInitSkin, IPopUp
 	{
@@ -37,6 +39,8 @@ package org.apache.flex.html.staticControls
 		public function Alert()
 		{
 			super();
+			
+			className = "Alert";
 		}
 		
 		// note: only passing parent to this function as I don't see a way to identify
@@ -95,6 +99,12 @@ package org.apache.flex.html.staticControls
 		
 		public function initSkin():void
 		{
+			if( getBeadByType(IBackgroundBead) == null ) {
+				addBead( new (ValuesManager.valuesImpl.getValue(this, "iBackgroundBead")) as IBead);
+			}
+			if( getBeadByType(IBorderBead) == null ) {
+				addBead(new (ValuesManager.valuesImpl.getValue(this, "iBorderBead")) as IBead);
+			}
 			if( getBeadByType(IAlertBead) == null ) {
 				addBead(new (ValuesManager.valuesImpl.getValue(this, "iAlertBead")) as IBead);
 			}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
index 536e7b7..140afda 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
@@ -25,6 +25,8 @@ package org.apache.flex.html.staticControls
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
+	import org.apache.flex.html.staticControls.beads.IBackgroundBead;
+	import org.apache.flex.html.staticControls.beads.IBorderBead;
 	import org.apache.flex.html.staticControls.beads.ISimpleAlertBead;
 	
 	[Event(name="close", type="org.apache.flex.events.Event")]
@@ -34,6 +36,8 @@ package org.apache.flex.html.staticControls
 		public function SimpleAlert()
 		{
 			super();
+			
+			className = "SimpleAlert";
 		}
 		
 		override public function initModel():void
@@ -62,6 +66,12 @@ package org.apache.flex.html.staticControls
 		
 		public function initSkin():void
 		{
+			if( getBeadByType(IBackgroundBead) == null ) {
+				addBead( new (ValuesManager.valuesImpl.getValue(this, "iBackgroundBead")) as IBead);
+			}
+			if( getBeadByType(IBorderBead) == null ) {
+				addBead(new (ValuesManager.valuesImpl.getValue(this, "iBorderBead")) as IBead);
+			}
 			if( getBeadByType(ISimpleAlertBead) == null ) {
 				addBead(new (ValuesManager.valuesImpl.getValue(this, "iAlertBead")) as IBead);
 			}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertBead.as
index b200c03..dcbd433 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertBead.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertBead.as
@@ -22,6 +22,7 @@ package org.apache.flex.html.staticControls.beads
 	import org.apache.flex.core.IMeasurementBead;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.createjs.staticControls.Label;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
@@ -29,8 +30,6 @@ package org.apache.flex.html.staticControls.beads
 	import org.apache.flex.html.staticControls.ControlBar;
 	import org.apache.flex.html.staticControls.TextButton;
 	import org.apache.flex.html.staticControls.TitleBar;
-	import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
-	import org.apache.flex.html.staticControls.supportClasses.Border;
 	
 	public class AlertBead implements IAlertBead
 	{
@@ -45,17 +44,12 @@ package org.apache.flex.html.staticControls.beads
 		private var _cancelButton:TextButton;
 		private var _yesButton:TextButton;
 		private var _noButton:TextButton;
-		private var _border:Border;
 		
 		private var _strand:IStrand;
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
 			
-			var bb:SolidBackgroundBead = new SolidBackgroundBead();
-			bb.backgroundColor = 0xffffff;
-			_strand.addBead(bb);
-			
 			var flags:uint = IAlertModel(UIBase(_strand).model).flags;
 			if( flags & Alert.OK ) {
 				_okButton = new TextButton();
@@ -108,11 +102,6 @@ package org.apache.flex.html.staticControls.beads
 			_controlBar.addToParent(_strand);
 			_label.addToParent(_strand);
 			
-			_border = new Border();
-			_border.addToParent(_strand);
-			_border.model = new SingleLineBorderModel();
-			_border.addBead(new SingleLineBorderBead());
-			
 			sizeHandler(null);
 		}
 		
@@ -123,24 +112,31 @@ package org.apache.flex.html.staticControls.beads
 			var ctrlMeasure:IMeasurementBead  = _controlBar.measurementBead;
 			var maxWidth:Number = Math.max(titleMeasure.measuredWidth, ctrlMeasure.measuredWidth, labelMeasure.measuredWidth);
 			
-			_titleBar.x = 0;
-			_titleBar.y = 0;
-			_titleBar.width = maxWidth;
+			var borderThickness:Object = ValuesManager.valuesImpl.getValue(_strand,"border-thickness");
+			var borderOffset:Number;
+			if( borderThickness == null ) {
+				borderOffset = 0;
+			}
+			else {
+				borderOffset = Number(borderThickness);
+				if( isNaN(borderOffset) ) borderOffset = 0;
+			}
+			
+			_titleBar.x = borderOffset;
+			_titleBar.y = borderOffset;
+			_titleBar.width = maxWidth - 2*borderOffset;
 			
 			// content placement here
-			_label.x = 0;
-			_label.y = _titleBar.height + 2;
-			_label.width = maxWidth;
+			_label.x = borderOffset;
+			_label.y = borderOffset + _titleBar.height + 2;
+			_label.width = maxWidth - 2*borderOffset;
 			
-			_controlBar.x = 0;
-			_controlBar.y = _label.y + _label.height + 2;
-			_controlBar.width = maxWidth;
+			_controlBar.x = borderOffset;
+			_controlBar.y = borderOffset + _label.y + _label.height + 2;
+			_controlBar.width = maxWidth - 2*borderOffset;
 			
 			UIBase(_strand).width = maxWidth;
-			UIBase(_strand).height = _controlBar.y + _controlBar.height;
-			
-			_border.width = UIBase(_strand).width;
-			_border.height = UIBase(_strand).height;
+			UIBase(_strand).height = _controlBar.y + _controlBar.height + borderOffset;
 		}
 		
 		private function handleOK(event:Event):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/beads/IGraphicsDrawing.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IGraphicsDrawing.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IGraphicsDrawing.as
new file mode 100644
index 0000000..dc1ca3d
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IGraphicsDrawing.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+	public interface IGraphicsDrawing
+	{
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/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 d10d7aa..1041d07 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
@@ -35,8 +35,6 @@ package org.apache.flex.html.staticControls.beads
 	import org.apache.flex.events.ValueChangeEvent;
 	import org.apache.flex.html.staticControls.Label;
 	import org.apache.flex.html.staticControls.TextButton;
-	import org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
-	import org.apache.flex.html.staticControls.supportClasses.Border;
 	
 	public class SimpleAlertBead implements ISimpleAlertBead
 	{
@@ -46,17 +44,12 @@ package org.apache.flex.html.staticControls.beads
 		
 		private var messageLabel:Label;
 		private var okButton:TextButton;
-		private var border:Border;
 		
 		private var _strand:IStrand;
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
 			
-			var bb:SolidBackgroundBead = new SolidBackgroundBead();
-			bb.backgroundColor = 0xffffff;
-			_strand.addBead(bb);
-			
 			var model:IAlertModel = _strand.getBeadByType(IAlertModel) as IAlertModel;
 			model.addEventListener("messageChange",handleMessageChange);
 			model.addEventListener("htmlMessageChange",handleMessageChange);
@@ -75,11 +68,6 @@ package org.apache.flex.html.staticControls.beads
 			okButton.addToParent(_strand);
 			okButton.addEventListener("click",handleOK);
 			
-			border = new Border();
-			border.addToParent(_strand);
-			border.model = new SingleLineBorderModel();
-			border.addBead(new SingleLineBorderBead());
-			
 			handleMessageChange(null);
 		}
 		
@@ -91,18 +79,25 @@ package org.apache.flex.html.staticControls.beads
 			}
 			var maxWidth:Number = Math.max(UIBase(_strand).width,ruler.measuredWidth);
 			
-			messageLabel.x = 0;
-			messageLabel.y = 0;
-			messageLabel.width = maxWidth;
+			var borderThickness:Object = ValuesManager.valuesImpl.getValue(_strand,"border-thickness");
+			var borderOffset:Number;
+			if( borderThickness == null ) {
+				borderOffset = 0;
+			}
+			else {
+				borderOffset = Number(borderThickness);
+				if( isNaN(borderOffset) ) borderOffset = 0;
+			}
+			
+			messageLabel.x = borderOffset;
+			messageLabel.y = borderOffset;
+			messageLabel.width = maxWidth-2*borderOffset;
 			
 			okButton.x = (UIBase(_strand).width - okButton.width)/2;
 			okButton.y = messageLabel.height + 20;
 			
 			UIBase(_strand).width = maxWidth;
-			UIBase(_strand).height = messageLabel.height + okButton.height + 20;
-			
-			border.width = UIBase(_strand).width;
-			border.height = UIBase(_strand).height;
+			UIBase(_strand).height = messageLabel.height + okButton.height + 20 + 2*borderOffset;
 		}
 		
 		private function handleOK(event:Event):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as
index e10dafe..0988cb9 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SingleLineBorderBead.as
@@ -23,15 +23,16 @@ package org.apache.flex.html.staticControls.beads
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 
-	public class SingleLineBorderBead implements IBead, IBorderBead
+	public class SingleLineBorderBead implements IBead, IBorderBead, IGraphicsDrawing
 	{
 		public function SingleLineBorderBead()
 		{
 		}
-				
+		
 		private var _strand:IStrand;
 		
 		public function get strand():IStrand
@@ -47,14 +48,25 @@ package org.apache.flex.html.staticControls.beads
 		        
 		private function changeHandler(event:Event):void
 		{
+			var styleObject:Object = ValuesManager.valuesImpl.getValue(_strand,"border-color");
+			var borderColor:Number = Number(styleObject);
+			if( isNaN(borderColor) ) borderColor = 0x000000;
+			styleObject = ValuesManager.valuesImpl.getValue(_strand,"border-thickness");
+			var borderThickness:Number = Number(styleObject);
+			if( isNaN(borderThickness) ) borderThickness = 1;
+			
             var host:UIBase = UIBase(_strand);
             var g:Graphics = host.graphics;
             var w:Number = host.width;
             var h:Number = host.height;
-            g.clear();
-            g.beginFill(0);
+			
+			var gd:IGraphicsDrawing = strand.getBeadByType(IGraphicsDrawing) as IGraphicsDrawing;
+			if( this == gd ) g.clear();
+			
+			g.lineStyle();
+            g.beginFill(borderColor);
             g.drawRect(0, 0, w, h);
-            g.drawRect(1, 1, w-2, h-2);
+            g.drawRect(borderThickness, borderThickness, w-2*borderThickness, h-2*borderThickness);
             g.endFill();
 		}
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/53b1bfcd/frameworks/as/src/org/apache/flex/html/staticControls/beads/SolidBackgroundBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SolidBackgroundBead.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SolidBackgroundBead.as
index 76133b6..90dbbb4 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SolidBackgroundBead.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SolidBackgroundBead.as
@@ -27,7 +27,7 @@ package org.apache.flex.html.staticControls.beads
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 
-	public class SolidBackgroundBead implements IBead, IBackgroundBead
+	public class SolidBackgroundBead implements IBead, IBackgroundBead, IGraphicsDrawing
 	{
 		public function SolidBackgroundBead()
 		{
@@ -49,6 +49,11 @@ package org.apache.flex.html.staticControls.beads
 			if( bgColor != null ) {
 				backgroundColor = uint(bgColor);
 			}
+			
+			var bgAlpha:Object = ValuesManager.valuesImpl.getValue(value, "opacity");
+			if( bgAlpha != null ) {
+				opacity = Number(bgAlpha);
+			}
 		}
 		
 		private var _backgroundColor:uint;
@@ -64,14 +69,31 @@ package org.apache.flex.html.staticControls.beads
 				changeHandler(null);
 		}
 		
+		private var _opacity:Number = 1.0;
+		
+		public function get opacity():Number
+		{
+			return _opacity;
+		}
+		
+		public function set opacity(value:Number):void
+		{
+			_opacity = value;
+			if( _strand )
+				changeHandler(null);
+		}
+		
 		private function changeHandler(event:Event):void
 		{
             var host:UIBase = UIBase(_strand);
             var g:Graphics = host.graphics;
             var w:Number = host.width;
             var h:Number = host.height;
-            g.clear();
-            g.beginFill(backgroundColor);
+			
+			var gd:IGraphicsDrawing = strand.getBeadByType(IGraphicsDrawing) as IGraphicsDrawing;
+			if( this == gd ) g.clear();
+
+            g.beginFill(backgroundColor,opacity);
             g.drawRect(0, 0, w, h);
             g.endFill();
 		}