1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-13 21:18:01 +03:00

HoveredIndex:Drop for containment

--a new implementation is needed which is going
to be simpler and lighter. Removing the current
implementation, parabolic effect works just fine
without issues and feels more responsive.
This commit is contained in:
Michail Vourlakos 2020-05-04 11:08:50 +03:00
parent 4096ed6b58
commit 63500ed524
9 changed files with 42 additions and 191 deletions

View File

@ -634,7 +634,7 @@ Window{
}
Text{
text: layoutsContainer.hoveredIndex
text: "--"//layoutsContainer.hoveredIndex
}
Text{
@ -642,7 +642,7 @@ Window{
}
Text{
text: root.latteAppletHoveredIndex
text: "--"//root.latteAppletHoveredIndex
}
Text{

View File

@ -37,7 +37,17 @@ Item {
signal sglUpdateLowerItemScale(int delegateIndex, real newScale, real step);
signal sglUpdateHigherItemScale(int delegateIndex, real newScale, real step);
property int lastIndex: -1
Connections {
target: root
onClearZoomSignal: parManager.lastIndex = -1;
}
function applyParabolicEffect(index, currentMousePosition, center) {
//! last item requested calculations
lastIndex = index;
var rDistance = Math.abs(currentMousePosition - center);
//check if the mouse goes right or down according to the center

View File

@ -22,13 +22,4 @@ import QtQuick 2.7
MouseArea{
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: {
if (root.mouseInHoverableArea()) {
root.stopCheckRestoreZoomTimer();
} else {
root.initializeHoveredIndexes();
root.startCheckRestoreZoomTimer()
}
}
}

View File

@ -154,7 +154,6 @@ Item {
readonly property bool screenEdgeMarginSupported: communicator.requires.screenEdgeMarginSupported
property int animationTime: appletItem.animations.speedFactor.normal * (1.2*appletItem.animations.duration.small)
property int hoveredIndex: layoutsContainer.hoveredIndex
property int index: -1
property int maxWidth: root.isHorizontal ? root.height : root.width
property int maxHeight: root.isHorizontal ? root.height : root.width
@ -383,9 +382,7 @@ Item {
//outside the LatteApplet Plasmoid
//property int debCounter: 0;
function clearZoom(){
if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex === -1) {
restoreAnimation.start();
}
restoreAnimation.start();
if (latteApplet) {
latteApplet.clearZoom();
@ -396,12 +393,6 @@ Item {
canBeHoveredTimer.start();
}
function sltInitializeHoveredIndexes() {
if (latteApplet) {
latteApplet.initializeHoveredIndex();
}
}
//! Reduce calculations and give the time to applet to adjust to prevent binding loops
Timer{
id: canBeHoveredTimer
@ -526,7 +517,6 @@ Item {
root.updateIndexes.connect(checkIndex);
root.clearZoomSignal.connect(clearZoom);
root.destroyInternalViewSplitters.connect(slotDestroyInternalViewSplitters);
root.sglInitializeHoveredIndexes.connect(sltInitializeHoveredIndexes);
}
Component.onDestruction: {
@ -550,7 +540,6 @@ Item {
root.updateIndexes.disconnect(checkIndex);
root.clearZoomSignal.disconnect(clearZoom);
root.destroyInternalViewSplitters.disconnect(slotDestroyInternalViewSplitters);
root.sglInitializeHoveredIndexes.disconnect(sltInitializeHoveredIndexes);
if (appletItem.latteApplet) {
appletItem.latteApplet.signalPreviewsShown.disconnect(slotPreviewsShown);
@ -561,38 +550,6 @@ Item {
Connections{
target: root
/* onGlobalDirectRenderChanged:{
if (root.globalDirectRender && restoreAnimation.running) {
// console.log("CLEAR APPLET SCALE !!!!");
//restoreAnimation.stop();
//wrapper.zoomScale = 1;
}
}*/
onLatteAppletHoveredIndexChanged: {
if ( (root.zoomFactor>1) && (root.latteAppletHoveredIndex >= 0) ){
var distance = 2;
//for Tasks plasmoid distance of 2 is not always safe there are
//cases that needs to be 3, when an internal separator there is
//between the hovered task and the current applet
if (root.hasInternalSeparator) {
if (index < root.latteAppletPos) {
var firstTaskIndex = root.latteApplet.parabolicManager.availableHigherIndex(0);
distance = firstTaskIndex+2;
} else if (index > root.latteAppletPos) {
var lastTaskIndex = root.latteApplet.parabolicManager.availableLowerIndex(root.tasksCount-1);
distance = root.tasksCount-1-lastTaskIndex+2;
}
}
if(Math.abs(index-root.latteAppletPos+root.latteAppletHoveredIndex)>=Math.max(2,distance)) {
appletItem.clearZoom();
}
}
}
onSignalActivateEntryAtIndex: {
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) {
latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex);
@ -610,30 +567,6 @@ Item {
}
}
Connections{
target: layoutsContainer
onHoveredIndexChanged:{
//for applets it is safe to consider that a distance of 2
//is enough to clearZoom
if ( (root.zoomFactor>1) && (layoutsContainer.hoveredIndex>=0)
&& (Math.abs(index-layoutsContainer.hoveredIndex)>=2))
appletItem.clearZoom();
if ((restoreAnimation.running) && (layoutsContainer.hoveredIndex !== -1)) {
restoreAnimation.stop();
}
}
}
Connections{
target: root
onLatteAppletHoveredIndexChanged: {
if ((restoreAnimation.running) && (root.latteAppletHoveredIndex !== -1)) {
restoreAnimation.stop();
}
}
}
Connections {
id: viewSignalsConnector
target: root.latteView ? root.latteView : null
@ -1008,10 +941,8 @@ Item {
property bool blockWheel: false
onEntered: {
if (containsMouse && !originalAppletBehavior && !communicator.requires.parabolicEffectLocked && appletItem.canBeHovered){
root.stopCheckRestoreZoomTimer();
}
onEntered: {
root.stopCheckRestoreZoomTimer();
if (restoreAnimation.running) {
restoreAnimation.stop();
@ -1021,17 +952,10 @@ Item {
root.showTooltipLabel(appletItem, applet.title);
}
//console.log("entered applet:" + layoutsContainer.hoveredIndex);
if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex===-1) {
if (!root.directRenderDelayerIsRunning) {
root.startDirectRenderDelayerDuringEntering();
}
if (!(root.latteViewIsHidden || root.inSlidingIn || root.inSlidingOut)){
layoutsContainer.hoveredIndex = index;
}
if (originalAppletBehavior || communicator.requires.parabolicEffectLocked || !canBeHovered) {
return;
}
@ -1074,16 +998,10 @@ Item {
return;
}
if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex===-1) {
root.startDirectRenderDelayerDuringEntering();
}
if (!(root.latteViewIsHidden || root.inSlidingIn || root.inSlidingOut)){
layoutsContainer.hoveredIndex = index;
}
if (!root.globalDirectRender && !root.directRenderDelayerIsRunning) {
if (parabolicManager.lastIndex>=0 && parabolicManager.lastIndex != index) {
root.setGlobalDirectRender(true);
} else if (!root.directRenderDelayerIsRunning) {
root.startDirectRenderDelayerDuringEntering();
}
if( ((wrapper.zoomScale == 1 || wrapper.zoomScale === root.zoomFactor) && !root.globalDirectRender) || root.globalDirectRender) {

View File

@ -727,33 +727,20 @@ Item{
return;
}
var distanceFromHovered = Math.abs(index - layoutsContainer.hoveredIndex);
//use the new parabolicManager in order to handle all parabolic effect messages
var scales = parabolicManager.applyParabolicEffect(index, currentMousePosition, center);
// A new algorithm trying to make the zoom calculation only once
// and at the same time fixing glitches
if ((distanceFromHovered == 0)&&
(currentMousePosition > 0) ){
//use the new parabolicManager in order to handle all parabolic effect messages
var scales = parabolicManager.applyParabolicEffect(index, currentMousePosition, center);
/*if (root.latteApplet && Math.abs(index - root.latteAppletPos) > 2){
root.latteApplet.clearZoom();
}*/
//Left hiddenSpacer
if(appletItem.firstAppletInContainer){
hiddenSpacerLeft.nScale = scales.leftScale - 1;
}
//Right hiddenSpacer ///there is one more item in the currentLayout ????
if(appletItem.lastAppletInContainer){
hiddenSpacerRight.nScale = scales.rightScale - 1;
}
zoomScale = root.zoomFactor;
//Left hiddenSpacer
if(appletItem.firstAppletInContainer){
hiddenSpacerLeft.nScale = scales.leftScale - 1;
}
//Right hiddenSpacer ///there is one more item in the currentLayout ????
if(appletItem.lastAppletInContainer){
hiddenSpacerRight.nScale = scales.rightScale - 1;
}
zoomScale = root.zoomFactor;
} //scale
@ -761,7 +748,6 @@ Item{
if(appletItem && !appletItem.containsMouse && (appletItem.index === nIndex)){
if ( ((canBeHovered && !appletItem.originalAppletBehavior) || appletItem.latteApplet)
&& (applet && applet.status !== PlasmaCore.Types.HiddenStatus)
//&& (index != currentLayout.hoveredIndex)
){
if(!appletItem.latteApplet){
if(nScale >= 0)

View File

@ -45,7 +45,7 @@ Loader {
acceptedButtons: Qt.LeftButton | Qt.MidButton
readonly property int localThickness: (root.isHovered ? (metrics.totals.thickness)*root.zoomFactor : (metrics.totals.thickness))
readonly property int localThickness: metrics.totals.thickness
readonly property int length: {
if (screenEdgeMarginEnabled && plasmoid.configuration.fittsLawIsRequested) {
return root.isHorizontal ? root.width : root.height;
@ -63,15 +63,6 @@ Loader {
property int lastPressX: -1
property int lastPressY: -1
onContainsMouseChanged: {
if (root.mouseInHoverableArea()) {
root.stopCheckRestoreZoomTimer();
} else {
root.initializeHoveredIndexes();
root.startCheckRestoreZoomTimer()
}
}
onClicked: {
if (root.closeActiveWindowEnabled && mouse.button === Qt.MidButton) {
selectedWindowsTracker.lastActiveWindow.requestClose();

View File

@ -40,7 +40,6 @@ Item{
property int allCount: root.latteApplet ? _mainLayout.count-1+latteApplet.tasksCount : _mainLayout.count
property int currentSpot: -1000
property int hoveredIndex: -1
readonly property int fillApplets: _startLayout.fillApplets + _mainLayout.fillApplets + _endLayout.fillApplets

View File

@ -53,7 +53,6 @@ Item {
signal clearZoomSignal();
signal destroyInternalViewSplitters();
signal emptyAreasWheel(QtObject wheel);
signal sglInitializeHoveredIndexes();
signal separatorsUpdated();
signal signalActivateEntryAtIndex(int entryIndex);
signal signalNewInstanceForEntryAtIndex(int entryIndex);
@ -232,8 +231,7 @@ Item {
property bool isHorizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal
property bool isReady: !(dockIsHidden || inSlidingIn || inSlidingOut)
property bool isVertical: !isHorizontal
property bool isHovered: latteApplet ? ((latteAppletHoveredIndex !== -1) || (layoutsContainer.hoveredIndex !== -1)) //|| wholeArea.containsMouse
: (layoutsContainer.hoveredIndex !== -1) //|| wholeArea.containsMouse
property bool mouseWheelActions: plasmoid.configuration.mouseWheelActions
property bool onlyAddingStarup: true //is used for the initialization phase in startup where there aren't removals, this variable provides a way to grow icon size
property bool shrinkThickMargins: plasmoid.configuration.shrinkThickMargins
@ -254,7 +252,6 @@ Item {
property bool plasma515: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,15,0)
property bool plasma518: LatteCore.Environment.plasmaDesktopVersion >= LatteCore.Environment.makeVersion(5,18,0)
property alias hoveredIndex: layoutsContainer.hoveredIndex
property alias directRenderDelayerIsRunning: directRenderDelayerForEnteringTimer.running
readonly property int minAppletLengthInConfigure: 64
@ -464,7 +461,6 @@ Item {
readonly property bool hasInternalSeparator: latteApplet ? latteApplet.hasInternalSeparator : false
property int latteAppletHoveredIndex: latteApplet ? latteApplet.hoveredIndex : -1
property int tasksCount: latteApplet ? latteApplet.tasksCount : 0
@ -607,12 +603,6 @@ Item {
}
}
onDockContainsMouseChanged: {
if (!dockContainsMouse) {
initializeHoveredIndexes();
}
}
onMaxLengthChanged: {
layoutsContainer.updateSizeForAppletsInFill();
}
@ -957,7 +947,7 @@ Item {
function disableDirectRender(){
// root.globalDirectRender = false;
// root.globalDirectRender = false;
}
function internalViewSplittersCount(){
@ -986,13 +976,6 @@ Item {
return splitters;
}
function initializeHoveredIndexes() {
layoutsContainer.hoveredIndex = -1;
layoutsContainer.currentSpot = -1000;
root.sglInitializeHoveredIndexes();
}
function layoutManager() {
return LayoutManager;
}
@ -1052,10 +1035,6 @@ Item {
return (latteView.visibility.containsMouse && !rootMouseArea.containsMouse && mouseInCanBeHoveredApplet());
}
function setHoveredIndex(ind) {
layoutsContainer.hoveredIndex = ind;
}
function hideTooltipLabel(debug){
titleTooltipDialog.hide(debug);
}
@ -1176,18 +1155,11 @@ Item {
}
function setGlobalDirectRender(value) {
if (latteApplet && latteApplet.tasksExtendedManager.waitingLaunchersLength() > 0)
return;
if (value === true) {
if (mouseInCanBeHoveredApplet()) {
root.globalDirectRender = true;
} else {
// console.log("direct render true ignored...");
}
} else {
root.globalDirectRender = false;
if (value === false) {
directRenderDelayerForEnteringTimer.stop();
}
root.globalDirectRender = value;
}
function updateContainsOnlyPlasmaTasks() {
@ -1304,20 +1276,6 @@ Item {
}
}
Connections{
target: layoutsContainer
onHoveredIndexChanged: {
if (latteApplet && layoutsContainer.hoveredIndex>-1){
latteApplet.setHoveredIndex(-1);
}
if (latteApplet && latteApplet.windowPreviewIsShown && layoutsContainer.hoveredIndex>-1) {
latteApplet.hidePreview();
}
}
}
////END interfaces
/////BEGIN: Title Tooltip///////////
@ -1693,7 +1651,7 @@ Item {
//Timer to check if the mouse is still outside the latteView in order to restore zooms to 1.0
Timer{
id:checkRestoreZoom
interval: 90
interval: 10
onTriggered: {
if (latteApplet && (latteApplet.previewContainsMouse() || latteApplet.contextMenu)) {
@ -1704,11 +1662,8 @@ Item {
return;
}
if (!mouseInHoverableArea()) {
setGlobalDirectRender(false);
root.initializeHoveredIndexes();
root.clearZoom();
}
setGlobalDirectRender(false);
root.clearZoom();
if (root.debugModeTimers) {
console.log("containment timer: checkRestoreZoom called...");
@ -1722,6 +1677,7 @@ Item {
Timer{
id:directRenderDelayerForEnteringTimer
interval: 3.2 * animations.speedFactor.current * animations.duration.small
onTriggered: setGlobalDirectRender(true);
}
//! It is used in order to slide-in the latteView on startup

View File

@ -268,7 +268,7 @@ Item{
}
onMScaleChanged: {
if ((mScale === root.zoomFactor) && !root.directRenderTimerIsRunning && !root.globalDirectRender) {
if ((mScale === root.zoomFactor) /*&& !root.directRenderTimerIsRunning*/ && !root.globalDirectRender) {
root.setGlobalDirectRender(true);
}