From 17d3c9ec0c6066c7994a38fcadd78aaec21cfe9d Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Tue, 20 Jun 2023 09:57:41 +0200 Subject: [PATCH 1/2] Parse multiple filters --- haxe/ui/styles/Style.hx | 57 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index b078c088a..c637f3191 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -401,35 +401,46 @@ class Style { case "filter": #if !haxeui_nofilters - - switch (v.value) { - case Value.VCall(f, vl): - var arr = ValueTools.array(vl); - arr.insert(0, f); - filter = [FilterParser.parseFilter(arr)]; - case Value.VConstant(f): - filter = [FilterParser.parseFilter([f])]; - case Value.VNone: - filter = null; - case _: + function parseFilter(value, filters) { + switch (value) { + case Value.VCall(f, vl): + var arr = ValueTools.array(vl); + arr.insert(0, f); + filters.push(FilterParser.parseFilter(arr)); + case Value.VConstant(f): + filters.push(FilterParser.parseFilter([f])); + case Value.VComposite(vl): + for ( v in vl ){ + parseFilter(v, filters); + } + case _: + } + return filters; } - + filter = []; + parseFilter(v.value, filter); #end case "backdrop-filter": #if !haxeui_nofilters - - switch (v.value) { - case Value.VCall(f, vl): - var arr = ValueTools.array(vl); - arr.insert(0, f); - backdropFilter = [FilterParser.parseFilter(arr)]; - case Value.VConstant(f): - backdropFilter = [FilterParser.parseFilter([f])]; - case Value.VNone: - backdropFilter = null; - case _: + function parseFilter(value, filters) { + switch (value) { + case Value.VCall(f, vl): + var arr = ValueTools.array(vl); + arr.insert(0, f); + filters.push(FilterParser.parseFilter(arr)); + case Value.VConstant(f): + filters.push(FilterParser.parseFilter([f])); + case Value.VComposite(vl): + for ( v in vl ){ + parseFilter(v, filters); + } + case _: + } + return filters; } + backdropFilter = []; + parseFilter(v.value, backdropFilter); #end From c7f1d6199cb0f43c76d98b1cbb234eaf3e4febee Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Tue, 20 Jun 2023 10:23:11 +0200 Subject: [PATCH 2/2] Moving parseFilters local function to a private function --- haxe/ui/styles/Style.hx | 49 ++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index c637f3191..d4bd1fa99 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -401,44 +401,12 @@ class Style { case "filter": #if !haxeui_nofilters - function parseFilter(value, filters) { - switch (value) { - case Value.VCall(f, vl): - var arr = ValueTools.array(vl); - arr.insert(0, f); - filters.push(FilterParser.parseFilter(arr)); - case Value.VConstant(f): - filters.push(FilterParser.parseFilter([f])); - case Value.VComposite(vl): - for ( v in vl ){ - parseFilter(v, filters); - } - case _: - } - return filters; - } filter = []; parseFilter(v.value, filter); #end case "backdrop-filter": #if !haxeui_nofilters - function parseFilter(value, filters) { - switch (value) { - case Value.VCall(f, vl): - var arr = ValueTools.array(vl); - arr.insert(0, f); - filters.push(FilterParser.parseFilter(arr)); - case Value.VConstant(f): - filters.push(FilterParser.parseFilter([f])); - case Value.VComposite(vl): - for ( v in vl ){ - parseFilter(v, filters); - } - case _: - } - return filters; - } backdropFilter = []; parseFilter(v.value, backdropFilter); @@ -800,6 +768,23 @@ class Style { private inline function createAnimationOptions() { if (animationOptions == null) animationOptions = {}; } + + private function parseFilter(value, filters) { + switch (value) { + case Value.VCall(f, vl): + var arr = ValueTools.array(vl); + arr.insert(0, f); + filters.push(FilterParser.parseFilter(arr)); + case Value.VConstant(f): + filters.push(FilterParser.parseFilter([f])); + case Value.VComposite(vl): + for ( v in vl ){ + parseFilter(v, filters); + } + case _: + } + return filters; + } public function clone():Style { var c:Style = {};