From e102fcf792f85ed3491edbcfe542bec37c5d6990 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 1 Jan 2021 15:30:47 +0200 Subject: [PATCH] parabolic:provide better rapid movement indicator --each item is now informing Parabolic ability about its visible index when the mouser enters first time its area. This is enough for parabolic effect to identify correctly when there is mouse rapid movement. --- .../abilities/privates/ParabolicEffectPrivate.qml | 15 +++++++++++++++ .../package/contents/ui/applet/ParabolicArea.qml | 10 ++++------ .../contents/ui/abilities/ParabolicEffect.qml | 6 ++++++ .../package/contents/ui/task/ParabolicArea.qml | 10 ++++------ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml b/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml index 125a809d9..30b7c9c2b 100644 --- a/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml +++ b/containment/package/contents/ui/abilities/privates/ParabolicEffectPrivate.qml @@ -36,6 +36,8 @@ AbilityHost.ParabolicEffect { readonly property bool horizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal + property int lastParabolicItemIndex: -1 + Connections { target: parabolic onSglClearZoom: parabolic._privates.lastIndex = -1; @@ -97,6 +99,18 @@ AbilityHost.ParabolicEffect { view.parabolic.currentItem = item; } + function setCurrentParabolicItemIndex(index) { + if (!directRenderingEnabled + && lastParabolicItemIndex > -1 + && index > -1 + && Math.abs(lastParabolicItemIndex-index) >=2 ) { + //! rapid movement + setDirectRenderingEnabled(true); + } + + lastParabolicItemIndex = index; + } + function applyParabolicEffect(index, currentMousePosition, center) { if (parabolic._privates.lastIndex === -1) { setDirectRenderingEnabled(false); @@ -159,6 +173,7 @@ AbilityHost.ParabolicEffect { return; } + parabolic.lastParabolicItemIndex = -1; parabolic.sglClearZoom(); if (debug.timersEnabled) { diff --git a/containment/package/contents/ui/applet/ParabolicArea.qml b/containment/package/contents/ui/applet/ParabolicArea.qml index 4cfd98d4a..b18f01d8f 100644 --- a/containment/package/contents/ui/applet/ParabolicArea.qml +++ b/containment/package/contents/ui/applet/ParabolicArea.qml @@ -43,6 +43,10 @@ Item { onEntered: { appletItem.parabolic.setCurrentParabolicItem(_parabolicArea); + + var vIndex = appletItem.indexer.visibleIndex(index); + appletItem.parabolic.setCurrentParabolicItemIndex(vIndex); + //! mouseX/Y can be trusted in that case in comparison to tasks that the relevant ParabolicAreaMouseArea does not _parabolicArea.parabolicEntered(mouseX, mouseY); } @@ -83,12 +87,6 @@ Item { return; } - var rapidMovement = appletItem.parabolic.lastIndex>=0 && Math.abs(appletItem.parabolic.lastIndex-index)>1; - - if (rapidMovement) { - parabolic.setDirectRenderingEnabled(true); - } - if( ((wrapper.zoomScale === 1 || wrapper.zoomScale === appletItem.parabolic.factor.zoom) && !parabolic.directRenderingEnabled) || parabolic.directRenderingEnabled) { if (root.isHorizontal){ var step = Math.abs(appletItem.layouts.currentSpot-mouseX); diff --git a/plasmoid/package/contents/ui/abilities/ParabolicEffect.qml b/plasmoid/package/contents/ui/abilities/ParabolicEffect.qml index 84907face..b38f0d3b3 100644 --- a/plasmoid/package/contents/ui/abilities/ParabolicEffect.qml +++ b/plasmoid/package/contents/ui/abilities/ParabolicEffect.qml @@ -128,6 +128,12 @@ ClientAbility.ParabolicEffect { } } + function setCurrentParabolicItemIndex(index) { + if (bridge) { + bridge.parabolic.host.setCurrentParabolicItemIndex(index); + } + } + function applyParabolicEffect(index, currentMousePosition, center) { if (parabolic.local._privates.lastIndex === -1) { diff --git a/plasmoid/package/contents/ui/task/ParabolicArea.qml b/plasmoid/package/contents/ui/task/ParabolicArea.qml index a53ebe094..e84229150 100644 --- a/plasmoid/package/contents/ui/task/ParabolicArea.qml +++ b/plasmoid/package/contents/ui/task/ParabolicArea.qml @@ -42,6 +42,10 @@ Item { onEntered: { taskItem.parabolic.setCurrentParabolicItem(_parabolicArea); + + var vIndex = taskItem.shortcuts.shortcutIndex(taskItem.itemIndex); + taskItem.parabolic.setCurrentParabolicItemIndex(vIndex); + // mouseX/Y can not be trusted at this point //_parabolicArea.parabolicEntered(mouseX, mouseY); } @@ -88,12 +92,6 @@ Item { } if((inAnimation == false)&&(!root.taskInAnimation)&&(!root.disableRestoreZoom) && taskItem.hoverEnabled){ - var rapidMovement = taskItem.parabolic.local.lastIndex>=0 && Math.abs(taskItem.parabolic.local.lastIndex-itemIndex)>1; - - if (rapidMovement) { - taskItem.parabolic.setDirectRenderingEnabled(true); - } - if( ((wrapper.mScale === 1 || wrapper.mScale === taskItem.parabolic.factor.zoom) && !taskItem.parabolic.directRenderingEnabled) || taskItem.parabolic.directRenderingEnabled || !taskItem.scalesUpdatedOnce) { if(root.dragSource == null){