diff --git a/components/AnchorAnim.qml b/components/AnchorAnim.qml new file mode 100644 index 00000000..dd62dc36 --- /dev/null +++ b/components/AnchorAnim.qml @@ -0,0 +1,51 @@ +import QtQuick +import Caelestia.Config + +AnchorAnimation { + enum Type { + StandardSmall = 0, + Standard, + StandardLarge, + StandardExtraLarge, + EmphasizedSmall, + Emphasized, + EmphasizedLarge, + EmphasizedExtraLarge, + FastSpatial, + DefaultSpatial, + SlowSpatial + } + + property int type: AnchorAnim.DefaultSpatial + + duration: { + if (type < AnchorAnim.StandardSmall || type > AnchorAnim.SlowSpatial) + return Tokens.anim.durations.expressiveDefaultSpatial; + + if (type == AnchorAnim.FastSpatial) + return Tokens.anim.durations.expressiveFastSpatial; + if (type == AnchorAnim.DefaultSpatial) + return Tokens.anim.durations.expressiveDefaultSpatial; + if (type == AnchorAnim.SlowSpatial) + return Tokens.anim.durations.expressiveSlowSpatial; + + const types = ["small", "normal", "large", "extraLarge"]; + const idx = type % 4; // 0-7 are the 4 standard types + return Tokens.anim.durations[types[idx]]; + } + easing: { + if (type == AnchorAnim.FastSpatial) + return Tokens.anim.expressiveFastSpatial; + if (type == AnchorAnim.DefaultSpatial) + return Tokens.anim.expressiveDefaultSpatial; + if (type == AnchorAnim.SlowSpatial) + return Tokens.anim.expressiveSlowSpatial; + + if (type >= AnchorAnim.StandardSmall && type <= AnchorAnim.StandardExtraLarge) + return Tokens.anim.standard; + if (type >= AnchorAnim.EmphasizedSmall && type <= AnchorAnim.EmphasizedExtraLarge) + return Tokens.anim.emphasized; + + return Tokens.anim.expressiveDefaultSpatial; + } +} diff --git a/components/Anim.qml b/components/Anim.qml index 69484591..8bc4468a 100644 --- a/components/Anim.qml +++ b/components/Anim.qml @@ -2,6 +2,47 @@ import QtQuick import Caelestia.Config NumberAnimation { - duration: Tokens.anim.durations.normal - easing: Tokens.anim.standard + enum Type { + StandardSmall = 0, + Standard, + StandardLarge, + StandardExtraLarge, + EmphasizedSmall, + Emphasized, + EmphasizedLarge, + EmphasizedExtraLarge, + FastSpatial, + DefaultSpatial, + SlowSpatial + } + + property int type: Anim.Standard + + duration: { + if (type < Anim.StandardSmall || type > Anim.SlowSpatial) + return Tokens.anim.durations.normal; + + if (type == Anim.FastSpatial) + return Tokens.anim.durations.expressiveFastSpatial; + if (type == Anim.DefaultSpatial) + return Tokens.anim.durations.expressiveDefaultSpatial; + if (type == Anim.SlowSpatial) + return Tokens.anim.durations.expressiveSlowSpatial; + + const types = ["small", "normal", "large", "extraLarge"]; + const idx = type % 4; // 0-7 are the 4 standard types + return Tokens.anim.durations[types[idx]]; + } + easing: { + if (type == Anim.FastSpatial) + return Tokens.anim.expressiveFastSpatial; + if (type == Anim.DefaultSpatial) + return Tokens.anim.expressiveDefaultSpatial; + if (type == Anim.SlowSpatial) + return Tokens.anim.expressiveSlowSpatial; + + if (type >= Anim.EmphasizedSmall && type <= Anim.EmphasizedExtraLarge) + return Tokens.anim.emphasized; + return Tokens.anim.standard; + } }