From 57f59e7da8ae83f1ad952e410601409eecf2e1c4 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 11 Nov 2021 01:01:30 +0800 Subject: Add Dispose Here region, introduce ValueAnimator --- .../client/favorites/CompoundFavoriteRenderer.java | 7 +- .../client/gui/animator/ConstantValueProvider.java | 53 + .../gui/animator/ConventionValueAnimator.java | 67 + .../gui/animator/DoubleValueAnimatorImpl.java | 109 ++ .../gui/animator/MappingProgressValueAnimator.java | 68 + .../client/gui/animator/MappingValueAnimator.java | 62 + .../api/client/gui/animator/NumberAnimator.java | 116 ++ .../client/gui/animator/NumberAnimatorWrapped.java | 80 ++ .../client/gui/animator/ProgressValueAnimator.java | 46 + .../client/gui/animator/RecordValueAnimator.java | 155 ++ .../gui/animator/RecordValueAnimatorArgs.java | 1487 ++++++++++++++++++++ .../rei/api/client/gui/animator/ValueAnimator.java | 192 +++ .../animator/ValueAnimatorAsNumberAnimator.java | 70 + .../rei/api/client/gui/animator/ValueProvider.java | 73 + .../rei/api/client/gui/drag/DraggingContext.java | 6 + .../api/common/category/CategoryIdentifier.java | 5 + .../me/shedaniel/rei/api/common/util/Animator.java | 6 + .../fabric/RoughlyEnoughItemsInitializerImpl.java | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 2 +- runtime/build.gradle | 1 + .../client/gui/dragging/CurrentDraggingStack.java | 40 +- .../gui/screen/UncertainDisplayViewingScreen.java | 5 +- .../impl/client/gui/widget/EntryListWidget.java | 4 +- .../client/gui/widget/EntryStacksRegionWidget.java | 6 +- .../client/gui/widget/FavoritesListWidget.java | 101 +- .../gui/widget/basewidgets/ButtonWidget.java | 18 +- .../basewidgets/FillRectangleDrawableConsumer.java | 10 +- .../client/gui/widget/basewidgets/LabelWidget.java | 36 +- .../client/gui/widget/region/RealRegionEntry.java | 24 +- .../gui/widget/region/RegionDraggableStack.java | 2 +- .../gui/widget/region/RegionEntryListEntry.java | 5 +- .../assets/roughlyenoughitems/lang/en_us.json | 1 + 33 files changed, 2755 insertions(+), 106 deletions(-) create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimatorArgs.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueAnimatorAsNumberAnimator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueProvider.java diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java index e9ce917dd..2ccba2166 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java @@ -29,7 +29,8 @@ import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.common.util.Animator; +import me.shedaniel.rei.api.client.gui.animator.NumberAnimator; +import me.shedaniel.rei.api.client.gui.animator.ValueAnimator; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.Util; @@ -40,7 +41,7 @@ import java.util.function.IntSupplier; @Environment(EnvType.CLIENT) public class CompoundFavoriteRenderer extends AbstractRenderer { - protected Animator offset = new Animator(0); + protected NumberAnimator offset = ValueAnimator.ofDouble(); protected Rectangle scissorArea = new Rectangle(); protected long nextSwitch = -1; protected IntFunction renderers; @@ -114,7 +115,7 @@ public class CompoundFavoriteRenderer extends AbstractRenderer { } if (Util.getMillis() - nextSwitch > 1000) { nextSwitch = Util.getMillis(); - offset.setTo(((int) offset.target() + 1) % count, 500); + offset.setTo((offset.target().intValue() + 1) % count, 500); } } else { offset.setTo(supplier.getAsInt() % count, 500); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java new file mode 100644 index 000000000..f213702b4 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java @@ -0,0 +1,53 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +final class ConstantValueProvider implements ValueProvider { + private final T value; + + public ConstantValueProvider(T value) { + this.value = value; + } + + @Override + public T value() { + return value; + } + + @Override + public T target() { + return value; + } + + @Override + public void completeImmediately() { + } + + @Override + public void update(double delta) { + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java new file mode 100644 index 000000000..41f4e8263 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java @@ -0,0 +1,67 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.Objects; +import java.util.function.Supplier; + +@ApiStatus.Internal +final class ConventionValueAnimator implements ValueAnimator { + private final ValueAnimator parent; + private final Supplier convention; + private final long duration; + + ConventionValueAnimator(ValueAnimator parent, Supplier convention, long duration) { + this.parent = parent; + this.convention = convention; + this.duration = duration; + setAs(convention.get()); + } + + @Override + public ValueAnimator setTo(T value, long duration) { + return parent.setTo(value, duration); + } + + @Override + public T target() { + return convention.get(); + } + + @Override + public T value() { + return parent.value(); + } + + @Override + public void update(double delta) { + parent.update(delta); + T target = target(); + if (!Objects.equals(parent.target(), target)) { + setTo(target, duration); + } + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java new file mode 100644 index 000000000..d3db45a40 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java @@ -0,0 +1,109 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import me.shedaniel.clothconfig2.impl.EasingMethod; +import net.minecraft.Util; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +final class DoubleValueAnimatorImpl extends NumberAnimator { + private double amount; + private double target; + private long start; + private long duration; + + DoubleValueAnimatorImpl() { + } + + DoubleValueAnimatorImpl(double amount) { + setAs(amount); + } + + @Override + public NumberAnimator setToNumber(Number value, long duration) { + double doubleValue = value.doubleValue(); + if (target != doubleValue) { + this.set(doubleValue, duration); + } + + return this; + } + + private void set(double value, long duration) { + this.target = value; + this.start = Util.getMillis(); + + if (duration > 0) { + this.duration = duration; + } else { + this.duration = 0; + this.amount = this.target; + } + } + + @Override + public void update(double delta) { + if (duration != 0) { + if (amount < target) { + this.amount = Math.min(ease(amount, target + (target - amount), Math.min(((double) Util.getMillis() - start) / duration * delta * 3.0D, 1.0D), EasingMethod.EasingMethodImpl.LINEAR), target); + } else if (amount > target) { + this.amount = Math.max(ease(amount, target - (amount - target), Math.min(((double) Util.getMillis() - start) / duration * delta * 3.0D, 1.0D), EasingMethod.EasingMethodImpl.LINEAR), target); + } + } + } + + private static double ease(double start, double end, double amount, EasingMethod easingMethod) { + return start + (end - start) * easingMethod.apply(amount); + } + + @Override + public int intValue() { + return (int) amount; + } + + @Override + public long longValue() { + return (long) amount; + } + + @Override + public float floatValue() { + return (float) amount; + } + + @Override + public double doubleValue() { + return amount; + } + + public Double target() { + return target; + } + + @Override + public Double value() { + return amount; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java new file mode 100644 index 000000000..6de268b2a --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java @@ -0,0 +1,68 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.function.Function; + +@ApiStatus.Internal +final class MappingProgressValueAnimator implements ProgressValueAnimator { + private final ValueAnimator parent; + private final Function converter; + private final Function backwardsConverter; + + MappingProgressValueAnimator(ValueAnimator parent, Function converter, Function backwardsConverter) { + this.parent = parent; + this.converter = converter; + this.backwardsConverter = backwardsConverter; + } + + @Override + public ProgressValueAnimator setTo(R value, long duration) { + parent.setTo(backwardsConverter.apply(value), duration); + return this; + } + + @Override + public R target() { + return converter.apply(parent.target()); + } + + @Override + public R value() { + return converter.apply(parent.value()); + } + + @Override + public void update(double delta) { + parent.update(delta); + } + + + @Override + public double progress() { + return parent.value() / 100; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java new file mode 100644 index 000000000..947807972 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java @@ -0,0 +1,62 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.function.Function; + +@ApiStatus.Internal +final class MappingValueAnimator implements ValueAnimator { + private final ValueAnimator parent; + private final Function converter; + private final Function backwardsConverter; + + MappingValueAnimator(ValueAnimator parent, Function converter, Function backwardsConverter) { + this.parent = parent; + this.converter = converter; + this.backwardsConverter = backwardsConverter; + } + + @Override + public ValueAnimator setTo(R value, long duration) { + parent.setTo(backwardsConverter.apply(value), duration); + return this; + } + + @Override + public R target() { + return converter.apply(parent.target()); + } + + @Override + public R value() { + return converter.apply(parent.value()); + } + + @Override + public void update(double delta) { + parent.update(delta); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java new file mode 100644 index 000000000..bf12081ed --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java @@ -0,0 +1,116 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.function.Supplier; + +@ApiStatus.Experimental +public abstract class NumberAnimator extends Number implements ValueAnimator { + public NumberAnimator asDouble() { + return new NumberAnimatorWrapped<>(this, Number::doubleValue); + } + + public NumberAnimator asFloat() { + return new NumberAnimatorWrapped<>(this, Number::floatValue); + } + + public NumberAnimator asInt() { + return new NumberAnimatorWrapped<>(this, d -> (int) Math.round(d.doubleValue())); + } + + public NumberAnimator asLong() { + return new NumberAnimatorWrapped<>(this, d -> Math.round(d.doubleValue())); + } + + @Override + public NumberAnimator setAs(T value) { + ValueAnimator.super.setAs(value); + return this; + } + + public NumberAnimator setAs(int value) { + setAsNumber(value); + return this; + } + + public NumberAnimator setAs(long value) { + setAsNumber(value); + return this; + } + + public NumberAnimator setAs(float value) { + setAsNumber(value); + return this; + } + + public NumberAnimator setAs(double value) { + setAsNumber(value); + return this; + } + + @Override + public NumberAnimator setTo(T value, long duration) { + setToNumber(value, duration); + return this; + } + + public NumberAnimator setTo(int value, long duration) { + setToNumber(value, duration); + return this; + } + + public NumberAnimator setTo(long value, long duration) { + setToNumber(value, duration); + return this; + } + + public NumberAnimator setTo(float value, long duration) { + setToNumber(value, duration); + return this; + } + + public NumberAnimator setTo(double value, long duration) { + setToNumber(value, duration); + return this; + } + + public NumberAnimator setAsNumber(Number value) { + return setToNumber(value, -1); + } + + public abstract NumberAnimator setToNumber(Number value, long duration); + + @Override + public NumberAnimator withConvention(Supplier convention, long duration) { + ValueAnimator parentConvention = ValueAnimator.super.withConvention(convention, duration); + return new ValueAnimatorAsNumberAnimator(parentConvention) { + @Override + public NumberAnimator setToNumber(Number value, long duration) { + return NumberAnimator.this.setToNumber(value, duration); + } + }; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java new file mode 100644 index 000000000..0214fb637 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java @@ -0,0 +1,80 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.function.Function; + +@ApiStatus.Internal +final class NumberAnimatorWrapped extends NumberAnimator { + private final NumberAnimator parent; + private final Function converter; + + NumberAnimatorWrapped(NumberAnimator parent, Function converter) { + this.parent = parent; + this.converter = converter; + } + + @Override + public NumberAnimator setToNumber(Number value, long duration) { + this.parent.setToNumber(value, duration); + return this; + } + + @Override + public T target() { + return converter.apply(parent.target()); + } + + @Override + public T value() { + return converter.apply(parent.value()); + } + + @Override + public void update(double delta) { + parent.update(delta); + } + + @Override + public int intValue() { + return parent.intValue(); + } + + @Override + public long longValue() { + return parent.longValue(); + } + + @Override + public float floatValue() { + return parent.floatValue(); + } + + @Override + public double doubleValue() { + return parent.doubleValue(); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java new file mode 100644 index 000000000..e7f596092 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java @@ -0,0 +1,46 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.function.Function; + +@ApiStatus.Experimental +public interface ProgressValueAnimator extends ValueAnimator { + double progress(); + + @Override + default ProgressValueAnimator setAs(T value) { + ValueAnimator.super.setAs(value); + return this; + } + + @Override + ProgressValueAnimator setTo(T value, long duration); + + static ProgressValueAnimator mapProgress(NumberAnimator parent, Function converter, Function backwardsConverter) { + return new MappingProgressValueAnimator<>(parent.asDouble(), converter, backwardsConverter); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java new file mode 100644 index 000000000..df17adaf1 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java @@ -0,0 +1,155 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; + +@ApiStatus.Internal +final class RecordValueAnimator> implements ValueAnimator { + private final A arg; + + RecordValueAnimator(A arg) { + this.arg = arg; + } + + @Override + public ValueAnimator setTo(T value, long duration) { + arg.set(value, duration); + return this; + } + + @Override + public T target() { + return arg.target(); + } + + @Override + public T value() { + return arg.value(); + } + + @Override + public void update(double delta) { + for (ValueAnimator dependency : arg.dependencies()) { + dependency.update(delta); + } + } + + @FunctionalInterface + public interface Setter { + void set(T value); + } + + public interface Arg { + List> dependencies(); + + void set(T value, long duration); + + T target(); + + T value(); + } + + public static RecordValueAnimator> of(ValueAnimator a1, RecordValueAnimatorArgs.Arg1.Op op, RecordValueAnimatorArgs.Arg1.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg1<>(a1, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, RecordValueAnimatorArgs.Arg2.Op op, RecordValueAnimatorArgs.Arg2.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg2<>(a1, a2, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, RecordValueAnimatorArgs.Arg3.Op op, RecordValueAnimatorArgs.Arg3.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg3<>(a1, a2, a3, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, RecordValueAnimatorArgs.Arg4.Op op, RecordValueAnimatorArgs.Arg4.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg4<>(a1, a2, a3, a4, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, RecordValueAnimatorArgs.Arg5.Op op, RecordValueAnimatorArgs.Arg5.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg5<>(a1, a2, a3, a4, a5, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, RecordValueAnimatorArgs.Arg6.Op op, RecordValueAnimatorArgs.Arg6.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg6<>(a1, a2, a3, a4, a5, a6, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, RecordValueAnimatorArgs.Arg7.Op op, RecordValueAnimatorArgs.Arg7.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg7<>(a1, a2, a3, a4, a5, a6, a7, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, RecordValueAnimatorArgs.Arg8.Op op, RecordValueAnimatorArgs.Arg8.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg8<>(a1, a2, a3, a4, a5, a6, a7, a8, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, RecordValueAnimatorArgs.Arg9.Op op, RecordValueAnimatorArgs.Arg9.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg9<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, RecordValueAnimatorArgs.Arg10.Op op, RecordValueAnimatorArgs.Arg10.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg10<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, RecordValueAnimatorArgs.Arg11.Op op, RecordValueAnimatorArgs.Arg11.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg11<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, RecordValueAnimatorArgs.Arg12.Op op, RecordValueAnimatorArgs.Arg12.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg12<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, RecordValueAnimatorArgs.Arg13.Op op, RecordValueAnimatorArgs.Arg13.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg13<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, RecordValueAnimatorArgs.Arg14.Op op, RecordValueAnimatorArgs.Arg14.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg14<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, RecordValueAnimatorArgs.Arg15.Op op, RecordValueAnimatorArgs.Arg15.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg15<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, ValueAnimator a16, RecordValueAnimatorArgs.Arg16.Op op, RecordValueAnimatorArgs.Arg16.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg16<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, ValueAnimator a16, ValueAnimator a17, RecordValueAnimatorArgs.Arg17.Op op, RecordValueAnimatorArgs.Arg17.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg17<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, ValueAnimator a16, ValueAnimator a17, ValueAnimator a18, RecordValueAnimatorArgs.Arg18.Op op, RecordValueAnimatorArgs.Arg18.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg18<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, ValueAnimator a16, ValueAnimator a17, ValueAnimator a18, ValueAnimator a19, RecordValueAnimatorArgs.Arg19.Op op, RecordValueAnimatorArgs.Arg19.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg19<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, op, up)); + } + + public static RecordValueAnimator> of(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, ValueAnimator a9, ValueAnimator a10, ValueAnimator a11, ValueAnimator a12, ValueAnimator a13, ValueAnimator a14, ValueAnimator a15, ValueAnimator a16, ValueAnimator a17, ValueAnimator a18, ValueAnimator a19, ValueAnimator a20, RecordValueAnimatorArgs.Arg20.Op op, RecordValueAnimatorArgs.Arg20.Up up) { + return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg20<>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, op, up)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimatorArgs.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimatorArgs.java new file mode 100644 index 000000000..5ba458c8c --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimatorArgs.java @@ -0,0 +1,1487 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.animator; + +import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; + +@ApiStatus.Internal +class RecordValueAnimatorArgs { + @FunctionalInterface + public interface Setter { + void set(T value); + } + + public static class Arg1 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final Op op; + private final Up up; + + public Arg1(ValueAnimator a1, Op op, Up up) { + this.a1 = a1; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration)); + } + + @Override + public T target() { + return op.construct(a1.target()); + } + + @Override + public T value() { + return op.construct(a1.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1); + } + } + + public static class Arg2 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final Op op; + private final Up up; + + public Arg2(ValueAnimator a1, ValueAnimator a2, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2); + } + } + + public static class Arg3 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final Op op; + private final Up up; + + public Arg3(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2, Setter arg3); + } + } + + public static class Arg4 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final ValueAnimator a4; + private final Op op; + private final Up up; + + public Arg4(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.a4 = a4; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .add(a4) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration), v4 -> a4.setTo(v4, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target(), a4.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value(), a4.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2, Setter arg3, Setter arg4); + } + } + + public static class Arg5 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final ValueAnimator a4; + private final ValueAnimator a5; + private final Op op; + private final Up up; + + public Arg5(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.a4 = a4; + this.a5 = a5; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .add(a4) + .add(a5) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration), v4 -> a4.setTo(v4, duration), v5 -> a5.setTo(v5, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target(), a4.target(), a5.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value(), a4.value(), a5.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2, Setter arg3, Setter arg4, Setter arg5); + } + } + + public static class Arg6 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final ValueAnimator a4; + private final ValueAnimator a5; + private final ValueAnimator a6; + private final Op op; + private final Up up; + + public Arg6(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.a4 = a4; + this.a5 = a5; + this.a6 = a6; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .add(a4) + .add(a5) + .add(a6) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration), v4 -> a4.setTo(v4, duration), v5 -> a5.setTo(v5, duration), v6 -> a6.setTo(v6, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target(), a4.target(), a5.target(), a6.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value(), a4.value(), a5.value(), a6.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2, Setter arg3, Setter arg4, Setter arg5, Setter arg6); + } + } + + public static class Arg7 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final ValueAnimator a4; + private final ValueAnimator a5; + private final ValueAnimator a6; + private final ValueAnimator a7; + private final Op op; + private final Up up; + + public Arg7(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.a4 = a4; + this.a5 = a5; + this.a6 = a6; + this.a7 = a7; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .add(a4) + .add(a5) + .add(a6) + .add(a7) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration), v4 -> a4.setTo(v4, duration), v5 -> a5.setTo(v5, duration), v6 -> a6.setTo(v6, duration), v7 -> a7.setTo(v7, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target(), a4.target(), a5.target(), a6.target(), a7.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value(), a4.value(), a5.value(), a6.value(), a7.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7); + } + + @FunctionalInterface + public interface Up { + void update(T value, Setter arg1, Setter arg2, Setter arg3, Setter arg4, Setter arg5, Setter arg6, Setter arg7); + } + } + + public static class Arg8 implements RecordValueAnimator.Arg { + private final ValueAnimator a1; + private final ValueAnimator a2; + private final ValueAnimator a3; + private final ValueAnimator a4; + private final ValueAnimator a5; + private final ValueAnimator a6; + private final ValueAnimator a7; + private final ValueAnimator a8; + private final Op op; + private final Up up; + + public Arg8(ValueAnimator a1, ValueAnimator a2, ValueAnimator a3, ValueAnimator a4, ValueAnimator a5, ValueAnimator a6, ValueAnimator a7, ValueAnimator a8, Op op, Up up) { + this.a1 = a1; + this.a2 = a2; + this.a3 = a3; + this.a4 = a4; + this.a5 = a5; + this.a6 = a6; + this.a7 = a7; + this.a8 = a8; + this.op = op; + this.up = up; + } + + @Override + public List> dependencies() { + return ImmutableList.>builder() + .add(a1) + .add(a2) + .add(a3) + .add(a4) + .add(a5) + .add(a6) + .add(a7) + .add(a8) + .build(); + } + + @Override + public void set(T value, long duration) { + up.update(value, v1 -> a1.setTo(v1, duration), v2 -> a2.setTo(v2, duration), v3 -> a3.setTo(v3, duration), v4 -> a4.setTo(v4, duration), v5 -> a5.setTo(v5, duration), v6 -> a6.setTo(v6, duration), v7 -> a7.setTo(v7, duration), v8 -> a8.setTo(v8, duration)); + } + + @Override + public T target() { + return op.construct(a1.target(), a2.target(), a3.target(), a4.target(), a5.target(), a6.target(), a7.target(), a8.target()); + } + + @Override + public T value() { + return op.construct(a1.value(), a2.value(), a3.value(), a4.value(), a5.value(), a6.value(), a7.value(), a8.value()); + } + + @FunctionalInterface + public interface Op { + T construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7, A8 arg8); + } + + @