Skip to content

Commit

Permalink
allow for color properties to be autoconverted
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed May 7, 2024
1 parent 3364b2e commit d723b90
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions haxe/ui/core/ItemRenderer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import haxe.ui.events.ItemEvent;
import haxe.ui.events.ItemRendererEvent;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.util.Color;
import haxe.ui.util.TypeConverter;
import haxe.ui.util.Variant;

Expand Down Expand Up @@ -264,9 +265,9 @@ class ItemRenderer extends Box {
if (property == "value") {
c.value = propValue;
} else if (typeInfo == "variant") {
Reflect.setProperty(c, property, Variant.fromDynamic(v));
Reflect.setProperty(c, property, Variant.fromDynamic(propValue));
} else {
Reflect.setProperty(c, property, v);
Reflect.setProperty(c, property, propValue);
}

if (autoRegisterInteractiveEvents) {
Expand Down
1 change: 1 addition & 0 deletions haxe/ui/macros/Macros.hx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class Macros {

for (f in builder.getFieldsWithMeta("style")) {
f.remove();
RTTI.addClassProperty(builder.fullPath, f.name, ComplexTypeTools.toString(f.type));

var defaultValue:Dynamic = null;
if (f.isNumeric == true) {
Expand Down
1 change: 1 addition & 0 deletions haxe/ui/util/RTTI.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class RTTI {
if (propertyType == "null<bool>") propertyType = "bool";
if (propertyType == "null<int>") propertyType = "int";
if (propertyType == "null<float>") propertyType = "float";
if (propertyType == "null<color>") propertyType = "color";

if (classInfo == null) {
classInfo = new Map<String, RTTIEntry>();
Expand Down
2 changes: 2 additions & 0 deletions haxe/ui/util/TypeConverter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class TypeConverter {
return 0;
}
return r;
case "color":
return Color.fromString(Std.string(input));
case "variant" | "dynamic" | "scalemode" | "selectionmode" | "scrollpolicy" | "scrollmode":
return input;
case _:
Expand Down

0 comments on commit d723b90

Please sign in to comment.