This is an automated email from the ASF dual-hosted git repository.

yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 8016941c9708e8a110a928657d4652fa60e622a2
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Mon Jan 1 14:02:27 2018 +0200

    First version where mask bead takes over an existing element and turns it 
into a mssk
---
 .../main/royale/org/apache/royale/core/IUIBase.as  |  13 ++
 .../main/royale/org/apache/royale/svg/MaskBead.as  | 136 +++++----------------
 ...nvert New Flex Project to Royale Project.launch |  10 +-
 3 files changed, 49 insertions(+), 110 deletions(-)

diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IUIBase.as 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IUIBase.as
index 565d118..eb1f607 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IUIBase.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/IUIBase.as
@@ -122,5 +122,18 @@ package org.apache.royale.core
          *  @productversion Royale 0.0
          */
         function get topMostEventDispatcher():IEventDispatcher;
+        /**
+                *  Set positioner of IUIBase. This can be useful for beads 
such as MaskBead
+                *  that change the parent element after it's been drawn.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9
+         *  all input events.
+         *  
+         */
+               COMPILE::JS
+        function set positioner(value:WrappedHTMLElement):void;
     }
 }
diff --git 
a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MaskBead.as
 
b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MaskBead.as
index e9b0367..8c8bc96 100644
--- 
a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MaskBead.as
+++ 
b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MaskBead.as
@@ -22,25 +22,23 @@ package org.apache.royale.svg
        import org.apache.royale.core.IBead;
        import org.apache.royale.core.IRenderedObject;
        import org.apache.royale.core.IStrand;
-       import org.apache.royale.graphics.PathBuilder;
 
        COMPILE::SWF {
-       import flash.display.Graphics;
-       import flash.display.Sprite;
-       import flash.display.DisplayObject;
+               import flash.display.Graphics;
+               import flash.display.Sprite;
+               import flash.display.DisplayObject;
        }
 
-               COMPILE::JS
-               {
-                       import org.apache.royale.utils.UIDUtil;
-               }
+       COMPILE::JS
+       {
+               import org.apache.royale.utils.UIDUtil;
+               import org.apache.royale.core.IUIBase;
+               import org.apache.royale.core.WrappedHTMLElement;
+               import org.apache.royale.core.IRenderedObject;
+       }
        /**
-        *  The MaskBead bead allows you to mask
-        *  a graphic Shape using a an mask graphic path.
-        *  The clipping path is defined in the path property
-        *  using a PathBuilder object. This Bead will not
-        *  work on the JS side side on components which are not implemented
-        *  using SVG.
+        *  The MaskBead transforms an IUIBase element into a mask definition
+        *  and contains methods to attach an existing element to this mask 
definition.
         *  
         *  @langversion 3.0
         *  @playerversion Flash 10.2
@@ -50,7 +48,6 @@ package org.apache.royale.svg
        public class MaskBead implements IBead
        {
                private var _strand:IStrand;
-               private var _path:PathBuilder;
                private var document:Object;
                private var maskElementId:String;
                
@@ -58,20 +55,11 @@ package org.apache.royale.svg
                {
                }
                
-               public function get path():PathBuilder
-               {
-                       return _path;
-               }
-               
-               public function set path(value:PathBuilder):void
-               {
-                       _path = value;
-                       mask();
-               }
-               
                /**
                 *  @copy org.apache.royale.core.IBead#strand
-                *  
+                *  @royaleignorecoercion Element
+                *  @royaleignorecoercion 
org.apache.royale.core.WrappedHTMLElement
+                * 
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -79,89 +67,27 @@ package org.apache.royale.svg
                 */             
                public function set strand(value:IStrand):void
                {
-                       _strand = value;
-                       if (path)
-                       {
-                               mask();
-                       }
-               }
-               
-               COMPILE::SWF
-               private function mask():void
-               {
-                       if (!path)
-                       {
-                               return;
-                       }
-                       var element:DisplayObject = host.$displayObject as 
DisplayObject;
-                       var mask:Sprite = new Sprite();
-                       var g:Graphics = mask.graphics;
-                       g.beginFill(0);
-                       path.draw(g);
-                       g.endFill();
-                       // remove existing mask from display list
-                       if (element.mask && element.mask.parent)
-                       {
-                               element.mask.parent.removeChild(element.mask);
-                       }
-                       // add new mask to display list
-                       if (element.parent)
-                       {
-                               element.parent.addChild(mask);
-                       }
-                       // set mask
-                       mask.x = element.x;
-                       mask.y = element.y;
-//                     element.mask = mask;
-               }
-               /**
-                * @royaleignorecoercion Element
-                * @royaleignorecoercion Object
-                */
-               COMPILE::JS
-               private function mask():void
-               {
-                       if (!path || !host)
+                       COMPILE::JS 
                        {
-                               return;
-                       }
-                       var svgElement:Node = host.element as Element;
-                       var defs:Element = getChildNode(svgElement, "defs") as 
Element;
-                       var maskElement:Element = getChildNode(defs, "mask") as 
Element;
-                       maskElementId = maskElement.id = "myMask" + 
UIDUtil.createUID();
-                       // clean up existing mask paths
-                       if (maskElement.hasChildNodes())
-                       {
-                               var childNodes:Object = maskElement.childNodes;
+                               _strand = value;
+                               var currentPositioner:Element = (value as 
IRenderedObject).element as Element;
+                               var myPositioner:Element = 
createChildNode(currentPositioner, "defs") as Element;
+                               myPositioner = createChildNode(myPositioner, 
"mask") as Element;
+                               maskElementId = myPositioner.id = "myMask" + 
UIDUtil.createUID();
+                               (value as IUIBase).positioner = myPositioner as 
WrappedHTMLElement;
+                               // this helps retains width and height
+                               myPositioner.setAttribute('style', 
currentPositioner.getAttribute('style'));
+                               // move children to new positioner
+                               var childNodes:Object = 
currentPositioner.childNodes;
                                for (var i:int = 0; i < childNodes.length; i++)
                                {
-                                       maskElement.removeChild(childNodes[i]);
-                               }
-                       }
-                       // create pathNode
-                       var pathNode:Element = createChildNode(maskElement, 
"path") as Element;
-                       pathNode.setAttribute("d", path.getPathString());
-                       // set style 
-//                     host.element.style["mask"] = "url(#" + maskElement.id + 
")";
-               }
-               
-               COMPILE::JS
-               private function getChildNode(node:Node, tagName:String):Node
-               {
-                       if (!node.hasChildNodes())
-                       {
-                               return createChildNode(node, tagName);
-                       }
-                       var childNodes:Object = node.childNodes;
-                       for (var i:int = 0; i < childNodes.length; i++)
-                       {
-                               if (childNodes[i].tagName == tagName)
-                               {
-                                       return childNodes[i];
+                                       var childNode:Element = childNodes[i] 
as Element;
+                                       if (childNode.tagName != "defs")
+                                       {
+                                               
myPositioner.appendChild(childNode);
+                                       }
                                }
-                                       
                        }
-                       return createChildNode(node, tagName);
                }
                
                COMPILE::JS
diff --git a/ide/flashbuilder/Convert New Flex Project to Royale Project.launch 
b/ide/flashbuilder/Convert New Flex Project to Royale Project.launch
index bc98d70..20218c9 100644
--- a/ide/flashbuilder/Convert New Flex Project to Royale Project.launch        
+++ b/ide/flashbuilder/Convert New Flex Project to Royale Project.launch        
@@ -21,17 +21,17 @@
 <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
 <listAttribute key='org.eclipse.debug.ui.favoriteGroups'>
 <listEntry value='org.eclipse.ui.externaltools.launchGroup'/>
-</listAttribute><listAttribute 
key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"/>
+</listAttribute><listAttribute 
key="org.eclipse.debug.core.MAPPED_RESOURCE_UNIX_UNIX_UNIX_PATHS"/>
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"/>
 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
-<mapEntry key="PATH" value="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"/>
+<mapEntry key="UNIX_UNIX_UNIX_PATH" 
value="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"/>
 </mapAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" 
value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<stringAttribute 
key="org.eclipse.jdt.launching.CLASSUNIX_UNIX_UNIX_PATH_PROVIDER" 
value="org.eclipse.ant.ui.AntClasspathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" 
value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" 
value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<stringAttribute 
key="org.eclipse.jdt.launching.SOURCE_UNIX_UNIX_UNIX_PATH_PROVIDER" 
value="org.eclipse.ant.ui.AntClasspathProvider"/>
 <booleanAttribute 
key="org.eclipse.ui.externaltools.ATTR_HIDE_INTERNAL_TARGETS" value="true"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" 
value="$ROYALE_HOME/ide/flashbuilder/antscripts.xml"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" 
value="C:/dev/flexjs/royale-asjs/ide/flashbuilder/antscripts.xml"/>
 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" 
value="-DprojectDir=&quot;${project_loc}&quot;"/>
 <stringAttribute key="process_factory_id" 
value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
 </launchConfiguration>

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to