diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index d0aaf9b51..e35e16d72 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -577,13 +577,13 @@ Item{ if (noCompositingEdit) { localX = 0; } else if (plasmoid.configuration.alignment === LatteCore.Types.Justify) { - localX = (latteView.width/2) - tempLength/2 + root.offset; + localX = (latteView.width/2) - tempLength/2 + background.offset; } else if (root.panelAlignment === LatteCore.Types.Left) { - localX = root.offset; + localX = background.offset; } else if (root.panelAlignment === LatteCore.Types.Center) { - localX = (latteView.width/2) - tempLength/2 + root.offset; + localX = (latteView.width/2) - tempLength/2 + background.offset; } else if (root.panelAlignment === LatteCore.Types.Right) { - localX = latteView.width - tempLength - root.offset; + localX = latteView.width - tempLength - background.offset; } } else if ((plasmoid.location === PlasmaCore.Types.LeftEdge) || (plasmoid.location === PlasmaCore.Types.RightEdge)){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) { @@ -607,13 +607,13 @@ Item{ if (noCompositingEdit) { localY = 0; } else if (plasmoid.configuration.alignment === LatteCore.Types.Justify) { - localY = (latteView.height/2) - tempLength/2 + root.offset; + localY = (latteView.height/2) - tempLength/2 + background.offset; } else if (root.panelAlignment === LatteCore.Types.Top) { - localY = root.offset; + localY = background.offset; } else if (root.panelAlignment === LatteCore.Types.Center) { - localY = (latteView.height/2) - tempLength/2 + root.offset; + localY = (latteView.height/2) - tempLength/2 + background.offset; } else if (root.panelAlignment === LatteCore.Types.Bottom) { - localY = latteView.height - tempLength - root.offset; + localY = latteView.height - tempLength - background.offset; } } diff --git a/containment/package/contents/ui/background/BackgroundProperties.qml b/containment/package/contents/ui/background/BackgroundProperties.qml index 6559511c1..f8a59298a 100644 --- a/containment/package/contents/ui/background/BackgroundProperties.qml +++ b/containment/package/contents/ui/background/BackgroundProperties.qml @@ -20,9 +20,25 @@ import QtQuick 2.0 import "./types" as BackgroundTypes +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore Item{ property bool isShown: false + + property bool hasAllBorders: false + property bool hasLeftBorder: false + property bool hasRightBorder: false + property bool hasTopBorder: false + property bool hasBottomBorder: false + readonly property bool hasBothLengthShadows:{ + if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { + return (hasTopBorder && hasBottomBorder); + } + + return (hasLeftBorder && hasRightBorder); + } + property int offset: 0 property int length: 0 property int thickness: 0 diff --git a/containment/package/contents/ui/background/MultiLayered.qml b/containment/package/contents/ui/background/MultiLayered.qml index a0ef6d01d..bf3fa524c 100644 --- a/containment/package/contents/ui/background/MultiLayered.qml +++ b/containment/package/contents/ui/background/MultiLayered.qml @@ -46,15 +46,21 @@ BackgroundProperties{ isShown: (solidBackground.opacity > 0) || (overlayedBackground.opacity > 0) - shadows.left: shadowsSvgItem.margins.left - shadows.right: shadowsSvgItem.margins.right - shadows.top: shadowsSvgItem.margins.top - shadows.bottom: shadowsSvgItem.margins.bottom + hasAllBorders: solidBackground.enabledBorders === PlasmaCore.FrameSvg.AllBorders + hasLeftBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.LeftBorder) > 0) + hasRightBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.RightBorder) > 0) + hasTopBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.TopBorder) > 0) + hasBottomBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.BottomBorder) > 0) + + shadows.left: hasLeftBorder ? shadowsSvgItem.margins.left : 0 + shadows.right: hasRightBorder ? shadowsSvgItem.margins.right : 0 + shadows.top: hasTopBorder ? shadowsSvgItem.margins.top : 0 + shadows.bottom: hasBottomBorder ? shadowsSvgItem.margins.bottom : 0 screenEdgeMargin: root.screenEdgeMarginEnabled ? Math.max(0, metrics.margin.screenEdge - shadows.tailThickness) : 0 paddings.top: { - if (root.isHorizontal) { + if (root.isHorizontal && hasTopBorder) { var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.topEdgeRoundness : 0; return Math.max(minimum, solidBackground.margins.top); } @@ -62,7 +68,7 @@ BackgroundProperties{ return 0; } paddings.bottom: { - if (root.isHorizontal) { + if (root.isHorizontal && hasBottomBorder) { var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.bottomEdgeRoundness : 0; return Math.max(minimum, solidBackground.margins.bottom); } @@ -71,7 +77,7 @@ BackgroundProperties{ } paddings.left: { - if (root.isVertical) { + if (root.isVertical && hasLeftBorder) { var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.leftEdgeRoundness : 0; return Math.max(minimum, solidBackground.margins.left); } @@ -80,7 +86,7 @@ BackgroundProperties{ } paddings.right: { - if (root.isVertical) { + if (root.isVertical && hasRightBorder) { var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.rightEdgeRoundness : 0; return Math.max(minimum, solidBackground.margins.right); } @@ -93,7 +99,7 @@ BackgroundProperties{ return root.isVertical ? root.height : root.width; } - if ((root.panelAlignment === LatteCore.Types.Justify) && root.isHorizontal) { + if (root.panelAlignment === LatteCore.Types.Justify) { return root.maxLength; } @@ -112,6 +118,30 @@ BackgroundProperties{ } } + offset: { + if (behaveAsPlasmaPanel || !LatteCore.WindowSystem.compositingActive) { + return 0; + } + + if (root.isHorizontal) { + if (root.panelAlignment === LatteCore.Types.Left) { + return root.offset - shadows.left; + } else if (root.panelAlignment === LatteCore.Types.Right) { + return root.offset - shadows.right; + } + } + + if (root.isVertical) { + if (root.panelAlignment === LatteCore.Types.Top) { + return root.offset - shadows.top; + } else if (root.panelAlignment === LatteCore.Types.Bottom) { + return root.offset - shadows.bottom; + } + } + + return root.offset;// (root.panelAlignment === LatteCore.Types.Center ? root.offset : 0); + } + totals.visualThickness: { var minimumBackground = paddings.headThickness + paddings.tailThickness; var itemMargins = root.shrinkThickMargins ? 0 : metrics.totals.thicknessEdges + metrics.margin.screenEdge; @@ -562,8 +592,8 @@ BackgroundProperties{ states: [ ///Left State { - name: "leftCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === LatteCore.Types.Center || root.panelAlignment === LatteCore.Types.Justify) + name: "leftCenter" + when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === LatteCore.Types.Center) AnchorChanges { target: barLine @@ -576,7 +606,25 @@ BackgroundProperties{ PropertyChanges{ target: barLine anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === LatteCore.Types.Center ? root.offset : 0); + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: background.offset; + } + }, + State { + name: "leftJustify" + when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === LatteCore.Types.Justify) + + AnchorChanges { + target: barLine + anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + } + AnchorChanges { + target: shadowsSvgItem + anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + } + PropertyChanges{ + target: barLine + anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Left @@ -594,7 +642,7 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:root.offset - shadowsSvgItem.margins.top; anchors.bottomMargin:0; + anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:background.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, @@ -613,14 +661,14 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset - shadowsSvgItem.margins.bottom; + anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:background.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Right State { - name: "rightCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === LatteCore.Types.Center || root.panelAlignment === LatteCore.Types.Justify) + name: "rightCenter" + when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === LatteCore.Types.Center) AnchorChanges { target: barLine @@ -633,7 +681,25 @@ BackgroundProperties{ PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === LatteCore.Types.Center ? root.offset : 0); + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: background.offset; + } + }, + State { + name: "rightJustify" + when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === LatteCore.Types.Justify) + + AnchorChanges { + target: barLine + anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + } + AnchorChanges { + target: shadowsSvgItem + anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + } + PropertyChanges{ + target: barLine + anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { @@ -650,7 +716,7 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:root.offset-shadowsSvgItem.margins.top; anchors.bottomMargin:0; + anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:background.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, @@ -668,14 +734,32 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:root.offset-shadowsSvgItem.margins.bottom; + anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:background.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Bottom State { - name: "bottomCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === LatteCore.Types.Center || root.panelAlignment === LatteCore.Types.Justify) + name: "bottomCenter" + when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === LatteCore.Types.Center) + + AnchorChanges { + target: barLine + anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + } + AnchorChanges { + target: shadowsSvgItem + anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + } + PropertyChanges{ + target: barLine + anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; + anchors.horizontalCenterOffset: background.offset; anchors.verticalCenterOffset: 0; + } + }, + State { + name: "bottomJustify" + when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === LatteCore.Types.Justify) AnchorChanges { target: barLine @@ -688,7 +772,7 @@ BackgroundProperties{ PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; - anchors.horizontalCenterOffset: (root.panelAlignment === LatteCore.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { @@ -707,7 +791,7 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: root.offset-shadowsSvgItem.margins.left; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; + anchors.leftMargin: background.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } @@ -728,14 +812,32 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: 0; anchors.rightMargin:root.offset-shadowsSvgItem.margins.right; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; + anchors.leftMargin: 0; anchors.rightMargin:background.offset; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Top State { - name: "topCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === LatteCore.Types.Center || root.panelAlignment === LatteCore.Types.Justify) + name: "topCenter" + when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === LatteCore.Types.Center) + + AnchorChanges { + target: barLine + anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + } + AnchorChanges { + target: shadowsSvgItem + anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + } + PropertyChanges{ + target: barLine + anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: background.offset; anchors.verticalCenterOffset: 0; + } + }, + State { + name: "topJustify" + when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === LatteCore.Types.Justify) AnchorChanges { target: barLine @@ -748,7 +850,7 @@ BackgroundProperties{ PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: (root.panelAlignment === LatteCore.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { @@ -767,7 +869,7 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: root.offset-shadowsSvgItem.margins.left; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; + anchors.leftMargin: background.offset; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, @@ -787,7 +889,7 @@ BackgroundProperties{ } PropertyChanges{ target: barLine - anchors.leftMargin: 0; anchors.rightMargin:root.offset-shadowsSvgItem.margins.right; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; + anchors.leftMargin: 0; anchors.rightMargin:background.offset; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } } diff --git a/containment/package/contents/ui/layouts/LayoutsContainer.qml b/containment/package/contents/ui/layouts/LayoutsContainer.qml index a40ebba65..b1fc7d062 100644 --- a/containment/package/contents/ui/layouts/LayoutsContainer.qml +++ b/containment/package/contents/ui/layouts/LayoutsContainer.qml @@ -64,7 +64,7 @@ Item{ } if ( latteView && root.isHorizontal && useMaxLength ){ - return ((latteView.width/2) - (root.maxLength/2) + root.offset); + return ((latteView.width/2) - (root.maxLength/2) + background.offset); } else { if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isVertical){ return; @@ -97,7 +97,7 @@ Item{ } if ( latteView && root.isVertical && useMaxLength ) { - return ((latteView.height/2) - (root.maxLength/2) + root.offset); + return ((latteView.height/2) - (root.maxLength/2) + background.offset); } else { if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isHorizontal){ return; @@ -191,7 +191,7 @@ Item{ AppletsContainer { id: _startLayout beginIndex: 0 - offset: background.totals.shadowsLength/2 + offset: background.totals.shadowsLength/2 //it is applied only in Justify when both background length shadows are drawn alignment: { switch(plasmoid.location) { case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeLeftAlign; @@ -207,11 +207,17 @@ Item{ AppletsContainer { id: _mainLayout beginIndex: 100 - offset: centered ? appliedOffset : root.offsetFixed + offset: { + if (background.hasBothLengthShadows && !centered) { + //! it is used for Top/Bottom/Left/Right alignments when they show both background length shadows + return background.offset + background.totals.shadowsLength/2; + } + + return (root.panelAlignment === LatteCore.Types.Justify) ? 0 : background.offset + } readonly property bool centered: (root.panelAlignment === LatteCore.Types.Center) || (root.panelAlignment === LatteCore.Types.Justify) readonly property bool reversed: Qt.application.layoutDirection === Qt.RightToLeft - readonly property int appliedOffset: root.panelAlignment === LatteCore.Types.Justify ? 0 : root.offset alignment: { if (plasmoid.location === PlasmaCore.Types.LeftEdge) { @@ -269,7 +275,7 @@ Item{ AppletsContainer { id: _endLayout beginIndex: 200 - offset: background.totals.shadowsLength/2 + offset: background.totals.shadowsLength/2 //it is applied only in Justify when both background length shadows are drawn alignment: { switch(plasmoid.location) { case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeRightAlign; diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 779f5db61..b238b82a6 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -343,10 +343,6 @@ Item { } } - //center the layout correctly when the user uses an offset - property int offsetFixed: (offset===0 || panelAlignment === LatteCore.Types.Center || plasmoid.configuration.alignment === LatteCore.Types.Justify)? - offset : offset + background.totals.shadowsLength/2 - property int editShadow: { if (!LatteCore.WindowSystem.compositingActive) { return 0;