From bc6e3cefb22705dd5452001b91c31433d4931541 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 31 Dec 2020 20:53:36 +0200 Subject: [PATCH] plenty of fixes for Justify splitters --- .../ui/abilities/privates/LayouterPrivate.qml | 51 +++++++++++-------- .../privates/layouter/AppletsContainer.qml | 6 +-- .../package/contents/ui/applet/AppletItem.qml | 21 +++++--- .../contents/ui/applet/ItemWrapper.qml | 13 ++--- 4 files changed, 52 insertions(+), 39 deletions(-) diff --git a/containment/package/contents/ui/abilities/privates/LayouterPrivate.qml b/containment/package/contents/ui/abilities/privates/LayouterPrivate.qml index beffc1c6d..3eda6c69a 100644 --- a/containment/package/contents/ui/abilities/privates/LayouterPrivate.qml +++ b/containment/package/contents/ui/abilities/privates/LayouterPrivate.qml @@ -30,6 +30,8 @@ Item { property Item indexer: null readonly property int fillApplets: startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets + readonly property int shownApplets: startLayout.shownApplets + mainLayout.shownApplets + endLayout.shownApplets + readonly property int sizeWithNoFillApplets: startLayout.sizeWithNoFillApplets + mainLayout.sizeWithNoFillApplets + endLayout.sizeWithNoFillApplets readonly property int maxLength: root.panelAlignment === LatteCore.Types.Justify ? contentsMaxLength : Math.min(root.minLength, contentsMaxLength) @@ -47,6 +49,10 @@ Item { grid: layouts.endLayout } + onFillAppletsChanged: layouter.updateSizeForAppletsInFill(); + onShownAppletsChanged: layouter.updateSizeForAppletsInFill(); + onSizeWithNoFillAppletsChanged: layouter.updateSizeForAppletsInFill(); + //! FILLWIDTH/FILLHEIGHT COMPUTATIONS //! Computations in order to calculate correctly the sizes for applets //! that are requesting fillWidth or fillHeight @@ -83,45 +89,47 @@ Item { for(var i=0; i=0 && minSize!==Infinity ? minSize : -1; prefSize = minSize>=0 && prefSize!==Infinity ? prefSize : -1; maxSize = maxSize>=0 && maxSize!== Infinity ? maxSize : -1; var appliedSize = -1; - //! check if the applet does not provide any valid metrics and for that case //! the system must decide what space to be given after the applets that provide //! nice metrics are assigned their sizes - var systemDecide = ((minSize<0) && (prefSize<0) && (maxSize<0)); + //var systemDecide = ((minSize<0) && (prefSize<0) && (maxSize<0)); + + var staticsize = (minSize>=0 && (maxSize === minSize) && (maxSize !== Infinity)); + var systemDecide = (prefSize<0 && !staticsize); if (!systemDecide) { if (noOfApplets>1) { appliedSize = appletPreferredLength(minSize, prefSize, maxSize); - // console.log( " s3_1 " + curApplet.applet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") -> " + appliedSize); + // console.log( "org.kde.latte s3_1 " + curApplet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") -> " + appliedSize); } else if (noOfApplets===1) { //! at this step if only one applet has remained for which the max size is not null, //! then for this applet we make sure the maximum size does not exceed the available space //! in order for the applet to not be drawn outside the boundaries appliedSize = appletPreferredLength(minSize, prefSize, Math.min(maxSize, sizePerApplet)); - // console.log( " s3_2 " + curApplet.applet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") -> " + appliedSize); + // console.log( "org.kde.latte s3_2 " + curApplet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") -> " + appliedSize); } //! appliedSize is valid and is also lower than the availableSpace, if it is not lower then //! for this applet the needed space will be provided as a second pass in a fair way //! between all remained applets that did not gain a valid fill space if (appliedSize>=0 && appliedSize<=sizePerApplet) { - var properSize = Math.min(appliedSize, availableSpace); - var thickness = root.isVertical ? root.width : root.height; - var adjustedSize = curApplet.isHidden ? 0 : Math.max(thickness, properSize); + var properSize = Math.min(appliedSize, availableSpace); + var adjustedSize = curApplet.isHidden ? 0 : properSize; if (inMaxAutoFillCalculations) { curApplet.maxAutoFillLength = adjustedSize; @@ -134,11 +142,11 @@ Item { noOfApplets = noOfApplets - 1; sizePerApplet = noOfApplets > 1 ? Math.floor(availableSpace / noOfApplets) : availableSpace; - // console.log( " s3_3 " + curApplet.applet.pluginName + " assigned: " + curApplet.maxAutoFillLength); + // console.log( "org.kde.latte s3_3 " + curApplet.pluginName + " assigned: " + curApplet.maxAutoFillLength); } } - // console.log("s3_r " +curApplet.applet.pluginName + " : " + availableSpace + " _ " + sizePerApplet + " _ " + noOfApplets + "\n"); + // console.log("org.kde.latte s3_r " +curApplet.pluginName + " : " + availableSpace + " _ " + sizePerApplet + " _ " + noOfApplets + "\n"); } } @@ -167,14 +175,15 @@ Item { //! the most demanding applet is the one that has maximum size set to Infinity //! AND is not Neutral, meaning that it provided some valid metrics //! AND at the same time gained from step one the biggest space - if (curApplet && curApplet.isAutoFillApplet && ((curApplet.applet && curApplet.applet.Layout) || curApplet.isInternalViewSplitter)) { + if (curApplet && curApplet.isAutoFillApplet && !curApplet.isHidden + && ((curApplet.applet && curApplet.applet.Layout) || curApplet.isInternalViewSplitter)) { var minSize = curApplet.appletMinimumLength; var prefSize = curApplet.appletPreferredLength; var maxSize = curApplet.appletMaximumLength; var isNeutral = (minSize<=0 && prefSize<=0); - // console.log( " s4_0 " + curApplet.applet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") "); + // console.log( " s4_0 " + curApplet.pluginName + " : (" +minSize+","+prefSize+","+maxSize+") "); if (!isNeutral && maxSize===Infinity && ((inMaxAutoFillCalculations && curApplet.maxAutoFillLength>mostDemandingAppletSize) @@ -203,7 +212,7 @@ Item { //! between all neutralApplets var adjustedAppletSize = (sizePerApplet / neutralAppletsNo); for (var j=0; j=1 - || appletItem.layouter.endLayout.fillApplet ===0)) - || (parent === layoutsContainer.endLayout - && appletItem.layouter.endLayout.fillApplets === 1 - && (appletItem.layouter.mainLayout.shownApplets>=1)) + readonly property int isFillSplitter: isInternalViewSplitter + && ((parent === layoutsContainer.startLayout + && appletItem.layouter.startLayout.fillApplets === 1 + && (appletItem.layouter.mainLayout.shownApplets>=1 /*main layout has applet in it*/ + || (appletItem.layouter.mainLayout.shownApplets===0 /*main layout is empty*/ + && appletItem.layouter.endLayout.fillApplets === 1))) + || (parent === layoutsContainer.endLayout + && appletItem.layouter.endLayout.fillApplets === 1 + && (appletItem.layouter.mainLayout.shownApplets>=1 /*main layout has applet in it*/ + || (appletItem.layouter.mainLayout.shownApplets===0 /*main layout is empty*/ + && appletItem.layouter.startLayout.fillApplets === 1)))) + readonly property bool inConfigureAppletsDragging: root.dragOverlay && root.dragOverlay.currentApplet @@ -283,6 +288,8 @@ Item { return 2 * lengthAppletPadding; } + readonly property string pluginName: isInternalViewSplitter ? "org.kde.latte.splitter" : (applet ? applet.pluginName : "") + //! are set by the indicator property int iconOffsetX: 0 property int iconOffsetY: 0 diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index a984c36db..6cc5c004f 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -96,25 +96,24 @@ Item{ return root.isHorizontal ? appletMinimumWidth : appletMinimumHeight } - readonly property int appletMinimumThickness: root.isHorizontal ? appletMinimumHeight : appletMinimumWidth + readonly property int appletPreferredLength: { if (isInternalViewSplitter) { - /*var isDragged = (root.dragOverlay - && root.dragOverlay.currentApplet - && root.dragOverlay.pressed);*/ return appletItem.isFillSplitter ? Infinity : -1; } return root.isHorizontal ? appletPreferredWidth : appletPreferredHeight; } - readonly property int appletPreferredThickness: root.isHorizontal ? appletPreferredHeight : appletPreferredWidth readonly property int appletMaximumLength: { if (isInternalViewSplitter) { - return Infinity; + return isFillSplitter ? (root.isHorizontal ? root.width : root.height) : appletMinimumLength; } root.isHorizontal ? appletMaximumWidth : appletMaximumHeight; } + + readonly property int appletMinimumThickness: root.isHorizontal ? appletMinimumHeight : appletMinimumWidth + readonly property int appletPreferredThickness: root.isHorizontal ? appletPreferredHeight : appletPreferredWidth readonly property int appletMaximumThickness: root.isHorizontal ? appletMaximumHeight : appletMaximumWidth property int iconSize: appletItem.metrics.iconSize @@ -217,6 +216,7 @@ Item{ onAppletPreferredLengthChanged: { updateAutoFillLength(); } + onAppletMaximumLengthChanged: { updateAutoFillLength(); } @@ -397,6 +397,7 @@ Item{ sourceComponent: LatteCore.IconItem{ id: overlayIconItem anchors.fill: parent + visible: false source: { if (communicator.appletIconItem && communicator.appletIconItem.visible) {