From ffeb353b663c7f3cb8af72aa3388e29da78c499e Mon Sep 17 00:00:00 2001 From: revenmartin Date: Tue, 25 May 2021 19:44:02 +0800 Subject: [PATCH] Perfect animation --- qml/AppItem.qml | 19 +++++++++++++++++ qml/DockItem.qml | 53 ++++++++++++++++++++++++++++++++++-------------- qml/main.qml | 19 +++++++++++++++++ 3 files changed, 76 insertions(+), 15 deletions(-) diff --git a/qml/AppItem.qml b/qml/AppItem.qml index e2ea3d1..625697c 100644 --- a/qml/AppItem.qml +++ b/qml/AppItem.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: rekols + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.12 import QtQuick.Controls 2.12 import Cutefish.Dock 1.0 diff --git a/qml/DockItem.qml b/qml/DockItem.qml index 61c9869..1955b03 100644 --- a/qml/DockItem.qml +++ b/qml/DockItem.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: rekols + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.12 import QtQuick.Controls 2.12 import QtGraphicalEffects 1.0 @@ -139,44 +158,48 @@ Item { } Rectangle { - id: activeLine - width: !isBottom ? parent.width * 0.06 : (isActive ? parent.height * 0.4 : parent.height * 0.06) - height: !isBottom ? (isActive ? parent.height * 0.4 : parent.height * 0.06) : parent.height * 0.06 - color: FishUI.Theme.textColor - radius: !isBottom ? width / 2 : height / 2 - visible: enableActivateDot && !dragStarted - opacity: isActive ? 1 : 0.6 + id: activeRect property var leftX: 3 property var leftY: (parent.height - height) / 2 property var bottomX: (parent.width - width) / 2 - property var bottomY: icon.y + icon.height + activeLine.height / 2 - 2 + property var bottomY: icon.y + icon.height + activeRect.height / 2 - 2 - property var rightX: icon.x + icon.width + activeLine.width / 2 - 2 + property var rightX: icon.x + icon.width + activeRect.width / 2 - 2 property var rightY: (parent.height - height) / 2 + property var circleSize: isBottom ? control.height * 0.06 : control.width * 0.06 + property var activeLength: isBottom ? control.height * 0.5 : control.height * 0.5 + + width: !isBottom ? circleSize : (isActive ? activeLength : circleSize) + height: !isBottom ? (isActive ? activeLength : circleSize) : circleSize + radius: !isBottom ? width / 2 : height / 2 + visible: enableActivateDot && !dragStarted + color: FishUI.Theme.textColor + opacity: 1.0 + x: isLeft ? leftX : isBottom ? bottomX : rightX y: isLeft ? leftY : isBottom ? bottomY : rightY Behavior on opacity { NumberAnimation { - duration: 125 - easing.type: Easing.InOutCubic + duration: 200 + easing.type: Easing.InOutSine } } Behavior on width { NumberAnimation { - duration: isBottom ? 125 : 0 - easing.type: Easing.InOutCubic + duration: isBottom ? 200 : 0 + easing.type: Easing.InOutSine } } Behavior on height { NumberAnimation { - duration: !isBottom ? 125 : 0 - easing.type: Easing.InOutCubic + duration: !isBottom ? 200 : 0 + easing.type: Easing.InOutSine } } } diff --git a/qml/main.qml b/qml/main.qml index 9dfe6ac..908c9d7 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: rekols + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12