From edb943db6b2c6b98f6e4b22e6e36195040742eab Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 25 May 2020 21:31:01 +0300 Subject: [PATCH] fixes for spacers and positioning of behaveAsPanel --fix positioning for Right/Bottom alignments when View behavesAsPlasmaPanel --- app/view/positioner.cpp | 8 ++++---- .../package/contents/ui/applet/AppletItem.qml | 18 ++++++++---------- .../contents/ui/applet/HiddenSpacer.qml | 13 +++++++++++-- .../package/contents/ui/applet/ItemWrapper.qml | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index bd50a5831..611360866 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -601,7 +601,7 @@ void Positioner::updatePosition(QRect availableScreenRect) if (m_view->alignment() == Latte::Types::Left) { position = {screenGeometry.x() + gap(screenGeometry.width()), y}; } else if (m_view->alignment() == Latte::Types::Right) { - position = {screenGeometry.x() + gapReversed(screenGeometry.width()), y}; + position = {screenGeometry.x() + gapReversed(screenGeometry.width()) + 1, y}; } else { position = {screenGeometry.x() + gapCentered(screenGeometry.width()), y}; } @@ -618,7 +618,7 @@ void Positioner::updatePosition(QRect availableScreenRect) if (m_view->alignment() == Latte::Types::Left) { position = {screenGeometry.x() + gap(screenGeometry.width()), y}; } else if (m_view->alignment() == Latte::Types::Right) { - position = {screenGeometry.x() + gapReversed(screenGeometry.width()), y}; + position = {screenGeometry.x() + gapReversed(screenGeometry.width()) + 1, y}; } else { position = {screenGeometry.x() + gapCentered(screenGeometry.width()), y}; } @@ -635,7 +635,7 @@ void Positioner::updatePosition(QRect availableScreenRect) if (m_view->alignment() == Latte::Types::Top) { position = {x, availableScreenRect.y() + gap(availableScreenRect.height())}; } else if (m_view->alignment() == Latte::Types::Bottom) { - position = {x, availableScreenRect.y() + gapReversed(availableScreenRect.height())}; + position = {x, availableScreenRect.y() + gapReversed(availableScreenRect.height()) + 1}; } else { position = {x, availableScreenRect.y() + gapCentered(availableScreenRect.height())}; } @@ -652,7 +652,7 @@ void Positioner::updatePosition(QRect availableScreenRect) if (m_view->alignment() == Latte::Types::Top) { position = {x, availableScreenRect.y() + gap(availableScreenRect.height())}; } else if (m_view->alignment() == Latte::Types::Bottom) { - position = {x, availableScreenRect.y() + gapReversed(availableScreenRect.height())}; + position = {x, availableScreenRect.y() + gapReversed(availableScreenRect.height()) + 1}; } else { position = {x, availableScreenRect.y() + gapCentered(availableScreenRect.height())}; } diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 073e75924..aeb92ae00 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -97,13 +97,13 @@ Item { property bool lastChildOfEndLayout: index === appletItem.layouter.endLayout.lastVisibleIndex readonly property bool atScreenEdge: { - if (root.panelAlignment !== LatteCore.Types.Justify || root.inConfigureAppletsMode || plasmoid.configuration.offset!==0) { + if (root.panelAlignment === LatteCore.Types.Center) { return false; } if (root.panelAlignment === LatteCore.Types.Justify) { //! Justify case - if (root.maxLengthPerCentage!==100) { + if (root.maxLengthPerCentage!==100 || plasmoid.configuration.offset!==0) { return false; } @@ -124,21 +124,19 @@ Item { return false; } - //! [disabled] because it is probably not needed at all. If in the future there is a report - //! describing a case that this would be useful this disablement choice can be rethought - /*if (root.panelAlignment === LatteCore.Types.Left) { + if (root.panelAlignment === LatteCore.Types.Left && plasmoid.configuration.offset===0) { //! Left case return firstChildOfMainLayout; - } else if (root.panelAlignment === LatteCore.Types.Right) { + } else if (root.panelAlignment === LatteCore.Types.Right && plasmoid.configuration.offset===0) { //! Right case - return lastChildOfMainLayout + return lastChildOfMainLayout; } - if (root.panelAlignment === LatteCore.Types.Top) { + if (root.panelAlignment === LatteCore.Types.Top && plasmoid.configuration.offset===0) { return firstChildOfMainLayout && latteView && latteView.y === latteView.screenGeometry.y; - } else if (root.panelAlignment === LatteCore.Types.Bottom) { + } else if (root.panelAlignment === LatteCore.Types.Bottom && plasmoid.configuration.offset===0) { return lastChildOfMainLayout && latteView && ((latteView.y + latteView.height) === (latteView.screenGeometry.y + latteView.screenGeometry.height)); - }*/ + } return false; } diff --git a/containment/package/contents/ui/applet/HiddenSpacer.qml b/containment/package/contents/ui/applet/HiddenSpacer.qml index 68c8da931..efcc1c91a 100644 --- a/containment/package/contents/ui/applet/HiddenSpacer.qml +++ b/containment/package/contents/ui/applet/HiddenSpacer.qml @@ -49,8 +49,17 @@ Item{ readonly property bool atEdgeForcingFittsLaw: !isSeparator && !parabolicEffectMarginsEnabled && atScreenEdge readonly property int subtrackedMargins: { - if (atEdgeForcingFittsLaw && !appletItem.isAutoFillApplet && ((firstChildOfStartLayout && rightSpacer) || (lastChildOfEndLayout && !rightSpacer ))) { - return (wrapper.edgeLengthMarginsDisabled ? appletItem.metrics.margin.length + appletItem.lengthAppletPadding : appletItem.metrics.margin.length); + if (atEdgeForcingFittsLaw && !appletItem.isAutoFillApplet) { + var inJustifyStart = (root.inFullJustify && firstChildOfStartLayout && rightSpacer); + var inJustifyEnd = (root.inFullJustify && lastChildOfEndLayout && !rightSpacer); + + var singleApplet = firstChildOfMainLayout && lastChildOfMainLayout; + var inSideStart = ((root.panelAlignment === LatteCore.Types.Left || root.panelAlignment === LatteCore.Types.Top) && firstChildOfMainLayout && rightSpacer); + var inSideEnd = ((root.panelAlignment === LatteCore.Types.Right || root.panelAlignment === LatteCore.Types.Bottom) && lastChildOfMainLayout && !rightSpacer); + + if (inJustifyStart || inJustifyEnd || inSideStart || inSideEnd) { + return (wrapper.edgeLengthMarginsDisabled ? appletItem.metrics.margin.length + appletItem.lengthAppletPadding : appletItem.metrics.margin.length); + } } return 0; diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 02f6ea999..b23d7736c 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -301,7 +301,7 @@ Item{ target: wrapper property: "marginsLength" when: latteView && (!root.inStartup || visibilityManager.inTempHiding) - value: root.inFullJustify && atScreenEdge && !parabolicEffectMarginsEnabled ? edgeLengthMargins : localLengthMargins + value: atScreenEdge && !parabolicEffectMarginsEnabled ? edgeLengthMargins : localLengthMargins } function updateAutoFillLength() {