From b400fc28379585b443f9230b6900c03731d93ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 12 Nov 2010 22:52:44 +0100 Subject: [PATCH] workspace-indicators: Add hover indication Scale up indicators on hover to hint at their clickability. https://bugzilla.gnome.org/show_bug.cgi?id=634948 --- js/ui/workspacesView.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index 85102f195..7e998bec1 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -25,6 +25,8 @@ const WORKSPACE_DRAGGING_SCALE = 0.85; const CONTROLS_POP_IN_FRACTION = 0.8; const CONTROLS_POP_IN_TIME = 0.1; +const INDICATOR_HOVER_SCALE = 1.1; + function WorkspacesView(width, height, x, y, workspaces) { this._init(width, height, x, y, workspaces); @@ -810,12 +812,13 @@ WorkspaceIndicatorPanel.prototype = { let availWidth = box.x2 - box.x1; let availHeight = box.y2 - box.y1; let [minWidth, natWidth] = this._box.get_preferred_width(-1); + let [minHeight, natHeight] = this._box.get_preferred_height(-1); let childBox = new Clutter.ActorBox(); childBox.x1 = Math.floor((availWidth - natWidth) / 2); childBox.x2 = childBox.x1 + natWidth; - childBox.y1 = 0; - childBox.y2 = availHeight; + childBox.y1 = Math.floor((availHeight - natHeight) / 2); + childBox.y2 = childBox.y2 + natHeight; this._box.allocate(childBox, flags); }, @@ -828,8 +831,8 @@ WorkspaceIndicatorPanel.prototype = { _getPreferredHeight: function(actor, forWidth, alloc) { let [minHeight, natHeight] = this._box.get_preferred_height(-1); - alloc.min_size = minHeight; - alloc.natural_size = natHeight; + alloc.min_size = minHeight * INDICATOR_HOVER_SCALE; + alloc.natural_size = natHeight * INDICATOR_HOVER_SCALE; }, updateWorkspaces: function(workspaces) { @@ -837,13 +840,22 @@ WorkspaceIndicatorPanel.prototype = { this._box.remove_all(); for (let i = 0; i < this._workspaces.length; i++) { - let actor = new St.Button({ style_class: 'workspace-indicator' }); + let actor = new St.Button({ style_class: 'workspace-indicator', + track_hover: true }); let workspace = this._workspaces[i]; let metaWorkspace = this._workspaces[i].metaWorkspace; actor.connect('clicked', Lang.bind(this, function() { metaWorkspace.activate(global.get_current_time()); })); + actor.connect('notify::hover', Lang.bind(this, function() { + if (actor.hover) + actor.set_scale_with_gravity(INDICATOR_HOVER_SCALE, + INDICATOR_HOVER_SCALE, + Clutter.Gravity.CENTER); + else + actor.set_scale(1.0, 1.0); + })); actor._delegate = { acceptDrop: Lang.bind(this,