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

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 
0008 import org.kde.plasma.core 2.0 as PlasmaCore
0009 import org.kde.latte.core 0.2 as LatteCore
0010 
0011 Item {
0012     property Item destination: null
0013 
0014     readonly property int headThickness: destination ? destination.headThicknessMargin : appletItem.metrics.margin.headThickness
0015     readonly property int tailThickness: destination ? destination.tailThicknessMargin : appletItem.metrics.margin.tailThickness
0016     readonly property int thickness: headThickness + tailThickness + (root.isHorizontal ? destination.height : destination.width)
0017     readonly property int lengthPadding: {
0018         if ( (root.myView.alignment === LatteCore.Types.Justify && appletItem.firstChildOfStartLayout)
0019                 || (root.myView.alignment === LatteCore.Types.Justify && appletItem.lastChildOfEndLayout)
0020                 || (root.myView.alignment !== LatteCore.Types.Justify && appletItem.firstChildOfMainLayout)
0021                 || (root.myView.alignment !== LatteCore.Types.Justify && appletItem.lastChildOfMainLayout)) {
0022             //! Fitts Law on corners
0023             return destination ? destination.zoomScaleThickness * appletItem.lengthAppletFullMargin : appletItem.lengthAppletFullMargin;
0024         }
0025 
0026         return destination ? destination.zoomScaleThickness * appletItem.lengthAppletPadding : appletItem.lengthAppletPadding;
0027     }
0028 
0029     readonly property bool active: parent ? parent.active : false
0030 
0031     Loader{
0032         anchors.fill: parent
0033         active: appletItem.debug.eventsSinkEnabled && active
0034 
0035         sourceComponent: Rectangle {
0036             anchors.fill: parent
0037             color: "yellow"
0038             opacity: 0.2
0039             visible: root.latteView && root.latteView.sink.destinationItem === destination
0040         }
0041     }
0042 
0043     Item {
0044         id: originParentItem
0045         anchors.fill: parent
0046 
0047         //! NOTICE: Do not add any more child items. These child items are used from SinkedEvents handler in order
0048         //! to identify the areas from which mouse events should be sunk into the destination item
0049 
0050         EventsSinkOriginArea {
0051             id: topArea
0052             width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : thickness
0053             height: {
0054                 if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
0055                     //! Fitt;s Law consider the spacer also from parabolic effect
0056                     return appletItem.firstAppletInContainer ? lengthPadding + hiddenSpacerLeft.height + 1 : lengthPadding;
0057                 } else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
0058                     return tailThickness;
0059                 } else {
0060                     return headThickness;
0061                 }
0062             }
0063 
0064             states:[
0065                 State{
0066                     name: "horizontal"
0067                     when: plasmoid.formFactor === PlasmaCore.Types.Horizontal
0068 
0069                     AnchorChanges{
0070                         target: topArea;
0071                         anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: undefined;
0072                         anchors.right: undefined; anchors.left: undefined; anchors.top: undefined; anchors.bottom: parent.top;
0073                     }
0074                 },
0075                 State{
0076                     name: "vertical"
0077                     when: plasmoid.formFactor === PlasmaCore.Types.Vertical
0078 
0079                     AnchorChanges{
0080                         target: topArea;
0081                         anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined;
0082                         anchors.right: undefined; anchors.left: leftArea.left; anchors.top: undefined; anchors.bottom: parent.top;
0083                     }
0084                 }
0085             ]
0086         }
0087 
0088         EventsSinkOriginArea {
0089             id: bottomArea
0090             width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : thickness
0091             height: {
0092                 if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
0093                     //! Fitt;s Law consider the spacer also from parabolic effect
0094                     return appletItem.lastAppletInContainer ? lengthPadding + hiddenSpacerRight.height + 1 : lengthPadding;
0095                 } else if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
0096                     return tailThickness;
0097                 } else {
0098                     return headThickness;
0099                 }
0100             }
0101 
0102             states:[
0103                 State{
0104                     name: "horizontal"
0105                     when: plasmoid.formFactor === PlasmaCore.Types.Horizontal
0106 
0107                     AnchorChanges{
0108                         target: bottomArea;
0109                         anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: undefined;
0110                         anchors.right: undefined; anchors.left: undefined; anchors.top: parent.bottom; anchors.bottom: undefined;
0111                     }
0112                 },
0113                 State{
0114                     name: "vertical"
0115                     when: plasmoid.formFactor === PlasmaCore.Types.Vertical
0116 
0117                     AnchorChanges{
0118                         target: bottomArea;
0119                         anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined;
0120                         anchors.right: undefined; anchors.left: leftArea.left; anchors.top: parent.bottom; anchors.bottom: undefined;
0121                     }
0122                 }
0123             ]
0124         }
0125 
0126         EventsSinkOriginArea {
0127             id: leftArea
0128             height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? thickness : destination.height + 2 * lengthPadding
0129             width: {
0130                 if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
0131                     //! Fitt;s Law consider the spacer also from parabolic effect
0132                     return appletItem.firstAppletInContainer ? lengthPadding + hiddenSpacerLeft.width + 1 : lengthPadding;
0133                 } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
0134                     return tailThickness;
0135                 } else {
0136                     return headThickness;
0137                 }
0138             }
0139 
0140             states:[
0141                 State{
0142                     name: "horizontal"
0143                     when: plasmoid.formFactor === PlasmaCore.Types.Horizontal
0144 
0145                     AnchorChanges{
0146                         target: leftArea;
0147                         anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined;
0148                         anchors.right: parent.left; anchors.left: undefined; anchors.top: undefined; anchors.bottom: bottomArea.bottom;
0149                     }
0150                 },
0151                 State{
0152                     name: "vertical"
0153                     when: plasmoid.formFactor === PlasmaCore.Types.Vertical
0154 
0155                     AnchorChanges{
0156                         target: leftArea;
0157                         anchors.horizontalCenter: undefined; anchors.verticalCenter: parent.verticalCenter;
0158                         anchors.right: parent.left; anchors.left: undefined; anchors.top: undefined; anchors.bottom: undefined;
0159                     }
0160                 }
0161             ]
0162         }
0163 
0164         EventsSinkOriginArea {
0165             id: rightArea
0166             height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? thickness : destination.height + 2 * lengthPadding
0167             width: {
0168                 if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
0169                     //! Fitt;s Law consider the spacer also from parabolic effect
0170                     return appletItem.lastAppletInContainer ? lengthPadding + hiddenSpacerRight.width + 1 : lengthPadding;
0171                 } else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
0172                     return tailThickness;
0173                 } else {
0174                     return headThickness;
0175                 }
0176             }
0177 
0178             states:[
0179                 State{
0180                     name: "horizontal"
0181                     when: plasmoid.formFactor === PlasmaCore.Types.Horizontal
0182 
0183                     AnchorChanges{
0184                         target: rightArea;
0185                         anchors.horizontalCenter: undefined; anchors.verticalCenter: undefined;
0186                         anchors.right: undefined; anchors.left: parent.right; anchors.top: undefined; anchors.bottom: bottomArea.bottom;
0187                     }
0188                 },
0189                 State{
0190                     name: "vertical"
0191                     when: plasmoid.formFactor === PlasmaCore.Types.Vertical
0192 
0193                     AnchorChanges{
0194                         target: rightArea;
0195                         anchors.horizontalCenter: undefined; anchors.verticalCenter: parent.verticalCenter;
0196                         anchors.right: undefined; anchors.left: parent.right; anchors.top: undefined; anchors.bottom: undefined;
0197                     }
0198                 }
0199             ]
0200         }
0201     }
0202 }