From 5aac422a65a535699490268475c993673f99b2d9 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Nov 2019 02:27:13 +0200 Subject: [PATCH] Fitt's Law improvements for applets --each applets layout can not identify properly which applet is the first/last visible from its contents. This way we can now identify properly at all cases which applets should remove their margins in order to follow Fitt's Law at screen edges. For example when a windows buttons applet is found at the screen edge and suddently it hides itself then the next visible applet should be considered at screen edge and such should remove its margins in order to touch the screen edge. --- .../package/contents/ui/applet/AppletItem.qml | 23 +++++---- .../contents/ui/layouts/AppletsContainer.qml | 51 +++++++++++++++++++ 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 08e3bc2d1..826cc3b34 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -84,8 +84,8 @@ Item { property bool isSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") property bool isSystray: applet && (applet.pluginName === "org.kde.plasma.systemtray" || applet.pluginName === "org.nomad.systemtray" ) - property bool firstChildOfStartLayout: (index === layoutsContainer.startLayout.beginIndex) - property bool lastChildOfEndLayout: ((index === layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1)&&(layoutsContainer.endLayout.count>1)) + property bool firstChildOfStartLayout: index === layoutsContainer.startLayout.firstVisibleIndex + property bool lastChildOfEndLayout: index === layoutsContainer.endLayout.lastVisibleIndex readonly property bool atScreenEdge: { if (root.isHorizontal) { @@ -106,14 +106,15 @@ Item { } //applet is in starting edge - /*property bool startEdge: index < layoutsContainer.endLayout.beginIndex ? (index === 0)&&(layoutsContainer.mainLayout.count > 1) : - (index === layoutsContainer.endLayout.beginIndex)&&(layoutsContainer.endLayout.count > 1)*/ - property bool startEdge: (index === layoutsContainer.startLayout.beginIndex) || (index === layoutsContainer.mainLayout.beginIndex) || (index === layoutsContainer.endLayout.beginIndex) + property bool startEdge: (index >=0) && + ((index === layoutsContainer.startLayout.firstVisibleIndex) + || (index === layoutsContainer.mainLayout.firstVisibleIndex) + || (index === layoutsContainer.endLayout.firstVisibleIndex)) //applet is in ending edge - property bool endEdge: plasmoid.configuration.panelPosition !== Latte.Types.Justify ? (index === layoutsContainer.mainLayout.beginIndex + layoutsContainer.mainLayout.count - 1)&&(layoutsContainer.mainLayout.count>1) : - (((index === layoutsContainer.startLayout.beginIndex+layoutsContainer.startLayout.count-2)&&(layoutsContainer.startLayout.count>2)) - ||((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 bool endEdge: (index >=0) && + ((index === layoutsContainer.startLayout.lastVisibleIndex) + || (index === layoutsContainer.mainLayout.lastVisibleIndex) + || (index === layoutsContainer.endLayout.lastVisibleIndex)) readonly property bool acceptMouseEvents: applet && !isLattePlasmoid && !originalAppletBehavior && !appletItem.isSeparator && !communicator.parabolicEffectLocked readonly property bool originalAppletBehavior: (root.zoomFactor === 1 && !lockZoom /*hacky flag to keep Latte behavior*/) @@ -466,8 +467,8 @@ Item { Component.onDestruction: { if (animationWasSent) { - root.slotAnimationsNeedBothAxis(-1); - animationWasSent = false; + root.slotAnimationsNeedBothAxis(-1); + animationWasSent = false; } if (isSeparator){ diff --git a/containment/package/contents/ui/layouts/AppletsContainer.qml b/containment/package/contents/ui/layouts/AppletsContainer.qml index 0839728b3..9dbe612e8 100644 --- a/containment/package/contents/ui/layouts/AppletsContainer.qml +++ b/containment/package/contents/ui/layouts/AppletsContainer.qml @@ -91,6 +91,57 @@ Grid { return no; } + property int firstVisibleIndex: -1 + property int lastVisibleIndex: -1 + + Binding{ + target: appletsContainer + property:"firstVisibleIndex" + when: appletsContainer + value: { + if (root.inConfigureAppletsMode) { + return; + } + + var ind = -1; + for (var i=0; i>=children[i].length-1; ++i){ + if (children[i] + && (children[i].index=0; --i){ + if (children[i] + && children[i].index>ind + && children[i].applet + && !children[i].isHidden + && !children[i].isInternalViewSplitter) { + ind = children[i].index; + } + } + + return ind; + } + } + onCountChanged: { if (root.editMode) { //! this is mainly used when removing/adding internal view splitters