Skip to content

Commit

Permalink
Merge pull request #532 from Shallowmallow/ParseMultipleFilters
Browse files Browse the repository at this point in the history
Parse multiple filters
  • Loading branch information
ianharrigan committed Jun 20, 2023
2 parents 9a7cc6d + c7f1d61 commit bf13434
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions haxe/ui/styles/Style.hx
Original file line number Diff line number Diff line change
Expand Up @@ -401,35 +401,14 @@ 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 _:
}

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 _:
}
backdropFilter = [];
parseFilter(v.value, backdropFilter);

#end

Expand Down Expand Up @@ -789,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 = {};
Expand Down

0 comments on commit bf13434

Please sign in to comment.