mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 17:54:45 +00:00
animation effect for the drag delegate
This commit is contained in:
parent
c036b12f7b
commit
6c32662123
2 changed files with 59 additions and 6 deletions
|
|
@ -9,8 +9,21 @@ Item {
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
property var modelData: model
|
property var modelData: model
|
||||||
|
property bool isDropTarget: delegateRoot != dragDelegate && root.reorderingApps && applicationsView.dragData && applicationsView.dragData.ApplicationStorageIdRole == modelData.ApplicationStorageIdRole
|
||||||
|
|
||||||
opacity: delegateRoot != dragDelegate && root.reorderingApps && applicationsView.dragData && applicationsView.dragData.ApplicationStorageIdRole == modelData.ApplicationStorageIdRole ? 0.3 : 1
|
opacity: isDropTarget ? 0.3 : 1
|
||||||
|
|
||||||
|
/*function syncDropTarget() {
|
||||||
|
if (isDropTarget) {
|
||||||
|
var pos = mapToItem(root, x, y);
|
||||||
|
dragDelegate.xTarget = pos.x;
|
||||||
|
dragDelegate.yTarget = pos.y;
|
||||||
|
print("AAAAA"+pos.x+" "+pos.x+" "+delegateRoot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onIsDropTargetChanged: syncDropTarget();
|
||||||
|
onXChanged: syncDropTarget();
|
||||||
|
onYChanged: syncDropTarget();*/
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
|
||||||
|
|
@ -172,10 +172,12 @@ MouseEventListener {
|
||||||
|
|
||||||
dragDelegate.modelData = applicationsView.dragData;
|
dragDelegate.modelData = applicationsView.dragData;
|
||||||
applicationsView.interactive = false;
|
applicationsView.interactive = false;
|
||||||
dragDelegate.x = mouse.x - dragDelegate.width/2;
|
|
||||||
dragDelegate.y = mouse.y - dragDelegate.height/2;
|
|
||||||
root.reorderingApps = true;
|
root.reorderingApps = true;
|
||||||
dragDelegate.visible = true;
|
dragDelegate.x = Math.floor(mouse.x / root.buttonHeight) * root.buttonHeight
|
||||||
|
dragDelegate.y = Math.floor(mouse.y / root.buttonHeight) * root.buttonHeight
|
||||||
|
dragDelegate.xTarget = mouse.x - dragDelegate.width/2;
|
||||||
|
dragDelegate.yTarget = mouse.y - dragDelegate.width/2;
|
||||||
|
dragDelegate.opacity = 1;
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
if (!applicationsView.dragData) {
|
if (!applicationsView.dragData) {
|
||||||
|
|
@ -184,7 +186,19 @@ MouseEventListener {
|
||||||
dragDelegate.x = mouse.x - dragDelegate.width/2;
|
dragDelegate.x = mouse.x - dragDelegate.width/2;
|
||||||
dragDelegate.y = mouse.y - dragDelegate.height/2;
|
dragDelegate.y = mouse.y - dragDelegate.height/2;
|
||||||
|
|
||||||
dragDelegate.updateRow();
|
var pos = mapToItem(applicationsView.contentItem, mouse.x, mouse.y);
|
||||||
|
|
||||||
|
//in favorites area?
|
||||||
|
if (applicationsView.headerItem.favoritesStrip.contains(mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y))) {
|
||||||
|
pos.y = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newRow = (Math.round(applicationsView.width / applicationsView.cellWidth) * Math.floor(pos.y / applicationsView.cellHeight) + Math.floor(pos.x / applicationsView.cellWidth));
|
||||||
|
|
||||||
|
if (applicationsView.dragData.ApplicationOriginalRowRole != newRow) {
|
||||||
|
appListModel.moveItem(applicationsView.dragData.ApplicationOriginalRowRole, newRow);
|
||||||
|
applicationsView.dragData.ApplicationOriginalRowRole = newRow;
|
||||||
|
}
|
||||||
|
|
||||||
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
||||||
//FAVORITES
|
//FAVORITES
|
||||||
|
|
@ -214,7 +228,9 @@ MouseEventListener {
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
applicationsView.interactive = true;
|
applicationsView.interactive = true;
|
||||||
dragDelegate.visible = false;
|
dragDelegate.xTarget = Math.floor(mouse.x / root.buttonHeight) * root.buttonHeight
|
||||||
|
dragDelegate.yTarget = Math.floor(mouse.y / root.buttonHeight) * root.buttonHeight
|
||||||
|
dragDelegate.opacity = 0;
|
||||||
applicationsView.dragData = null;
|
applicationsView.dragData = null;
|
||||||
root.reorderingApps = false;
|
root.reorderingApps = false;
|
||||||
applicationsView.forceLayout();
|
applicationsView.forceLayout();
|
||||||
|
|
@ -296,6 +312,8 @@ MouseEventListener {
|
||||||
HomeLauncher {
|
HomeLauncher {
|
||||||
id: dragDelegate
|
id: dragDelegate
|
||||||
z: 999
|
z: 999
|
||||||
|
property int xTarget
|
||||||
|
property int yTarget
|
||||||
function updateRow() {
|
function updateRow() {
|
||||||
if (!applicationsView.dragData) {
|
if (!applicationsView.dragData) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -315,6 +333,28 @@ MouseEventListener {
|
||||||
applicationsView.dragData.ApplicationOriginalRowRole = newRow;
|
applicationsView.dragData.ApplicationOriginalRowRole = newRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Behavior on opacity {
|
||||||
|
ParallelAnimation {
|
||||||
|
OpacityAnimator {
|
||||||
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
PropertyAnimation {
|
||||||
|
properties: "x"
|
||||||
|
to: dragDelegate.xTarget
|
||||||
|
target: dragDelegate
|
||||||
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
PropertyAnimation {
|
||||||
|
properties: "y"
|
||||||
|
to: dragDelegate.yTarget
|
||||||
|
target: dragDelegate
|
||||||
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GridView {
|
GridView {
|
||||||
id: applicationsView
|
id: applicationsView
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue