add ParabolicManager in the plasmoid
--move all the logic around parabolic effect signals into one place, ParabolicManager. The ParabolicManager is responsible for triggering all the messages to tasks that are neighbour to the hovered task. This will help a lot to catch cases such as separators and proper clearing zoom.pull/1/head
parent
569644073f
commit
a9df1d6745
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2016 Smith AR <audoban@openmailbox.org>
|
||||
* Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* This file is part of Latte-Dock
|
||||
*
|
||||
* Latte-Dock is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Latte-Dock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
// holds all the logic around parabolic effect signals into one place.
|
||||
// ParabolicManager is responsible for triggering all the messages to tasks
|
||||
// that are neighbour to the hovered task. This will help a lot to catch cases
|
||||
// such as separators and proper clearing zoom.
|
||||
|
||||
Item {
|
||||
id: parManager
|
||||
|
||||
property bool hasInternalSeparator: internalSeparatorPos > -1
|
||||
|
||||
property int internalSeparatorPos: -1
|
||||
|
||||
//!this is used in order to update the index when the signal is for applets
|
||||
//!outside the latte plasmoid
|
||||
function updateIdSendScale(index, zScale, zStep){
|
||||
if ((index>=0 && index<=root.tasksCount-1) || (!root.latteDock)){
|
||||
root.updateScale(index, zScale, zStep);
|
||||
} else{
|
||||
var appletId = latteDock.latteAppletPos;
|
||||
if (index<0)
|
||||
appletId = latteDock.latteAppletPos + index;
|
||||
else if (index>root.tasksCount-1){
|
||||
var step=index-root.tasksCount+1;
|
||||
appletId = latteDock.latteAppletPos + step;
|
||||
}
|
||||
|
||||
latteDock.updateScale(appletId, zScale, zStep);
|
||||
}
|
||||
}
|
||||
|
||||
function applyParabolicEffect(index, currentMousePosition, center) {
|
||||
var rDistance = Math.abs(currentMousePosition - center);
|
||||
|
||||
//check if the mouse goes right or down according to the center
|
||||
var positiveDirection = ((currentMousePosition - center) >= 0 );
|
||||
|
||||
var minimumZoom = 1;
|
||||
|
||||
//finding the zoom center e.g. for zoom:1.7, calculates 0.35
|
||||
var zoomCenter = ((root.zoomFactor + minimumZoom)/2) - 1;
|
||||
|
||||
//computes the in the scale e.g. 0...0.35 according to the mouse distance
|
||||
//0.35 on the edge and 0 in the center
|
||||
var firstComputation = (rDistance / center) * (zoomCenter-minimumZoom+1);
|
||||
|
||||
//calculates the scaling for the neighbour tasks
|
||||
var bigNeighbourZoom = Math.min(1 + zoomCenter + firstComputation, root.zoomFactor);
|
||||
var smallNeighbourZoom = Math.max(1 + zoomCenter - firstComputation, minimumZoom);
|
||||
|
||||
//bigNeighbourZoom = Number(bigNeighbourZoom.toFixed(4));
|
||||
//smallNeighbourZoom = Number(smallNeighbourZoom.toFixed(4));
|
||||
|
||||
var leftScale;
|
||||
var rightScale;
|
||||
|
||||
if(positiveDirection === true){
|
||||
rightScale = bigNeighbourZoom;
|
||||
leftScale = smallNeighbourZoom;
|
||||
} else {
|
||||
rightScale = smallNeighbourZoom;
|
||||
leftScale = bigNeighbourZoom;
|
||||
}
|
||||
|
||||
// console.debug(leftScale + " " + rightScale + " " + index);
|
||||
|
||||
if(!hasInternalSeparator || Math.abs(index-internalSeparatorPos)>=2){
|
||||
//activate messages to update the the neighbour scales
|
||||
updateIdSendScale(index+1, rightScale, 0);
|
||||
updateIdSendScale(index-1, leftScale, 0);
|
||||
|
||||
updateIdSendScale(index+2, 1, 0);
|
||||
updateIdSendScale(index-2, 1, 0);
|
||||
} else if(root.internalSeparatorPos>=0) {
|
||||
if(internalSeparatorPos === index+1){
|
||||
updateIdSendScale(index+2, rightScale, 0);
|
||||
updateIdSendScale(index-1, leftScale, 0);
|
||||
|
||||
|
||||
updateIdSendScale(index+3, 1, 0);
|
||||
updateIdSendScale(index-2, 1, 0);
|
||||
} else if(internalSeparatorPos === index-1) {
|
||||
updateIdSendScale(index-2, leftScale, 0);
|
||||
updateIdSendScale(index+1, rightScale, 0);
|
||||
|
||||
updateIdSendScale(index+2, 1, 0);
|
||||
updateIdSendScale(index-3, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return {leftScale:leftScale, rightScale:rightScale};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue