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 fb39f05ab8 Needs work, but finally have something working
new b0796b3bc0 Merge branch 'develop' of
https://github.com/apache/royale-asjs into develop
fb39f05ab8 is described below
commit fb39f05ab8c5ae126dca61bcf341869d0849ce43
Author: Harbs <[email protected]>
AuthorDate: Wed Mar 18 12:55:18 2026 +0200
Needs work, but finally have something working
---
.../royale/org/apache/royale/style/CheckBox.as | 21 +++---
.../royale/org/apache/royale/style/IStyleUIBase.as | 1 +
.../royale/org/apache/royale/style/StyleSkin.as | 6 +-
.../royale/org/apache/royale/style/StyleUIBase.as | 80 ++++++++++++++++------
.../org/apache/royale/style/skins/CheckBoxSkin.as | 14 ++--
.../royale/style/stylebeads/LeafStyleBase.as | 2 +-
.../royale/style/stylebeads/border/Border.as | 2 +-
.../royale/style/stylebeads/border/Outline.as | 2 +-
.../style/stylebeads/flexgrid/GridColumnStart.as | 2 +-
.../royale/style/stylebeads/spacing/Padding.as | 2 +
10 files changed, 84 insertions(+), 48 deletions(-)
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/CheckBox.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/CheckBox.as
index 092f151bce..5b42bf745f 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/CheckBox.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/CheckBox.as
@@ -103,14 +103,9 @@ package org.apache.royale.style
override protected function applySkin():void
{
var checkSkin:ICheckBoxSkin = skin as ICheckBoxSkin;
- var styles:Array = checkSkin?.styles || [];
- for each(var style:IStyleBead in styles){
- addStyleBead(style);
- }
- styles = checkSkin?.boxStyles || [];
- for each(style in styles){
- box.addStyleBead(style);
- }
+ assert(checkSkin, "CheckBox requires a skin that
implements ICheckBoxSkin");
+ var styles:Array = checkSkin.boxStyles || [];
+ box.setStyles(styles);
applyCheckSkin();
applyIndeterminateSkin();
applyLabelSkin();
@@ -120,11 +115,10 @@ package org.apache.royale.style
*/
private function applyLabelSkin():void
{
+ if(!span) return;
var checkSkin:ICheckBoxSkin = skin as ICheckBoxSkin;
- var styles:Array = checkSkin?.labelStyles || [];
- for each(var style:IStyleBead in styles){
- span.addStyleBead(style);
- }
+ assert(checkSkin && checkSkin.labelStyles, "CheckBox
requires a skin that implements ICheckBoxSkin");
+ span.setStyles(checkSkin.labelStyles);
}
private var _truncate:Boolean;
@@ -216,7 +210,8 @@ package org.apache.royale.style
COMPILE::JS
{
var checkSkin:ICheckBoxSkin = skin as
ICheckBoxSkin;
- var icon:IStyleUIBase =
checkSkin?.indeterminateIcon;
+ assert(checkSkin, "CheckBox needs a skin");
+ var icon:IStyleUIBase =
checkSkin.indeterminateIcon;
if(icon && icon != indeterminateIcon){
if(indeterminateIcon &&
indeterminateIcon.parent){
assert(indeterminateIcon.parent
== this, "Indeterminate icon should be a child of this");
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleUIBase.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleUIBase.as
index 88e53a668d..93f7f5b118 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleUIBase.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/IStyleUIBase.as
@@ -33,6 +33,7 @@ package org.apache.royale.style
{
function toggleClass(classNameVal:String,add:Boolean):void;
function addStyleBead(bead:IStyleBead):void;
+ function setStyles(styles:Array, overrideExisting:Boolean =
false):void;
function get theme():String;
function get skin():IStyleSkin;
function get unit():String;
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 942c2a7024..80a67deddd 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
@@ -51,10 +51,8 @@ package org.apache.royale.style
super.strand = value;
assert(value is IStyleUIBase, "StyleSkin can only be
added to components that implement IStyleUIBase");
var styleUIBase:IStyleUIBase = value as IStyleUIBase;
- for each(var styleBead:IStyleBead in styles)
- {
- styleUIBase.addStyleBead(styleBead);
- }
+ if(styles)
+ styleUIBase.setStyles(styles);
}
protected var _styles:Array;
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 8f460a0cd6..69251b930e 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
@@ -117,28 +117,37 @@ package org.apache.royale.style
*/
public function addStyleBead(bead:IStyleBead):void
{
+ assert(bead != null, "bead cannot be null");
COMPILE::JS
{
- assert(bead != null, "bead cannot be null");
- if(!styleTypes)
- styleTypes = new Map();
-
- var leaves:Array = bead.getLeaves();
- for each(var leaf:ILeafStyleBead in leaves)
+ addStyleInternal(bead, false);
+ }
+ }
+ COMPILE::JS
+ private function addStyleInternal(bead:IStyleBead,
overrideExisting:Boolean):void
+ {
+ if(!styleTypes)
+ styleTypes = new Map();
+
+ var leaves:Array = bead.getLeaves();
+ for each(var leaf:ILeafStyleBead in leaves)
+ {
+ assert(leaf.isLeaf, "getLeaves() should only
return leaf style beads");
+ /**
+ * Only add the first found leaf for each style
type.
+ * This is to prevent duplicate styles from
being added to the style sheet
+ * and enables proper handling of styling
overrides.
+ */
+ if(styleTypes.has(leaf.styleType))
{
- assert(leaf.isLeaf, "getLeaves() should
only return leaf style beads");
- /**
- * Only add the first found leaf for
each style type.
- * This is to prevent duplicate styles
from being added to the style sheet
- * and enables proper handling of
styling overrides.
- */
- if(styleTypes.has(leaf.styleType))
- continue;
- styleTypes.set(leaf.styleType, leaf);
- leaf.strand = this;
- _styleBeads.push(leaf);
+ if(overrideExisting)
+ (styleTypes.get(leaf.styleType)
as ILeafStyleBead).value = leaf.value;
+
+ continue;
}
- refreshStyles();
+ styleTypes.set(leaf.styleType, leaf);
+ leaf.strand = this;
+ _styleBeads.push(leaf);
}
}
COMPILE::JS
@@ -152,6 +161,7 @@ package org.apache.royale.style
for each(var bead:IStyleBead in styleBeads)
addStyleBead(bead);
}
+ refreshSuspended = true;
styleBeads = null;
_stylesLoaded = true;
if(!_skin)
@@ -162,8 +172,30 @@ package org.apache.royale.style
addBead(_skin);
applySkin();
}
+ refreshSuspended = false;
refreshStyles();
}
+ /**
+ * Sets styles on the component using an array of style beads.
+ * Use this for applying styles to an existing component that
already has a skin applied.
+ *
+ * To change existing applied styles, set overrideExisting to
true.
+ * This will change the values of existing styles beads to the
new ones provided in the styles array.
+ *
+ * @langversion 3.0
+ * @productversion Royale 0.9.13
+ */
+ public function setStyles(styles:Array,
overrideExisting:Boolean = false):void
+ {
+ COMPILE::JS
+ {
+ for each(var style:IStyleBead in styles)
+ {
+ addStyleInternal(style,
overrideExisting);
+ }
+ refreshStyles();
+ }
+ }
/**
* @royaleignorecoercion
org.apache.royale.style.stylebeads.ILeafStyleBead
*/
@@ -247,8 +279,11 @@ package org.apache.royale.style
if(_stylesLoaded)
{
assert(getBeadByType(IStyleSkin) == null,
"skins cannot be replaced once loaded");
+ refreshSuspended = true;
addBead(value);
applySkin();
+ refreshSuspended = false;
+ refreshStyles();
}
}
/**
@@ -268,9 +303,14 @@ package org.apache.royale.style
{
// default implementation does nothing
}
-
+ /**
+ * Used to prevent multiple setting of the style classes when
internally setting styles and skins
+ */
+ private var refreshSuspended:Boolean;
protected function refreshStyles():void
{
+ if(refreshSuspended)
+ return;
COMPILE::JS
{
utilityList.clear();
@@ -278,7 +318,7 @@ package org.apache.royale.style
{
applyStyle(styleBead);
}
- computeFinalClassNames();
+ setClassName(computeFinalClassNames());
}
}
protected function applyStyle(styleBead:ILeafStyleBead):void
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/skins/CheckBoxSkin.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/skins/CheckBoxSkin.as
index 994bef6fd3..5cf9d7c1f0 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/skins/CheckBoxSkin.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/skins/CheckBoxSkin.as
@@ -95,6 +95,7 @@ package org.apache.royale.style.skins
// Manually set. Don't create the default ones.
if(_styles)
return;
+
var size:Number = 16 * getMultiplier();
var box:String = computeSize(size * 1.25, host.unit);
var gap:String = computeSize(size * 0.75, host.unit);
@@ -111,6 +112,7 @@ package org.apache.royale.style.skins
new UserSelect("none"),
disabledStyle
];
+ host.setStyles(_styles);
}
private function getMultiplier():Number
{
@@ -283,8 +285,7 @@ package org.apache.royale.style.skins
public function get checkIcon():IStyleUIBase
{
if(!_checkIcon){
- var div:Div = new Div();
- _checkIcon = div;
+ _checkIcon = new Div();
// var iconName:String = "style_checkIconSmall";
// if(!Icon.isRegistered(iconName))
// Icon.registerIcon(iconName,
@@ -302,8 +303,7 @@ package org.apache.royale.style.skins
var borderWidth:BorderWidth = new BorderWidth();
borderWidth.bottom = 3;
borderWidth.right = 3;
- var styles:CompositeStyle = new
CompositeStyle();
- styles.styles = [
+ var styles:Array = [
new GridColumnStart("1"),
new GridRowStart("1"),
new HeightStyle(computeSize(size *
0.625, host.unit)),
@@ -326,7 +326,7 @@ package org.apache.royale.style.skins
])
])
];
- div.addStyleBead(styles);
+ _checkIcon.setStyles(styles);
// TODO dark mode styles
}
@@ -366,8 +366,7 @@ dark:peer-disabled:border-slate-500
_indeterminateIcon = new Div();
var size:Number = 16 * getMultiplier();
- var styles:CompositeStyle = new
CompositeStyle();
- styles.styles = [
+ var styles:Array = [
new GridColumnStart("1"),
new GridRowStart("1"),
new HeightStyle("14%"),
@@ -386,6 +385,7 @@ dark:peer-disabled:border-slate-500
])
])
];
+ _indeterminateIcon.setStyles(styles);
// var iconName:String =
"style_indeterminateIconSmall";
// if(!Icon.isRegistered(iconName))
// Icon.registerIcon(iconName,
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/LeafStyleBase.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/LeafStyleBase.as
index 2043827d90..537b25a94a 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/LeafStyleBase.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/LeafStyleBase.as
@@ -34,7 +34,7 @@ package org.apache.royale.style.stylebeads
super();
_selectorBase = selectorBase;
_ruleBase = ruleBase;
- if(value)
+ if(value != null)
this.value = value;
}
override public function get isLeaf():Boolean
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Border.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Border.as
index 63e5da5b20..6281925407 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Border.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Border.as
@@ -33,7 +33,7 @@ package org.apache.royale.style.stylebeads.border
*/
public class Border extends CompositeStyle
{
- public function Border(value:* = null)
+ public function Border()
{
super();
styles = [];
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Outline.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Outline.as
index 0f9641755b..f84f36e6c5 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Outline.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/border/Outline.as
@@ -27,7 +27,7 @@ package org.apache.royale.style.stylebeads.border
*/
public class Outline extends CompositeStyle
{
- public function Outline(value:* = null)
+ public function Outline()
{
super();
styles = [];
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/flexgrid/GridColumnStart.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/flexgrid/GridColumnStart.as
index fbb58cbabb..22a7a3b2da 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/flexgrid/GridColumnStart.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/flexgrid/GridColumnStart.as
@@ -22,7 +22,7 @@ package org.apache.royale.style.stylebeads.flexgrid
{
public function GridColumnStart(value:* = null)
{
- super("col-start", "grid-column-start");
+ super("col-start", "grid-column-start", value);
}
}
}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/spacing/Padding.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/spacing/Padding.as
index 5f1c653718..1155ad7dfe 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/spacing/Padding.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/spacing/Padding.as
@@ -29,6 +29,8 @@ package org.apache.royale.style.stylebeads.spacing
{
super();
styles = [];
+ if(value != null)
+ this.padding = value;
}
public var unit:String = "px";
private var paddingStyle:Pad;