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

carlosrovira 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 391bf9a  jewel-layouts: -Make StyledLayoutBase implement 
ILayoutStyleProperties instead of implement its own method -Make BasicLayout 
and the rest of layouts dispathc "sizeChanged" instead of layoutNeeded -End to 
implement the dispatch of events in the rest of jewel layouts and update to the 
ILayoutStyleProperties
391bf9a is described below

commit 391bf9a10238ea79c87bd1d05ea6c37bae084ad4
Author: Carlos Rovira <carlosrov...@apache.org>
AuthorDate: Sun Mar 15 22:41:48 2020 +0100

    jewel-layouts:
    -Make StyledLayoutBase implement ILayoutStyleProperties instead of 
implement its own method
    -Make BasicLayout and the rest of layouts dispathc "sizeChanged" instead of 
layoutNeeded
    -End to implement the dispatch of events in the rest of jewel layouts and 
update to the ILayoutStyleProperties
---
 .../royale/jewel/beads/layouts/BasicLayout.as      | 20 ++++++++++---
 .../royale/jewel/beads/layouts/GridCellLayout.as   |  2 ++
 .../royale/jewel/beads/layouts/GridLayout.as       |  1 +
 .../beads/layouts/HorizontalCenteredLayout.as      | 35 ++++------------------
 .../jewel/beads/layouts/HorizontalFlowLayout.as    | 35 ++++------------------
 .../royale/jewel/beads/layouts/HorizontalLayout.as | 12 ++------
 .../jewel/beads/layouts/SimpleHorizontalLayout.as  |  2 +-
 .../jewel/beads/layouts/SimpleVerticalLayout.as    |  2 +-
 .../royale/jewel/beads/layouts/StyledLayoutBase.as | 18 ++++-------
 .../jewel/beads/layouts/VerticalCenteredLayout.as  | 35 ++++------------------
 .../jewel/beads/layouts/VerticalFlowLayout.as      | 35 ++++------------------
 .../royale/jewel/beads/layouts/VerticalLayout.as   | 12 ++------
 12 files changed, 53 insertions(+), 156 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
index e475078..e34e244 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/BasicLayout.as
@@ -19,11 +19,9 @@
 package org.apache.royale.jewel.beads.layouts
 {
        COMPILE::JS {
-       import org.apache.royale.core.UIBase;
-    }
-       import org.apache.royale.core.ILayoutChild;
+       import org.apache.royale.core.UIBase;
        import org.apache.royale.core.ILayoutView;
-       import org.apache.royale.core.IUIBase;
+    }
        import org.apache.royale.events.Event;
 
     /**
@@ -219,6 +217,20 @@ package org.apache.royale.jewel.beads.layouts
                         *      position: absolute  
                                 *  }
                                 */
+                               
+                               // We just need to make chids resize themselves 
(through `sizeChanged` event)
+                               var contentView:ILayoutView = layoutView;
+                               var n:int = contentView.numElements;
+                               var child:UIBase;
+
+                               if (n == 0) return false;
+                               
+                               for(var i:int=0; i < n; i++) {
+                                       child = contentView.getElementAt(i) as 
UIBase;
+                                       if (!child)
+                                               continue;
+                                       child.dispatchEvent('sizeChanged');
+                               }
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridCellLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridCellLayout.as
index cb8c852..2c23d1a 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridCellLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridCellLayout.as
@@ -615,6 +615,8 @@ package org.apache.royale.jewel.beads.layouts
 
             COMPILE::JS
             {
+                               super.layout();
+                               
                 return true;
             }
                }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridLayout.as
index 2c1c380..4b46483 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/GridLayout.as
@@ -204,6 +204,7 @@ package org.apache.royale.jewel.beads.layouts
                                 *              padding: 1em 0 0 1em;
                                 *      }
                                 */
+                               super.layout();
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalCenteredLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalCenteredLayout.as
index a676589..a107b02 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalCenteredLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalCenteredLayout.as
@@ -145,8 +145,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
-               {       
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               {
+                       super.applyStyleToLayout(component, cssProperty);
+
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -300,34 +302,7 @@ package org.apache.royale.jewel.beads.layouts
             }
             COMPILE::JS
             {
-                               //applyStyleToLayout(c, "gap");
-
-                               /*var children:Array = 
contentView.internalChildren();
-                               var i:int;
-                               var n:int = children.length;
-                               for (i = 0; i < n; i++)
-                {
-                    var child:WrappedHTMLElement = children[i] as 
WrappedHTMLElement;
-                                       if (child == null) continue;
-                                       child.style.marginTop = _paddingTop + 
'px';
-                                       if(i === (n - 1))
-                                       {
-                                               child.style.marginRight = 
_paddingRight + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginRight = '0px';
-                                       }
-                                       child.style.marginBottom = 
_paddingBottom + 'px';
-                                       if(i == 0)
-                                       {
-                                               child.style.marginLeft = 
_paddingLeft + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginLeft = _gap + 
'px';
-                                       }                                       
-                               }*/
+                               super.layout();
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalFlowLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalFlowLayout.as
index 60ec20b..e2dee9b 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalFlowLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalFlowLayout.as
@@ -145,8 +145,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
-               {       
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               {
+                       super.applyStyleToLayout(component, cssProperty);
+
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -300,34 +302,7 @@ package org.apache.royale.jewel.beads.layouts
             }
             COMPILE::JS
             {
-                               //applyStyleToLayout(c, "gap");
-
-                               /*var children:Array = 
contentView.internalChildren();
-                               var i:int;
-                               var n:int = children.length;
-                               for (i = 0; i < n; i++)
-                {
-                    var child:WrappedHTMLElement = children[i] as 
WrappedHTMLElement;
-                                       if (child == null) continue;
-                                       child.style.marginTop = _paddingTop + 
'px';
-                                       if(i === (n - 1))
-                                       {
-                                               child.style.marginRight = 
_paddingRight + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginRight = '0px';
-                                       }
-                                       child.style.marginBottom = 
_paddingBottom + 'px';
-                                       if(i == 0)
-                                       {
-                                               child.style.marginLeft = 
_paddingLeft + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginLeft = _gap + 
'px';
-                                       }                                       
-                               }*/
+                               super.layout();
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
index e869404..960f477 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/HorizontalLayout.as
@@ -138,8 +138,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
                {       
+                       super.applyStyleToLayout(component, cssProperty);
+                       
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -149,14 +151,6 @@ package org.apache.royale.jewel.beads.layouts
                                                if(!gapInitialized)
                                                        gap = Number(cssValue);
                                                break;
-                                       case "itemsVerticalAlign":
-                                               
if(!itemsVerticalAlignInitialized)
-                                                       itemsVerticalAlign = 
cssValue;
-                                               break;
-                                       case "itemsHorizontalAlign":
-                                               
if(!itemsHorizontalAlignInitialized)
-                                                       itemsHorizontalAlign = 
cssValue;
-                                               break;
                                        case "variableRowHeight":
                                                
if(!variableRowHeightInitialized)
                                                        variableRowHeight = 
Boolean(cssValue);
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleHorizontalLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleHorizontalLayout.as
index a37a9c1..b942c58 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleHorizontalLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleHorizontalLayout.as
@@ -209,7 +209,7 @@ package org.apache.royale.jewel.beads.layouts
                                        child = contentView.getElementAt(i) as 
UIBase;
                                        if (!child)
                                                continue;
-                                       child.dispatchEvent('layoutNeeded');
+                                       child.dispatchEvent('sizeChanged');
                                }
                                
                 return true;
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleVerticalLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleVerticalLayout.as
index a8cbf47..3285b44 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleVerticalLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/SimpleVerticalLayout.as
@@ -210,7 +210,7 @@ package org.apache.royale.jewel.beads.layouts
                                        child = contentView.getElementAt(i) as 
UIBase;
                                        if (!child)
                                                continue;
-                                       child.dispatchEvent('layoutNeeded');
+                                       child.dispatchEvent('sizeChanged');
                                }
 
                                return true;
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
index 89a4cba..649f4d0 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
@@ -25,6 +25,7 @@ package org.apache.royale.jewel.beads.layouts
        import org.apache.royale.core.ValuesManager;
        import org.apache.royale.events.Event;
        import org.apache.royale.events.IEventDispatcher;
+       import org.apache.royale.core.layout.ILayoutStyleProperties;
        
     /**
      *  The StyledLayoutBase class is an extension of LayoutBase
@@ -36,7 +37,7 @@ package org.apache.royale.jewel.beads.layouts
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.4
      */
-       public class StyledLayoutBase extends LayoutBase
+       public class StyledLayoutBase extends LayoutBase implements 
ILayoutStyleProperties
        {
         /**
          *  Constructor.
@@ -99,13 +100,13 @@ package org.apache.royale.jewel.beads.layouts
                {
                        COMPILE::JS
                        {
-                               initStyleToLayout(hostComponent, "itemsExpand");
+                               applyStyleToLayout(hostComponent, 
"itemsExpand");
                                setHostClassList("itemsExpand", _itemsExpand ? 
"itemsExpand":"");
 
-                               initStyleToLayout(hostComponent, 
"itemsHorizontalAlign");
+                               applyStyleToLayout(hostComponent, 
"itemsHorizontalAlign");
                                setHostClassList(_itemsHorizontalAlign, 
_itemsHorizontalAlign);
 
-                               initStyleToLayout(hostComponent, 
"itemsVerticalAlign");
+                               applyStyleToLayout(hostComponent, 
"itemsVerticalAlign");
                                setHostClassList(_itemsVerticalAlign, 
_itemsVerticalAlign);
                        }
                }
@@ -121,15 +122,8 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               protected function initStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
                {       
-                       ///-----------------------------------------
-                       /// This function works as the same as 
-                       /// 
org.apache.royale.core.layout.ILayoutStyleProperties#applyStyleToLayout(component:IUIBase,
 cssProperty:String):void
-                       /// Because StyledLayoutBase does not implement 
ILayoutStyleProperties
-                       /// To avoid conflict with subclass like 
HorizontalLayout.applyStyleToLayout
-                       /// Names this function - initStyleToLayout
-                       ///-----------------------------------------
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalCenteredLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalCenteredLayout.as
index d9dae9d..57ab84e 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalCenteredLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalCenteredLayout.as
@@ -145,8 +145,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
-               {       
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               {
+                       super.applyStyleToLayout(component, cssProperty);
+                               
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -300,34 +302,7 @@ package org.apache.royale.jewel.beads.layouts
             }
             COMPILE::JS
             {
-                               //applyStyleToLayout(c, "gap");
-
-                               /*var children:Array = 
contentView.internalChildren();
-                               var i:int;
-                               var n:int = children.length;
-                               for (i = 0; i < n; i++)
-                {
-                    var child:WrappedHTMLElement = children[i] as 
WrappedHTMLElement;
-                                       if (child == null) continue;
-                                       child.style.marginTop = _paddingTop + 
'px';
-                                       if(i === (n - 1))
-                                       {
-                                               child.style.marginRight = 
_paddingRight + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginRight = '0px';
-                                       }
-                                       child.style.marginBottom = 
_paddingBottom + 'px';
-                                       if(i == 0)
-                                       {
-                                               child.style.marginLeft = 
_paddingLeft + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginLeft = _gap + 
'px';
-                                       }                                       
-                               }*/
+                               super.layout();
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalFlowLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalFlowLayout.as
index f2e12bb..0e66e93 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalFlowLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalFlowLayout.as
@@ -146,8 +146,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
-               {       
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               {
+                       super.applyStyleToLayout(component, cssProperty);
+
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -301,34 +303,7 @@ package org.apache.royale.jewel.beads.layouts
             }
             COMPILE::JS
             {
-                               //applyStyleToLayout(c, "gap");
-
-                               /*var children:Array = 
contentView.internalChildren();
-                               var i:int;
-                               var n:int = children.length;
-                               for (i = 0; i < n; i++)
-                {
-                    var child:WrappedHTMLElement = children[i] as 
WrappedHTMLElement;
-                                       if (child == null) continue;
-                                       child.style.marginTop = _paddingTop + 
'px';
-                                       if(i === (n - 1))
-                                       {
-                                               child.style.marginRight = 
_paddingRight + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginRight = '0px';
-                                       }
-                                       child.style.marginBottom = 
_paddingBottom + 'px';
-                                       if(i == 0)
-                                       {
-                                               child.style.marginLeft = 
_paddingLeft + 'px';
-                                       }
-                                       else
-                                       {
-                                               child.style.marginLeft = _gap + 
'px';
-                                       }                                       
-                               }*/
+                               super.layout();
 
                 return true;
             }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
index d8eb478..ebc30d3 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VerticalLayout.as
@@ -138,8 +138,10 @@ package org.apache.royale.jewel.beads.layouts
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
-               public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
+               override public function applyStyleToLayout(component:IUIBase, 
cssProperty:String):void
                {       
+                       super.applyStyleToLayout(component, cssProperty);
+                       
                        var cssValue:* = 
ValuesManager.valuesImpl.getValue(component, cssProperty);
                        if (cssValue !== undefined)
                        {
@@ -149,14 +151,6 @@ package org.apache.royale.jewel.beads.layouts
                                                if(!gapInitialized)
                                                        gap = Number(cssValue);
                                                break;
-                                       case "itemsVerticalAlign":
-                                               
if(!itemsVerticalAlignInitialized)
-                                                       itemsVerticalAlign = 
cssValue;
-                                               break;
-                                       case "itemsHorizontalAlign":
-                                               
if(!itemsHorizontalAlignInitialized)
-                                                       itemsHorizontalAlign = 
cssValue;
-                                               break;
                                        case "variableRowHeight":
                                                
if(!variableRowHeightInitialized)
                                                        variableRowHeight = 
Boolean(cssValue);

Reply via email to