From f3f6dccf65a4f95e863915886f8e8141bbfe491e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 16 Mar 2019 19:41:04 +0200 Subject: [PATCH] support Outline option for compositing mode --works much better than I was expecting and at the same time it simplifies the PanelBox code a lot --- containment/package/contents/config/main.xml | 2 +- containment/package/contents/ui/PanelBox.qml | 76 ++++++------------- .../ui/colorizer/CustomBackground.qml | 22 +++--- .../package/contents/ui/colorizer/Manager.qml | 6 +- containment/package/contents/ui/main.qml | 4 +- .../configuration/pages/AppearanceConfig.qml | 10 +-- 6 files changed, 47 insertions(+), 73 deletions(-) diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index 45f128077..48c13a82a 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -75,7 +75,7 @@ 100 - + false diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index 5f9423585..17f498294 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -135,10 +135,8 @@ Item{ PlasmaCore.FrameSvgItem{ id: shadowsSvgItem - width: root.isVertical ? panelSize + marginsWidth - (solidBackground.leftIncreaser + solidBackground.rightIncreaser) : - Math.min(parent.width + marginsWidth, root.width - marginsWidth) - height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : - panelSize + marginsHeight - (solidBackground.topIncreaser + solidBackground.bottomIncreaser) + width: root.isVertical ? panelSize + marginsWidth : Math.min(parent.width + marginsWidth, root.width - marginsWidth) + height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : panelSize + marginsHeight imagePath: hideShadow ? "" : "widgets/panel-background" prefix: hideShadow ? "" : "shadow" @@ -313,6 +311,7 @@ Item{ opacity: solidBackground.opacity backgroundColor: colorizerManager.backgroundColor roundness: overlayedBackground.roundness + visible: Latte.WindowSystem.compositingActive Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive @@ -327,10 +326,10 @@ Item{ PlasmaCore.FrameSvgItem{ id: solidBackground - anchors.leftMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.left - leftIncreaser : 0 - anchors.rightMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.right - rightIncreaser : 0 - anchors.topMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.top - topIncreaser : 0 - anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom - bottomIncreaser : 0 + anchors.leftMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.left : 0 + anchors.rightMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.right : 0 + anchors.topMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.top : 0 + anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom : 0 anchors.fill:parent opacity: { @@ -347,7 +346,7 @@ Item{ property rect efGeometry: Qt.rect(-1,-1,0,0) - imagePath: root.solidStylePanel ? "opaque/dialogs/background" : "widgets/panel-background" + imagePath: Latte.WindowSystem.compositingActive ? "widgets/panel-background" : "opaque/dialogs/background" onWidthChanged: updateEffectsArea(); onHeightChanged: updateEffectsArea(); @@ -361,6 +360,8 @@ Item{ root.updateEffectsArea.disconnect(updateEffectsArea); } + onImagePathChanged: solidBackground.adjustPrefix(); + Binding{ target: root property: "currentPanelTransparency" @@ -375,10 +376,6 @@ Item{ solidBackground.updateEffectsArea(); } } - - onSolidStylePanelChanged: { - solidBackground.adjustPrefix(); - } } //! Fix for FrameSvgItem QML version not updating its margins after a theme change @@ -417,41 +414,6 @@ Item{ } } - //! the increases used when the user forces a solid background and the background - //! must be increased in order to look ok in the corners - property int rightIncreaser: { - if (!(root.solidStylePanel && root.isVertical && plasmoid.location === PlasmaCore.Types.LeftEdge) - || !Latte.WindowSystem.compositingActive) - return 0; - else - return hiddenPanelBackground.margins.right; - } - - property int leftIncreaser: { - if (!(root.solidStylePanel && root.isVertical && plasmoid.location === PlasmaCore.Types.RightEdge) - || !Latte.WindowSystem.compositingActive) - return 0; - else - return hiddenPanelBackground.margins.left; - } - - property int topIncreaser: { - if (!(root.solidStylePanel && root.isVertical && plasmoid.location === PlasmaCore.Types.BottomEdge) - || !Latte.WindowSystem.compositingActive) - return 0; - else - return hiddenPanelBackground.margins.top; - } - - property int bottomIncreaser: { - if (!(root.solidStylePanel && root.isVertical && plasmoid.location === PlasmaCore.Types.TopEdge) - || !Latte.WindowSystem.compositingActive) - return 0; - else - return hiddenPanelBackground.margins.bottom; - } - - Binding { target: root property: "panelThickMarginHigh" @@ -564,6 +526,18 @@ Item{ } } + //! Outline drawing + Loader{ + anchors.fill: solidBackground + active: root.panelOutline && Latte.WindowSystem.compositingActive + sourceComponent: Colorizer.CustomBackground{ + backgroundColor: "transparent" + borderColor: colorizerManager.outlineColor + borderWidth: 1 + roundness: overlayedBackground.roundness + } + } + //! CustomBackground debugger /*Colorizer.CustomBackground { anchors.fill: solidBackground @@ -572,12 +546,6 @@ Item{ borderColor: "red" roundness: overlayedBackground.roundness }*/ - - PlasmaCore.FrameSvgItem{ - id: hiddenPanelBackground - imagePath: "widgets/panel-background" - visible: false - } } transitions: Transition { diff --git a/containment/package/contents/ui/colorizer/CustomBackground.qml b/containment/package/contents/ui/colorizer/CustomBackground.qml index 3eb09ec6a..0d26b320e 100644 --- a/containment/package/contents/ui/colorizer/CustomBackground.qml +++ b/containment/package/contents/ui/colorizer/CustomBackground.qml @@ -103,16 +103,18 @@ Item{ width: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { - if (drawWithoutRoundness || noOfBorders === 3) { - return parent.width; + if (drawWithoutRoundness) { + return parent.width + 2*borderWidth; } else if (noOfBorders === 2) { - return parent.width + roundness; + return parent.width + Math.max(roundness,borderWidth); + } else if (noOfBorders === 3) { + return parent.width; } } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { if (drawWithoutRoundness) { return parent.width + borderWidth; } else if (noOfBorders === 2 || noOfBorders === 3) { - return parent.width + roundness; + return parent.width + Math.max(roundness,borderWidth); } } } @@ -123,13 +125,15 @@ Item{ if (drawWithoutRoundness) { return parent.height + borderWidth; } else if (noOfBorders === 2 || noOfBorders === 3) { - return parent.height + roundness; + return parent.height + Math.max(roundness,borderWidth); } } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { - if (drawWithoutRoundness || noOfBorders === 3) { - return parent.height; + if (drawWithoutRoundness) { + return parent.height + 2*borderWidth; } else if (noOfBorders === 2) { - return parent.height + roundness; + return parent.height + Math.max(roundness,borderWidth); + } else if (noOfBorders === 3) { + return parent.height; } } } @@ -139,7 +143,7 @@ Item{ border.width: main.borderWidth border.color: main.borderColor - readonly property int centerStep: Math.max( (drawWithoutRoundness ? 0 : roundness), 2*borderWidth) / 2 + readonly property int centerStep: Math.max(Math.ceil((drawWithoutRoundness ? 0 : roundness) / 2) , borderWidth) states: [ State { diff --git a/containment/package/contents/ui/colorizer/Manager.qml b/containment/package/contents/ui/colorizer/Manager.qml index c71590b70..a63243ea7 100644 --- a/containment/package/contents/ui/colorizer/Manager.qml +++ b/containment/package/contents/ui/colorizer/Manager.qml @@ -34,8 +34,10 @@ Loader{ readonly property bool backgroundIsBusy: item ? item.isBusy : false - readonly property real themeTextColorBrightness: ColorizerTools.colorBrightness(theme.textColor) - readonly property color minimizedDotColor: themeTextColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7) + readonly property real themeTextColorBrightness: ColorizerTools.colorBrightness(textColor) + readonly property real backgroundColorBrightness: ColorizerTools.colorBrightness(backgroundColor) + readonly property color minimizedDotColor: themeTextColorBrightness > 127.5 ? Qt.darker(textColor, 1.7) : Qt.lighter(textColor, 7) + readonly property color outlineColor: backgroundColorBrightness > 127.5 ? Qt.darker(backgroundColor, 1.3) : Qt.lighter(backgroundColor, 2) readonly property bool mustBeShown: (applyTheme && applyTheme !== theme) diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 4e2a5e593..b06fc43af 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -78,7 +78,7 @@ DragDrop.DropArea { return (visibilityManager.panelIsBiggerFromIconSize && (maxZoomFactor === 1.0) && (latteView.visibility.mode === Latte.Types.AlwaysVisible || latteView.visibility.mode === Latte.Types.WindowsGoBelow) - && (plasmoid.configuration.panelPosition === Latte.Types.Justify) && !(root.solidStylePanel && panelShadowsActive)); + && (plasmoid.configuration.panelPosition === Latte.Types.Justify)); } property int viewType: { @@ -166,7 +166,6 @@ DragDrop.DropArea { property bool showAppletShortcutBadges: false property bool showMetaBadge: false property int applicationLauncherId: -1 - property bool solidStylePanel: Latte.WindowSystem.compositingActive ? plasmoid.configuration.solidPanel : true //FIXME: possibly this is going to be the default behavior, this user choice //has been dropped from the Dock Configuration Window @@ -220,6 +219,7 @@ DragDrop.DropArea { property int modifierClickAction: plasmoid.configuration.modifierClickAction property int modifierClick: plasmoid.configuration.modifierClick + property bool panelOutline: plasmoid.configuration.panelOutline property int panelEdgeSpacing: Math.max(panelBoxBackground.lengthMargins, 1.5*appShadowSize) property int panelTransparency: plasmoid.configuration.panelTransparency //user set property int currentPanelTransparency: 0 //application override diff --git a/shell/package/contents/configuration/pages/AppearanceConfig.qml b/shell/package/contents/configuration/pages/AppearanceConfig.qml index 7e14cd6a4..b90cc3b0b 100644 --- a/shell/package/contents/configuration/pages/AppearanceConfig.qml +++ b/shell/package/contents/configuration/pages/AppearanceConfig.qml @@ -870,14 +870,14 @@ PlasmaComponents.Page { PlasmaComponents.Button { id: solidBackground Layout.fillWidth: true - text: i18n("Solid Style") - checked: plasmoid.configuration.solidPanel + text: i18n("Outline") + checked: plasmoid.configuration.panelOutline checkable: true - enabled: showBackground.checked - tooltip: i18n("Background uses a solid style image provided from plasma theme") + enabled: showBackground.checked && Latte.WindowSystem.compositingActive + tooltip: i18n("Background draws a line for its borders. You can set the line size from Latte Preferences") onClicked: { - plasmoid.configuration.solidPanel = checked + plasmoid.configuration.panelOutline = !plasmoid.configuration.panelOutline; } } }