Warning, /plasma/latte-dock/containment/package/contents/ui/background/MultiLayered.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.1
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Window 2.2
0010 import QtGraphicalEffects 1.0
0011 
0012 import org.kde.plasma.plasmoid 2.0
0013 
0014 import org.kde.plasma.core 2.0 as PlasmaCore
0015 import org.kde.plasma.components 2.0 as PlasmaComponents
0016 import org.kde.kquickcontrolsaddons 2.0
0017 
0018 import org.kde.latte.core 0.2 as LatteCore
0019 
0020 import "../colorizer" as Colorizer
0021 
0022 BackgroundProperties{
0023     id:barLine
0024 
0025     readonly property alias panelBackgroundSvg: solidBackground
0026 
0027     //! Layer 0: Multi-Layer container in order to provide a consistent final element that acts
0028     //! as a single entity/background
0029     width: root.isHorizontal ? totals.visualLength : 16
0030     height: root.isVertical ? totals.visualLength : 16
0031 
0032     opacity: root.useThemePanel ? 1 : 0
0033     currentOpacity: overlayedBackground.backgroundOpacity>0 ? overlayedBackground.backgroundOpacity : solidBackground.opacity
0034 
0035     isShown: (solidBackground.opacity > 0) || (overlayedBackground.backgroundOpacity > 0)
0036 
0037     hasAllBorders: solidBackground.enabledBorders === PlasmaCore.FrameSvg.AllBorders
0038     hasLeftBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.LeftBorder) > 0)
0039     hasRightBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.RightBorder) > 0)
0040     hasTopBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.TopBorder) > 0)
0041     hasBottomBorder: hasAllBorders || ((solidBackground.enabledBorders & PlasmaCore.FrameSvg.BottomBorder) > 0)
0042 
0043     shadows.left: hasLeftBorder && root.behaveAsDockWithMask ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.left) : 0
0044     shadows.right: hasRightBorder && root.behaveAsDockWithMask ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.right) : 0
0045     shadows.top: hasTopBorder && root.behaveAsDockWithMask ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.top) : 0
0046     shadows.bottom: hasBottomBorder && root.behaveAsDockWithMask ? (customShadowIsEnabled ? customShadow : shadowsSvgItem.margins.bottom) : 0
0047 
0048     shadows.fixedLeft: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.left
0049     shadows.fixedRight: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.right
0050     shadows.fixedTop: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.top
0051     shadows.fixedBottom: (customDefShadowIsEnabled || customUserShadowIsEnabled) ? customShadow : shadowsSvgItem.fixedMargins.bottom
0052 
0053     //! it can accept negative values in DockMode
0054     screenEdgeMargin: root.screenEdgeMarginEnabled ? metrics.margin.screenEdge - shadows.tailThickness : -shadows.tailThickness
0055 
0056     paddings.top: {
0057         if (hasTopBorder) {
0058             var customAppliedRadius = customRadiusIsEnabled ? customRadius : 0;
0059             var themePadding = themeExtendedBackground ? themeExtendedBackground.paddingTop : 0;
0060             var solidBackgroundPadding = solidBackground.margins.top;
0061 
0062             if (root.isVertical) {
0063                 var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0064                 expected = Math.max(0, expected - metrics.margin.length); //! remove from roundness padding the applied margins
0065                 return expected * indicators.info.backgroundCornerMargin;
0066             } else {
0067                 return Math.max(themePadding, solidBackgroundPadding);
0068             }
0069         }
0070 
0071         return 0;
0072     }
0073     paddings.bottom: {
0074         if (hasBottomBorder) {
0075             var customAppliedRadius = customRadiusIsEnabled ? customRadius : 0;
0076             var themePadding = themeExtendedBackground ? themeExtendedBackground.paddingBottom : 0;
0077             var solidBackgroundPadding = solidBackground.margins.bottom;
0078 
0079             if (root.isVertical) {
0080                 var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0081                 expected = Math.max(0, expected - metrics.margin.length); //! remove from roundness padding the applied margins
0082                 return expected * indicators.info.backgroundCornerMargin;
0083             } else {
0084                 return Math.max(themePadding, solidBackgroundPadding);
0085             }
0086         }
0087 
0088         return 0;
0089     }
0090 
0091     paddings.left: {
0092         if (hasLeftBorder) {
0093             var customAppliedRadius = customRadiusIsEnabled ? customRadius : 0;
0094             var themePadding = themeExtendedBackground ? themeExtendedBackground.paddingLeft : 0;
0095             var solidBackgroundPadding = solidBackground.margins.left;
0096 
0097             if (root.isHorizontal) {
0098                 var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0099                 expected = Math.max(0, expected - metrics.margin.length); //! remove from roundness padding the applied margins
0100                 return expected * indicators.info.backgroundCornerMargin;
0101             } else {
0102                 return Math.max(themePadding, solidBackgroundPadding);
0103             }
0104         }
0105 
0106         return 0;
0107     }
0108 
0109     paddings.right: {
0110         if (hasRightBorder) {
0111             var customAppliedRadius = customRadiusIsEnabled? customRadius : 0;
0112             var themePadding = themeExtendedBackground ? themeExtendedBackground.paddingRight : 0;
0113             var solidBackgroundPadding = solidBackground.margins.right;
0114 
0115             if (root.isHorizontal) {
0116                 var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0117                 expected = Math.max(0, expected - metrics.margin.length); //! remove from roundness padding the applied margins
0118                 return expected * indicators.info.backgroundCornerMargin;
0119             } else {
0120                 return Math.max(themePadding, solidBackgroundPadding);
0121             }
0122         }
0123 
0124         return 0;
0125     }
0126 
0127     length: {
0128         if (root.behaveAsPlasmaPanel && LatteCore.WindowSystem.compositingActive) {
0129             return root.isVertical ? root.height : root.width;
0130         }
0131 
0132         if (myView.alignment === LatteCore.Types.Justify) {
0133             return root.maxLength;
0134         }
0135 
0136         return Math.max(root.minLength, layoutsContainerItem.mainLayout.length + totals.paddingsLength);
0137     }
0138 
0139     thickness: {
0140         if (root.behaveAsPlasmaPanel) {
0141             return metrics.totals.thickness;
0142         } else {
0143             return Math.min(metrics.totals.thickness, background.totals.visualThickness);
0144         }
0145     }
0146 
0147     offset: {
0148         if (behaveAsPlasmaPanel) {
0149             return 0;
0150         }
0151 
0152         if (root.isHorizontal) {
0153             if (myView.alignment === LatteCore.Types.Left) {
0154                 return root.offset - shadows.left;
0155             } else if (myView.alignment === LatteCore.Types.Right) {
0156                 return root.offset - shadows.right;
0157             }
0158         }
0159 
0160         if (root.isVertical) {
0161             if (myView.alignment === LatteCore.Types.Top) {
0162                 return root.offset - shadows.top;
0163             } else if (myView.alignment === LatteCore.Types.Bottom) {
0164                 return root.offset - shadows.bottom;
0165             }
0166         }
0167 
0168         var parabolicOffseting = myView.alignment === LatteCore.Types.Center ? layoutsContainerItem.mainLayout.parabolicOffsetting : 0;
0169         return root.offset + parabolicOffseting;
0170     }
0171 
0172     totals.visualThickness: {
0173         var itemMargins = 2*metrics.margin.tailThickness;
0174         var maximumItem = metrics.iconSize + itemMargins;
0175 
0176         if (totals.minThickness < maximumItem) {
0177             maximumItem = maximumItem - totals.minThickness;
0178         }
0179 
0180         var percentage = LatteCore.WindowSystem.compositingActive ? plasmoid.configuration.panelSize/100 : 1;
0181         return Math.max(totals.minThickness, totals.minThickness + (percentage*maximumItem));
0182     }
0183 
0184     totals.visualMaxThickness: {
0185         var itemMargins = 2*metrics.margin.maxTailThickness;
0186         var maximumItem = metrics.maxIconSize + itemMargins;
0187 
0188         if (totals.minThickness < maximumItem) {
0189             maximumItem = maximumItem - totals.minThickness;
0190         }
0191 
0192         var percentage = LatteCore.WindowSystem.compositingActive ? plasmoid.configuration.panelSize/100 : 1;
0193         return Math.max(totals.minThickness, totals.minThickness + (percentage*maximumItem));
0194     }
0195 
0196     totals.visualLength: {
0197         if (root.behaveAsPlasmaPanel) {
0198             return root.isVertical ? root.height : root.width;
0199         }
0200 
0201         return Math.max(background.length + totals.shadowsLength, totals.paddingsLength + totals.shadowsLength)
0202     }
0203 
0204     readonly property int tailRoundness: {
0205         if ((root.isHorizontal && hasLeftBorder) || (!root.isHorizontal && hasTopBorder)) {
0206             var customAppliedRadius = customRadiusIsEnabled ? customRadius : 0;
0207             var themePadding = themeExtendedBackground ? (root.isHorizontal ? themeExtendedBackground.paddingLeft : themeExtendedBackground.paddingTop) : 0;
0208             var solidBackgroundPadding = root.isHorizontal ? solidBackground.margins.left : solidBackground.margins.top;
0209             var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0210             return Math.max(0, expected - metrics.margin.length);
0211         }
0212 
0213         return 0;
0214     }
0215 
0216     readonly property int headRoundness: {
0217         if ((root.isHorizontal && hasRightBorder) || (!root.isHorizontal && hasBottomBorder)) {
0218             var customAppliedRadius = customRadiusIsEnabled ? customRadius : 0;
0219             var themePadding = themeExtendedBackground ? (root.isHorizontal ? themeExtendedBackground.paddingRight : themeExtendedBackground.paddingBottom) : 0;
0220             var solidBackgroundPadding = root.isHorizontal ? solidBackground.margins.right : solidBackground.margins.bottom;
0221             var expected = customRadiusIsEnabled ? customAppliedRadius : Math.max(themePadding, solidBackgroundPadding);
0222             return Math.max(0, expected - metrics.margin.length);
0223         }
0224 
0225         return 0;
0226     }
0227 
0228     readonly property int tailRoundnessMargin: {
0229         //! used from contents geometry in order to remove any roundness sectors, e.g. for popups placement
0230         if (root.isHorizontal) {
0231             return paddings.left > metrics.margin.length ? metrics.margin.length : 0
0232         } else {
0233             return paddings.top > metrics.margin.length ? metrics.margin.length : 0
0234         }
0235     }
0236 
0237     readonly property int headRoundnessMargin: {
0238         //! used from contents geometry in order to remove any roundness sectors, e.g. for popups placement
0239         if (root.isHorizontal) {
0240             return paddings.right > metrics.margin.length ? metrics.margin.length : 0
0241         } else {
0242             return paddings.bottom > metrics.margin.length ? metrics.margin.length : 0
0243         }
0244     }
0245 
0246     property int animationTime: 6*animations.speedFactor.current*animations.duration.small
0247 
0248     //! Opacity related
0249     readonly property bool isDefaultOpacityEnabled: plasmoid.configuration.panelTransparency===-1
0250 
0251     //! Metrics related
0252     readonly property bool isGreaterThanItemThickness: root.useThemePanel && (totals.visualThickness >= (metrics.iconSize + metrics.margin.tailThickness))
0253 
0254     //! CustomShadowedRectangle  properties
0255     readonly property bool customShadowedRectangleIsEnabled: customRadiusIsEnabled || (customDefShadowIsEnabled || customUserShadowIsEnabled)
0256 
0257     readonly property bool customShadowIsSupported: LatteCore.WindowSystem.compositingActive
0258                                                     && kirigamiLibraryIsFound
0259 
0260     //!current shadow state but do not change other values of normal mode, for example if a Dock hides its screen edge thickness
0261     //!shouldnt change the fact that customShadowedRectangle is still used
0262     readonly property bool customShadowIsEnabled: (customDefShadowIsEnabled || customUserShadowIsEnabled) && panelShadowsActive
0263     readonly property bool customDefShadowIsEnabled: customShadowIsSupported && !customUserShadowIsEnabled && customRadiusIsEnabled
0264     readonly property bool customUserShadowIsEnabled: customShadowIsSupported && plasmoid.configuration.backgroundShadowSize >= 0
0265 
0266     readonly property bool customRadiusIsEnabled: kirigamiLibraryIsFound && plasmoid.configuration.backgroundRadius >= 0
0267 
0268     readonly property int customRadius: {
0269         if (customDefShadowIsEnabled && !customRadiusIsEnabled && themeExtendedBackground) {
0270             return themeExtendedBackground.roundness;
0271         }
0272 
0273         return plasmoid.formFactor === PlasmaCore.Types.Horizontal ?
0274                     (plasmoid.configuration.backgroundRadius/100) * solidBackground.height :
0275                     (plasmoid.configuration.backgroundRadius/100) * solidBackground.width
0276     }
0277     readonly property int customShadow: {
0278         if (customDefShadowIsEnabled && themeExtendedBackground) {
0279             return themeExtendedBackground.shadowSize;
0280         }
0281 
0282         return plasmoid.configuration.backgroundShadowSize;
0283     }
0284 
0285     readonly property color customShadowColor: themeExtendedBackground ? themeExtendedBackground.shadowColor : "black"
0286 
0287     property QtObject themeExtendedBackground: null
0288 
0289     Behavior on opacity{
0290         enabled: LatteCore.WindowSystem.compositingActive
0291         NumberAnimation {
0292             duration: barLine.animationTime
0293         }
0294     }
0295 
0296     Behavior on opacity{
0297         enabled: !LatteCore.WindowSystem.compositingActive
0298         NumberAnimation {
0299             duration: 0
0300         }
0301     }
0302 
0303     Binding {
0304         target: barLine
0305         property: "themeExtendedBackground"
0306         when: themeExtended
0307         value: {
0308             switch(plasmoid.location) {
0309             case PlasmaCore.Types.BottomEdge: return themeExtended.backgroundBottomEdge;
0310             case PlasmaCore.Types.LeftEdge: return themeExtended.backgroundLeftEdge;
0311             case PlasmaCore.Types.TopEdge: return themeExtended.backgroundTopEdge;
0312             case PlasmaCore.Types.RightEdge: return themeExtended.backgroundRightEdge;
0313             default: return null;
0314             }
0315         }
0316     }
0317 
0318     onXChanged: solidBackground.updateEffectsArea();
0319     onYChanged: solidBackground.updateEffectsArea();
0320     onScreenEdgeMarginChanged: solidBackground.updateEffectsArea();
0321 
0322     //! Layer 1: Shadows that are drawn around the background but always inside the View window (these are internal drawn shadows).
0323     //!          When the container has chosen external shadows (these are shadows that are drawn out of the View window from the compositor)
0324     //!          in such case the internal drawn shadows are NOT drawn at all.
0325     PlasmaCore.FrameSvgItem{
0326         id: shadowsSvgItem
0327         width: root.isVertical ?  background.thickness + totals.shadowsThickness : totals.visualLength
0328         height: root.isVertical ? totals.visualLength : background.thickness + totals.shadowsThickness
0329         enabledBorders: latteView && latteView.effects ? latteView.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder
0330         imagePath: "widgets/panel-background"
0331         prefix: "shadow"
0332         opacity: hideShadow || !root.useThemePanel || (root.forceTransparentPanel && !root.forcePanelForBusyBackground) ? 0 : 1
0333         visible: (opacity == 0) ? false : true
0334 
0335         //! set true by default in order to avoid crash on startup because imagePath is set to ""
0336         readonly property bool themeHasShadow: themeExtended ? themeExtended.hasShadow : true
0337 
0338         readonly property bool hideShadow: root.behaveAsPlasmaPanel
0339                                            || !LatteCore.WindowSystem.compositingActive
0340                                            || !root.panelShadowsActive
0341                                            || !themeHasShadow
0342                                            || customShadowedRectangleIsEnabled
0343 
0344         Behavior on opacity {
0345             enabled: LatteCore.WindowSystem.compositingActive
0346             NumberAnimation { duration: barLine.animationTime }
0347         }
0348 
0349 
0350         Behavior on opacity{
0351             enabled: !LatteCore.WindowSystem.compositingActive
0352             NumberAnimation { duration: 0 }
0353         }
0354     }
0355 
0356     //! Layer 2: Provide visual solidness. Plasma themes by design may provide a panel-background svg that is not
0357     //!          solid. That means that user can not gain full solidness in such cases. This layer is responsible
0358     //!          to solve the previous mentioned plasma theme limitation.
0359     Colorizer.CustomBackground {
0360         id: backgroundLowestRectangle
0361         anchors.fill: solidBackground
0362         opacity: normalizedOpacity
0363         backgroundColor: colorizerManager.backgroundColor
0364         roundness: overlayedBackground.roundness
0365         visible: LatteCore.WindowSystem.compositingActive && solidBackground.exceedsThemeOpacityLimits
0366 
0367         readonly property real normalizedOpacity: visible ?  Math.min(1, (appliedOpacity - solidBackground.themeMaxOpacity)/(1-solidBackground.themeMaxOpacity)) : 0
0368         readonly property real appliedOpacity: visible ? solidBackground.appliedOpacity : 0
0369 
0370         Behavior on opacity{
0371             enabled: LatteCore.WindowSystem.compositingActive
0372             NumberAnimation { duration: barLine.animationTime }
0373         }
0374 
0375         Behavior on opacity{
0376             enabled: !LatteCore.WindowSystem.compositingActive
0377             NumberAnimation { duration: 0 }
0378         }
0379     }
0380 
0381     //! Layer 3: Original Plasma Theme "panel-background" svg. It is used for calculations and also to draw
0382     //!          the original background when to special settings and options exist from the user. It is also
0383     //!          doing one very important job which is to calculate the Effects Rectangle which is used from
0384     //!          the compositor to provide blurriness and from Mask calculations to provide the View Local Geometry
0385     PlasmaCore.FrameSvgItem{
0386         id: solidBackground
0387         anchors.leftMargin: shadows.left
0388         anchors.rightMargin: shadows.right
0389         anchors.topMargin: shadows.top
0390         anchors.bottomMargin: shadows.bottom
0391         anchors.fill: shadowsSvgItem
0392 
0393         imagePath: "widgets/panel-background"
0394         opacity: normalizedOpacity
0395 
0396         readonly property bool exceedsThemeOpacityLimits: appliedOpacity > themeMaxOpacity
0397         readonly property bool forceSolidness: root.forceSolidPanel || !LatteCore.WindowSystem.compositingActive
0398 
0399         //! must be normalized to plasma theme maximum opacity
0400         readonly property real normalizedOpacity: Math.min(1, appliedOpacity / themeMaxOpacity)
0401 
0402         readonly property real appliedOpacity: overlayedBackground.backgroundOpacity > 0 && !paintInstantly ? 0 : overlayedBackground.midOpacity
0403         readonly property real themeMaxOpacity: themeExtendedBackground ? themeExtendedBackground.maxOpacity : 1
0404 
0405         //! When switching from overlaied background to regular one this must be done
0406         //! instantly otherwise the transition is not smooth
0407         readonly property bool paintInstantly: (root.hasExpandedApplet && root.plasmaBackgroundForPopups && !customRadiusIsEnabled)
0408 
0409         property rect efGeometry: Qt.rect(-1,-1,0,0)
0410 
0411         property int paddingsWidth: margins.left+margins.right
0412         property int paddingsHeight: margins.top + margins.bottom
0413 
0414         onWidthChanged: updateEffectsArea();
0415         onHeightChanged: updateEffectsArea();
0416         onImagePathChanged: solidBackground.adjustPrefix();
0417 
0418 
0419         Component.onCompleted: {
0420             root.updateEffectsArea.connect(updateEffectsArea);
0421             adjustPrefix();
0422         }
0423 
0424         Component.onDestruction: {
0425             root.updateEffectsArea.disconnect(updateEffectsArea);
0426         }
0427 
0428         //! Fix for FrameSvgItem QML version not updating its margins after a theme change
0429         //! with this hack we enforce such update. I could use the repaintNeeded signal but
0430         //! it is called more often than the themeChanged one.
0431         Connections {
0432             target: themeExtended
0433             onThemeChanged: {
0434                 solidBackground.adjustPrefix();
0435                 plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows;
0436                 plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows;
0437                 updateEffectsArea();
0438             }
0439         }
0440 
0441         Connections {
0442             target: latteView ? latteView.visibility : null
0443             onIsHiddenChanged: solidBackground.updateEffectsArea();
0444         }
0445 
0446 
0447         Connections{
0448             target: plasmoid
0449             onLocationChanged: solidBackground.adjustPrefix();
0450         }
0451 
0452         function updateEffectsArea() {
0453             if (!updateEffectsAreaTimer.running) {
0454                // invUpdateEffectsArea(); // disabled in order to force Timer at all cases
0455                 updateEffectsAreaTimer.start();
0456             }
0457         }
0458 
0459         function invUpdateEffectsArea(){
0460             if (!latteView)
0461                 return;
0462 
0463             if (!LatteCore.WindowSystem.compositingActive) {
0464                 //! NOCOMPOSITING mode is a special case and Effects Area is also used for
0465                 //! different calculations for View::mask()
0466                 var rootGeometry = mapToItem(root, 0, 0);
0467                 efGeometry.x = rootGeometry.x;
0468                 efGeometry.y = rootGeometry.y;
0469                 efGeometry.width = width;
0470                 efGeometry.height = height;
0471             } else {
0472                 if (latteView.visibility.isHidden) {
0473                     //! valid hide mask
0474                     efGeometry.x = -1;
0475                     efGeometry.y = -1;
0476                     efGeometry.width = 1;
0477                     efGeometry.height = 1;
0478                 } else {
0479                     if (!root.behaveAsPlasmaPanel) {
0480                         var rootGeometry = mapToItem(root, 0, 0);
0481                         efGeometry.x = rootGeometry.x;
0482                         efGeometry.y = rootGeometry.y;
0483                     } else {
0484                         efGeometry.x = 0;
0485                         efGeometry.y = 0;
0486                     }
0487 
0488                     efGeometry.width = width;
0489                     efGeometry.height = height;
0490                 }
0491             }
0492 
0493             latteView.effects.rect = efGeometry;
0494         }
0495 
0496         Timer {
0497             id: updateEffectsAreaTimer
0498             interval: 11 //! 90Hz or 90calls/sec
0499             onTriggered: solidBackground.invUpdateEffectsArea();
0500         }
0501 
0502         onRepaintNeeded: {
0503             if (root.behaveAsPlasmaPanel)
0504                 adjustPrefix();
0505         }
0506 
0507         enabledBorders: latteView && latteView.effects ? latteView.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder
0508 
0509         Behavior on opacity{
0510             enabled: LatteCore.WindowSystem.compositingActive && !solidBackground.paintInstantly
0511             NumberAnimation { duration: barLine.animationTime }
0512         }
0513 
0514         Behavior on opacity{
0515             enabled: !LatteCore.WindowSystem.compositingActive
0516             NumberAnimation { duration: 0 }
0517         }
0518 
0519         function adjustPrefix() {
0520             if (!plasmoid) {
0521                 return "";
0522             }
0523             var pre;
0524             switch (plasmoid.location) {
0525             case PlasmaCore.Types.LeftEdge:
0526                 pre = "west";
0527                 break;
0528             case PlasmaCore.Types.TopEdge:
0529                 pre = "north";
0530                 break;
0531             case PlasmaCore.Types.RightEdge:
0532                 pre = "east";
0533                 break;
0534             case PlasmaCore.Types.BottomEdge:
0535                 pre = "south";
0536                 break;
0537             default:
0538                 prefix = "";
0539             }
0540 
0541             prefix = [pre, ""];
0542         }
0543     }
0544 
0545     //! Layer 4: Plasma theme design does not provide a way to colorize the background. This layer
0546     //!          solves this by providing a custom background layer that respects the Colorizer palette
0547     Colorizer.CustomBackground {
0548         id: overlayedBackground
0549         anchors.fill: solidBackground
0550 
0551         readonly property bool busyBackground: root.forcePanelForBusyBackground
0552                                                && (solidBackground.opacity === 0 || !solidBackground.paintInstantly)
0553         readonly property bool coloredView: colorizerManager.mustBeShown && colorizerManager.applyTheme !== theme
0554 
0555         backgroundOpacity: {
0556             if (busyBackground && !forceSolidness) {
0557                 return root.myView.backgroundStoredOpacity;
0558             }
0559 
0560             if (coloredView || customShadowedRectangleIsEnabled) {
0561                 return midOpacity;
0562             }
0563 
0564             return 0;
0565         }
0566 
0567         backgroundColor: colorizerManager.backgroundColor
0568         shadowColor: customShadowColor
0569         shadowSize: customShadowIsEnabled ? customShadow : 0
0570 
0571         roundness: {
0572             if (customRadiusIsEnabled) {
0573                 return customRadius;
0574             }
0575 
0576             return themeExtendedBackground ? themeExtendedBackground.roundness : 0
0577         }
0578 
0579         property real midOpacity: {
0580             if (forceSolidness) {
0581                 return 1;
0582             } else if (!root.userShowPanelBackground || root.forcePanelForBusyBackground || root.forceTransparentPanel) {
0583                 return 0;
0584             } else {
0585                 return root.myView.backgroundStoredOpacity;
0586             }
0587         }
0588 
0589         readonly property bool forceSolidness: root.forceSolidPanel || !LatteCore.WindowSystem.compositingActive
0590 
0591         Behavior on backgroundOpacity{
0592             enabled: LatteCore.WindowSystem.compositingActive
0593             NumberAnimation { duration: barLine.animationTime }
0594         }
0595 
0596         Behavior on backgroundOpacity{
0597             enabled: !LatteCore.WindowSystem.compositingActive
0598             NumberAnimation { duration: 0 }
0599         }
0600 
0601         Behavior on backgroundColor{
0602             enabled: LatteCore.WindowSystem.compositingActive
0603             ColorAnimation { duration: barLine.animationTime }
0604         }
0605 
0606         Behavior on backgroundColor{
0607             enabled: !LatteCore.WindowSystem.compositingActive
0608             ColorAnimation { duration: 0 }
0609         }
0610     }
0611 
0612     //! Layer 5: Plasma theme design does not provide a way to draw background outline on demand. This layer
0613     //!          solves this by providing a custom background layer that only draws an outline on top of all
0614     //!          previous layers
0615     Loader{
0616         anchors.fill: solidBackground
0617         active: root.panelOutline && !(root.hasExpandedApplet && root.plasmaBackgroundForPopups)
0618         sourceComponent: Colorizer.CustomBackground{
0619             backgroundColor: "transparent"
0620             borderColor: colorizerManager.outlineColor
0621             borderWidth: themeExtended ? themeExtended.outlineWidth : 1
0622             roundness: overlayedBackground.roundness
0623         }
0624     }
0625 
0626     //! CustomBackground debugger
0627     /*Colorizer.CustomBackground {
0628         anchors.fill: solidBackground
0629         backgroundColor: "transparent"
0630         borderWidth: 1
0631         borderColor: "red"
0632         roundness: overlayedBackground.roundness
0633     }*/
0634 
0635 
0636     //BEGIN states
0637     //user set Panel Positions
0638     //0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom
0639     states: [
0640         ///Left
0641         State {
0642             name: "leftCenter"
0643             when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(myView.alignment === LatteCore.Types.Center)
0644 
0645             AnchorChanges {
0646                 target: barLine
0647                 anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0648             }
0649             AnchorChanges {
0650                 target: shadowsSvgItem
0651                 anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0652             }
0653             PropertyChanges{
0654                 target: barLine
0655                 anchors.leftMargin: barLine.screenEdgeMargin;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin:0;
0656                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: background.offset;
0657             }
0658         },
0659         State {
0660             name: "leftJustify"
0661             when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(myView.alignment === LatteCore.Types.Justify)
0662 
0663             AnchorChanges {
0664                 target: barLine
0665                 anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0666             }
0667             AnchorChanges {
0668                 target: shadowsSvgItem
0669                 anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0670             }
0671             PropertyChanges{
0672                 target: barLine
0673                 anchors.leftMargin: barLine.screenEdgeMargin;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin:0;
0674                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0675             }
0676         },
0677         ///Left
0678         State {
0679             name: "leftTop"
0680             when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(myView.alignment === LatteCore.Types.Top)
0681 
0682             AnchorChanges {
0683                 target: barLine
0684                 anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0685             }
0686             AnchorChanges {
0687                 target: shadowsSvgItem
0688                 anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0689             }
0690             PropertyChanges{
0691                 target: barLine
0692                 anchors.leftMargin: barLine.screenEdgeMargin;    anchors.rightMargin:0;     anchors.topMargin:background.offset;    anchors.bottomMargin:0;
0693                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0694             }
0695         },
0696         ///Left
0697         State {
0698             name: "leftBottom"
0699             when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(myView.alignment === LatteCore.Types.Bottom)
0700 
0701             AnchorChanges {
0702                 target: barLine
0703                 anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0704             }
0705             AnchorChanges {
0706                 target: shadowsSvgItem
0707                 anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0708             }
0709             PropertyChanges{
0710                 target: barLine
0711                 anchors.leftMargin: barLine.screenEdgeMargin;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin:background.offset;
0712                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0713             }
0714         },
0715         ///Right
0716         State {
0717             name: "rightCenter"
0718             when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(myView.alignment === LatteCore.Types.Center)
0719 
0720             AnchorChanges {
0721                 target: barLine
0722                 anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0723             }
0724             AnchorChanges {
0725                 target: shadowsSvgItem
0726                 anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0727             }
0728             PropertyChanges{
0729                 target: barLine
0730                 anchors.leftMargin: 0;    anchors.rightMargin: barLine.screenEdgeMargin;     anchors.topMargin:0;    anchors.bottomMargin:0;
0731                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: background.offset;
0732             }
0733         },
0734         State {
0735             name: "rightJustify"
0736             when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(myView.alignment === LatteCore.Types.Justify)
0737 
0738             AnchorChanges {
0739                 target: barLine
0740                 anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0741             }
0742             AnchorChanges {
0743                 target: shadowsSvgItem
0744                 anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
0745             }
0746             PropertyChanges{
0747                 target: barLine
0748                 anchors.leftMargin: 0;    anchors.rightMargin: barLine.screenEdgeMargin;     anchors.topMargin:0;    anchors.bottomMargin:0;
0749                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0750             }
0751         },
0752         State {
0753             name: "rightTop"
0754             when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(myView.alignment === LatteCore.Types.Top)
0755 
0756             AnchorChanges {
0757                 target: barLine
0758                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0759             }
0760             AnchorChanges {
0761                 target: shadowsSvgItem
0762                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0763             }
0764             PropertyChanges{
0765                 target: barLine
0766                 anchors.leftMargin: 0;    anchors.rightMargin: barLine.screenEdgeMargin;     anchors.topMargin:background.offset;    anchors.bottomMargin:0;
0767                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0768             }
0769         },
0770         State {
0771             name: "rightBottom"
0772             when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(myView.alignment === LatteCore.Types.Bottom)
0773 
0774             AnchorChanges {
0775                 target: barLine
0776                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined }
0777             }
0778             AnchorChanges {
0779                 target: shadowsSvgItem
0780                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0781             }
0782             PropertyChanges{
0783                 target: barLine
0784                 anchors.leftMargin: 0;    anchors.rightMargin: barLine.screenEdgeMargin;     anchors.topMargin:0;    anchors.bottomMargin:background.offset;
0785                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0786             }
0787         },
0788         ///Bottom
0789         State {
0790             name: "bottomCenter"
0791             when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(myView.alignment === LatteCore.Types.Center)
0792 
0793             AnchorChanges {
0794                 target: barLine
0795                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0796             }
0797             AnchorChanges {
0798                 target: shadowsSvgItem
0799                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0800             }
0801             PropertyChanges{
0802                 target: barLine
0803                 anchors.leftMargin: 0;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin: barLine.screenEdgeMargin;
0804                 anchors.horizontalCenterOffset: background.offset; anchors.verticalCenterOffset: 0;
0805             }
0806         },
0807         State {
0808             name: "bottomJustify"
0809             when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(myView.alignment === LatteCore.Types.Justify)
0810 
0811             AnchorChanges {
0812                 target: barLine
0813                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0814             }
0815             AnchorChanges {
0816                 target: shadowsSvgItem
0817                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0818             }
0819             PropertyChanges{
0820                 target: barLine
0821                 anchors.leftMargin: 0;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin: barLine.screenEdgeMargin;
0822                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0823             }
0824         },
0825         State {
0826             name: "bottomLeft"
0827             when: (plasmoid.location === PlasmaCore.Types.BottomEdge)
0828                   &&(((myView.alignment === LatteCore.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft))
0829                      || ((myView.alignment === LatteCore.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft)))
0830 
0831             AnchorChanges {
0832                 target: barLine
0833                 anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0834             }
0835             AnchorChanges {
0836                 target: shadowsSvgItem
0837                 anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0838             }
0839             PropertyChanges{
0840                 target: barLine
0841                 anchors.leftMargin: background.offset;    anchors.rightMargin:0;     anchors.topMargin:0;    anchors.bottomMargin: barLine.screenEdgeMargin;
0842                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0843             }
0844 
0845         },
0846         State {
0847             name: "bottomRight"
0848             when: (plasmoid.location === PlasmaCore.Types.BottomEdge)
0849                   &&(((myView.alignment === LatteCore.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft))
0850                      ||((myView.alignment === LatteCore.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft)))
0851 
0852             AnchorChanges {
0853                 target: barLine
0854                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0855             }
0856             AnchorChanges {
0857                 target: shadowsSvgItem
0858                 anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0859             }
0860             PropertyChanges{
0861                 target: barLine
0862                 anchors.leftMargin: 0;    anchors.rightMargin:background.offset;     anchors.topMargin:0;    anchors.bottomMargin: barLine.screenEdgeMargin;
0863                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0864             }
0865         },
0866         ///Top
0867         State {
0868             name: "topCenter"
0869             when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(myView.alignment === LatteCore.Types.Center)
0870 
0871             AnchorChanges {
0872                 target: barLine
0873                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0874             }
0875             AnchorChanges {
0876                 target: shadowsSvgItem
0877                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0878             }
0879             PropertyChanges{
0880                 target: barLine
0881                 anchors.leftMargin: 0;    anchors.rightMargin:0;     anchors.topMargin: barLine.screenEdgeMargin;    anchors.bottomMargin:0;
0882                 anchors.horizontalCenterOffset: background.offset; anchors.verticalCenterOffset: 0;
0883             }
0884         },
0885         State {
0886             name: "topJustify"
0887             when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(myView.alignment === LatteCore.Types.Justify)
0888 
0889             AnchorChanges {
0890                 target: barLine
0891                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0892             }
0893             AnchorChanges {
0894                 target: shadowsSvgItem
0895                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
0896             }
0897             PropertyChanges{
0898                 target: barLine
0899                 anchors.leftMargin: 0;    anchors.rightMargin:0;     anchors.topMargin: barLine.screenEdgeMargin;    anchors.bottomMargin:0;
0900                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0901             }
0902         },
0903         State {
0904             name: "topLeft"
0905             when: (plasmoid.location === PlasmaCore.Types.TopEdge)
0906                   &&(((myView.alignment === LatteCore.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft))
0907                      || ((myView.alignment === LatteCore.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft)))
0908 
0909             AnchorChanges {
0910                 target: barLine
0911                 anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0912             }
0913             AnchorChanges {
0914                 target: shadowsSvgItem
0915                 anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
0916             }
0917             PropertyChanges{
0918                 target: barLine
0919                 anchors.leftMargin: background.offset;    anchors.rightMargin:0;     anchors.topMargin: barLine.screenEdgeMargin;    anchors.bottomMargin:0;
0920                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0921             }
0922         },
0923         State {
0924             name: "topRight"
0925             when: (plasmoid.location === PlasmaCore.Types.TopEdge)
0926                   &&(((myView.alignment === LatteCore.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft))
0927                      ||((myView.alignment === LatteCore.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft)))
0928 
0929             AnchorChanges {
0930                 target: barLine
0931                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0932             }
0933             AnchorChanges {
0934                 target: shadowsSvgItem
0935                 anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
0936             }
0937             PropertyChanges{
0938                 target: barLine
0939                 anchors.leftMargin: 0;    anchors.rightMargin:background.offset;     anchors.topMargin: barLine.screenEdgeMargin;    anchors.bottomMargin:0;
0940                 anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
0941             }
0942         }
0943     ]
0944     //END states
0945 }
0946 
0947