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

0001 /*
0002     SPDX-FileCopyrightText: 2022 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 import org.kde.latte.core 0.2 as LatteCore
0008 
0009 Item {
0010     id: edgeSpacer
0011     width: length
0012     height: length
0013 
0014     readonly property bool isParabolicEdgeSpacer: true
0015     readonly property bool isHidden: true
0016 
0017     readonly property bool isAutoFillApplet: false
0018     readonly property bool isInternalViewSplitter: false
0019     readonly property bool isPlaceHolder: false
0020     readonly property bool isTailSpacer: index < parent.beginIndex
0021     readonly property bool isHeadSpacer: index >= parent.beginIndex
0022 
0023     readonly property int animationTime: animations.speedFactor.normal * (1.2*animations.duration.small)
0024     readonly property int hiddenItemsCount: (parabolic.spread - 1)/2
0025 
0026     property int index: -1
0027     property real length: 0
0028 
0029     Behavior on length {
0030         id: animatedLengthBehavior
0031         enabled: !parabolic.directRenderingEnabled || restoreAnimation.running
0032         NumberAnimation {
0033             duration: 3 * edgeSpacer.animationTime
0034             easing.type: Easing.OutCubic
0035         }
0036     }
0037 
0038     Behavior on length {
0039         enabled: !animatedLengthBehavior.enabled
0040         NumberAnimation { duration: 0 }
0041     }
0042 
0043     ParallelAnimation{
0044         id: restoreAnimation
0045 
0046         PropertyAnimation {
0047             target: edgeSpacer
0048             property: "length"
0049             to: 0
0050             duration: 4 * edgeSpacer.animationTime
0051             easing.type: Easing.InCubic
0052         }
0053     }
0054 
0055     function updateScale(istail, newScales) {
0056         var nextFactor = 0;
0057         for (var i=0; i<hiddenItemsCount; ++i) {
0058             if (i<newScales.length) {
0059                 nextFactor += (newScales[i] - 1);
0060             }
0061         }
0062 
0063         length = nextFactor * metrics.totals.length;
0064     }
0065 
0066     function sltUpdateLowerItemScale(delegateIndex, newScales) {
0067         if (!isTailSpacer || delegateIndex !== index) {
0068             return;
0069         }
0070 
0071         if (myView.alignment === LatteCore.Types.Center || myView.alignment === LatteCore.Types.Justify) {
0072             updateScale(isTailSpacer, newScales);
0073         } else {
0074             length = 0;
0075         }
0076 
0077         //! clear side neighbours
0078         parabolic.sglUpdateLowerItemScale(index - 1, [1]);
0079     }
0080 
0081     function sltUpdateHigherItemScale(delegateIndex, newScales) {
0082         if (!isHeadSpacer || delegateIndex !== index) {
0083             return;
0084         }
0085 
0086         if (myView.alignment === LatteCore.Types.Center || myView.alignment === LatteCore.Types.Justify) {
0087             updateScale(isHeadSpacer, newScales);
0088         } else {
0089             length = 0;
0090         }
0091 
0092         //! clear side neighbours
0093         parabolic.sglUpdateHigherItemScale(index + 1, [1]);
0094     }
0095 
0096     function sltClearZoom(){
0097         restoreAnimation.start();
0098     }
0099 
0100     Component.onCompleted: {
0101         parabolic.sglClearZoom.connect(sltClearZoom);
0102         parabolic.sglUpdateLowerItemScale.connect(sltUpdateLowerItemScale);
0103         parabolic.sglUpdateHigherItemScale.connect(sltUpdateHigherItemScale);
0104     }
0105 
0106     Component.onDestruction: {
0107         parabolic.sglClearZoom.disconnect(sltClearZoom);
0108         parabolic.sglUpdateLowerItemScale.disconnect(sltUpdateLowerItemScale);
0109         parabolic.sglUpdateHigherItemScale.disconnect(sltUpdateHigherItemScale);
0110     }
0111 
0112     Loader{
0113         anchors.fill: parent
0114         active: debug.spacersEnabled
0115 
0116         sourceComponent: Rectangle{
0117             color: "#44ff0000"
0118             border.width: 1
0119             border.color: "red"
0120         }
0121     }
0122 }