From 25b636465afbc999a3bf49fe041b9c42ddb10a69 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 11 Mar 2019 19:13:07 +0200 Subject: [PATCH] split animations and make par.effect independent --- containment/package/contents/config/main.xml | 37 ++++-- .../package/contents/ui/VisibilityManager.qml | 14 +-- .../package/contents/ui/applet/AppletItem.qml | 2 +- .../contents/ui/applet/ItemWrapper.qml | 2 +- containment/package/contents/ui/main.qml | 35 +++++- plasmoid/package/contents/ui/main.qml | 12 ++ .../package/contents/ui/task/TaskItem.qml | 2 +- plasmoid/package/contents/ui/task/Wrapper.qml | 2 +- .../configuration/pages/EffectsConfig.qml | 110 ++++++++++-------- 9 files changed, 145 insertions(+), 71 deletions(-) diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index 28e5811ce..45f128077 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -286,15 +286,9 @@ 100 - - - false - - - false - - - false + + + true @@ -305,6 +299,31 @@ 2 + + true + + + true + + + true + + + true + + + true + + + + false + + + false + + + false + diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index ab57d2d25..dbc1d3f16 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -41,7 +41,7 @@ Item{ property bool previousNormalState : false // this is only for debugging purposes property bool panelIsBiggerFromIconSize: root.useThemePanel && (root.themePanelThickness >= (root.iconSize + root.thickMargin)) - property int animationSpeed: Latte.WindowSystem.compositingActive ? root.durationTime * 1.2 * units.longDuration : 0 + property int animationSpeed: Latte.WindowSystem.compositingActive ? root.appliedDurationTime * 1.2 * units.longDuration : 0 property bool inSlidingIn: false //necessary because of its init structure property alias inSlidingOut: slidingAnimationAutoHiddenOut.running property bool inTempHiding: false @@ -51,17 +51,17 @@ Item{ -thicknessNormal : thicknessNormal; property int thicknessAutoHidden: Latte.WindowSystem.compositingActive ? 2 : 1 - property int thicknessMid: (1 + (0.65 * (root.zoomFactor-1)))*(root.iconSize+root.thickMargins+extraThickMask) //needed in some animations + property int thicknessMid: (1 + (0.65 * (root.maxZoomFactor-1)))*(root.iconSize+root.thickMargins+extraThickMask) //needed in some animations property int thicknessNormal: Math.max(root.iconSize + root.thickMargins + extraThickMask + 1, root.realPanelSize + root.panelShadow) - property int thicknessZoom: ((root.iconSize+root.thickMargins+extraThickMask) * root.zoomFactor) + 2 + property int thicknessZoom: ((root.iconSize+root.thickMargins+extraThickMask) * root.maxZoomFactor) + 2 //it is used to keep thickness solid e.g. when iconSize changes from auto functions - property int thicknessMidOriginal: Math.max(thicknessNormalOriginal,extraThickMask + (1 + (0.65 * (root.zoomFactor-1)))*(root.maxIconSize+root.maxThickMargin)) //needed in some animations + property int thicknessMidOriginal: Math.max(thicknessNormalOriginal,extraThickMask + (1 + (0.65 * (root.maxZoomFactor-1)))*(root.maxIconSize+root.maxThickMargin)) //needed in some animations property int thicknessNormalOriginal: !root.behaveAsPlasmaPanel || root.editMode ? thicknessNormalOriginalValue : root.realPanelSize + root.panelShadow property int thicknessNormalOriginalValue: root.maxIconSize + (root.maxThickMargin * 2) + extraThickMask + 1 - property int thicknessZoomOriginal: Math.max( ((root.maxIconSize+(root.maxThickMargin * 2)) * root.zoomFactor) + extraThickMask + 2, + property int thicknessZoomOriginal: Math.max( ((root.maxIconSize+(root.maxThickMargin * 2)) * root.maxZoomFactor) + extraThickMask + 2, root.realPanelSize + root.panelShadow, (Latte.WindowSystem.compositingActive ? thicknessEditMode + root.editShadow : thicknessEditMode)) @@ -634,7 +634,7 @@ Item{ if (!manager.inTempHiding) { updateMaskArea(); - } else if (plasmoid.configuration.durationTime === 0) { + } else { sendHideDockDuringLocationChangeFinished(); } } @@ -649,7 +649,7 @@ Item{ id: slidingAnimationAutoHiddenIn PauseAnimation{ - duration: manager.inTempHiding && root.durationTime>0 ? 500 : 0 + duration: manager.inTempHiding && animationsEnabled ? 500 : 0 } PropertyAnimation { diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 5b3a3a04e..3d4832b5f 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -94,7 +94,7 @@ Item { ||((index === layoutsContainer.mainLayout.beginIndex+layoutsContainer.mainLayout.count-2)&&(layoutsContainer.mainLayout.count>2)) ||((index === layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1)&&(layoutsContainer.endLayout.count>1))) - property int animationTime: root.durationTime* (1.2 *units.shortDuration) // 70 + property int animationTime: appliedDurationTime * (1.2 *units.shortDuration) property int hoveredIndex: layoutsContainer.hoveredIndex property int index: -1 property int maxWidth: root.isHorizontal ? root.height : root.width diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 7c1da9d9f..4ddb99229 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -627,7 +627,7 @@ Item{ } function calculateScales( currentMousePosition ){ - if (root.zoomFactor===1 || root.durationTime===0) { + if (root.zoomFactor===1) { return; } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 16d0e1006..12ba60adf 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -76,7 +76,7 @@ DragDrop.DropArea { if (!latteView || !latteView.visibility) return false; - return (visibilityManager.panelIsBiggerFromIconSize && (zoomFactor === 1.0) + return (visibilityManager.panelIsBiggerFromIconSize && (maxZoomFactor === 1.0) && (latteView.visibility.mode === Latte.Types.AlwaysVisible || latteView.visibility.mode === Latte.Types.WindowsGoBelow) && (plasmoid.configuration.panelPosition === Latte.Types.Justify) && !(root.solidStylePanel && panelShadowsActive)); } @@ -331,7 +331,6 @@ DragDrop.DropArea { //! to be always correctly centered property int thickMargins: 2 * thickMargin - //it is used in order to not break the calculations for the thickness placement //especially in automatic icon sizes calculations property int maxThickMargin: thickMarginFactor * maxIconSize @@ -347,7 +346,7 @@ DragDrop.DropArea { ( plasmoid.configuration.panelPosition === Latte.Types.Justify ? Latte.Types.Center : plasmoid.configuration.panelPosition ) - property real zoomFactor: (Latte.WindowSystem.compositingActive && durationTime>0) ? ( 1 + (plasmoid.configuration.zoomLevel / 20) ) : 1 + property real zoomFactor: Latte.WindowSystem.compositingActive ? ( 1 + (plasmoid.configuration.zoomLevel / 20) ) : 1 readonly property string plasmoidName: "org.kde.latte.plasmoid" @@ -424,11 +423,25 @@ DragDrop.DropArea { property int launchersGroup: plasmoid.configuration.launchersGroup property int tasksCount: latteApplet ? latteApplet.tasksCount : 0 + //! Animations + property bool animationsEnabled: plasmoid.configuration.animationsEnabled && Latte.WindowSystem.compositingActive + property bool animationLauncherBouncing: animationsEnabled && latteApplet && plasmoid.configuration.animationLauncherBouncing + property bool animationWindowInAttention: animationsEnabled && latteApplet && plasmoid.configuration.animationWindowInAttention + property bool animationNewWindowSliding: animationsEnabled && latteApplet && plasmoid.configuration.animationNewWindowSliding + property bool animationWindowAddedInGroup: animationsEnabled && latteApplet && plasmoid.configuration.animationWindowAddedInGrou + property bool animationWindowRemovedFromGroup: animationsEnabled && latteApplet && plasmoid.configuration.animationWindowRemovedFromGroup + + property real appliedDurationTime: animationsEnabled ? durationTime : 2 property real durationTime: { - if ((latteView && latteView.effects && latteView.effects.animationsBlocked) || !Latte.WindowSystem.compositingActive) { + if (!animationsEnabled) { return 0; } + /*if ((latteView && latteView.effects && latteView.effects.animationsBlocked) + || !animationsEnabled) { + return 0; + }*/ + if (plasmoid.configuration.durationTime === 0 || plasmoid.configuration.durationTime === 2 ) return plasmoid.configuration.durationTime; @@ -440,6 +453,20 @@ DragDrop.DropArea { return 2; } + property real animationsZoomFactor : { + if (!animationsEnabled) { + return 1; + } + + if (latteApplet && (animationLauncherBouncing || animationWindowInAttention || animationWindowAddedInGroup)) { + return 1.65; + } + + return 1; + } + + property real maxZoomFactor: Math.max(zoomFactor, animationsZoomFactor) + property rect screenGeometry: latteView ? latteView.screenGeometry : plasmoid.screenGeometry readonly property color minimizedDotColor: colorizerManager.minimizedDotColor diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 19a720759..7db65af3c 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -217,6 +217,18 @@ Item { property int tasksWidth: mouseHandler.width property int userPanelPosition: latteView ? latteView.panelAlignment : plasmoid.configuration.plasmoidPosition + //! Animations + property bool animationsEnabled: latteView ? latteView.animationsEnabled : durationTime !== 0 + property bool animationLauncherBouncing: latteView ? latteView.animationLauncherBouncing : durationTime !== 0 + property bool animationWindowInAttention: latteView ? latteView.animationWindowInAttention : durationTime !== 0 + property bool animationNewWindowSliding: latteView ? latteView.animationNewWindowSliding : durationTime !== 0 + property bool animationWindowAddedInGroup: latteView ? latteView.animationWindowAddedInGrou : durationTime !== 0 + property bool animationWindowRemovedFromGroup: latteView ? latteView.animationWindowRemovedFromGroup : durationTime !== 0 + + property real animationsZoomFactor: latteView ? latteView.animationsZoomFactor : durationTime === 0 ? 1 : 1.65 + property real maxZoomFactor: latteView ? latteView.maxZoomFactor : Math.max(zoomFactor, animationsZoomFactor) + + property real appliedDurationTime: animationsEnabled ? durationTime : 2 property real durationTime: latteView ? latteView.durationTime : plasmoid.configuration.durationTime property real zoomFactor: latteView ? latteView.zoomFactor : ( 1 + (plasmoid.configuration.zoomLevel / 20) ) diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index 33e7ee3fc..24e2dbfc8 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -126,7 +126,7 @@ MouseArea{ property bool pressed: false property bool wheelIsBlocked: false - property int animationTime: root.durationTime * 1.2 * units.shortDuration + property int animationTime: (animationsEnabled ? root.durationTime : 2) * (1.2 *units.shortDuration) property int badgeIndicator: 0 //it is used from external apps property int hoveredIndex: icList.hoveredIndex property int itemIndex: index diff --git a/plasmoid/package/contents/ui/task/Wrapper.qml b/plasmoid/package/contents/ui/task/Wrapper.qml index 702f8a51e..27f368483 100644 --- a/plasmoid/package/contents/ui/task/Wrapper.qml +++ b/plasmoid/package/contents/ui/task/Wrapper.qml @@ -142,7 +142,7 @@ Item{ } function calculateScales( currentMousePosition ){ - if (root.zoomFactor===1 || root.durationTime===0) { + if (root.zoomFactor===1) { return; } diff --git a/shell/package/contents/configuration/pages/EffectsConfig.qml b/shell/package/contents/configuration/pages/EffectsConfig.qml index b3b5a1650..db3eccec0 100644 --- a/shell/package/contents/configuration/pages/EffectsConfig.qml +++ b/shell/package/contents/configuration/pages/EffectsConfig.qml @@ -312,66 +312,82 @@ PlasmaComponents.Page { Layout.rightMargin: units.smallSpacing * 2 spacing: units.smallSpacing - LatteExtraControls.Header { + LatteExtraControls.HeaderSwitch { + id: animationsHeader + Layout.fillWidth: true + Layout.minimumHeight: implicitHeight + Layout.topMargin: units.smallSpacing + + checked: plasmoid.configuration.animationsEnabled text: i18n("Animations") - } + tooltip: i18n("Enable/disable all animations") - LatteExtraControls.SubHeader { - Layout.leftMargin: units.smallSpacing * 2 - isFirstSubCategory: true - text: i18n("Duration") + onPressed: { + plasmoid.configuration.animationsEnabled = !plasmoid.configuration.animationsEnabled; + } } - RowLayout { - Layout.fillWidth: true - Layout.leftMargin: units.smallSpacing * 2 - spacing: 2 - - property int duration: plasmoid.configuration.durationTime + ColumnLayout { + spacing: 0 + enabled: plasmoid.configuration.animationsEnabled - ExclusiveGroup { - id: animationsGroup - onCurrentChanged: { - if (current.checked) - plasmoid.configuration.durationTime = current.duration - } + LatteExtraControls.SubHeader { + Layout.leftMargin: units.smallSpacing * 2 + isFirstSubCategory: true + text: i18n("Speed") } - PlasmaComponents.Button { + RowLayout { Layout.fillWidth: true - text: i18n("Instant") - checked: parent.duration === duration - checkable: true - exclusiveGroup: animationsGroup + Layout.leftMargin: units.smallSpacing * 2 + spacing: 2 - readonly property int duration: 0 - } - PlasmaComponents.Button { - Layout.fillWidth: true - text: i18n("x1") - checked: parent.duration === duration - checkable: true - exclusiveGroup: animationsGroup + property int duration: plasmoid.configuration.durationTime - readonly property int duration: 1 - } - PlasmaComponents.Button { - Layout.fillWidth: true - text: i18n("x2") - checked: parent.duration === duration - checkable: true - exclusiveGroup: animationsGroup + ExclusiveGroup { + id: animationsGroup + onCurrentChanged: { + if (current.checked) + plasmoid.configuration.durationTime = current.duration + } + } + + PlasmaComponents.Button { + Layout.fillWidth: true + text: i18n("x1") + checked: parent.duration === duration + checkable: true + exclusiveGroup: animationsGroup - readonly property int duration: 2 + readonly property int duration: 3 + } + PlasmaComponents.Button { + Layout.fillWidth: true + text: i18n("x2") + checked: parent.duration === duration + checkable: true + exclusiveGroup: animationsGroup + + readonly property int duration: 2 + } + PlasmaComponents.Button { + Layout.fillWidth: true + text: i18n("x3") + checked: parent.duration === duration + checkable: true + exclusiveGroup: animationsGroup + + readonly property int duration: 1 + } } - PlasmaComponents.Button { - Layout.fillWidth: true - text: i18n("x3") - checked: parent.duration === duration - checkable: true - exclusiveGroup: animationsGroup - readonly property int duration: 3 + ColumnLayout { + spacing: 0 + LatteExtraControls.SubHeader { + Layout.leftMargin: units.smallSpacing * 2 + isFirstSubCategory: true + text: i18n("Tasks") + } } } }