From 411a7bfcdcbda96b0e9d3e58c8e2619e95427719 Mon Sep 17 00:00:00 2001 From: "instance.id" Date: Fri, 9 Jun 2023 16:51:07 -0500 Subject: [PATCH] Added several new animations, helper datatypes, etc. Updated to 2022.2 --- .../Animations/ContinuousAnimations.cs | 6 + .../Runtime/Animations/Easy.cs | 38 +- .../Runtime/Animations/HoverAnimations.cs | 119 +- .../Animations/VisualElementBaseAnimation.cs | 386 ++- .../AnimatedFoldout/AnimatedFoldout.cs | 195 +- .../AnimatedFoldout/Resources.meta} | 2 +- .../AnimatedFoldout/Resources/Style.meta | 3 + .../Resources/Style/AnimatedFoldoutStyle.sass | 4 + .../Style/AnimatedFoldoutStyle.sass.meta} | 4 +- .../Resources/Style/AnimatedFoldoutStyle.uss | 45 + .../Style/AnimatedFoldoutStyle.uss.meta | 11 + .../Resources/Style/elements.meta | 8 + .../Resources/Style/elements/_containers.sass | 35 + .../Style/elements/_containers.sass.meta | 7 + .../Resources/Style/elements/_index.sass | 3 + .../Resources/Style/elements/_index.sass.meta | 7 + .../AnimatedFoldout/UIElementExpander.cs | 111 +- .../Attributes/EditorFieldAttribute.cs | 12 +- .../Enhancements/FastLinq/FastLinq.asmdef | 3 - .../FastLinq/ImprovedAggregate.cs | 153 - .../Enhancements/FastLinq/ImprovedAll.cs | 59 - .../Enhancements/FastLinq/ImprovedAny.cs | 92 - .../Enhancements/FastLinq/ImprovedContains.cs | 67 - .../Enhancements/FastLinq/ImprovedCount.cs | 79 - .../FastLinq/ImprovedCount.cs.meta | 11 - .../Enhancements/FastLinq/ImprovedFirst.cs | 79 - .../FastLinq/ImprovedFirst.cs.meta | 11 - .../FastLinq/ImprovedFirstOrDefault.cs | 73 - .../FastLinq/ImprovedFirstOrDefault.cs.meta | 11 - .../Enhancements/FastLinq/ImprovedLast.cs | 105 - .../FastLinq/ImprovedLast.cs.meta | 11 - .../FastLinq/ImprovedLastOrDefault.cs | 105 - .../FastLinq/ImprovedLastOrDefault.cs.meta | 11 - .../FastLinq/ImprovedSequenceEqual.cs | 70 - .../FastLinq/ImprovedSequenceEqual.cs.meta | 11 - .../Runtime/Enhancements/Tasks.meta | 8 + .../Enhancements/Tasks/ITaskSequence.cs | 32 + .../Enhancements/Tasks/ITaskSequence.cs.meta | 3 + .../Runtime/Enhancements/Tasks/SingleTask.cs | 62 + .../Enhancements/Tasks/SingleTask.cs.meta | 3 + .../Runtime/Enhancements/Tasks/WaitUntil.cs | 46 + .../Enhancements/Tasks/WaitUntil.cs.meta | 3 + .../Scripts/Extensions/AssetFileExtensions.cs | 45 +- .../Extensions/DataTypes/AnimColorStore.cs | 38 + .../DataTypes/AnimColorStore.cs.meta} | 2 +- .../Scripts/Extensions/DataTypes/AnimTime.cs | 23 + .../Extensions/DataTypes/AnimTime.cs.meta} | 2 +- .../Extensions/DataTypes/AnimValueStore.cs | 271 ++ .../DataTypes/AnimValueStore.cs.meta} | 2 +- .../Extensions/DataTypes/AnimateElement.cs | 76 + .../DataTypes/AnimateElement.cs.meta} | 2 +- .../Scripts/Extensions/DataTypes/ClassData.cs | 2 +- .../Scripts/Extensions/DataTypes/Editor.meta | 8 + .../Editor/SerializedDictionaryEditor.cs | 351 ++ .../Editor/SerializedDictionaryEditor.cs.meta | 3 + .../Scripts/Extensions/DataTypes/GetEasing.cs | 51 + .../Extensions/DataTypes/GetEasing.cs.meta | 11 + .../Extensions/DataTypes/ImageAsset.cs | 23 + .../Extensions/DataTypes/ImageAsset.cs.meta | 11 + .../DataTypes/SerializedDictionary.cs | 84 + .../DataTypes/SerializedDictionary.cs.meta | 11 + .../Extensions/DataTypes/VersionElement.meta | 8 + .../VersionElement/VersionElement.cs | 105 + .../VersionElement/VersionElement.cs.meta | 3 + .../ElementGeneration/ContainerData.cs | 8 +- .../ElementGeneration/ContainerType.cs | 12 + .../ElementGeneration/ContainerType.cs.meta | 11 + .../ElementGeneration/ElementGeneration.cs | 277 +- .../ElementGeneration/IMGuiObject.cs | 92 + .../ElementGeneration/IMGuiObject.cs.meta | 11 + .../UIElementsEditorHelper.cs | 231 ++ .../UIElementsEditorHelper.cs.meta | 11 + .../Elements/VisualElementExtension.cs | 1537 +++++++++ .../Elements/VisualElementExtension.cs.meta | 11 + .../Scripts/Extensions/LinqExtensions.cs | 347 ++ .../Scripts/Extensions/LinqExtensions.cs.meta | 11 + .../Scripts/Extensions/ParseElements.cs | 6 + .../Scripts/Extensions/PropertyExtensions.cs | 14 + .../Extensions/PropertyExtensions.cs.meta | 11 + .../Scripts/Extensions/ReflectionExten.cs | 18 +- .../Runtime/Scripts/Extensions/Timer.cs | 180 + .../Runtime/Scripts/Extensions/Timer.cs.meta | 11 + .../Extensions/VisualElementEvents.meta | 8 + .../VisualElementEvents.cs | 0 .../VisualElementEvents.cs.meta | 2 +- .../Extensions/VisualElementExtension.cs | 3072 ++++++++--------- .../Runtime/Scripts/ScriptableObjects.meta | 8 + .../ScriptableObjects/AssetInstance.cs | 217 ++ .../ScriptableObjects/AssetInstance.cs.meta | 3 + .../ScriptableObjects/StyleAssets.meta | 3 + .../StyleAssets/EATKStyleAsset.cs | 209 ++ .../StyleAssets/EATKStyleAsset.cs.meta | 3 + .../Runtime/Scripts/UI/EATKEditor.cs.meta | 2 +- .../Runtime/Scripts/UI/Style.meta | 2 +- .../Scripts/UI/Style/EATKEditor.uss.meta | 2 +- .../Runtime/Scripts/UI/Style/Resources.meta | 2 +- .../Scripts/UI/Style/Resources/Fonts.meta | 2 +- .../Fonts/SourceCodePro--iMedium-It.otf.meta | 2 +- .../Fonts/SourceCodePro-Black.otf.meta | 2 +- .../Fonts/SourceCodePro-BlackIt.otf.meta | 2 +- .../Fonts/SourceCodePro-Bold.otf.meta | 2 +- .../Fonts/SourceCodePro-BoldIt.otf.meta | 2 +- .../Fonts/SourceCodePro-ExtraLight.otf.meta | 2 +- .../Fonts/SourceCodePro-ExtraLightIt.otf.meta | 2 +- .../Resources/Fonts/SourceCodePro-It.otf.meta | 2 +- .../Fonts/SourceCodePro-Light.otf.meta | 2 +- .../Fonts/SourceCodePro-LightIt.otf.meta | 2 +- .../Fonts/SourceCodePro-Medium.otf.meta | 2 +- .../Fonts/SourceCodePro-Regular.otf.meta | 2 +- .../Fonts/SourceCodePro-Semibold.otf.meta | 2 +- .../Fonts/SourceCodePro-SemiboldIt.otf.meta | 2 +- .../Runtime/Scripts/UI/Windows.meta | 8 + .../Scripts/UI/Windows/BaseEditorWindow.meta | 3 + .../UI/Windows/BaseEditorWindow/Style.meta | 3 + .../BaseEditorWindow/Style/elements.meta | 8 + .../Style/elements/_containers.sass | 3 + .../Style/elements/_containers.sass.meta | 7 + .../Style/elements/_fields.sass | 3 + .../Style/elements/_fields.sass.meta | 7 + .../Style/elements/_index.sass | 4 + .../Style/elements/_index.sass.meta | 7 + .../Style/idEditorWindowStyle.sass | 44 + .../Style/idEditorWindowStyle.sass.meta | 7 + .../Style/idEditorWindowStyle.uss | 52 + .../Style/idEditorWindowStyle.uss.meta | 11 + .../BaseEditorWindow/idEditorWindow.cs | 67 + .../BaseEditorWindow/idEditorWindow.cs.meta | 3 + .../Scripts/UI/Windows/EATKEditor.meta | 3 + .../UI/Windows/EATKEditor/EATKEditor.cs | 1264 +++++++ .../UI/Windows/EATKEditor/EATKEditor.cs.meta | 3 + .../Scripts/UI/Windows/EATKEditor/Style.meta | 3 + .../Windows/EATKEditor/Style/EATKEditor.uss | 392 +++ .../EATKEditor/Style/EATKEditor.uss.meta | 3 + .../Windows/EATKEditor/Style/Resources.meta | 8 + .../EATKEditor/Style/Resources/Fonts.meta | 8 + .../Fonts/SourceCodePro--iMedium-It.otf | Bin 0 -> 122368 bytes .../Fonts/SourceCodePro--iMedium-It.otf.meta | 26 + .../Resources/Fonts/SourceCodePro-Black.otf | Bin 0 -> 149272 bytes .../Fonts/SourceCodePro-Black.otf.meta | 25 + .../Resources/Fonts/SourceCodePro-BlackIt.otf | Bin 0 -> 124432 bytes .../Fonts/SourceCodePro-BlackIt.otf.meta | 31 + .../Resources/Fonts/SourceCodePro-Bold.otf | Bin 0 -> 148456 bytes .../Fonts/SourceCodePro-Bold.otf.meta | 32 + .../Resources/Fonts/SourceCodePro-BoldIt.otf | Bin 0 -> 123112 bytes .../Fonts/SourceCodePro-BoldIt.otf.meta | 28 + .../Fonts/SourceCodePro-ExtraLight.otf | Bin 0 -> 141356 bytes .../Fonts/SourceCodePro-ExtraLight.otf.meta | 24 + .../Fonts/SourceCodePro-ExtraLightIt.otf | Bin 0 -> 120104 bytes .../Fonts/SourceCodePro-ExtraLightIt.otf.meta | 30 + .../Resources/Fonts/SourceCodePro-It.otf | Bin 0 -> 122288 bytes .../Resources/Fonts/SourceCodePro-It.otf.meta | 29 + .../Resources/Fonts/SourceCodePro-Light.otf | Bin 0 -> 145036 bytes .../Fonts/SourceCodePro-Light.otf.meta | 27 + .../Resources/Fonts/SourceCodePro-LightIt.otf | Bin 0 -> 123040 bytes .../Fonts/SourceCodePro-LightIt.otf.meta | 33 + .../Resources/Fonts/SourceCodePro-Medium.otf | Bin 0 -> 145516 bytes .../Fonts/SourceCodePro-Medium.otf.meta | 22 + .../Resources/Fonts/SourceCodePro-Regular.otf | Bin 0 -> 145556 bytes .../Fonts/SourceCodePro-Regular.otf.meta | 34 + .../Fonts/SourceCodePro-Semibold.otf | Bin 0 -> 146808 bytes .../Fonts/SourceCodePro-Semibold.otf.meta | 23 + .../Fonts/SourceCodePro-SemiboldIt.otf | Bin 0 -> 122652 bytes .../Fonts/SourceCodePro-SemiboldIt.otf.meta | 26 + .../Runtime/VisualElementEvents.meta | 3 - Packages/manifest.json | 16 +- Packages/packages-lock.json | 51 +- ProjectSettings/MemorySettings.asset | 35 + ProjectSettings/ProjectVersion.txt | 4 +- ProjectSettings/VersionControlSettings.asset | 8 + UserSettings/EditorUserSettings.asset | 19 + 170 files changed, 9267 insertions(+), 2778 deletions(-) rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq.meta => Elements/AnimatedFoldout/Resources.meta} (77%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/AnimatedFoldoutStyle.sass rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq/FastLinq.asmdef.meta => Elements/AnimatedFoldout/Resources/Style/AnimatedFoldoutStyle.sass.meta} (59%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/AnimatedFoldoutStyle.uss create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/AnimatedFoldoutStyle.uss.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/elements.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/elements/_containers.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/elements/_containers.sass.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/elements/_index.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/Resources/Style/elements/_index.sass.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/FastLinq.asmdef delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedAggregate.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedAll.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedAny.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedContains.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedCount.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedCount.cs.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedFirst.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedFirst.cs.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedFirstOrDefault.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedFirstOrDefault.cs.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedLast.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedLast.cs.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedLastOrDefault.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedLastOrDefault.cs.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedSequenceEqual.cs delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/FastLinq/ImprovedSequenceEqual.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/ITaskSequence.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/ITaskSequence.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/SingleTask.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/SingleTask.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/WaitUntil.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Enhancements/Tasks/WaitUntil.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/AnimColorStore.cs rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq/ImprovedAny.cs.meta => Scripts/Extensions/DataTypes/AnimColorStore.cs.meta} (83%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/AnimTime.cs rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq/ImprovedAggregate.cs.meta => Scripts/Extensions/DataTypes/AnimTime.cs.meta} (83%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/AnimValueStore.cs rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq/ImprovedContains.cs.meta => Scripts/Extensions/DataTypes/AnimValueStore.cs.meta} (83%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/AnimateElement.cs rename Assets/instance.id/ElementAnimationToolkit/Runtime/{Enhancements/FastLinq/ImprovedAll.cs.meta => Scripts/Extensions/DataTypes/AnimateElement.cs.meta} (83%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/Editor.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/Editor/SerializedDictionaryEditor.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/Editor/SerializedDictionaryEditor.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/GetEasing.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/GetEasing.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/ImageAsset.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/ImageAsset.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/SerializedDictionary.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/SerializedDictionary.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/VersionElement.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/VersionElement/VersionElement.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/DataTypes/VersionElement/VersionElement.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/ContainerType.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/ContainerType.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/IMGuiObject.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/IMGuiObject.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/UIElementsEditorHelper.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/ElementGeneration/UIElementsEditorHelper.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/Elements/VisualElementExtension.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/Elements/VisualElementExtension.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/LinqExtensions.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/LinqExtensions.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/PropertyExtensions.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/PropertyExtensions.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/Timer.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/Timer.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/Extensions/VisualElementEvents.meta rename Assets/instance.id/ElementAnimationToolkit/Runtime/{ => Scripts/Extensions}/VisualElementEvents/VisualElementEvents.cs (100%) rename Assets/instance.id/ElementAnimationToolkit/Runtime/{ => Scripts/Extensions}/VisualElementEvents/VisualElementEvents.cs.meta (83%) create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects/AssetInstance.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects/AssetInstance.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects/StyleAssets.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects/StyleAssets/EATKStyleAsset.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/ScriptableObjects/StyleAssets/EATKStyleAsset.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_containers.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_containers.sass.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_fields.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_fields.sass.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_index.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/elements/_index.sass.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/idEditorWindowStyle.sass create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/idEditorWindowStyle.sass.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/idEditorWindowStyle.uss create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/Style/idEditorWindowStyle.uss.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/idEditorWindow.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/BaseEditorWindow/idEditorWindow.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/EATKEditor.cs create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/EATKEditor.cs.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/EATKEditor.uss create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/EATKEditor.uss.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro--iMedium-It.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Black.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Black.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-BlackIt.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Bold.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Bold.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-BoldIt.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-ExtraLight.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-ExtraLightIt.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-It.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-It.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Light.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Light.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-LightIt.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-LightIt.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Medium.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Medium.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Regular.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Regular.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Semibold.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-Semibold.otf.meta create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf create mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/Scripts/UI/Windows/EATKEditor/Style/Resources/Fonts/SourceCodePro-SemiboldIt.otf.meta delete mode 100644 Assets/instance.id/ElementAnimationToolkit/Runtime/VisualElementEvents.meta create mode 100644 ProjectSettings/MemorySettings.asset create mode 100644 ProjectSettings/VersionControlSettings.asset create mode 100644 UserSettings/EditorUserSettings.asset diff --git a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/ContinuousAnimations.cs b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/ContinuousAnimations.cs index ddba53a..c302327 100644 --- a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/ContinuousAnimations.cs +++ b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/ContinuousAnimations.cs @@ -16,6 +16,12 @@ public static class ContinuousAnimations { public static bool debug = false; + public static IVisualElementScheduledItem AnimBorderPulse( + this VisualElement element, + AnimValueStore valueStore) + { + return AnimBorderPulse(element, valueStore.initial, valueStore.final); + } // -------------------------------------------------- @HoverBorder // --------------------------------------------------------------- /// diff --git a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/Easy.cs b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/Easy.cs index d618ef9..aa8f2f8 100644 --- a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/Easy.cs +++ b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/Easy.cs @@ -14,24 +14,15 @@ namespace instance.id.EATK public static class Easy { private const float HalfPi = 1.570796f; - public static float Step(float t) => (double) t < 0.5 ? 0.0f : 1f; - public static float Linear(float t) => t; - public static float InSine(float t) => Mathf.Sin((float) (1.57079637050629 * ((double) t - 1.0))) + 1f; - public static float OutSine(float t) => Mathf.Sin(t * 1.570796f); - public static float InOutSine(float t) => (float) (((double) Mathf.Sin((float) (3.14159274101257 * ((double) t - 0.5))) + 1.0) * 0.5); - public static float InQuad(float t) => t * t; - public static float OutQuad(float t) => t * (2f - t); - public static float OutExpo(float t) { return t.Equals(1f) ? 1 : 1 - Mathf.Pow(2, -10 * t); - } public static float InOutQuad(float t) @@ -41,13 +32,9 @@ public static float InOutQuad(float t) } public static float InCubic(float t) => Easy.InPower(t, 3); - public static float OutCubic(float t) => Easy.OutPower(t, 3); - public static float InOutCubic(float t) => Easy.InOutPower(t, 3); - public static float InPower(float t, int power) => Mathf.Pow(t, (float) power); - public static float OutPower(float t, int power) { int num = power % 2 == 0 ? -1 : 1; @@ -57,20 +44,16 @@ public static float OutPower(float t, int power) public static float InOutPower(float t, int power) { t *= 2f; - if ((double) t < 1.0) - return Easy.InPower(t, power) * 0.5f; + if ((double) t < 1.0) return Easy.InPower(t, power) * 0.5f; int num = power % 2 == 0 ? -1 : 1; return (float) ((double) num * 0.5 * ((double) Mathf.Pow(t - 2f, (float) power) + (double) (num * 2))); } public static float InBounce(float t) => 1f - Easy.OutBounce(1f - t); - public static float OutBounce(float t) { - if ((double) t < 0.363636374473572) - return 121f / 16f * t * t; - if ((double) t < 0.727272748947144) - return (float) (121.0 / 16.0 * (double) (t -= 0.5454546f) * (double) t + 0.75); + if ((double) t < 0.363636374473572) return 121f / 16f * t * t; + if ((double) t < 0.727272748947144) return (float) (121.0 / 16.0 * (double) (t -= 0.5454546f) * (double) t + 0.75); return (double) t < 0.909090936183929 ? (float) (121.0 / 16.0 * (double) (t -= 0.8181818f) * (double) t + 15.0 / 16.0) : (float) (121.0 / 16.0 * (double) (t -= 0.9545454f) * (double) t + 63.0 / 64.0); @@ -81,10 +64,8 @@ public static float InOutBounce(float t) => public static float InElastic(float t) { - if ((double) t == 0.0) - return 0.0f; - if ((double) t == 1.0) - return 1f; + if ((double) t == 0.0) return 0.0f; + if ((double) t == 1.0) return 1f; float num1 = 0.3f; float num2 = num1 / 4f; return (float) -((double) Mathf.Pow(2f, 10f * --t) * (double) Mathf.Sin((float) (((double) t - (double) num2) * 6.28318548202515) / num1)); @@ -92,10 +73,8 @@ public static float InElastic(float t) public static float OutElastic(float t) { - if ((double) t == 0.0) - return 0.0f; - if ((double) t == 1.0) - return 1f; + if ((double) t == 0.0) return 0.0f; + if ((double) t == 1.0) return 1f; float num1 = 0.3f; float num2 = num1 / 4f; return (float) ((double) Mathf.Pow(2f, -10f * t) * (double) Mathf.Sin((float) (((double) t - (double) num2) * 6.28318548202515) / num1) + 1.0); @@ -116,9 +95,7 @@ public static float InOutBack(float t) => (double) t < 0.5 ? Easy.InBack(t * 2f) * 0.5f : (float) ((double) Easy.OutBack((float) (((double) t - 0.5) * 2.0)) * 0.5 + 0.5); public static float InBack(float t, float s) => (float) ((double) t * (double) t * (((double) s + 1.0) * (double) t - (double) s)); - public static float OutBack(float t, float s) => 1f - Easy.InBack(1f - t, s); - public static float InOutBack(float t, float s) => (double) t < 0.5 ? Easy.InBack(t * 2f, s) * 0.5f : (float) ((double) Easy.OutBack((float) (((double) t - 0.5) * 2.0), s) * 0.5 + 0.5); @@ -139,7 +116,6 @@ public static float InOutCirc(float t) return (float) (0.5 * ((double) Mathf.Sqrt((float) (1.0 - (double) t * (double) t)) + 1.0)); } - public static float EaseInOutQuint(float t) { return (float) (t < 0.5f ? 16f * t * t * t * t * t : 1 - Math.Pow(-2 * t + 2, 5) / 2); diff --git a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/HoverAnimations.cs b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/HoverAnimations.cs index 37e7c3f..6b93809 100644 --- a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/HoverAnimations.cs +++ b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/HoverAnimations.cs @@ -16,7 +16,6 @@ namespace instance.id.EATK public static class HoverAnimations { #region Hover Animations - // --------------------------------------------------- @HoverColor // --------------------------------------------------------------- /// @@ -38,7 +37,7 @@ public static class HoverAnimations /// Whether to animate the transition of the background color /// Whether this command is issued to register or unregister this event public static void HoverColor(this T target, StyleColor original, Color hoverColor, Func condition = null, - T conditionElement = null, bool animate = false, bool unregister = false) where T : VisualElement + T conditionElement = null, bool animate = false, bool unregister = false) where T : VisualElement { ValueAnimation mouseOver = new ValueAnimation(); ValueAnimation mouseOut = new ValueAnimation(); @@ -123,7 +122,7 @@ public static void HoverColor(this T target, StyleColor original, Color hover /// The element in which the optional condition will be evaluated. Ex. in the example of 'bool Condition(VisualElement sRow) => selectedRow == packageListRow;', the conditionalElement would be 'VisualElement selectedRow' /// Whether to animate the transition of the background color public static void HoverBackground(this VisualElement target, StyleColor original, Color hoverColor, Func condition = null, - VisualElement conditionElement = null, bool animate = false, int animDuration = 250) + VisualElement conditionElement = null, bool animate = false, int animDuration = 250) { var mouseOver = new ValueAnimation(); var mouseOut = new ValueAnimation(); @@ -189,7 +188,6 @@ public static void HoverBorder(this VisualElement target, Color original, Color target.style.borderRightColor = hoverColor; target.style.borderTopColor = hoverColor; - evt.StopPropagation(); }); target.RegisterCallback(evt => @@ -202,7 +200,6 @@ public static void HoverBorder(this VisualElement target, Color original, Color target.style.borderTopWidth = borderStartEndWidth.y; } - target.style.borderBottomColor = original; target.style.borderLeftColor = original; target.style.borderRightColor = original; @@ -242,18 +239,18 @@ public static void HoverBorder(this VisualElement target, Color original, Color /// public static AnimatedItems HoverBorderPulse( - this VisualElement target, - Color pulseStartColor, - Color pulseEndColor, - Color original = default, - bool addBorder = false, - Vector2 borderStartEndWidth = default, - int colorDuration = 1000, - bool includeChildren = true, - bool stopPropagation = true, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown, - AnimatedItems animatedItems = null, - params ValueAnimation[] animRunCheck) + this VisualElement target, + Color pulseStartColor, + Color pulseEndColor, + Color original = default, + bool addBorder = false, + Vector2 borderStartEndWidth = default, + int colorDuration = 1000, + bool includeChildren = true, + bool stopPropagation = true, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown, + AnimatedItems animatedItems = null, + params ValueAnimation[] animRunCheck) { if (borderStartEndWidth == default) borderStartEndWidth = new Vector2(1, 0); @@ -340,20 +337,19 @@ void PulseOut(in ValueAnimation pulse) target.RegisterCallback(mouseOverEvent, includeChildren, useTrickleDown); target.RegisterCallback(mouseOutEvent, includeChildren, useTrickleDown); - animatedItems.AnimatedItemList = new List> { pulseIn, pulseOut }; + animatedItems.AnimatedItemList = new List> {pulseIn, pulseOut}; animatedItems.EventCallbacks = (mouseOverEvent, mouseOutEvent); return animatedItems; } #region Unregister - public static void HoverBorderPulseUnregister( - this VisualElement target, Color pulseStartColor, Color pulseEndColor, Color original = default, bool addBorder = false, - Vector2 borderStartEndWidth = default, - int colorDuration = 1000, - bool includeChildren = true, - bool stopPropagation = true, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + this VisualElement target, Color pulseStartColor, Color pulseEndColor, Color original = default, bool addBorder = false, + Vector2 borderStartEndWidth = default, + int colorDuration = 1000, + bool includeChildren = true, + bool stopPropagation = true, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) { if (borderStartEndWidth == default) borderStartEndWidth = new Vector2(1, 0); @@ -419,7 +415,6 @@ void PulseOut(in ValueAnimation pulse) if (pulseIn.isRunning) pulseIn.Stop(); if (pulseOut.isRunning) pulseOut.Stop(); - target.style.borderBottomColor = original; target.style.borderLeftColor = original; target.style.borderRightColor = original; @@ -428,10 +423,9 @@ void PulseOut(in ValueAnimation pulse) if (stopPropagation) evt.StopPropagation(); }, includeChildren); } - #endregion - // -------------------------------------------------- @HoverBorder + // -------------------------------------------------- @HoverBorder // --------------------------------------------------------------- /// /// Adds background hover capability that will not be lost like CSS:hover when programatically setting background color @@ -457,17 +451,17 @@ public static void HoverOpacity(this VisualElement target, float startValue, flo evt.StopPropagation(); }); } - + // -------------------------------------------------------- @HoverWidth // -- Animate the width of target element to desired value on hover -- // -------------------------------------------------------------------- public static AnimatedItems HoverWidth( - this VisualElement target, float initialWidth = 0f, float desiredWidth = 100f, int duration = 1000, Action hoverCallback = null, - Action leaveCallback = null, - bool afterAnimation = false, - bool includeChildren = true, - bool stopPropagation = true, - TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) + this VisualElement target, float initialWidth = 0f, float desiredWidth = 100f, int duration = 1000, Action hoverCallback = null, + Action leaveCallback = null, + bool afterAnimation = false, + bool includeChildren = true, + bool stopPropagation = true, + TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) { initialWidth = initialWidth == 0f ? target.resolvedStyle.width : initialWidth; var enterAnim = new ValueAnimation(); @@ -510,7 +504,7 @@ void MouseEnter() return new AnimatedItems(target) { - AnimatedItemList = new List> { enterAnim, leaveAnim }, + AnimatedItemList = new List> {enterAnim, leaveAnim}, EventCallbacks = (mouseOverEvent, mouseOutEvent) }; } @@ -519,13 +513,13 @@ void MouseEnter() // -- Animate the Height of target element to desired value on hover -- // -------------------------------------------------------------------- public static AnimatedItems HoverHeight( - this VisualElement target, - float initialHeight = 0f, - float desiredHeight = 100f, - int duration = 1000, - Action hoverCallback = null, - Action leaveCallback = null, - bool afterAnimation = false) + this VisualElement target, + float initialHeight = 0f, + float desiredHeight = 100f, + int duration = 1000, + Action hoverCallback = null, + Action leaveCallback = null, + bool afterAnimation = false) { initialHeight = initialHeight == 0f ? target.resolvedStyle.height : initialHeight; var enterAnim = new ValueAnimation(); @@ -562,7 +556,7 @@ void MouseEnter() return new AnimatedItems(target) { - AnimatedItemList = new List> { enterAnim, leaveAnim }, + AnimatedItemList = new List> {enterAnim, leaveAnim}, EventCallbacks = (mouseOverEvent, mouseOutEvent) }; } @@ -583,6 +577,43 @@ public static void HoverToolTip(this VisualElement target, Action callback) }); } + public static void HoverAction(this VisualElement target, Action mouseInAction, Action mouseOutAction = default, List extendedTargets = default) + { + target.RegisterCallback(evt => + { + mouseInAction?.Invoke(); + // evt.StopPropagation(); + }); + + if (extendedTargets != default) + { + foreach (var extendedTarget in extendedTargets) + { + extendedTarget.RegisterCallback(evt => + { + mouseInAction?.Invoke(); + // evt.StopPropagation(); + }); + } + } + + target.RegisterCallback(evt => + { + if (extendedTargets != default && extendedTargets.Contains(evt.currentTarget)) return; + mouseOutAction?.Invoke(); + // evt.StopPropagation(); + }); + + if (extendedTargets == default) return; + foreach (var extendedTarget in extendedTargets) + { + extendedTarget.RegisterCallback(evt => + { + mouseOutAction?.Invoke(); + // evt.StopPropagation(); + }); + } + } #endregion } } diff --git a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/VisualElementBaseAnimation.cs b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/VisualElementBaseAnimation.cs index e64c931..9e09f1e 100644 --- a/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/VisualElementBaseAnimation.cs +++ b/Assets/instance.id/ElementAnimationToolkit/Runtime/Animations/VisualElementBaseAnimation.cs @@ -9,11 +9,104 @@ using UnityEngine; using UnityEngine.UIElements; using UnityEngine.UIElements.Experimental; +// ReSharper disable ConvertIfStatementToNullCoalescingAssignment namespace instance.id.EATK { public static class VisualElementBaseAnimation { + #region Generic Animation + public static ValueAnimation Animate(this VisualElement target, AnimValueStore valueStore, + Func easing = null, bool reverse = false, int durationOverride = default, int delayOverride = default, Action callback = default) where T : struct + { + ValueAnimation anim = valueStore.Animation ?? new ValueAnimation(); + + StyleValues from; + StyleValues to; + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var valueCallback = reverse ? valueStore.reverseCallback : valueStore.callback; + + // @formatter:off + switch (valueStore.element) + { + case AnimateElement.Height: from = new StyleValues {height = (float) Convert.ChangeType(start, typeof(float))}; to = new StyleValues {height = (float) Convert.ChangeType(end, typeof(float))}; break; + case AnimateElement.Width: from = new StyleValues {width = (float) Convert.ChangeType(start, typeof(float))}; to = new StyleValues {width = (float) Convert.ChangeType(end, typeof(float))}; break; + case AnimateElement.Opacity: from = new StyleValues {opacity = (float) Convert.ChangeType(start, typeof(float))}; to = new StyleValues {opacity = (float) Convert.ChangeType(end, typeof(float))}; break; + case AnimateElement.Color: from = new StyleValues {color = (Color) Convert.ChangeType(start, typeof(Color))}; to = new StyleValues {color = (Color) Convert.ChangeType(end, typeof(Color))}; break; + case AnimateElement.BackgroundColor: from = new StyleValues {backgroundColor = (Color) Convert.ChangeType(start, typeof(Color))}; to = new StyleValues {backgroundColor = (Color) Convert.ChangeType(end, typeof(Color))}; break; + case AnimateElement.BorderColor: from = new StyleValues {borderColor = (Color) Convert.ChangeType(start, typeof(Color))}; to = new StyleValues {borderColor = (Color) Convert.ChangeType(end, typeof(Color))}; break; + case AnimateElement.UnityBackgroundImageTintColor: from = new StyleValues {unityBackgroundImageTintColor = (Color) Convert.ChangeType(start, typeof(Color))}; to = new StyleValues {unityBackgroundImageTintColor = (Color) Convert.ChangeType(end, typeof(Color))}; break; + } // @formatter:on + + if (easing == default) easing = Easy.EaseInOutQuint; + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(from, to, durationOverride != default ? durationOverride : valueStore.duration) + .Ease(easing) + .OnCompleted(callback ?? valueCallback); + }).StartingIn(delayOverride != default ? delayOverride : valueStore.delay); + return valueStore.Animation = anim; + } + + public static ValueAnimation Animate(this VisualElement target, AnimValueStore valueStore, + Func easing = null, bool reverse = false, int durationOverride = default, int delayOverride = default, Action callback = default) + where TValue : struct + where TStyle : struct + { + ValueAnimation anim = valueStore.Animation ?? new ValueAnimation(); + StyleValues from; + StyleValues to; + + var i = valueStore.initial; + var e = valueStore.final; + + // @formatter:off + switch (valueStore.element) + { + case AnimateElement.Height: + from = new StyleValues {height = (float) Convert.ChangeType(valueStore.initial, typeof(float))}; + to = new StyleValues {height = (float) Convert.ChangeType(valueStore.final, typeof(StyleLength))}; break; + case AnimateElement.Width: + from = new StyleValues {width = (float) Convert.ChangeType(i, typeof(float))}; + to = new StyleValues {width = e.ToString().TryParseFloat() }; break; + case AnimateElement.Opacity: + from = new StyleValues {opacity = (float) Convert.ChangeType(valueStore.initial, typeof(float))}; + to = new StyleValues {opacity = (float) Convert.ChangeType(valueStore.final, typeof(StyleLength))}; break; + case AnimateElement.Color: + from = new StyleValues {color = (Color) Convert.ChangeType(valueStore.initial, typeof(Color))}; + to = new StyleValues {color = (Color) Convert.ChangeType(valueStore.final, typeof(StyleColor))}; break; + case AnimateElement.BackgroundColor: + from = new StyleValues {backgroundColor = (Color) Convert.ChangeType(valueStore.initial, typeof(Color))}; + to = new StyleValues {backgroundColor = (Color) Convert.ChangeType(valueStore.final, typeof(StyleColor))}; break; + case AnimateElement.BorderColor: + from = new StyleValues {borderColor = (Color) Convert.ChangeType(valueStore.initial, typeof(Color))}; + to = new StyleValues {borderColor = (Color) Convert.ChangeType(valueStore.final, typeof(StyleColor))}; break; + case AnimateElement.UnityBackgroundImageTintColor: + from = new StyleValues {unityBackgroundImageTintColor = (Color) Convert.ChangeType(valueStore.initial, typeof(Color))}; + to = new StyleValues {unityBackgroundImageTintColor = (Color) Convert.ChangeType(valueStore.final, typeof(StyleColor))}; break; + } // @formatter:on + + var start = reverse ? to : from; + var end = reverse ? from : to; + var valueCallback = reverse ? valueStore.reverseCallback : valueStore.callback; + + Debug.Log($"start: {start.width} end: {end.width}"); + + if (easing == default) easing = Easy.EaseInOutQuint; + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(start, end, durationOverride != default ? durationOverride : valueStore.duration) + .Ease(easing) + .OnCompleted(callback ?? valueCallback); + }).StartingIn(delayOverride != default ? delayOverride : valueStore.delay); + return valueStore.Animation = anim; + } + #endregion + #region Base Animation Extensions // --------------------------------------- @AnimateBackgroundColor // --------------------------------------------------------------- @@ -27,7 +120,7 @@ public static class VisualElementBaseAnimation /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateBackgroundColor(this VisualElement target, Color startColor, Color endColor, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -36,6 +129,19 @@ public static ValueAnimation AnimateBackgroundColor(this VisualElem .OnCompleted(callback); } + public static ValueAnimation AnimateBackgroundColor(this VisualElement target, AnimValueStore valueStore, Func easing = null, bool reverse = false) + { + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {backgroundColor = start}, new StyleValues {backgroundColor = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + /// /// Animate the background color of target element to desired value after delay /// @@ -47,7 +153,7 @@ public static ValueAnimation AnimateBackgroundColor(this VisualElem /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateBackgroundColorDelayed(this VisualElement target, Color startColor, Color endColor, int durationMs = 500, int delayMs = 0, Action callback = null, - Func easing = null) + Func easing = null) { ValueAnimation anim = new ValueAnimation(); @@ -72,7 +178,7 @@ public static ValueAnimation AnimateBackgroundColorDelayed(this Vis /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateBackgroundColor(this VisualElement target, string startColor, string endColor, int durationMs, Action callback = null, - Func easing = null) => + Func easing = null) => AnimateBackgroundColor(target, startColor.EnsureHex().FromHex(), endColor.EnsureHex().FromHex(), durationMs, callback, easing); // ------------------------------------------- @AnimateBorderColor @@ -87,7 +193,7 @@ public static ValueAnimation AnimateBackgroundColor(this VisualElem /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateBorderColor(this VisualElement target, Color startColor, Color endColor, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -96,6 +202,34 @@ public static ValueAnimation AnimateBorderColor(this VisualElement .OnCompleted(callback); } + public static ValueAnimation AnimateBorderColor(this VisualElement target, AnimColorStore colorStore, + Func easing = null, bool reverse = false) + { + var start = reverse ? colorStore.final : colorStore.initial; + var end = reverse ? colorStore.initial : colorStore.final; + var callback = reverse ? colorStore.reverseCallback : colorStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {borderColor = start}, new StyleValues {borderColor = end}, colorStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + + public static ValueAnimation AnimateBorderColor(this VisualElement target, AnimValueStore colorStore, + Func easing = null, bool reverse = false) + { + var start = reverse ? colorStore.final : colorStore.initial; + var end = reverse ? colorStore.initial : colorStore.final; + var callback = reverse ? colorStore.reverseCallback : colorStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {borderColor = start}, new StyleValues {borderColor = end}, colorStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + /// /// Animate the background color of target element to desired value /// @@ -106,7 +240,7 @@ public static ValueAnimation AnimateBorderColor(this VisualElement /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateBorderColor(this VisualElement target, string startColor, string endColor, int durationMs, Action callback = null, - Func easing = null) => + Func easing = null) => AnimateBorderColor(target, startColor.EnsureHex().FromHex(), endColor.EnsureHex().FromHex(), durationMs, callback, easing); // ------------------------------------------------- @AnimateColor @@ -115,13 +249,39 @@ public static ValueAnimation AnimateBorderColor(this VisualElement /// Animate the color of target element to desired value /// /// VisualElement to animate - /// Initial color of element - /// The desired end result color which to animate - /// The length of time in which the animation will occur(in milliseconds) - /// Function that can be called when the animation is completed + /// Contains all the necessary values in a single element /// Controls the animation timing curve mathematically + /// Play the animation in reverse order + public static ValueAnimation AnimateColor(this VisualElement target, AnimColorStore colorStore, + Func easing = null, bool reverse = false) + { + var start = reverse ? colorStore.final : colorStore.initial; + var end = reverse ? colorStore.initial : colorStore.final; + var callback = reverse ? colorStore.reverseCallback : colorStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {color = start}, new StyleValues {color = end}, colorStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + + public static ValueAnimation AnimateColor(this VisualElement target, AnimValueStore colorStore, + Func easing = null, bool reverse = false) + { + var start = reverse ? colorStore.final : colorStore.initial; + var end = reverse ? colorStore.initial : colorStore.final; + var callback = reverse ? colorStore.reverseCallback : colorStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {color = start}, new StyleValues {color = end}, colorStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + public static ValueAnimation AnimateColor(this VisualElement target, Color startColor, Color endColor, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -140,7 +300,7 @@ public static ValueAnimation AnimateColor(this VisualElement target /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateColor(this VisualElement target, string startColor, string endColor, int durationMs, Action callback = null, - Func easing = null) => + Func easing = null) => AnimateColor(target, startColor.EnsureHex().FromHex(), endColor.EnsureHex().FromHex(), durationMs, callback, easing); // ---------------------------------------- @AnimateImageTintColor @@ -155,7 +315,7 @@ public static ValueAnimation AnimateColor(this VisualElement target /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateImageTintColor(this VisualElement target, Color startColor, Color endColor, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -174,7 +334,7 @@ public static ValueAnimation AnimateImageTintColor(this VisualEleme /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateImageTintColor(this VisualElement target, string startColor, string endColor, int durationMs, Action callback = null, - Func easing = null) => + Func easing = null) => AnimateImageTintColor(target, startColor.EnsureHex().FromHex(), endColor.EnsureHex().FromHex(), durationMs, callback, easing); // ----------------------------------------------- @AnimateOpacity @@ -190,7 +350,7 @@ public static ValueAnimation AnimateImageTintColor(this VisualEleme /// Controls the animation timing curve mathematically /// If enabled, animation can trigger from start value regardless of current opacity value public static ValueAnimation AnimateOpacity(this VisualElement target, float startOpacity, float endOpacity, int durationMs, Action callback = null, - Func easing = null, bool reanimate = false) + Func easing = null, bool reanimate = false) { if (!reanimate) { @@ -207,6 +367,28 @@ public static ValueAnimation AnimateOpacity(this VisualElement targ .OnCompleted(callback); } + public static ValueAnimation AnimateOpacity(this VisualElement target, + AnimValueStore valueStore, + Func easing = null, + bool reanimate = false, + bool reverse = false) + { + if (!reanimate) + { + if (target.style.opacity == valueStore.final) return null; + } + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {opacity = start}, new StyleValues {opacity = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + // ----------------------------------------------- @AnimateOpacity // --------------------------------------------------------------- /// @@ -215,11 +397,12 @@ public static ValueAnimation AnimateOpacity(this VisualElement targ /// VisualElement to animate /// Initial opacity of element /// The desired end result opacity which to animate - /// The length of time in which the animation will occur(in milliseconds) + /// The length of time in which the animation will occur (in milliseconds) + /// Delay the animation from starting for X amount of time (in milliseconds) /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateOpacityDelayed(this VisualElement target, float startOpacity, float endOpacity, int durationMs, int delayMs, Action callback = null, - Func easing = null) + Func easing = null) { ValueAnimation anim = new ValueAnimation(); if (startOpacity == 0) startOpacity = 0.Zero(); @@ -237,6 +420,26 @@ public static ValueAnimation AnimateOpacityDelayed(this VisualEleme return anim; } + public static ValueAnimation AnimateOpacityDelayed(this VisualElement target, AnimValueStore valueStore, Func easing = null, bool reverse = false) + { + ValueAnimation anim = new ValueAnimation(); + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(new StyleValues {opacity = start}, new StyleValues {opacity = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + }).StartingIn(valueStore.delay); + + return anim; + } + // ----------------------------------------------- @AnimateOpacity // --------------------------------------------------------------- /// @@ -248,7 +451,7 @@ public static ValueAnimation AnimateOpacityDelayed(this VisualEleme /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateDisplay(this VisualElement target, bool setDisplay, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { switch (setDisplay) { @@ -272,11 +475,10 @@ public static ValueAnimation AnimateDisplay(this VisualElement targ startOpacity = 1; endOpacity = 0.Zero(); target.SetOpacity(startOpacity); - if (callback == null) - callback = () => target.SetDisplay(false); + callback ??= () => target.SetDisplay(false); } - if (easing == null) easing = Easy.EaseInOutQuint; + easing ??= Easy.EaseInOutQuint; return target.experimental.animation .Start(new StyleValues {opacity = startOpacity}, new StyleValues {opacity = endOpacity}, durationMs) .Ease(easing) @@ -295,7 +497,7 @@ public static ValueAnimation AnimateDisplay(this VisualElement targ /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateWidth(this VisualElement target, float startWidth, float endWidth, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -304,8 +506,31 @@ public static ValueAnimation AnimateWidth(this VisualElement target .OnCompleted(callback); } + public static ValueAnimation AnimateWidth(this VisualElement target, AnimValueStore valueStore, Func easing = null, bool reverse = false) + { + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + return target.experimental.animation + .Start(new StyleValues {width = start}, new StyleValues {width = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + } + + /// + /// Animate the width of target element to desired value + /// + /// VisualElement to animate + /// Initial width of element + /// The desired end result width which to animate + /// The length of time in which the animation will occur(in milliseconds) + /// The length of time in which to wait before initially starting the animation + /// Function that can be called when the animation is completed + /// Controls the animation timing curve mathematically public static ValueAnimation AnimateWidthDelayed(this VisualElement target, float startWidth, float endWidth, int durationMs, int delayMs, Action callback = null, - Func easing = null) + Func easing = null) { ValueAnimation anim = new ValueAnimation(); if (easing == null) easing = Easy.EaseInOutQuint; @@ -320,6 +545,25 @@ public static ValueAnimation AnimateWidthDelayed(this VisualElement return anim; } + public static ValueAnimation AnimateWidthDelayed(this VisualElement target, AnimValueStore valueStore, Func easing = null, bool reverse = false) + { + ValueAnimation anim = new ValueAnimation(); + if (easing == null) easing = Easy.EaseInOutQuint; + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(new StyleValues {width = start}, new StyleValues {width = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + }).StartingIn(valueStore.delay); + return anim; + } + // ------------------------------------------------ @AnimateHeight // --------------------------------------------------------------- /// @@ -332,7 +576,7 @@ public static ValueAnimation AnimateWidthDelayed(this VisualElement /// Function that can be called when the animation is completed /// Controls the animation timing curve mathematically public static ValueAnimation AnimateHeight(this VisualElement target, float startHeight, float endHeight, int durationMs, Action callback = null, - Func easing = null) + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -341,8 +585,38 @@ public static ValueAnimation AnimateHeight(this VisualElement targe .OnCompleted(callback); } + public static ValueAnimation AnimateHeight(this VisualElement target, AnimValueStore valueStore, + Func easing = null, bool reverse = false, int durationOverride = default, int delayOverride = 0) + { + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + ValueAnimation anim = new ValueAnimation(); + + if (easing == null) easing = Easy.EaseInOutQuint; + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(new StyleValues {height = start}, new StyleValues {height = end}, durationOverride != default ? durationOverride : valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + }).StartingIn(delayOverride != default ? delayOverride : valueStore.delay); + return anim; + } + + /// + /// Animate the height of target element to desired value + /// + /// VisualElement to animate + /// Initial height of element + /// Desired ending height after animation + /// The length of time in which the animation will occur(in milliseconds) + /// The length of time in which to wait before initially starting the animation + /// Function that can be called when the animation is completed + /// Controls the animation timing curve mathematically public static ValueAnimation AnimateHeightDelayed(this VisualElement target, float startHeight, float endHeight, int durationMs, int delayMs, Action callback = null, - Func easing = null) + Func easing = null) { ValueAnimation anim = new ValueAnimation(); if (easing == null) easing = Easy.EaseInOutQuint; @@ -356,6 +630,26 @@ public static ValueAnimation AnimateHeightDelayed(this VisualElemen return anim; } + public static ValueAnimation AnimateHeightDelayed(this VisualElement target, AnimValueStore valueStore, + Func easing = null, bool reverse = false) + { + ValueAnimation anim = new ValueAnimation(); + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (easing == null) easing = Easy.EaseInOutQuint; + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(new StyleValues {height = start}, new StyleValues {height = end}, valueStore.duration) + .Ease(easing) + .OnCompleted(callback); + }).StartingIn(valueStore.delay); + return anim; + } + /// /// Animate an arbitrary float value /// @@ -367,8 +661,14 @@ public static ValueAnimation AnimateHeightDelayed(this VisualElemen /// /// /// - public static ValueAnimation AnimateValue(this VisualElement target, float startValue, float endValue, int durationMs, Action valueChange = null, Action callback = null, - Func easing = null) + public static ValueAnimation AnimateValue( + this VisualElement target, + float startValue, + float endValue, + int durationMs, + Action valueChange = null, + Action callback = null, + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation @@ -376,9 +676,39 @@ public static ValueAnimation AnimateValue(this VisualElement target, floa .Ease(easing) .OnCompleted(callback); } + + public static ValueAnimation AnimateValue( + this VisualElement target, + AnimValueStore valueStore, + bool reverse = false, + Action valueChange = null) + { + ValueAnimation anim = new ValueAnimation(); + + var start = reverse ? valueStore.final : valueStore.initial; + var end = reverse ? valueStore.initial : valueStore.final; + var callback = reverse ? valueStore.reverseCallback : valueStore.callback; + + if (valueStore.easing == null) valueStore.easing = Easy.EaseInOutQuint; + + target.parent.schedule.Execute(() => + { + anim = target.experimental.animation + .Start(start, end, valueStore.duration, valueChange) + .Ease(valueStore.easing) + .OnCompleted(callback); + }).StartingIn(valueStore.delay); + return anim; + } - public static ValueAnimation AnimateSlider(this Slider target, float startValue, float endValue, int durationMs, Action valueChange = null, Action callback = null, - Func easing = null) + public static ValueAnimation AnimateSlider( + this Slider target, + float startValue, + float endValue, + int durationMs, + Action valueChange = null, + Action callback = null, + Func easing = null) { if (easing == null) easing = Easy.EaseInOutQuint; return target.experimental.animation diff --git a/Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/AnimatedFoldout.cs b/Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/AnimatedFoldout.cs index 84bc375..1b07c29 100644 --- a/Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/AnimatedFoldout.cs +++ b/Assets/instance.id/ElementAnimationToolkit/Runtime/Elements/AnimatedFoldout/AnimatedFoldout.cs @@ -6,6 +6,8 @@ #if UNITY_EDITOR using System; using instance.id.EATK.Extensions; +using UnityEditor; +using UnityEngine; using UnityEngine.UIElements; namespace instance.id.EATK @@ -18,12 +20,30 @@ public class AnimatedFoldout : BindableElement, INotifyValueChanged internal static readonly string ussFoldoutDepthClassName = "unity-foldout--depth-"; internal static readonly int ussFoldoutMaxDepth = 4; private Toggle m_Toggle; - private VisualElement m_Container; public Expander expander; + private VisualElement m_Container; + private VisualElement headerBorderLine; + private VisualElement resolvableElement; + private AnimValueStore headerBorderValues; + private bool m_Value; private bool isAnimating; + public bool toggleAsHeader = true; + public bool startExpand = false; + public bool disableAnimation = false; + public Action stateChange = () => { }; + public Action OnComplete + { + get => expander.onComplete; + set => expander.onComplete = value; + } + + public int initialHeaderBorderWidth = default; + private int initialHeaderWidth; + public static readonly string toggleName = "ExpandToggle"; + /// /// USS class name of elements of this type. /// @@ -45,6 +65,7 @@ public class AnimatedFoldout : BindableElement, INotifyValueChanged public static readonly string expanderUssClassName = ussClassName + "__expander"; private string toggleLabelUssClass; + public string ToggleLabelUssClass { get => toggleLabelUssClass; @@ -89,68 +110,161 @@ public bool value public void SetValueWithoutNotify(bool newValue) { m_Value = newValue; - m_Toggle.value = m_Value; + value = newValue; + expander.startExpanded = newValue; } public AnimatedFoldout() => BuildFoldout(); - public AnimatedFoldout(VisualElement headerElement, FlexDirection direction = FlexDirection.Column, Align alignSelf = default) => BuildFoldout(headerElement, direction, alignSelf); + public AnimatedFoldout(bool startExpanded = false) => BuildFoldout(startExpanded: startExpanded); + + public AnimatedFoldout(VisualElement headerElement, FlexDirection direction = FlexDirection.Column, Align alignSelf = default) => + BuildFoldout(headerElement, direction, alignSelf); - private void BuildFoldout(VisualElement headerElement = default, FlexDirection direction = FlexDirection.Column, Align alignSelf = default) + public AnimatedFoldout(VisualElement headerElement, bool replaceHeader, FlexDirection direction = FlexDirection.Column, Align alignSelf = default, VisualElement resolvableElement = default) => + BuildFoldout(headerElement, direction, alignSelf, replaceHeader: replaceHeader, resolvable: resolvableElement, headerBorderWidth: 0); + + private void BuildFoldout( + VisualElement headerElement = default, + FlexDirection direction = FlexDirection.Column, + Align alignSelf = default, + int headerBorderWidth = default, + bool startExpanded = false, + bool replaceHeader = default, + VisualElement resolvable = default) { - m_Value = true; + startExpand = startExpanded; + initialHeaderBorderWidth = headerBorderWidth; + resolvableElement = resolvable; + m_Value = false; AddToClassList(ussClassName); new Expander().Create(out expander).ToUSS(nameof(expander)); - new Toggle { value = true }.Create(out m_Toggle).ToUSS(toggleUssClassName) + new VisualElement().Create(out headerBorderLine).ToUSS(nameof(headerBorderLine)); + new Toggle {value = false, name = toggleName}.Create(out m_Toggle, name: toggleName).ToUSS(toggleUssClassName, "expandToggle") .RegisterValueChangedCallback(evt => { - value = m_Toggle.value; + if (evt.currentTarget != evt.target) return; + value = evt.newValue; expander.Activate(value); + if (toggleAsHeader) + ToggleHeaderAnimation(value); + evt.StopPropagation(); }); + m_Toggle.name = toggleName; hierarchy.Add(m_Toggle); + if (toggleAsHeader) hierarchy.Add(headerBorderLine); + + var checkmarkParent = m_Toggle.Query("unity-checkmark").First().parent; + checkmarkParent.name = toggleAsHeader ? "ExpandToggleContainerHeader" : "ExpandToggleContainer"; + checkmarkParent.AddToClassList(toggleAsHeader ? "expandToggleContainerHeader" : "expandToggleContainer"); + if (headerElement != default) { - m_Toggle.Add(headerElement); - m_Toggle.Query("unity-checkmark").First().parent.style.flexGrow = 0; - if (alignSelf != default) m_Toggle.style.alignSelf = alignSelf; - if (direction != FlexDirection.Column) style.flexDirection = direction; + if (direction == FlexDirection.Row) + { + checkmarkParent.Add(headerElement); + m_Toggle.contentContainer.Add(headerElement); + checkmarkParent.style.flexGrow = 1; + } + else + { + checkmarkParent.style.flexGrow = 0; + if (alignSelf != default) m_Toggle.style.alignSelf = alignSelf; + } } new VisualElement().Create(out m_Container, "unity-content").ToUSS(contentUssClassName); expander.AddToExpansionGroup(m_Container); hierarchy.Add(expander); + + expander.AddToClassList("variables"); + expander.RegisterCallback(OnCustomStyleResolved); + RegisterCallback(new EventCallback(OnAttachToPanel)); - RegisterCallback(DeferredExecution); + RegisterCallback(evt => DeferredExecution(evt, headerElement)); + if (startExpand) + SetValueWithoutNotify(true); } - private void DeferredExecution(GeometryChangedEvent evt) + private void DeferredExecution(GeometryChangedEvent evt, VisualElement headerElement) { - UnregisterCallback(DeferredExecution); + UnregisterCallback(e => DeferredExecution(e, headerElement)); + headerBorderLine.style.maxWidth = new StyleLength(Length.Percent(100)); + GetStyles(); var label = this.Query