flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject [1/2] git commit: [flex-asjs] [refs/heads/develop] - Added CenterElement bead. Also, make sure layouts throw the 'layoutComplete' event in both JS and SWF.
Date Wed, 08 Feb 2017 11:05:19 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 2fc25fccd -> 82b692096


Added CenterElement bead. Also, make sure layouts throw the 'layoutComplete' event in both
JS and SWF.


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

Branch: refs/heads/develop
Commit: 4f08e7e36e597948ed7ce6d0ea501a27a7a9de33
Parents: 92bcb5a
Author: yishayw <yishayjobs@hotmail.com>
Authored: Wed Feb 8 13:03:56 2017 +0200
Committer: yishayw <yishayjobs@hotmail.com>
Committed: Wed Feb 8 13:03:56 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flex/html/beads/CenterElement.as | 84 ++++++++++++++++++++
 .../flex/html/beads/layouts/BasicLayout.as      |  1 +
 .../flex/html/beads/layouts/HorizontalLayout.as |  1 +
 .../flex/html/beads/layouts/VerticalLayout.as   |  1 +
 .../HTML/src/main/resources/basic-manifest.xml  |  1 +
 5 files changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f08e7e3/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/CenterElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/CenterElement.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/CenterElement.as
new file mode 100644
index 0000000..163679b
--- /dev/null
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/CenterElement.as
@@ -0,0 +1,84 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.beads
+{
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IChild;
+	import org.apache.flex.core.ILayoutChild;
+	import org.apache.flex.core.ILayoutParent;
+	import org.apache.flex.core.IParent;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	
+	/**
+	 *  The CenterElement bead breaks the normal layout flow and forces
+	 *  a particlular element to stay centered.
+	 * 	  
+	 *  @viewbead
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	
+	public class CenterElement implements IBead
+	{
+		private var _strand:IStrand;
+		public function CenterElement()
+		{
+		}
+		
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			var layoutParent:ILayoutParent = getLayoutParent((value as IChild).parent);
+			IEventDispatcher(layoutParent).addEventListener('layoutComplete', layoutCompleteHandler);
+		}
+		
+		private function layoutCompleteHandler(e:Event):void
+		{
+			var childWidth:Number = host.width;
+			var parentWidth:Number = (host.parent as ILayoutChild).width;
+			var childHeight:Number = host.height;
+			var parentHeight:Number = (host.parent as ILayoutChild).height;
+			host.x = (parentWidth - childWidth) / 2;
+			host.y = (parentHeight - childHeight) / 2;
+		}
+		
+		private function get host():ILayoutChild
+		{
+			return _strand as ILayoutChild;
+		}
+		
+		private function getLayoutParent(value:IParent):ILayoutParent
+		{
+			while (value)
+			{
+				if (value is ILayoutParent)
+				{
+					return value as ILayoutParent;
+				}
+				value = IChild(value).parent;
+			}
+			return null;
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f08e7e3/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/BasicLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/BasicLayout.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/BasicLayout.as
index 500f7a0..642b14c 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/BasicLayout.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/BasicLayout.as
@@ -441,6 +441,7 @@ package org.apache.flex.html.beads.layouts
                 if (!hasHeight && n > 0 && !isNaN(maxHeight)) {
                     contentView.height = maxHeight;
                 }
+				host.dispatchEvent( new Event("layoutComplete") );
                 return true;
             }
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f08e7e3/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
index b316e26..4230c5e 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/HorizontalLayout.as
@@ -253,6 +253,7 @@ package org.apache.flex.html.beads.layouts
                 if (!hasWidth && n > 0 && !isNaN(computedWidth)) {
                     contentView.width = computedWidth + 1; // some browser need one more
pixel
                 }
+				host.dispatchEvent( new Event("layoutComplete") );
                 return true;
             }
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f08e7e3/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
index c8970ba..b3f0638 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/layouts/VerticalLayout.as
@@ -302,6 +302,7 @@ package org.apache.flex.html.beads.layouts
 					maxWidth += npl + npr;
 					contentView.width = maxWidth;
 				}
+				host.dispatchEvent( new Event("layoutComplete") );
 				return true;
 			}
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4f08e7e3/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index 8b322f9..e3a27f3 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -68,6 +68,7 @@
     <component id="TileLayout" class="org.apache.flex.html.beads.layouts.TileLayout"/>
     <component id="ListView" class="org.apache.flex.html.beads.ListView"/>
     <component id="AccordionView" class="org.apache.flex.html.beads.AccordionView"/>
+    <component id="CenterElement" class="org.apache.flex.html.beads.CenterElement"/>
     <!--<component id="MultilineTextFieldView" class="org.apache.flex.html.beads.MultilineTextFieldView"/>-->
     
     <component id="SimpleAlert" class="org.apache.flex.html.SimpleAlert"/>


Mime
View raw message