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

harbs 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 c31c9848d2 Change the way skins are applied
c31c9848d2 is described below

commit c31c9848d2fd7b09325247524fd87fed9a3b2868
Author: Harbs <[email protected]>
AuthorDate: Wed Mar 11 12:22:44 2026 +0200

    Change the way skins are applied
---
 .../royale/org/apache/royale/style/IStyleSkin.as   |  2 +-
 .../royale/org/apache/royale/style/StyleSkin.as    | 13 ++++++--
 .../royale/org/apache/royale/style/StyleUIBase.as  | 35 +++++++++++++++-------
 3 files changed, 37 insertions(+), 13 deletions(-)

diff --git 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleSkin.as
 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleSkin.as
index acb2bdb400..82c148b4aa 100644
--- 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleSkin.as
+++ 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleSkin.as
@@ -22,6 +22,6 @@ package org.apache.royale.style
 
        public interface IStyleSkin extends IBead
        {
-               
+               function get styles():Array;
        }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleSkin.as
 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleSkin.as
index 2628d5b8ac..035edb0fb8 100644
--- 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleSkin.as
+++ 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleSkin.as
@@ -54,13 +54,22 @@ package org.apache.royale.style
                                styleUIBase.addStyleBead(styleBead);
                        }
                }
+               private var _styles:Array;
+
                /**
                 *  The array of style beads that this StyleSkin will apply to 
the component.
                 *  @langversion 3.0
                 *  @productversion Royale 0.9.13
                 * 
-                *  @royalesuppresspublicvarwarning
                 */
-               public var styles:Array;
+               public function get styles():Array
+               {
+                       return _styles;
+               }
+
+               public function set styles(value:Array):void
+               {
+                       _styles = value;
+               }
        }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleUIBase.as
 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleUIBase.as
index a9b1923527..79581d078f 100644
--- 
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleUIBase.as
+++ 
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/StyleUIBase.as
@@ -123,8 +123,15 @@ package org.apache.royale.style
                                        addStyleBead(bead);
                        }
                        styleBeads = null;
-                       applySkin();
                        _stylesLoaded = true;
+                       if(!_skin)
+                               _skin = loadBeadFromValuesManager(IStyleSkin, 
"iStyleSkin", this) as IStyleSkin;                                
+                       
+                       if(_skin)
+                       {
+                               addBead(_skin);
+                               applySkin();
+                       }
                        refreshStyles();
                }
                /**
@@ -209,19 +216,27 @@ package org.apache.royale.style
                        _skin = value;
                        if(_stylesLoaded)
                        {
+                               assert(getBeadByType(IStyleSkin) == null, 
"skins cannot be replaced once loaded");
                                addBead(value);
+                               applySkin();
                        }
                }
-               private function applySkin():void
+               /**
+                * Skins have style beads and properties which can be applied 
in two ways:
+                * 1. When the skin is added as a bead, the strand setter can 
apply the styles in the skin code.
+                * 2. The applySkin method can be called to apply the styles 
after the skin is added.
+                *    This is useful if there's a need to optimize the styling 
in a way whereit's not appropriate
+                *    to make parts of the component publically available as 
StyleUIBase instances.
+                * 
+                * Override this method in subclasses as needed.
+                * 
+                * @langversion 3.0
+                * @productversion Royale 0.9.13
+                * 
+                */
+               protected function applySkin():void
                {
-                       if(skin)
-                       {
-                               addBead(skin);
-                       }
-                       else
-                       {
-                               _skin = loadBeadFromValuesManager(IStyleSkin, 
"iStyleSkin", this) as IStyleSkin;                                
-                       }
+                       // default implementation does nothing
                }
 
                protected function refreshStyles():void

Reply via email to