[gnome-shell/gbsneto/icon-grid-dnd: 2/10] 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: 2/10] appIcon: Hide itself when starting drag
- Date: Tue, 16 Jul 2019 23:42:55 +0000 (UTC)
commit 749ce25ac90eae442f90acf5b37c34c7607ebe77
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.
Add a new icon parameter 'hideWhileDragging', that is false
by default, so as to preserve the current behavior or the
Dash and the search results.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 54 ++++++++++++++++++++++++++++++++++++-----------------
js/ui/dash.js | 2 ++
2 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index ac5e5a325..e04383aa2 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -474,7 +474,8 @@ var AllView = class AllView extends BaseAppView {
let app = appSys.lookup_app(appId);
let icon = new AppIcon(app, this,
- { isDraggable: favoritesWritable });
+ { isDraggable: favoritesWritable,
+ hideWhileDragging: true });
newApps.push(icon);
});
@@ -839,10 +840,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();
@@ -850,9 +847,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;
}
@@ -872,6 +867,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;
@@ -1330,8 +1334,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;
}
@@ -1340,8 +1343,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);
@@ -1395,7 +1407,7 @@ var FolderView = class FolderView extends BaseAppView {
if (!app.get_app_info().should_show())
return;
- let icon = new AppIcon(app, this);
+ let icon = new AppIcon(app, this, { hideWhileDragging: true });
apps.push(icon);
};
@@ -1552,8 +1564,11 @@ var FolderIcon = class FolderIcon {
acceptDrop(source, actor, x, y, time) {
this._unscheduleOpenPopup();
- if (!this._canDropAt(source))
+ if (!this._canDropAt(source)) {
+ // AppIcon hides itself, show it again
+ source.actor.show();
return true;
+ }
let app = source.app;
let folderApps = this._folder.get_strv('apps');
@@ -1860,10 +1875,14 @@ var AppIcon = class AppIcon {
this._scaleInId = 0;
// Get the isDraggable property without passing it on to the BaseIcon:
- let appIconParams = Params.parse(iconParams, { isDraggable: true }, true);
+ let appIconParams = Params.parse(iconParams, { isDraggable: true,
+ hideWhileDragging: false, }, true);
let isDraggable = appIconParams['isDraggable'];
delete iconParams['isDraggable'];
+ let hideWhileDragging = appIconParams['hideWhileDragging'];
+ delete iconParams['hideWhileDragging'];
+
iconParams['createIcon'] = this._createIcon.bind(this);
iconParams['setSizeManually'] = true;
this.icon = new IconGrid.BaseIcon(app.get_name(), iconParams);
@@ -1884,18 +1903,19 @@ var AppIcon = class AppIcon {
this._draggable = DND.makeDraggable(this.actor);
this._draggable.connect('drag-begin', () => {
this._dragging = true;
- this.actor.opacity = 0;
+ if (hideWhileDragging)
+ 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 && hideWhileDragging)
+ this.actor.show();
Main.overview.endItemDrag(this);
});
}
diff --git a/js/ui/dash.js b/js/ui/dash.js
index bde0fe094..b7a1d33e6 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -871,6 +871,8 @@ var Dash = class Dash {
acceptDrop(source, actor, x, y, time) {
let app = getAppFromSource(source);
+ source.actor.show();
+
// Don't allow favoriting of transient apps
if (app == null || app.is_window_backed()) {
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]