Warning, /plasma/latte-dock/declarativeimports/abilities/definition/ParabolicEffect.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.0 0007 0008 import org.kde.plasma.plasmoid 2.0 0009 import org.kde.plasma.core 2.0 as PlasmaCore 0010 0011 import "./paraboliceffect" as ParabolicEffectTypes 0012 0013 Item { 0014 property bool isEnabled: false 0015 property bool restoreZoomIsBlocked: false 0016 0017 property int spread: 3 0018 0019 property ParabolicEffectTypes.Factor factor: ParabolicEffectTypes.Factor{ 0020 zoom: 1.6 0021 maxZoom: 1.6 0022 marginThicknessZoomInPercentage: 1.0 0023 } 0024 0025 readonly property ParabolicEffectTypes.PrivateProperties _privates: ParabolicEffectTypes.PrivateProperties { 0026 directRenderingEnabled: false 0027 } 0028 0029 property Item currentParabolicItem: null 0030 0031 signal sglClearZoom(); 0032 signal sglUpdateLowerItemScale(int delegateIndex, variant newScales); 0033 signal sglUpdateHigherItemScale(int delegateIndex, variant newScales); 0034 0035 readonly property int _spreadSteps: (spread - 1) / 2 0036 0037 function applyParabolicEffect(itemIndex, itemMousePosition, itemLength) { 0038 var percentage = Math.max(0, Math.min(1, itemMousePosition / itemLength)); 0039 0040 //! left scales 0041 var leftScales = []; 0042 for (var i=_spreadSteps; i>=1; --i) { 0043 leftScales.push(scaleForItem(1-percentage, i, _spreadSteps)); 0044 } 0045 leftScales.push(1); //! clearing 0046 0047 //! right scales 0048 var rightScales = []; 0049 for (var j=_spreadSteps; j>=1; --j) { 0050 rightScales.push(scaleForItem(percentage, j, _spreadSteps)); 0051 } 0052 rightScales.push(1); //! clearing 0053 0054 var reversed = Qt.application.layoutDirection === Qt.RightToLeft && (plasmoid.formFactor === PlasmaCore.Types.Horizontal); 0055 0056 if (reversed) { 0057 var temp = leftScales; 0058 leftScales = rightScales; 0059 rightScales = temp; 0060 } 0061 0062 sglUpdateHigherItemScale(itemIndex+1, rightScales); 0063 sglUpdateLowerItemScale(itemIndex-1, leftScales); 0064 0065 return {leftScale:leftScales[0], rightScale:rightScales[0]}; 0066 } 0067 0068 function scaleForItem(mousePosPercentage, itemIndex, itemsCount) { 0069 //! split x axis to different slices and find for the current slice its minimum and maximum x values 0070 var xSliceLength = 1/itemsCount; 0071 var minX = (itemIndex-1) * xSliceLength; 0072 var maxX = itemIndex * xSliceLength; 0073 //! use minimum and maximum values in order to adjust mousePorPercentage and provide the current x for that slice 0074 var curX = minX + (maxX-minX) * mousePosPercentage; 0075 return 1+scaleLinear(curX); 0076 } 0077 0078 function scaleLinear(x) { 0079 //! just a simple linear function y=a*x where [a = maxZoom - 1] 0080 return (factor.zoom - 1) * x; 0081 } 0082 }