mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-13 16:58:17 +03:00
add customBackground class for colorizer
--in order to overlay properly the panel background a roundness option was needed that takes into account which borders should be drawn. In an upcoming commit the user will be able to adjut the current plasma theme roundness. The Colorizer is using now the CustomBackground in order to draw the background when the user wants to draw the contents based on the current active window color scheme.
This commit is contained in:
parent
1510f1013c
commit
89b86c4b3e
@ -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{
|
||||
|
200
containment/package/contents/ui/colorizer/CustomBackground.qml
Normal file
200
containment/package/contents/ui/colorizer/CustomBackground.qml
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user