From 4675b6e142a2110bcbafcd4610f10f062b45d8b7 Mon Sep 17 00:00:00 2001 From: swordcube <49110074+swordcube@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:10:16 -0500 Subject: [PATCH 1/4] Fix compiling errors with haxeui-flixel A recent commit was made that makes set_height in Panel use Null, however this causes a compiler error when using the Flixel backend of HaxeUI, since FlxObjects do not take in a Null for their height --- haxe/ui/containers/Panel.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haxe/ui/containers/Panel.hx b/haxe/ui/containers/Panel.hx index 55d55e0a4..d14ee1e51 100644 --- a/haxe/ui/containers/Panel.hx +++ b/haxe/ui/containers/Panel.hx @@ -49,7 +49,7 @@ class Panel extends VBox { return super.set_percentHeight(value); } - #if ((haxeui_openfl || haxeui_nme) && !haxeui_flixel) + #if (haxeui_openfl || haxeui_nme || haxeui_flixel) public override function set_height(value:Float):Float { contentContainer.percentHeight = 100; From 9df3c2a1abeedf25ac2867c60e592036b123b342 Mon Sep 17 00:00:00 2001 From: Jarrio Date: Mon, 21 Oct 2024 13:47:41 +0100 Subject: [PATCH 2/4] Update Style.hx - Added font weight support --- haxe/ui/styles/Style.hx | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index fdbddacf5..cc3ec7028 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -13,6 +13,33 @@ enum StyleBorderType { Compound; } +enum abstract FontWeight(Int) from Int { + var THIN = 100; + var EXTRA_LIGHT = 200; + var LIGHT = 300; + var REGULAR = 400; + var MEDIUM = 500; + var SEMI_BOLD = 600; + var BOLD = 700; + var EXTRA_BOLD = 800; + var BLACK = 900; + + @:from static public function fromString(value:String) { + return switch(value.toLowerCase()) { + case 'thin': THIN; + case 'extra_light': EXTRA_LIGHT; + case 'light': LIGHT; + case 'regular': REGULAR; + case 'medium': MEDIUM; + case 'semi_bold': SEMI_BOLD; + case 'bold': BOLD; + case 'extra_bold': EXTRA_BOLD; + case 'black': BLACK; + default: REGULAR; + } + } +} + @:structInit class Style { /** The left (x) position relative to its parent. **/ @:optional public var left:Null; @@ -118,6 +145,7 @@ class Style { /** A path to a font file to be used for the text inside the object **/ @:optional public var fontName:Null; /** The visual size of the font **/ @:optional public var fontSize:Null; /** Whether or not this text should use the **bold** variation of its font **/ @:optional public var fontBold:Null; + /** The weight of the font in increments of 100 **/ @:optional public var fontWeight:Null; /** Whether or not to underline the text **/ @:optional public var fontUnderline:Null; /** Whether or not this text should use the *italic* variation of its font **/ @:optional public var fontItalic:Null; @:optional public var fontStrikeThrough:Null; @@ -409,9 +437,7 @@ class Style { case "font-size": fontSize = ValueTools.calcDimension(v.value); case "font-weight": - if (ValueTools.string(v.value) != null) { - fontBold = ValueTools.string(v.value).toLowerCase() == "bold"; - } + fontWeight = ValueTools.int(v.value); case "font-bold": fontBold = ValueTools.bool(v.value); case "font-underline": @@ -673,6 +699,7 @@ class Style { if (s.fontName != null) fontName = s.fontName; if (s.fontSize != null) fontSize = s.fontSize; if (s.fontBold != null) fontBold = s.fontBold; + if (s.fontWeight != null) fontWeight = s.fontWeight; if (s.fontUnderline != null) fontUnderline = s.fontUnderline; if (s.fontStrikeThrough != null) fontStrikeThrough = s.fontStrikeThrough; if (s.fontItalic != null) fontItalic = s.fontItalic; @@ -836,6 +863,7 @@ class Style { if (s.fontName != fontName) return false; if (s.fontSize != fontSize) return false; if (s.fontBold != fontBold) return false; + if (s.fontWeight != fontWeight) return false; if (s.fontUnderline != fontUnderline) return false; if (s.fontStrikeThrough != fontStrikeThrough) return false; if (s.fontItalic != fontItalic) return false; From 0beab28a99bbda3f1d98ff7079aa9a8be74474ef Mon Sep 17 00:00:00 2001 From: Jarrio Date: Mon, 21 Oct 2024 13:53:07 +0100 Subject: [PATCH 3/4] Update Style.hx --- haxe/ui/styles/Style.hx | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index cc3ec7028..e5380b662 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -23,21 +23,6 @@ enum abstract FontWeight(Int) from Int { var BOLD = 700; var EXTRA_BOLD = 800; var BLACK = 900; - - @:from static public function fromString(value:String) { - return switch(value.toLowerCase()) { - case 'thin': THIN; - case 'extra_light': EXTRA_LIGHT; - case 'light': LIGHT; - case 'regular': REGULAR; - case 'medium': MEDIUM; - case 'semi_bold': SEMI_BOLD; - case 'bold': BOLD; - case 'extra_bold': EXTRA_BOLD; - case 'black': BLACK; - default: REGULAR; - } - } } @:structInit From ecd74e5695310a83a8dbe02f6b493cc58735bc54 Mon Sep 17 00:00:00 2001 From: Jarrio Date: Mon, 21 Oct 2024 19:25:29 +0100 Subject: [PATCH 4/4] Update Style.hx - Add old code back --- haxe/ui/styles/Style.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index e5380b662..66f513a47 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -422,6 +422,9 @@ class Style { case "font-size": fontSize = ValueTools.calcDimension(v.value); case "font-weight": + if (ValueTools.string(v.value) != null) { + fontBold = ValueTools.string(v.value).toLowerCase() == "bold"; + } fontWeight = ValueTools.int(v.value); case "font-bold": fontBold = ValueTools.bool(v.value);