workspace-indicators: Add hover indication

Scale up indicators on hover to hint at their clickability.

https://bugzilla.gnome.org/show_bug.cgi?id=634948
This commit is contained in:
Florian Müllner 2010-11-12 22:52:44 +01:00
parent a66af6fbac
commit b400fc2837

View File

@ -25,6 +25,8 @@ const WORKSPACE_DRAGGING_SCALE = 0.85;
const CONTROLS_POP_IN_FRACTION = 0.8; const CONTROLS_POP_IN_FRACTION = 0.8;
const CONTROLS_POP_IN_TIME = 0.1; const CONTROLS_POP_IN_TIME = 0.1;
const INDICATOR_HOVER_SCALE = 1.1;
function WorkspacesView(width, height, x, y, workspaces) { function WorkspacesView(width, height, x, y, workspaces) {
this._init(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 availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1; let availHeight = box.y2 - box.y1;
let [minWidth, natWidth] = this._box.get_preferred_width(-1); let [minWidth, natWidth] = this._box.get_preferred_width(-1);
let [minHeight, natHeight] = this._box.get_preferred_height(-1);
let childBox = new Clutter.ActorBox(); let childBox = new Clutter.ActorBox();
childBox.x1 = Math.floor((availWidth - natWidth) / 2); childBox.x1 = Math.floor((availWidth - natWidth) / 2);
childBox.x2 = childBox.x1 + natWidth; childBox.x2 = childBox.x1 + natWidth;
childBox.y1 = 0; childBox.y1 = Math.floor((availHeight - natHeight) / 2);
childBox.y2 = availHeight; childBox.y2 = childBox.y2 + natHeight;
this._box.allocate(childBox, flags); this._box.allocate(childBox, flags);
}, },
@ -828,8 +831,8 @@ WorkspaceIndicatorPanel.prototype = {
_getPreferredHeight: function(actor, forWidth, alloc) { _getPreferredHeight: function(actor, forWidth, alloc) {
let [minHeight, natHeight] = this._box.get_preferred_height(-1); let [minHeight, natHeight] = this._box.get_preferred_height(-1);
alloc.min_size = minHeight; alloc.min_size = minHeight * INDICATOR_HOVER_SCALE;
alloc.natural_size = natHeight; alloc.natural_size = natHeight * INDICATOR_HOVER_SCALE;
}, },
updateWorkspaces: function(workspaces) { updateWorkspaces: function(workspaces) {
@ -837,13 +840,22 @@ WorkspaceIndicatorPanel.prototype = {
this._box.remove_all(); this._box.remove_all();
for (let i = 0; i < this._workspaces.length; i++) { 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 workspace = this._workspaces[i];
let metaWorkspace = this._workspaces[i].metaWorkspace; let metaWorkspace = this._workspaces[i].metaWorkspace;
actor.connect('clicked', Lang.bind(this, function() { actor.connect('clicked', Lang.bind(this, function() {
metaWorkspace.activate(global.get_current_time()); 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 = { actor._delegate = {
acceptDrop: Lang.bind(this, acceptDrop: Lang.bind(this,