+ First working draft of tabs and groups getting pushed out of the way by the creation of a new group

+ The grid feature now removes all the tabs from their groups beforehand; it doesn't restore tab sizes properly yet
+ You can now rearrange tabs inside a group
+ More geometry:
++ The Rect constructor now accepts either coordinates or another Rect
++ Rect.inset now accepts either coordinates or a Point
++ New functions: Rect.offset and Rect.equals
This commit is contained in:
Ian Gilman 2010-03-26 11:34:09 -07:00
parent a1ca195f7b
commit f8af9b8d0d

View File

@ -17,37 +17,50 @@ var consoleService = Cc["@mozilla.org/consoleservice;1"]
var extensionManager = Cc["@mozilla.org/extensions/manager;1"]
.getService(Ci.nsIExtensionManager);
// ----------
// ##########
window.Point = function(x, y) {
this.x = (typeof(x) == 'undefined' ? 0 : x);
this.y = (typeof(y) == 'undefined' ? 0 : y);
}
// ----------
window.Rect = function(left, top, width, height) {
this.left = left;
this.top = top;
this.width = width;
this.height = height;
// ##########
window.Rect = function(a, top, width, height) {
if(typeof(a.left) != 'undefined' && typeof(a.top) != 'undefined'
&& typeof(a.right) != 'undefined' && typeof(a.bottom) != 'undefined') {
this.left = a.left;
this.top = a.top;
this.width = a.width;
this.height = a.height;
} else {
this.left = a;
this.top = top;
this.width = width;
this.height = height;
}
}
window.Rect.prototype = {
// ----------
get right() {
return this.left + this.width;
},
// ----------
set right(value) {
this.width = value - this.left;
},
// ----------
get bottom() {
return this.top + this.height;
},
// ----------
set bottom(value) {
this.height = value - this.top;
},
// ----------
intersects: function(rect) {
return (rect.right > this.left
&& rect.left < this.right
@ -55,19 +68,45 @@ window.Rect.prototype = {
&& rect.top < this.bottom);
},
// ----------
center: function() {
return new Point(this.left + (this.width / 2), this.top + (this.height / 2));
},
inset: function(x, y) {
this.left += x;
this.width -= x * 2;
this.top += y;
this.height -= y * 2;
// ----------
inset: function(a, b) {
if(typeof(a.x) != 'undefined' && typeof(a.y) != 'undefined') {
b = a.y;
a = a.x;
}
this.left += a;
this.width -= a * 2;
this.top += b;
this.height -= b * 2;
},
// ----------
offset: function(a, b) {
if(typeof(a.x) != 'undefined' && typeof(a.y) != 'undefined') {
this.left += a.x;
this.top += a.y;
} else {
this.left += a;
this.top += b;
}
},
// ----------
equals: function(a) {
return (a.left == this.left
&& a.top == this.top
&& a.right == this.right
&& a.bottom == this.bottom);
}
};
// ----------
// ##########
var Utils = {
// ___ Windows and Tabs
get activeWindow(){