From 7df53a05d0b3e7235b68c5a23cb2902ad503b499 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 15 Apr 2026 17:31:26 +1000 Subject: [PATCH] feat: add anim type shorthand + anchor anim --- components/AnchorAnim.qml | 51 +++++++++++++++++++++++++++++++++++++++ components/Anim.qml | 45 ++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 components/AnchorAnim.qml 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; + } }