[panel] Fix allocation positioning for boxes

This change doesn't actually affect anything visibly, but
using the absolute coordinates of our allocation box in allocate()
is wrong; we should be positioning our children at 0,0 and using
width/height as a reference.

https://bugzilla.gnome.org/show_bug.cgi?id=616951
This commit is contained in:
Colin Walters 2010-04-27 09:46:19 -04:00
parent 9d21b2cb25
commit 3715109ebe

View File

@ -310,34 +310,34 @@ Panel.prototype = {
let x; let x;
let childBox = new Clutter.ActorBox(); let childBox = new Clutter.ActorBox();
childBox.x1 = box.x1; childBox.x1 = 0;
childBox.y1 = box.y1; childBox.y1 = 0;
childBox.x2 = x = childBox.x1 + leftWidth; childBox.x2 = x = childBox.x1 + leftWidth;
childBox.y2 = box.y2; childBox.y2 = allocHeight;
this._leftBox.allocate(childBox, flags); this._leftBox.allocate(childBox, flags);
let centerNaturalX = Math.floor((box.x2 - box.x1) / 2 - (centerWidth / 2)); let centerNaturalX = Math.floor(allocWidth / 2 - (centerWidth / 2));
/* Check left side */ /* Check left side */
if (x < centerNaturalX) { if (x < centerNaturalX) {
/* We didn't overflow the left, use the natural. */ /* We didn't overflow the left, use the natural. */
x = centerNaturalX; x = centerNaturalX;
} }
/* Check right side */ /* Check right side */
if (x + centerWidth > (box.x2 - rightWidth)) { if (x + centerWidth > (allocWidth - rightWidth)) {
x = box.x2 - rightWidth - centerWidth; x = allocWidth - rightWidth - centerWidth;
} }
childBox = new Clutter.ActorBox(); childBox = new Clutter.ActorBox();
childBox.x1 = x; childBox.x1 = x;
childBox.y1 = box.y1; childBox.y1 = 0;
childBox.x2 = x = childBox.x1 + centerWidth; childBox.x2 = x = childBox.x1 + centerWidth;
childBox.y2 = box.y2; childBox.y2 = allocHeight;
this._centerBox.allocate(childBox, flags); this._centerBox.allocate(childBox, flags);
childBox = new Clutter.ActorBox(); childBox = new Clutter.ActorBox();
childBox.x1 = box.x2 - rightWidth; childBox.x1 = allocWidth - rightWidth;
childBox.y1 = box.y1; childBox.y1 = 0;
childBox.x2 = box.x2; childBox.x2 = allocWidth;
childBox.y2 = box.y2; childBox.y2 = allocHeight;
this._rightBox.allocate(childBox, flags); this._rightBox.allocate(childBox, flags);
})); }));