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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 0ec9932  CanvasLayout was not doing anything for constraint-based 
children in JS (SWF not checked). This may need some tweaking, but it is an 
progress
0ec9932 is described below

commit 0ec99320149c59ecac8be6699398d67c5159965e
Author: greg-dove <[email protected]>
AuthorDate: Thu Dec 16 16:37:52 2021 +1300

    CanvasLayout was not doing anything for constraint-based children in JS 
(SWF not checked). This may need some tweaking, but it is an progress
---
 .../royale/mx/containers/beads/CanvasLayout.as     | 37 +++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/CanvasLayout.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/CanvasLayout.as
index aeab418..c52937a 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/CanvasLayout.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/CanvasLayout.as
@@ -103,6 +103,10 @@ public class CanvasLayout extends LayoutBase
     //
     
//--------------------------------------------------------------------------
 
+       /**
+        *
+        * @royaleignorecoercion Number
+        */
        override public function layout():Boolean
        {
                COMPILE::SWF
@@ -212,7 +216,8 @@ public class CanvasLayout extends LayoutBase
                        // each child must have position:absolute for 
BasicLayout to work
                        for (i=0; i < n; i++) {
                                var child:IUIComponent = 
target.getLayoutChildAt(i);
-                               var hCenter:Number = Number((child as 
ILayoutElement).horizontalCenter);
+                               var layoutChild:ILayoutElement = child as 
ILayoutElement;
+                               var hCenter:Number = 
Number(layoutChild.horizontalCenter);
                                child.positioner.style.position = "absolute";
                                var layoutNeeded:Boolean = true;
                                var hh:Number = child.height;
@@ -227,6 +232,36 @@ public class CanvasLayout extends LayoutBase
                                        ww = target.width * child.percentWidth 
/ 100;
                                        layoutNeeded = false;
                                }
+                               if (layoutNeeded) {
+                                       //@todo check precedence here of 
percent-based vs. constraint-based
+                                       if (!isNaN(layoutChild.left)) {
+                                               child.x = layoutChild.left as 
Number;
+                                               if (!isNaN(layoutChild.right)) {
+                                                       
child.element.style.right = layoutChild.right+'px';
+                                               } else {
+                                                       
child.element.style.right = '';
+                                               }
+                                       } else //@todo check this:
+                                               if (!isNaN(layoutChild.right)) {
+                                               child.element.style.right = 
layoutChild.right+'px';
+                                       } else {
+                                               child.element.style.right = '';
+                                       }
+                                       if (!isNaN(layoutChild.top)) {
+                                               child.y = layoutChild.top as 
Number;
+                                               if (!isNaN(layoutChild.bottom)) 
{
+                                                       
child.element.style.bottom = layoutChild.bottom+'px';
+                                               } else {
+                                                       
child.element.style.bottom = '';
+                                               }
+                                       } else  //@todo check this:
+                                               if (!isNaN(layoutChild.bottom)) 
{
+                                               child.element.style.bottom = 
layoutChild.bottom+'px';
+                                       } else {
+                                               child.element.style.bottom = '';
+                                       }
+                               }
+
                                if (!isNaN(hCenter))
                                {
                                        // TODO consider how this affects 
measurement of target

Reply via email to