diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index 262442e73..ba8138180 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -28,6 +28,8 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 +import "colorizer" as Colorizer + import org.kde.latte 0.1 as Latte Item{ @@ -473,10 +475,11 @@ Item{ } } - Rectangle { + Colorizer.CustomBackground { anchors.fill: solidBackground opacity: root.forceColorizeFromActiveWindowScheme ? solidBackground.opacity : 0 - color: root.forceColorizeFromActiveWindowScheme ? dock.visibility.touchingWindowScheme.backgroundColor : "#00000000" + backgroundColor: root.forceColorizeFromActiveWindowScheme ? dock.visibility.touchingWindowScheme.backgroundColor : "transparent" + roundness: 4 } PlasmaCore.FrameSvgItem{ diff --git a/containment/package/contents/ui/colorizer/CustomBackground.qml b/containment/package/contents/ui/colorizer/CustomBackground.qml new file mode 100644 index 000000000..c7a318e68 --- /dev/null +++ b/containment/package/contents/ui/colorizer/CustomBackground.qml @@ -0,0 +1,200 @@ +/* +* Copyright 2018 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.7 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.latte 0.1 as Latte + +Item{ + id: main + anchors.fill: parent + clip: true + + property int roundness: 0 + property color backgroundColor + + property bool topBorder: false + property bool leftBorder: false + property bool bottomBorder: false + property bool rightBorder: false + + property int noOfBorders: { + var i = 0; + + if (topBorder) { + i = i + 1; + } + if (leftBorder) { + i = i + 1; + } + if (rightBorder) { + i = i + 1; + } + if (bottomBorder) { + i = i + 1; + } + + return i; + } + + readonly property bool drawWithoutRoundness: noOfBorders === 1 || !Latte.WindowSystem.compositingActive + + Binding{ + target: main + property: "topBorder" + when: dock + value: { + return ((dock.enabledBorders & PlasmaCore.FrameSvg.TopBorder) > 0); + } + } + + Binding{ + target: main + property: "leftBorder" + when: dock + value: { + return ((dock.enabledBorders & PlasmaCore.FrameSvg.LeftBorder) > 0); + } + } + + Binding{ + target: main + property: "bottomBorder" + when: dock + value: { + return ((dock.enabledBorders & PlasmaCore.FrameSvg.BottomBorder) > 0); + } + } + + Binding{ + target: main + property: "rightBorder" + when: dock + value: { + return ((dock.enabledBorders & PlasmaCore.FrameSvg.RightBorder) > 0); + } + } + + Rectangle{ + id: painter + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenterOffset: -centerStep + + width: { + if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { + if (drawWithoutRoundness || noOfBorders === 3) { + return parent.width; + } else if (noOfBorders === 2) { + return parent.width + roundness; + } + } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { + if (drawWithoutRoundness) { + return parent.width; + } else if (noOfBorders === 2 || noOfBorders === 3) { + return parent.width + roundness; + } + } + } + + + height: { + if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { + if (drawWithoutRoundness) { + return parent.height; + } else if (noOfBorders === 2 || noOfBorders === 3) { + return parent.height + roundness; + } + } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { + if (drawWithoutRoundness || noOfBorders === 3) { + return parent.height; + } else if (noOfBorders === 2) { + return parent.height + roundness; + } + } + } + + radius: drawWithoutRoundness ? 0 : roundness + color: parent.backgroundColor + border.width: 0; border.color: "transparent" + + readonly property int centerStep: roundness / 2 + + states: [ + State { + name: "horizontal" + when: (plasmoid.formFactor === PlasmaCore.Types.Horizontal) + + PropertyChanges{ + target: painter + anchors.horizontalCenterOffset: { + if (drawWithoutRoundness || noOfBorders === 3) { + return 0; + } else if (noOfBorders === 2) { + if (leftBorder) { + return centerStep; + } else if (rightBorder) { + return -centerStep; + } + } + } + anchors.verticalCenterOffset: { + if (drawWithoutRoundness) { + return 0; + } else { + //top edge and bottom edge + return plasmoid.location === PlasmaCore.Types.TopEdge ? -centerStep : centerStep; + } + } + } + }, + State { + name: "vertical" + when: (plasmoid.formFactor === PlasmaCore.Types.Vertical) + + PropertyChanges{ + target: painter + anchors.verticalCenterOffset: { + if (drawWithoutRoundness || noOfBorders === 3) { + return 0; + } else if (noOfBorders === 2) { + if (bottomBorder) { + return -centerStep; + } else if (topBorder) { + return centerStep; + } + } + } + anchors.horizontalCenterOffset: { + if (drawWithoutRoundness) { + return 0; + } else { + //left edge and right edge + return plasmoid.location === PlasmaCore.Types.LeftEdge ? -centerStep : centerStep; + } + } + } + } + ] + } + +} diff --git a/containment/package/contents/ui/ColorizerManager.qml b/containment/package/contents/ui/colorizer/Manager.qml similarity index 100% rename from containment/package/contents/ui/ColorizerManager.qml rename to containment/package/contents/ui/colorizer/Manager.qml diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index f761a3e30..e925a9e83 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -32,6 +32,7 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.1 as Latte import "applet" as Applet +import "colorizer" as Colorizer import "../code/LayoutManager.js" as LayoutManager @@ -104,7 +105,7 @@ DragDrop.DropArea { property bool forceColorizer: Latte.WindowSystem.compositingActive && plasmoid.configuration.colorizeTransparentPanels property bool forceColorizeFromActiveWindowScheme: plasmoid.configuration.colorizeFromActiveWindowScheme && !editMode - && (dock && dock.visibility + && (dock && dock.visibility && dock.visibility.touchingWindowScheme && (dock.visibility.existsWindowMaximized || dock.visibility.existsWindowSnapped) && !hasExpandedApplet) @@ -1839,7 +1840,7 @@ DragDrop.DropArea { return Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, 1); //remove any transparency } - sourceComponent: ColorizerManager{} + sourceComponent: Colorizer.Manager{} } ///////////////END UI elements