1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

PARABOLIC:new parabolic effect implementation

--the new implementation relies on items in order to
forward scale signals properly to their neighbours. So
parabolic effect does not have to know separators and
hidden items any more. As it appears it is lighter
also and more responsive. This is a very important
milestone for the parabolic effect.
This commit is contained in:
Michail Vourlakos 2020-05-03 20:49:48 +03:00
parent 69267e493a
commit 9145634434
6 changed files with 159 additions and 240 deletions

View File

@ -34,51 +34,8 @@ Item {
property var hidden: []
property var separators: []
//!this is used in order to update the index when the signal is for the internal latte plasmoid
//!this is used in order to update the index when the signal is for the internal latte plasmoid
function updateIdSendScale(appIndex, index, zScale, zStep){
// console.log(appIndex + " _ "+index+ " _ "+zScale + " _ "+ zStep);
if(root.latteApplet
&& root.latteApplet.parabolicManager.firstRealTaskIndex !== -1
&& ((appIndex<root.latteAppletPos && index>=root.latteAppletPos)
|| (appIndex>root.latteAppletPos && index<=root.latteAppletPos)) ){
var appStep = Math.abs(root.latteAppletPos-appIndex);
var signalStep = Math.abs(index - appIndex);
var taskIndex = -1;
var internSepStep = 0;
if(appIndex<root.latteAppletPos){
if (root.latteApplet.parabolicManager.taskIsSeparator(0)
|| (!root.showWindowsWithNoLaunchers && root.latteApplet.parabolicManager.taskIsForcedHidden(0)) )
internSepStep = root.latteApplet.parabolicManager.availableHigherIndex(0);
taskIndex = signalStep-appStep+internSepStep;
if (root.latteApplet.parabolicManager.taskIsSeparator(taskIndex))
taskIndex = root.latteApplet.parabolicManager.availableHigherIndex(taskIndex + 1);
//console.log("normal:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
} else if (appIndex>root.latteAppletPos){
if (root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1)
|| (!root.showWindowsWithNoLaunchers && root.latteApplet.parabolicManager.taskIsForcedHidden(root.tasksCount-1)) )
internSepStep = Math.abs(root.tasksCount-1 - root.latteApplet.parabolicManager.availableLowerIndex(root.tasksCount-1));
taskIndex = root.tasksCount-1 - (signalStep-appStep) - internSepStep;
if (root.latteApplet.parabolicManager.taskIsSeparator(taskIndex))
taskIndex = root.latteApplet.parabolicManager.availableLowerIndex(taskIndex - 1);
//console.log("reverse:" + taskIndex + " step:"+internSepStep + " zoom:"+zScale);
}
root.latteApplet.updateScale(taskIndex, zScale,zStep);
return taskIndex;
} else {
// console.log("ch 2...");
root.updateScale(index, zScale, zStep);
return -1;
}
}
signal sglUpdateLowerItemScale(int delegateIndex, real newScale, real step);
signal sglUpdateHigherItemScale(int delegateIndex, real newScale, real step);
function applyParabolicEffect(index, currentMousePosition, center) {
var rDistance = Math.abs(currentMousePosition - center);
@ -116,127 +73,16 @@ Item {
leftScale = bigNeighbourZoom;
}
var gAppletIndex = -1;
var lAppletIndex = -1;
var gTaskIndex = -1;
var lTaskIndex = -1;
var tLIndex = -1;
var tHIndex = -1;
var gAppN = availableHigherId(index+1);
var lAppN = availableLowerId(index-1);
var latteNeighbour = root.latteApplet && ((gAppN === root.latteAppletPos) || (lAppN === root.latteAppletPos ));
if(!root.latteApplet || !latteNeighbour || !root.hasInternalSeparator
|| (root.latteApplet && root.latteApplet.parabolicManager.firstRealTaskIndex===-1)
|| (root.latteApplet && root.hasInternalSeparator
&& ((!root.latteApplet.parabolicManager.taskIsSeparator(0) && !root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1))
|| (root.latteApplet.parabolicManager.taskIsSeparator(0) && index>root.latteAppletPos)
|| (root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1) && index<root.latteAppletPos)))
){
//console.log("style 1...");
gAppletIndex = gAppN;
lAppletIndex = lAppN;
updateIdSendScale(index, gAppletIndex, rightScale, 0);
updateIdSendScale(index, lAppletIndex, leftScale, 0);
tLIndex = (lAppletIndex !== root.latteAppletPos) ? availableLowerId(lAppletIndex-1) : lAppletIndex-1;
tHIndex = (gAppletIndex !== root.latteAppletPos) ? availableHigherId(gAppletIndex+1) : gAppletIndex+1;
gTaskIndex = updateIdSendScale(index, tHIndex, 1 ,0);
lTaskIndex = updateIdSendScale(index, tLIndex, 1, 0);
} else{
if(gAppN === root.latteAppletPos && root.latteApplet.parabolicManager.taskIsSeparator(0)){
//console.log("style 2...");
gAppletIndex = availableHigherId(index+1);
lAppletIndex= availableLowerId(index-1);
updateIdSendScale(index, gAppletIndex, rightScale, 0);
updateIdSendScale(index, lAppletIndex, leftScale, 0);
tLIndex = availableLowerId(lAppletIndex-1);
gTaskIndex = updateIdSendScale(index, gAppletIndex+1, 1, 0);
lTaskIndex = updateIdSendScale(index, tLIndex, 1, 0);
} else if(lAppN === root.latteAppletPos && root.latteApplet.parabolicManager.taskIsSeparator(root.tasksCount-1)) {
//console.log("style 3...");
gAppletIndex = gAppN;
lAppletIndex= lAppN;
updateIdSendScale(index, lAppletIndex, leftScale, 0);
updateIdSendScale(index, gAppletIndex, rightScale, 0);
tHIndex = availableHigherId(gAppletIndex+1);
gTaskIndex = updateIdSendScale(index, tHIndex, 1, 0);
lTaskIndex = updateIdSendScale(index, lAppletIndex-1, 1, 0);
}
}
//!when there isnt a single task
if (latteApplet && (root.latteApplet.parabolicManager.firstRealTaskIndex !== root.latteApplet.parabolicManager.lastRealTaskIndex)) {
if (gTaskIndex === -1 && lTaskIndex === -1){
latteApplet.parabolicManager.clearTasksGreaterThan(-1);
} else {
if (gTaskIndex > -1)
latteApplet.parabolicManager.clearTasksGreaterThan(gTaskIndex);
if (lTaskIndex > -1)
latteApplet.parabolicManager.clearTasksLowerThan(lTaskIndex);
}
}
clearAppletsGreaterThan(gAppletIndex+1, 1, 0);
clearAppletsLowerThan(lAppletIndex-1, 1, 0);
sglUpdateHigherItemScale(index+1 , rightScale, 0);
sglUpdateLowerItemScale(index-1, leftScale, 0);
return {leftScale:leftScale, rightScale:rightScale};
}
function clearAppletsGreaterThan(index) {
var startLastIndex = layoutsContainer.startLayout.beginIndex+layoutsContainer.startLayout.count-1;
if (index<startLastIndex) {
for (var i=index+1; i<=startLastIndex; ++i)
root.updateScale(i, 1, 0);
}
var mainLastIndex = layoutsContainer.mainLayout.beginIndex+layoutsContainer.mainLayout.count-1;
if (index<mainLastIndex){
var mainClearStart = index>layoutsContainer.mainLayout.beginIndex ? index+1 : layoutsContainer.mainLayout.beginIndex;
for (var j=mainClearStart; j<=mainLastIndex; ++j)
root.updateScale(j, 1, 0);
}
var endLastIndex = layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1;
if (index<endLastIndex){
var endClearStart = index>layoutsContainer.endLayout.beginIndex ? index+1 : layoutsContainer.endLayout.beginIndex;
for (var k=endClearStart; k<=endLastIndex; ++k)
root.updateScale(k, 1, 0);
}
}
function clearAppletsLowerThan(index) {
var startBeginIndex = layoutsContainer.startLayout.beginIndex;
var startLastIndex = layoutsContainer.startLayout.beginIndex+layoutsContainer.startLayout.count-1;
if (index>startBeginIndex) {
var startClearStart = index<=startLastIndex ? index-1 : startLastIndex;
for (var i=startClearStart; i>=startBeginIndex; --i)
root.updateScale(i, 1, 0);
}
var mainBeginIndex = layoutsContainer.mainLayout.beginIndex;
var mainLastIndex = layoutsContainer.mainLayout.beginIndex+layoutsContainer.mainLayout.count-1;
if (index>mainBeginIndex) {
var mainClearStart = index<=mainLastIndex ? index-1 : mainLastIndex;
for (var j=mainClearStart; j>=mainBeginIndex; --j)
root.updateScale(j, 1, 0);
}
var endBeginIndex = layoutsContainer.endLayout.beginIndex;
var endLastIndex = layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1;
if (index>endBeginIndex) {
var endClearStart = index<=endLastIndex ? index-1 : endLastIndex;
for (var k=endClearStart; k>=endBeginIndex; --k)
root.updateScale(k, 1, 0);
}
}
// update the registered separators

View File

@ -386,6 +386,10 @@ Item {
if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex === -1) {
restoreAnimation.start();
}
if (latteApplet) {
latteApplet.clearZoom();
}
}
function checkCanBeHovered(){

View File

@ -773,11 +773,71 @@ Item{
}
}
function sltUpdateLowerItemScale(delegateIndex, newScale, step) {
if (delegateIndex === appletItem.index) {
if (appletItem.isLattePlasmoid) {
appletItem.latteApplet.parabolicManager.hostRequestUpdateLowerItemScale(newScale, step);
return;
}
if (!appletItem.isSeparator && !appletItem.isHidden) {
//! when accepted
signalUpdateScale(delegateIndex, newScale, step);
if (newScale > 1) { // clear lower items
parabolicManager.sglUpdateLowerItemScale(delegateIndex-1, 1, 0);
}
} else {
parabolicManager.sglUpdateLowerItemScale(delegateIndex-1, newScale, step);
}
} else if ((newScale === 1) && (appletItem.index < delegateIndex)) {
//! apply zoom clearing
if (appletItem.isLattePlasmoid) {
appletItem.latteApplet.parabolicManager.hostRequestUpdateLowerItemScale(1, step);
} else {
signalUpdateScale(appletItem.index, 1, 0);
}
}
}
function sltUpdateHigherItemScale(delegateIndex, newScale, step) {
if (delegateIndex === appletItem.index) {
if (appletItem.isLattePlasmoid) {
appletItem.latteApplet.parabolicManager.hostRequestUpdateHigherItemScale(newScale, step);
return;
}
if (!appletItem.isSeparator && !appletItem.isHidden) {
//! when accepted
signalUpdateScale(delegateIndex, newScale, step);
if (newScale > 1) { // clear higher items
parabolicManager.sglUpdateHigherItemScale(delegateIndex+1, 1, 0);
}
} else {
parabolicManager.sglUpdateHigherItemScale(delegateIndex+1, newScale, step);
}
} else if ((newScale === 1) && (appletItem.index > delegateIndex)) {
//! apply zoom clearing
if (appletItem.isLattePlasmoid) {
appletItem.latteApplet.parabolicManager.hostRequestUpdateHigherItemScale(1, step);
} else {
signalUpdateScale(appletItem.index, 1, 0);
}
}
}
Component.onCompleted: {
root.updateScale.connect(signalUpdateScale);
parabolicManager.sglUpdateLowerItemScale.connect(sltUpdateLowerItemScale);
parabolicManager.sglUpdateHigherItemScale.connect(sltUpdateHigherItemScale);
}
Component.onDestruction: {
root.updateScale.disconnect(signalUpdateScale);
parabolicManager.sglUpdateLowerItemScale.disconnect(sltUpdateLowerItemScale);
parabolicManager.sglUpdateHigherItemScale.disconnect(sltUpdateHigherItemScale);
}
}// Main task area // id:wrapper

View File

@ -118,6 +118,16 @@ Item{
readonly property Item animations: appletItem.animations.publicApi
readonly property Item metrics: appletItem.metrics.publicApi
readonly property Item parabolic: Item {
function clientRequestUpdateLowerItemScale(newScale, step) {
parabolicManager.sglUpdateLowerItemScale(index-1, newScale, step);
}
function clientRequestUpdateHigherItemScale(newScale, step) {
parabolicManager.sglUpdateHigherItemScale(index+1, newScale, step);
}
}
Connections {
target: root
onBroadcastedToApplet: {

View File

@ -36,6 +36,9 @@ Item {
property int lastRealTaskIndex: -1
property int countRealTasks: -1
signal sglUpdateLowerItemScale(int delegateIndex, real newScale, real step);
signal sglUpdateHigherItemScale(int delegateIndex, real newScale, real step);
Connections{
target: root
onTasksCountChanged: parManager.updateTasksEdgesIndexes();
@ -46,10 +49,16 @@ Item {
updateHasInternalSeparator();
updateTasksEdgesIndexes();
root.separatorsUpdated.connect(updateHasInternalSeparator);
parManager.sglUpdateLowerItemScale.connect(sltTrackLowerItemScale);
parManager.sglUpdateHigherItemScale.connect(sltTrackHigherItemScale);
}
Component.onDestruction: {
root.separatorsUpdated.disconnect(updateHasInternalSeparator);
parManager.sglUpdateLowerItemScale.disconnect(sltTrackLowerItemScale);
parManager.sglUpdateHigherItemScale.disconnect(sltTrackHigherItemScale);
}
function updateTasksEdgesIndexes() {
@ -80,23 +89,35 @@ Item {
hasInternalSeparator = false;
}
//!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.latteView)){
root.updateScale(index, zScale, zStep);
return -1;
} else{
var appletId = latteView.latteAppletPos;
if (index<0)
appletId = latteView.parabolicManager.availableLowerId(latteView.latteAppletPos + index);
else if (index>root.tasksCount-1){
var step=index-root.tasksCount+1;
appletId = latteView.parabolicManager.availableHigherId(latteView.latteAppletPos + step);
}
function hostRequestUpdateLowerItemScale(newScale, step){
//! function called from host
sglUpdateLowerItemScale(root.tasksCount-1, newScale, step);
}
latteView.updateScale(appletId, zScale, zStep);
return appletId;
function hostRequestUpdateHigherItemScale(newScale, step){
//! function called from host
sglUpdateHigherItemScale(0, newScale, step);
}
function sltTrackLowerItemScale(delegateIndex, newScale, step){
//! send update signal to host
if (latteBridge) {
if (delegateIndex === -1) {
latteBridge.parabolic.clientRequestUpdateLowerItemScale(newScale, step);
} else if (newScale === 1 && delegateIndex>=0) {
latteBridge.parabolic.clientRequestUpdateLowerItemScale(1, 0);
}
}
}
function sltTrackHigherItemScale(delegateIndex, newScale, step) {
//! send update signal to host
if (latteBridge) {
if (delegateIndex >= root.tasksCount) {
latteBridge.parabolic.clientRequestUpdateHigherItemScale(newScale, step);
} else if (newScale === 1 && delegateIndex<root.tasksCount) {
latteBridge.parabolic.clientRequestUpdateHigherItemScale(1, 0);
}
}
}
@ -137,80 +158,17 @@ Item {
leftScale = bigNeighbourZoom;
}
sglUpdateHigherItemScale(index+1 , rightScale, 0);
sglUpdateLowerItemScale(index-1, leftScale, 0);
// console.debug(leftScale + " " + rightScale + " " + index);
//first applets accessed
var gPAppletId = -1;
var lPAppletId = -1;
//secondary applets accessed to restore zoom
var gAppletId = -1;
var lAppletId = -1;
var gStep = 1;
var lStep = 1;
//console.log("--- task style 2...");
var aGId1 = availableHigherIndex(index+1);
var aLId1 = availableLowerIndex(index-1);
gPAppletId = updateIdSendScale(aGId1, rightScale, 0);
lPAppletId = updateIdSendScale(aLId1, leftScale, 0);
// console.log("index:"+index + " lattePos:"+latteView.latteAppletPos);
// console.log("gApp:"+gPAppletId+" lApp:"+lPAppletId+ " aG1:"+aGId1+" aLId1:"+aLId1);
gStep = aGId1 - index;
lStep = index - aLId1;
if (latteView) {
if (gPAppletId > -1)
gStep = Math.abs(gPAppletId - latteView.latteAppletPos + (root.tasksCount-1-index));
if (lPAppletId > -1)
lStep = Math.abs(lPAppletId - latteView.latteAppletPos - index);
}
//console.log("gs:"+gStep+" ls:"+lStep);
gAppletId = updateIdSendScale(index+gStep+1, 1, 0);
lAppletId = updateIdSendScale(index-lStep-1, 1, 0);
//console.log(" cgApp:"+gAppletId+" clApp:"+lAppletId);
clearTasksGreaterThan(aGId1+1);
clearTasksLowerThan(aLId1-1);
if (latteView){
if (gAppletId > -1) {
latteView.parabolicManager.clearAppletsGreaterThan(gAppletId);
} else if (index < lastRealTaskIndex && lastRealTaskIndex!==-1) {
latteView.parabolicManager.clearAppletsGreaterThan(latteView.latteAppletPos);
}
if (lAppletId > -1) {
latteView.parabolicManager.clearAppletsLowerThan(lAppletId);
} else if (index > firstRealTaskIndex && firstRealTaskIndex!==-1) {
latteView.parabolicManager.clearAppletsLowerThan(latteView.latteAppletPos);
}
}
return {leftScale:leftScale, rightScale:rightScale};
}
function clearTasksGreaterThan(index) {
if (index<root.tasksCount-1){
for(var i=index+1; i<root.tasksCount; ++i)
root.updateScale(i, 1, 0);
}
}
function clearTasksLowerThan(index) {
if (index>0 && root.tasksCount>2) {
for(var i=0; i<index; ++i)
root.updateScale(i, 1, 0);
}
}
function neighbourIsHovered(index) {

View File

@ -225,6 +225,41 @@ Item{
}
}
function sltUpdateLowerItemScale(delegateIndex, newScale, step) {
if (delegateIndex === index) {
if (!taskItem.isSeparator) {
//! when accepted
signalUpdateScale(delegateIndex, newScale, step);
if (newScale > 1) { // clear lower items
parabolicManager.sglUpdateLowerItemScale(delegateIndex-1, 1, 0);
}
} else {
parabolicManager.sglUpdateLowerItemScale(delegateIndex-1, newScale, step);
}
} else if ((newScale === 1) && (index < delegateIndex)) {
signalUpdateScale(index, 1, 0);
}
}
function sltUpdateHigherItemScale(delegateIndex, newScale, step) {
if (delegateIndex === index) {
if (!taskItem.isSeparator) {
//! when accepted
signalUpdateScale(delegateIndex, newScale, step);
if (newScale > 1) { // clear lower items
parabolicManager.sglUpdateHigherItemScale(delegateIndex+1, 1, 0); // clear higher items
}
} else {
parabolicManager.sglUpdateHigherItemScale(delegateIndex+1, newScale, step);
}
} else if ((newScale === 1) && (index > delegateIndex)) {
signalUpdateScale(index, 1, 0);
}
}
function sendEndOfNeedBothAxisAnimation(){
if (taskItem.isZoomed) {
taskItem.isZoomed = false;
@ -265,9 +300,15 @@ Item{
}
root.updateScale.connect(signalUpdateScale);
parabolicManager.sglUpdateLowerItemScale.connect(sltUpdateLowerItemScale);
parabolicManager.sglUpdateHigherItemScale.connect(sltUpdateHigherItemScale);
}
Component.onDestruction: {
root.updateScale.disconnect(signalUpdateScale);
parabolicManager.sglUpdateLowerItemScale.disconnect(sltUpdateLowerItemScale);
parabolicManager.sglUpdateHigherItemScale.disconnect(sltUpdateHigherItemScale);
}
}// Main task area // id:wrapper