dash: Ignore hiding items in _adjustIconSize()
Rather than relying on the caller to hide the remove target and removed items before calling _adjustIconSize(), move that logic into _adjustIconSize() itself. https://bugzilla.gnome.org/show_bug.cgi?id=649248
This commit is contained in:
parent
9439da81c4
commit
b07f9932db
@ -37,6 +37,7 @@ DashItemContainer.prototype = {
|
|||||||
this.child = null;
|
this.child = null;
|
||||||
this._childScale = 1;
|
this._childScale = 1;
|
||||||
this._childOpacity = 255;
|
this._childOpacity = 255;
|
||||||
|
this.animatingOut = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_allocate: function(actor, box, flags) {
|
_allocate: function(actor, box, flags) {
|
||||||
@ -115,6 +116,7 @@ DashItemContainer.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.animatingOut = true;
|
||||||
this.childScale = 1.0;
|
this.childScale = 1.0;
|
||||||
Tweener.addTween(this,
|
Tweener.addTween(this,
|
||||||
{ childScale: 0.0,
|
{ childScale: 0.0,
|
||||||
@ -177,12 +179,6 @@ RemoveFavoriteIcon.prototype = {
|
|||||||
this._iconBin._delegate = this;
|
this._iconBin._delegate = this;
|
||||||
|
|
||||||
this.setChild(this._iconBin);
|
this.setChild(this._iconBin);
|
||||||
this.hiding = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
animateOutAndDestroy: function() {
|
|
||||||
DashItemContainer.prototype.animateOutAndDestroy.call(this);
|
|
||||||
this.hiding = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_createIcon: function(size) {
|
_createIcon: function(size) {
|
||||||
@ -314,15 +310,12 @@ Dash.prototype = {
|
|||||||
_endDrag: function() {
|
_endDrag: function() {
|
||||||
this._clearDragPlaceholder();
|
this._clearDragPlaceholder();
|
||||||
if (this._favRemoveTarget) {
|
if (this._favRemoveTarget) {
|
||||||
this._favRemoveTarget.actor.hide();
|
|
||||||
this._adjustIconSize();
|
|
||||||
this._favRemoveTarget.actor.show();
|
|
||||||
|
|
||||||
this._favRemoveTarget.animateOutAndDestroy();
|
this._favRemoveTarget.animateOutAndDestroy();
|
||||||
this._favRemoveTarget.actor.connect('destroy', Lang.bind(this,
|
this._favRemoveTarget.actor.connect('destroy', Lang.bind(this,
|
||||||
function() {
|
function() {
|
||||||
this._favRemoveTarget = null;
|
this._favRemoveTarget = null;
|
||||||
}));
|
}));
|
||||||
|
this._adjustIconSize();
|
||||||
}
|
}
|
||||||
DND.removeDragMonitor(this._dragMonitor);
|
DND.removeDragMonitor(this._dragMonitor);
|
||||||
},
|
},
|
||||||
@ -401,8 +394,18 @@ Dash.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_adjustIconSize: function() {
|
_adjustIconSize: function() {
|
||||||
let children = this._box.get_children();
|
// For the icon size, we only consider children which are "proper"
|
||||||
if (children.length == 0) {
|
// icons (i.e. ignoring drag placeholders) and which are not
|
||||||
|
// animating out (which means they will be destroyed at the end of
|
||||||
|
// the animation)
|
||||||
|
let iconChildren = this._box.get_children().filter(function(actor) {
|
||||||
|
return actor._delegate.child &&
|
||||||
|
actor._delegate.child._delegate &&
|
||||||
|
actor._delegate.child._delegate.icon &&
|
||||||
|
!actor._delegate.animatingOut;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (iconChildren.length == 0) {
|
||||||
this._box.add_style_pseudo_class('empty');
|
this._box.add_style_pseudo_class('empty');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -412,23 +415,39 @@ Dash.prototype = {
|
|||||||
if (this._maxHeight == -1)
|
if (this._maxHeight == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let iconChildren = children.filter(function(actor) {
|
|
||||||
return actor.visible &&
|
|
||||||
actor._delegate.child &&
|
|
||||||
actor._delegate.child._delegate &&
|
|
||||||
actor._delegate.child._delegate.icon;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Compute the amount of extra space (or missing space) we have
|
let themeNode = this.actor.get_theme_node();
|
||||||
// per icon with the current icon size
|
let maxAllocation = new Clutter.ActorBox({ x1: 0, y1: 0,
|
||||||
let [minHeight, natHeight] = this.actor.get_preferred_height(-1);
|
x2: 42 /* whatever */,
|
||||||
let diff = (this._maxHeight - natHeight) / iconChildren.length;
|
y2: this._maxHeight });
|
||||||
|
let maxContent = themeNode.get_content_box(maxAllocation);
|
||||||
|
let availHeight = maxContent.y2 - maxContent.y1;
|
||||||
|
let spacing = themeNode.get_length('spacing');
|
||||||
|
|
||||||
|
|
||||||
|
let firstIcon = iconChildren[0]._delegate.child._delegate.icon;
|
||||||
|
|
||||||
|
// Icons may be animating, so enforce the current icon size
|
||||||
|
// during the size request
|
||||||
|
let [currentWidth, currentHeight] = firstIcon.icon.get_size();
|
||||||
|
|
||||||
|
firstIcon.icon.set_size(this.iconSize, this.iconSize);
|
||||||
|
let [minHeight, natHeight] = iconChildren[0].get_preferred_height(-1);
|
||||||
|
|
||||||
|
firstIcon.icon.set_size(currentWidth, currentHeight);
|
||||||
|
|
||||||
|
|
||||||
|
// Subtract icon padding and box spacing from the available height
|
||||||
|
availHeight -= iconChildren.length * (natHeight - this.iconSize) +
|
||||||
|
(iconChildren.length - 1) * spacing;
|
||||||
|
|
||||||
|
let availSize = availHeight / iconChildren.length;
|
||||||
|
|
||||||
let iconSizes = [ 16, 22, 24, 32, 48, 64 ];
|
let iconSizes = [ 16, 22, 24, 32, 48, 64 ];
|
||||||
|
|
||||||
let newIconSize = 16;
|
let newIconSize = 16;
|
||||||
for (let i = 0; i < iconSizes.length; i++) {
|
for (let i = 0; i < iconSizes.length; i++) {
|
||||||
if (iconSizes[i] < this.iconSize + diff)
|
if (iconSizes[i] < availSize)
|
||||||
newIconSize = iconSizes[i];
|
newIconSize = iconSizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,29 +585,7 @@ Dash.prototype = {
|
|||||||
this._box.insert_actor(addedItems[i].item.actor,
|
this._box.insert_actor(addedItems[i].item.actor,
|
||||||
addedItems[i].pos);
|
addedItems[i].pos);
|
||||||
|
|
||||||
// Hide removed actors to not take them into account
|
|
||||||
// when adjusting the icon size ...
|
|
||||||
for (let i = 0; i < removedActors.length; i++)
|
|
||||||
removedActors[i].hide();
|
|
||||||
|
|
||||||
// ... and do the same for the remove target if necessary
|
|
||||||
if (this._favRemoveTarget && this._favRemoveTarget.hiding)
|
|
||||||
this._favRemoveTarget.actor.hide();
|
|
||||||
|
|
||||||
this._adjustIconSize();
|
|
||||||
|
|
||||||
if (this._favRemoveTarget && this._favRemoveTarget.hiding)
|
|
||||||
this._favRemoveTarget.actor.show();
|
|
||||||
|
|
||||||
// Skip animations on first run when adding the initial set
|
|
||||||
// of items, to avoid all items zooming in at once
|
|
||||||
if (!this._shownInitially) {
|
|
||||||
this._shownInitially = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < removedActors.length; i++) {
|
for (let i = 0; i < removedActors.length; i++) {
|
||||||
removedActors[i].show();
|
|
||||||
let item = removedActors[i]._delegate;
|
let item = removedActors[i]._delegate;
|
||||||
|
|
||||||
// Don't animate item removal when the overview is hidden
|
// Don't animate item removal when the overview is hidden
|
||||||
@ -598,6 +595,15 @@ Dash.prototype = {
|
|||||||
item.actor.destroy();
|
item.actor.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._adjustIconSize();
|
||||||
|
|
||||||
|
// Skip animations on first run when adding the initial set
|
||||||
|
// of items, to avoid all items zooming in at once
|
||||||
|
if (!this._shownInitially) {
|
||||||
|
this._shownInitially = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't animate item addition when the overview is hidden
|
// Don't animate item addition when the overview is hidden
|
||||||
if (!Main.overview.visible)
|
if (!Main.overview.visible)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user