From d1f5d301c21d03bdc0e93801d86afc1703a3f062 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Sun, 31 Aug 2025 21:36:30 -0400 Subject: [PATCH] Color animations: more uniform across NWidgets --- Widgets/NCheckbox.qml | 23 ++++++++++++----------- Widgets/NComboBox.qml | 18 +++++++++++++++++- Widgets/NRadioButton.qml | 9 +++++++-- Widgets/NSlider.qml | 6 ++++++ Widgets/NSpinBox.qml | 2 -- Widgets/NTextInput.qml | 6 ++++++ Widgets/NToggle.qml | 12 ++++++++++++ 7 files changed, 60 insertions(+), 16 deletions(-) diff --git a/Widgets/NCheckbox.qml b/Widgets/NCheckbox.qml index 962b303..48d76e5 100644 --- a/Widgets/NCheckbox.qml +++ b/Widgets/NCheckbox.qml @@ -37,6 +37,18 @@ RowLayout { border.color: root.checked ? root.activeColor : Color.mOutline border.width: Math.max(1, Style.borderM * scaling) + Behavior on color { + ColorAnimation { + duration: Style.animationNormal + } + } + + Behavior on border.color { + ColorAnimation { + duration: Style.animationNormal + } + } + NIcon { visible: root.checked anchors.centerIn: parent @@ -59,16 +71,5 @@ RowLayout { } onClicked: root.toggled(!root.checked) } - - Behavior on color { - ColorAnimation { - duration: Style.animationFast - } - } - Behavior on border.color { - ColorAnimation { - duration: Style.animationFast - } - } } } diff --git a/Widgets/NComboBox.qml b/Widgets/NComboBox.qml index a51f690..90d417f 100644 --- a/Widgets/NComboBox.qml +++ b/Widgets/NComboBox.qml @@ -56,6 +56,12 @@ RowLayout { border.color: combo.activeFocus ? Color.mSecondary : Color.mOutline border.width: Math.max(1, Style.borderS * scaling) radius: Style.radiusM * scaling + + Behavior on border.color { + ColorAnimation { + duration: Style.animationFast + } + } } contentItem: NText { @@ -113,12 +119,22 @@ RowLayout { color: highlighted ? Color.mSurface : Color.mOnSurface verticalAlignment: Text.AlignVCenter elide: Text.ElideRight + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } } background: Rectangle { width: combo.width - Style.marginM * scaling * 3 - color: highlighted ? Color.mSecondary : Color.transparent + color: highlighted ? Color.mTertiary : Color.transparent radius: Style.radiusS * scaling + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } } } } diff --git a/Widgets/NRadioButton.qml b/Widgets/NRadioButton.qml index b81991a..9c44f13 100644 --- a/Widgets/NRadioButton.qml +++ b/Widgets/NRadioButton.qml @@ -25,12 +25,17 @@ RadioButton { radius: width * 0.5 color: Qt.alpha(Color.mPrimary, root.checked ? 1 : 0) + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } } Behavior on border.color { ColorAnimation { - duration: Style.animationNormal - easing.type: Easing.InQuad + duration: Style.animationFast } } } diff --git a/Widgets/NSlider.qml b/Widgets/NSlider.qml index 81b3137..c4bd096 100644 --- a/Widgets/NSlider.qml +++ b/Widgets/NSlider.qml @@ -77,6 +77,12 @@ Slider { border.color: Color.mPrimary border.width: Math.max(1, Style.borderL * scaling) + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } + // Press feedback halo (using accent color, low opacity) Rectangle { anchors.centerIn: parent diff --git a/Widgets/NSpinBox.qml b/Widgets/NSpinBox.qml index 79debec..8049cf6 100644 --- a/Widgets/NSpinBox.qml +++ b/Widgets/NSpinBox.qml @@ -49,7 +49,6 @@ RowLayout { Behavior on border.color { ColorAnimation { duration: Style.animationFast - easing.type: Easing.InOutCubic } } @@ -126,7 +125,6 @@ RowLayout { Behavior on color { ColorAnimation { duration: Style.animationFast - easing.type: Easing.InOutCubic } } diff --git a/Widgets/NTextInput.qml b/Widgets/NTextInput.qml index cad5077..adb1f95 100644 --- a/Widgets/NTextInput.qml +++ b/Widgets/NTextInput.qml @@ -51,6 +51,12 @@ ColumnLayout { color: Color.transparent border.color: input.activeFocus ? Color.mSecondary : Color.transparent border.width: input.activeFocus ? Math.max(1, Style.borderS * scaling) : 0 + + Behavior on border.color { + ColorAnimation { + duration: Style.animationFast + } + } } RowLayout { diff --git a/Widgets/NToggle.qml b/Widgets/NToggle.qml index ddf1e80..f04d117 100644 --- a/Widgets/NToggle.qml +++ b/Widgets/NToggle.qml @@ -34,6 +34,18 @@ RowLayout { border.color: root.checked ? Color.mPrimary : Color.mOutline border.width: Math.max(1, Style.borderM * scaling) + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } + + Behavior on border.color { + ColorAnimation { + duration: Style.animationFast + } + } + Rectangle { implicitWidth: (root.baseSize - 5) * scaling implicitHeight: (root.baseSize - 5) * scaling