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 7b79825194 Added flex beads
7b79825194 is described below
commit 7b79825194824ee42f38e4e8f4e3ffb3b592fc7e
Author: Harbs <[email protected]>
AuthorDate: Sun Feb 22 11:29:19 2026 +0200
Added flex beads
---
.../royale/style/stylebeads/FlexContainerStyle.as | 139 +++++++++++++++++++++
.../royale/style/stylebeads/FlexItemStyle.as | 124 ++++++++++++++++++
.../{FlexStyle.as => IMeasurementStyleBead.as} | 32 +----
.../{FlexStyle.as => MeasurementStyleBase.as} | 29 ++---
.../royale/style/stylebeads/PositionStyle.as | 4 +-
.../{stylebeads/FlexStyle.as => util/CSSUnit.as} | 42 +++----
.../org/apache/royale/style/util/StyleManager.as | 12 ++
7 files changed, 303 insertions(+), 79 deletions(-)
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexContainerStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexContainerStyle.as
new file mode 100644
index 0000000000..fa128c7491
--- /dev/null
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexContainerStyle.as
@@ -0,0 +1,139 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.style.stylebeads
+{
+ public class FlexContainerStyle extends StyleBeadBase
+ {
+ public function FlexContainerStyle()
+ {
+ super();
+ }
+
+ private var _flex:Boolean = true;
+ /**
+ * Added a FlexContainerStyle is implicitly flex.
+ * This is only needed if you need to set flex to false.
+ * For example, if you have a container that is flex by default
+ * and you want to make it not flex,
+ * then you would add a FlexContainerStyle with flex set to
false.
+ *
+ */
+ public function get flex():Boolean
+ {
+ return _flex;
+ }
+ public function set flex(value:Boolean):void
+ {
+ _flex = value;
+ }
+
+ private var _inline:Boolean;
+ public function get inline():Boolean
+ {
+ return _inline;
+ }
+
+ public function set inline(value:Boolean):void
+ {
+ _inline = value;
+ }
+
+ private var _column:Boolean;
+ /**
+ * Added a FlexContainerStyle is implicitly row.
+ * Set column to true to make it column.
+ */
+ public function get column():Boolean
+ {
+ return _column;
+ }
+ public function set column(value:Boolean):void
+ {
+ _column = value;
+ }
+
+ private var _reverse:Boolean;
+ public function get reverse():Boolean
+ {
+ return _reverse;
+ }
+
+ public function set reverse(value:Boolean):void
+ {
+ _reverse = value;
+ }
+
+ private var _wrap:*;
+ /**
+ * Wrap by default inherits from parent, which is the same as
nowrap.
+ * Set wrap to true to make it wrap, false to make it nowrap.
+ */
+ public function get wrap():Boolean
+ {
+ return !!_wrap;
+ }
+
+ public function set wrap(value:Boolean):void
+ {
+ _wrap = value;
+ }
+
+ private var _value:String;
+
+ /**
+ * Possible selectors:
+ * flex-direction if wrap is undefined.
+ * flex-flow: row nowrap | row wrap | row wrap-reverse | column
nowrap | column wrap | column wrap-reverse
+ * flex-flow: row;
+flex-flow: row-reverse;
+flex-flow: column;
+flex-flow: column-reverse;
+
+
+flex-flow: row nowrap;
+flex-flow: column wrap;
+flex-flow: column-reverse wrap-reverse;
+ */
+ private function stringify(sep:String):String
+ {
+ var wrapStr:String = wrap ? "wrap" : "nowrap";
+ var direction:String = column ? "column" : "row";
+ if(reverse){
+ if(wrap)
+ wrapStr += "-reverse";
+ else
+ direction += "-reverse";
+ }
+ if(_wrap == undefined)
+ return direction;
+
+ return direction + sep + wrapStr;
+ }
+ override public function get selectors():Array
+ {
+ return [".flex-flow" + stringify("-")];
+ }
+
+ override public function get rules():Array
+ {
+ return ["flex-flow:" + stringify(" ") + ";"];
+ }
+
+ }
+}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexItemStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexItemStyle.as
new file mode 100644
index 0000000000..b53da0e9e5
--- /dev/null
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexItemStyle.as
@@ -0,0 +1,124 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.style.stylebeads
+{
+ public class FlexItemStyle extends StyleBeadBase
+ {
+ public function FlexItemStyle()
+ {
+ super();
+ }
+
+ public function get grow():Boolean
+ {
+ return _growFactor > 0;
+ }
+
+ public function set grow(value:Boolean):void
+ {
+ _growFactor = value ? 1 : 0;
+ }
+
+ private var _growFactor:Number;
+ public function get growFactor():Number
+ {
+ return _growFactor;
+ }
+ public function set growFactor(value:Number):void
+ {
+ _growFactor = value;
+ }
+
+
+ private var _shrink:Boolean;
+
+ public function get shrink():Boolean
+ {
+ return _shrinkFactor > 0;
+ }
+
+ public function set shrink(value:Boolean):void
+ {
+ _shrinkFactor = value ? 1 : 0;
+ }
+
+ private var _shrinkFactor:Number;
+
+ public function get shrinkFactor():Number
+ {
+ return _shrinkFactor;
+ }
+
+ public function set shrinkFactor(value:Number):void
+ {
+ _shrinkFactor = value;
+ }
+ private var _basis:String = "auto";
+
+ public function get basis():String
+ {
+ return _basis;
+ }
+
+ public function set basis(value:String):void
+ {
+ _basis = value;
+ }
+
+ private var _value:String;
+
+ private function computeShrink():String
+ {
+ if (isNaN(_shrinkFactor))
+ return "1";
+ return "" + _shrinkFactor;
+ }
+
+ private function computeGrow():String
+ {
+ if (isNaN(_growFactor))
+ return "1";
+ return "" + _growFactor;
+ }
+ private function computeBasis():String
+ {
+ return basis || "auto";
+ }
+
+ private function stringify(sep:String):String
+ {
+ var grow:String = computeGrow();
+ var shrink:String = computeShrink();
+ var basis:String = computeBasis();
+ if(grow == "0" && shrink == "0")
+ return "none";
+ return grow + sep + shrink + sep + basis;
+ }
+
+ override public function get selectors():Array
+ {
+ return [".flex-" + stringify("-")];
+ }
+
+ override public function get rules():Array
+ {
+ return ["flex:" + stringify(" ") + ";"];
+ }
+ }
+}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/IMeasurementStyleBead.as
similarity index 65%
copy from
frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
copy to
frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/IMeasurementStyleBead.as
index a6a30e6b79..84da136ed1 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/IMeasurementStyleBead.as
@@ -18,35 +18,9 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.style.stylebeads
{
- public class FlexStyle extends StyleBeadBase
+ public interface IMeasurementStyleBead extends IStyleBead
{
- public function FlexStyle()
- {
- super();
- }
-
- private var _value:String;
-
- [[Inspectable(category="General", enumeration="none,flex",
defaultValue="none")]]
- public function get value():String
- {
- return _value;
- }
-
- public function set value(value:String):void
- {
- _value = value;
- }
-
- override public function get selectors():Array
- {
- return ["." + value];
- }
-
- override public function get rules():Array
- {
- return ["display:" + value + ";"];
- }
-
+ function get unit():String;
+ function set unit(value:String):void;
}
}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/MeasurementStyleBase.as
similarity index 68%
copy from
frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
copy to
frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/MeasurementStyleBase.as
index a6a30e6b79..c401d31c74 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/MeasurementStyleBase.as
@@ -18,35 +18,24 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.style.stylebeads
{
- public class FlexStyle extends StyleBeadBase
+ import org.apache.royale.style.util.CSSUnit;
+
+ abstract public class MeasurementStyleBase extends StyleBeadBase
implements IMeasurementStyleBead
{
- public function FlexStyle()
+ public function MeasurementStyleBase()
{
super();
}
+ private var _unit:String;
- private var _value:String;
-
- [[Inspectable(category="General", enumeration="none,flex",
defaultValue="none")]]
- public function get value():String
- {
- return _value;
- }
-
- public function set value(value:String):void
+ public function get unit():String
{
- _value = value;
+ return _unit || CSSUnit.PX;
}
- override public function get selectors():Array
+ public function set unit(value:String):void
{
- return ["." + value];
+ _unit = value;
}
-
- override public function get rules():Array
- {
- return ["display:" + value + ";"];
- }
-
}
}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/PositionStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/PositionStyle.as
index 8f264ba573..88aa703b5b 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/PositionStyle.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/PositionStyle.as
@@ -18,7 +18,7 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.style.stylebeads
{
- public class PositionStyle extends StyleBeadBase
+ public class PositionStyle extends MeasurementStyleBase
{
public function PositionStyle()
{
@@ -45,7 +45,7 @@ package org.apache.royale.style.stylebeads
override public function get rules():Array
{
- return ["position:" + value + ";"];
+ return ["position:" + value + unit + ";"];
}
}
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/CSSUnit.as
similarity index 63%
rename from
frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
rename to
frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/CSSUnit.as
index a6a30e6b79..df86682335 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/stylebeads/FlexStyle.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/CSSUnit.as
@@ -16,37 +16,23 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package org.apache.royale.style.stylebeads
+package org.apache.royale.style.util
{
- public class FlexStyle extends StyleBeadBase
+ public class CSSUnit
{
- public function FlexStyle()
+ private function CSSUnit()
{
- super();
+ // Static only class.
}
-
- private var _value:String;
-
- [[Inspectable(category="General", enumeration="none,flex",
defaultValue="none")]]
- public function get value():String
- {
- return _value;
- }
-
- public function set value(value:String):void
- {
- _value = value;
- }
-
- override public function get selectors():Array
- {
- return ["." + value];
- }
-
- override public function get rules():Array
- {
- return ["display:" + value + ";"];
- }
-
+ public static const PX:String = "px";
+ public static const EM:String = "em";
+ public static const REM:String = "rem";
+ public static const PERCENT:String = "%";
+ public static const VW:String = "vw";
+ public static const VH:String = "vh";
+ public static const VMIN:String = "vmin";
+ public static const VMAX:String = "vmax";
+ public static const EX:String = "ex";
+ public static const CH:String = "ch";
}
}
\ No newline at end of file
diff --git
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/StyleManager.as
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/StyleManager.as
index de4cc2c9bd..8072ace786 100644
---
a/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/StyleManager.as
+++
b/frameworks/projects/Style/src/main/royale/org/apache/royale/style/util/StyleManager.as
@@ -65,5 +65,17 @@ package org.apache.royale.style.util
ss.insertRule(selector + "{" + rule + "}",
ruleIdx++);
}
}
+
+ private var _defaultUnit:String = "px";
+
+ public function get defaultUnit():String
+ {
+ return _defaultUnit;
+ }
+
+ public function set defaultUnit(value:String):void
+ {
+ _defaultUnit = value;
+ }
}
}
\ No newline at end of file