From a2813a1c439f24332d87b7783fe97175add0cd50 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 11 Sep 2021 14:05:00 +0300 Subject: [PATCH] fix Fitt's Law for parabolic effect items --fix Fitt's law for items touching the screen edge and at the same time using parabolic effect --- .../package/contents/ui/applet/EventsSink.qml | 25 +++++++++++-------- .../contents/ui/applet/ItemWrapper.qml | 8 +++--- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/containment/package/contents/ui/applet/EventsSink.qml b/containment/package/contents/ui/applet/EventsSink.qml index 9bbfac59f..391a8b3d5 100644 --- a/containment/package/contents/ui/applet/EventsSink.qml +++ b/containment/package/contents/ui/applet/EventsSink.qml @@ -20,15 +20,14 @@ Item { || (root.myView.alignment !== LatteCore.Types.Justify && appletItem.firstChildOfMainLayout) || (root.myView.alignment !== LatteCore.Types.Justify && appletItem.lastChildOfMainLayout)) { //! Fitts Law on corners - return appletItem.lengthAppletFullMargin; + return destination ? destination.zoomScaleThickness * appletItem.lengthAppletFullMargin : appletItem.lengthAppletFullMargin; } - return appletItem.lengthAppletPadding; + return destination ? destination.zoomScaleThickness * appletItem.lengthAppletPadding : appletItem.lengthAppletPadding; } readonly property bool active: parent ? parent.active : false - Loader{ anchors.fill: parent active: appletItem.debug.eventsSinkEnabled && active @@ -53,7 +52,8 @@ Item { width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : thickness height: { if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { - return lengthPadding; + //! Fitt;s Law consider the spacer also from parabolic effect + return appletItem.firstAppletInContainer ? lengthPadding + hiddenSpacerLeft.height + 1 : lengthPadding; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { return tailThickness; } else { @@ -79,7 +79,7 @@ Item { AnchorChanges{ target: topArea; anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined; - anchors.right: undefined; anchors.left: leftArea.left; anchors.top: leftArea.top; anchors.bottom: undefined; + anchors.right: undefined; anchors.left: leftArea.left; anchors.top: undefined; anchors.bottom: parent.top; } } ] @@ -90,7 +90,8 @@ Item { width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : thickness height: { if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { - return lengthPadding; + //! Fitt;s Law consider the spacer also from parabolic effect + return appletItem.lastAppletInContainer ? lengthPadding + hiddenSpacerRight.height + 1 : lengthPadding; } else if (plasmoid.location === PlasmaCore.Types.BottomEdge) { return tailThickness; } else { @@ -116,7 +117,7 @@ Item { AnchorChanges{ target: bottomArea; anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined; - anchors.right: undefined; anchors.left: leftArea.left; anchors.top: undefined; anchors.bottom: leftArea.bottom; + anchors.right: undefined; anchors.left: leftArea.left; anchors.top: parent.bottom; anchors.bottom: undefined; } } ] @@ -127,7 +128,8 @@ Item { height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? thickness : destination.height + 2 * lengthPadding width: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { - return lengthPadding; + //! Fitt;s Law consider the spacer also from parabolic effect + return appletItem.firstAppletInContainer ? lengthPadding + hiddenSpacerLeft.width + 1 : lengthPadding; } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) { return tailThickness; } else { @@ -143,7 +145,7 @@ Item { AnchorChanges{ target: leftArea; anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined; - anchors.right: undefined; anchors.left: bottomArea.left; anchors.top: undefined; anchors.bottom: bottomArea.bottom; + anchors.right: parent.left; anchors.left: undefined; anchors.top: undefined; anchors.bottom: bottomArea.bottom; } }, State{ @@ -164,7 +166,8 @@ Item { height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? thickness : destination.height + 2 * lengthPadding width: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { - return lengthPadding; + //! Fitt;s Law consider the spacer also from parabolic effect + return appletItem.lastAppletInContainer ? lengthPadding + hiddenSpacerRight.width + 1 : lengthPadding; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { return tailThickness; } else { @@ -180,7 +183,7 @@ Item { AnchorChanges{ target: rightArea; anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined; - anchors.right: bottomArea.right; anchors.left: undefined; anchors.top: undefined; anchors.bottom: bottomArea.bottom; + anchors.right: undefined; anchors.left: parent.right; anchors.top: undefined; anchors.bottom: bottomArea.bottom; } }, State{ diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index ce38695f4..d5ced3db3 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -464,12 +464,14 @@ Item{ if (appletItem.canFillThickness || appletItem.canFillScreenEdge) { return 0; } else if (appletItem.inMarginsArea) { - return appletItem.metrics.marginsArea.marginThickness; + return (wrapper.zoomScaleThickness * appletItem.metrics.marginsArea.marginThickness); } - return appletItem.metrics.margin.thickness + return (wrapper.zoomScaleThickness * appletItem.metrics.margin.thickness); } + readonly property real zoomScaleThickness: wrapper.zoomScaleThickness + Binding { target: _wrapperContainer property: "_thickness" @@ -642,7 +644,7 @@ Item{ Loader { id: eventsSinkLoader anchors.fill: _wrapperContainer - active: !communicator.parabolicEffectIsSupported && !isSeparator && !isSpacer + active: !communicator.parabolicEffectIsSupported && !isSeparator && !isSpacer && !isHidden && !isInternalViewSplitter //! The following can be added in case EventsSink creates slaginess with parabolic effect //!(appletItem.lockZoom || !appletItem.parabolic.isEnabled || !appletItem.parabolicEffectIsSupported)