[gnome-shell/gbsneto/icon-grid-dnd: 1/2] appIcon: Hide itself when starting drag
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 1/2] appIcon: Hide itself when starting drag
- Date: Thu, 4 Jul 2019 22:51:39 +0000 (UTC)
commit 9ed4772248f65e88e4c82e0d910f0df188bfa19b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Jul 4 18:39:13 2019 -0300
appIcon: Hide itself when starting drag
As per design direction, hide the app icon when starting
dragging it, and show it again if the drop is accepted.
Clutter takes care of animating the rest of icon positions
through implicit animations.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index c061f549b..5fb007557 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -838,10 +838,6 @@ var AllView = class AllView extends BaseAppView {
handleDragOver(source, actor, x, y, time) {
[x, y] = this._transformToGridCoordinates(x, y);
- let sourceIndex = -1;
- if (source.parentView == this)
- sourceIndex = this._allItems.indexOf(source);
-
let [index, dragLocation] = this.canDropAt(x, y);
this.removeNudges();
@@ -849,9 +845,7 @@ var AllView = class AllView extends BaseAppView {
this._schedulePopdown();
if (index != -1) {
- if (sourceIndex == -1 || (index != sourceIndex && index != sourceIndex + 1))
- this.nudgeItemsAtIndex(index, dragLocation);
-
+ this.nudgeItemsAtIndex(index, dragLocation);
return DND.DragMotionResult.MOVE_DROP;
}
@@ -871,6 +865,15 @@ var AllView = class AllView extends BaseAppView {
source = this._items[source.id];
}
+ // AppIcon hides itself, show it again
+ source.actor.show();
+
+ // When moving to a position forward, the index will be misadjusted by
+ // one, because the original actor is hidden. Adjust it back.
+ let sourceIndex = this._allItems.indexOf(source);
+ if (sourceIndex != -1 && index > sourceIndex)
+ index++;
+
this.moveItem(source, index);
this.removeNudges();
return true;
@@ -1329,8 +1332,7 @@ var FolderView = class FolderView extends BaseAppView {
this._folderIcon._parentView.removeNudges();
this.removeNudges();
- if (index != -1 && index != sourceIndex && index != sourceIndex + 1)
- this.nudgeItemsAtIndex(index, dragLocation);
+ this.nudgeItemsAtIndex(index, dragLocation);
return DND.DragMotionResult.MOVE_DROP;
}
@@ -1339,8 +1341,17 @@ var FolderView = class FolderView extends BaseAppView {
[x, y] = this._transformToGridCoordinates(x, y);
let [index, dragLocation] = this.canDropAt(x, y);
+ let sourceIndex = this._allItems.indexOf(source);
let success = index != -1;
+ // AppIcon hides itself, show it again
+ source.actor.show();
+
+ // When moving to a position forward, the index will be misadjusted by
+ // one, because the original actor is hidden. Adjust it back.
+ if (sourceIndex != -1 && index > sourceIndex)
+ index++;
+
if (success)
this.moveItem(source, index);
@@ -1895,18 +1906,18 @@ var AppIcon = class AppIcon {
this._draggable = DND.makeDraggable(this.actor);
this._draggable.connect('drag-begin', () => {
this._dragging = true;
- this.actor.opacity = 0;
+ this.actor.hide();
this._removeMenuTimeout();
Main.overview.beginItemDrag(this);
});
this._draggable.connect('drag-cancelled', () => {
this._dragging = false;
- this.actor.opacity = 255;
Main.overview.cancelledItemDrag(this);
});
- this._draggable.connect('drag-end', () => {
+ this._draggable.connect('drag-end', (source, time, success) => {
this._dragging = false;
- this.actor.opacity = 255;
+ if (!success)
+ this.actor.show();
Main.overview.endItemDrag(this);
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]