[gnome-shell/gbsneto/40-stuff: 24/68] workspacesView: Scale hover workspaces




commit efef0fab8565ac3ff3fa1044302c33627ddd50f0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Jan 5 15:21:50 2021 -0300

    workspacesView: Scale hover workspaces
    
    So that it provides visual feedback that one can interact with
    the workspace.

 js/ui/workspace.js      |  2 ++
 js/ui/workspacesView.js | 32 +++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 983bdedf60..018305f642 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -951,6 +951,8 @@ class Workspace extends St.Widget {
     _init(metaWorkspace, monitorIndex) {
         super._init({
             style_class: 'window-picker',
+            reactive: true,
+            track_hover: true,
             pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
             layout_manager: new WorkspaceLayout(metaWorkspace, monitorIndex),
         });
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index b34fa77ca1..d22c263c6d 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -17,6 +17,7 @@ const WORKSPACE_MIN_SPACING = 24;
 const WORKSPACE_MAX_SPACING = 80;
 
 const WORKSPACE_INACTIVE_SCALE = 0.94;
+const WORKSPACE_HOVER_SCALE = 0.98;
 
 var WorkspacesViewBase = GObject.registerClass({
     GTypeFlags: GObject.TypeFlags.ABSTRACT,
@@ -206,17 +207,29 @@ class WorkspacesView extends WorkspacesViewBase {
         return Math.clamp(spacing, WORKSPACE_MIN_SPACING, WORKSPACE_MAX_SPACING);
     }
 
-    _updateWorkspacesState() {
+    _updateWorkspacesScale(index, animate = false) {
+        const workspace = this._workspaces[index];
         const adj = this._scrollAdjustment;
+        const distanceToCurrentWorkspace = Math.abs(adj.value - index);
 
-        // Fade and scale inactive workspaces
-        this._workspaces.forEach((w, index) => {
-            const distanceToCurrentWorkspace = Math.abs(adj.value - index);
+        const progress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
+
+        let scale = Math.interpolate(WORKSPACE_INACTIVE_SCALE, 1, progress);
+        if (workspace.hover)
+            scale = Math.max(scale, WORKSPACE_HOVER_SCALE);
 
-            const progress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
+        workspace.ease({
+            scale_x: scale,
+            scale_y: scale,
+            duration: animate ? WORKSPACE_SWITCH_TIME : 0,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
+    }
 
-            const scale = Math.interpolate(WORKSPACE_INACTIVE_SCALE, 1, progress);
-            w.set_scale(scale, scale);
+    _updateWorkspacesState() {
+        this._workspaces.forEach((w, index) => {
+            // Fade and scale inactive workspaces
+            this._updateWorkspacesScale(index);
         });
     }
 
@@ -321,6 +334,11 @@ class WorkspacesView extends WorkspacesViewBase {
                 workspace = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
                 this.add_actor(workspace);
                 this._workspaces[j] = workspace;
+
+                workspace.connect('notify::hover', () => {
+                    const index = this._workspaces.indexOf(workspace);
+                    this._updateWorkspacesScale(index, true);
+                });
             } else  {
                 workspace = this._workspaces[j];
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]