+ Trying -moz-crisp-edges… doesn't seem to improve speed much on 3.6, and looks worse

+ Created Utils.copy to make duplicating objects cleaner
+ Fixed a number of issues with pulling tabs out of a tray. Temporarily disabled the delay on drag as well.
+ Improved the threshold for switching from grid to stack; only happens when the grid fills up.
+ No longer announcing "bad storage data" when there is in fact no storage data (fresh start)
+ A couple more asserts
This commit is contained in:
Ian Gilman 2010-05-11 17:22:06 -07:00
parent 1004e2f203
commit 91317331e1
7 changed files with 88 additions and 41 deletions

View File

@ -41,7 +41,7 @@ window.Group = function(listOfEls, options) {
this._isStacked = false;
this._stackAngles = [0];
this.expanded = null;
this.locked = (options.locked ? $.extend({}, options.locked) : {});
this.locked = (options.locked ? Utils.copy(options.locked) : {});
if(isPoint(options.userSize))
this.userSize = new Point(options.userSize);
@ -232,7 +232,7 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
var data = {
bounds: this.getBounds(),
userSize: null,
locked: $.extend({}, this.locked),
locked: Utils.copy(this.locked),
title: this.getTitle(),
id: this.id
};
@ -543,8 +543,10 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
this._children.splice(index, 1);
item.parent = null;
$el.removeClass("tabInGroup");
item.removeClass("tabInGroup");
item.removeClass("stacked");
item.removeClass("stack-trayed");
item.setRotation(0);
item.setSize(item.defaultSize.x, item.defaultSize.y);
$el.droppable("enable");
@ -571,30 +573,41 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
// ----------
shouldStack: function(count) {
if(count <= 1)
return false;
var bb = this.getContentBounds();
var result = !(count == 1 || (bb.width * bb.height) / count > 7000);
return result;
var options = {
pretend: true,
count: count
};
var rects = Items.arrange(null, bb, options);
return (rects[0].width < TabItems.minTabWidth * 1.5);
},
// ----------
arrange: function(options) {
if(this.expanded)
return;
var count = this._children.length;
if(!count)
return;
var bb = this.getContentBounds();
if(!this.shouldStack(count)) {
this._children.forEach(function(child){
child.removeClass("stacked")
});
Items.arrange(this._children, bb, options);
this._isStacked = false;
} else
this._stackArrange(bb, options);
if(this.expanded) {
var box = new Rect(this.expanded.bounds);
box.inset(8, 8);
Items.arrange(this._children, box, $.extend({}, options, {padding: 8, z: 99999}));
} else {
var count = this._children.length;
if(!count)
return;
var bb = this.getContentBounds();
if(!this.shouldStack(count)) {
this._children.forEach(function(child){
child.removeClass("stacked")
});
Items.arrange(this._children, bb, options);
this._isStacked = false;
} else
this._stackArrange(bb, options);
}
},
// ----------
@ -716,10 +729,6 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
child.addClass("stack-trayed");
});
var box = new Rect(pos.left, pos.top, overlayWidth, overlayHeight);
box.inset(8, 8);
Items.arrange(this._children, box, {padding: 8, z: 99999});
var $shield = $('<div />')
.css({
left: 0,
@ -739,8 +748,11 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
this.expanded = {
$tray: $tray,
$shield: $shield
$shield: $shield,
bounds: new Rect(pos.left, pos.top, overlayWidth, overlayHeight)
};
this.arrange();
return {};
},
@ -972,10 +984,9 @@ DragInfo.prototype = {
if(this.parent && this.parent.expanded) {
var now = Utils.getMilliseconds();
var distance = this.startPosition.distance(new Point(event.clientX, event.clientY));
if(now - this.startTime > 500 && distance > 100) {
this.item.locked.bounds = true;
if(true) { //now - this.startTime > 500 && distance > 100) {
this.parent.remove(this.item);
this.parent.collapse();
this.item.locked.bounds = false;
}
}
},
@ -993,6 +1004,9 @@ DragInfo.prototype = {
this.parent.remove(this.parent._children[0]);
}*/
if(this.parent && this.parent.expanded)
this.parent.arrange();
if(this.item && !this.$el.hasClass('willGroup') && !this.item.parent) {
this.item.setZ(drag.zIndex);
drag.zIndex++;

View File

@ -1,3 +1,5 @@
// Title: storage.js (revision-a)
// ##########
Storage = {
// ----------

View File

@ -1,3 +1,5 @@
// Title: tabitems.js (revision-a)
// ##########
window.TabItem = function(container, tab) {
this.defaultSize = new Point(TabItems.tabWidth, TabItems.tabHeight);
@ -63,6 +65,11 @@ window.TabItem.prototype = $.extend(new Item(), {
// ----------
setBounds: function(rect, immediately) {
if(!isRect(rect)) {
Utils.trace('TabItem.setBounds: rect is not a real rectangle!', rect);
return;
}
var $container = $(this.container);
var $title = $('.tab-title', $container);
var $thumb = $('.thumb', $container);
@ -97,6 +104,7 @@ window.TabItem.prototype = $.extend(new Item(), {
return;
this.bounds.copy(rect);
// If this is a brand new tab don't animate it in from
// a random location (i.e., from [0,0]). Instead, just
// have it appear where it should be.
@ -131,6 +139,9 @@ window.TabItem.prototype = $.extend(new Item(), {
this._updateDebugBounds();
this._hasBeenDrawn = true;
if(!isRect(this.bounds))
Utils.trace('TabItem.setBounds: this.bounds is not a real rectangle!', this.bounds);
},
// ----------

View File

@ -1,3 +1,5 @@
// Title: ui.js (revision-a)
(function(){
// ##########
@ -516,17 +518,18 @@ UIClass.prototype = {
// ----------
storageSanity: function(data) {
var sane = true;
if(data) {
sane = sane && typeof(data.dataVersion) == 'number';
sane = sane && isRect(data.pageBounds);
if($.isEmptyObject(data))
return true;
if(data.tabs)
sane = sane && TabItems.storageSanity(data.tabs);
if(data.groups)
sane = sane && Groups.storageSanity(data.groups);
}
var sane = true;
sane = sane && typeof(data.dataVersion) == 'number';
sane = sane && isRect(data.pageBounds);
if(data.tabs)
sane = sane && TabItems.storageSanity(data.tabs);
if(data.groups)
sane = sane && Groups.storageSanity(data.groups);
return sane;
},

View File

@ -1,3 +1,4 @@
// Title: tabs.js
(function(){

View File

@ -309,6 +309,8 @@ window.Subscribable.prototype = {
};
// ##########
// Class: Utils
// Singelton with common utility functions.
var Utils = {
// ___ Windows and Tabs
get activeWindow(){
@ -527,8 +529,21 @@ var Utils = {
},
// ----------
// Function: isNumber
// Returns true if the argument is a valid number.
isNumber: function(n) {
return (typeof(n) == 'number' && !isNaN(n));
},
// ----------
// Function: copy
// Returns a copy of the argument. Note that this is a shallow copy; if the argument
// has properties that are themselves objects, those properties will be copied by reference.
copy: function(value) {
if(value && typeof(value) == 'object')
return $.extend({}, value);
return value;
}
};

View File

@ -1,5 +1,6 @@
html {
overflow: hidden;
image-rendering: -moz-crisp-edges;
}
body {