[gnome-shell/wip/jimmac/dash-icon-spacing: 22/72] workspacesView: Scale hover workspaces
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/jimmac/dash-icon-spacing: 22/72] workspacesView: Scale hover workspaces
- Date: Tue, 2 Feb 2021 11:58:18 +0000 (UTC)
commit b9c6359768edceac22c64c90244c38741a3f9903
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 f11c7f8032..55291e6548 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]