Revert "auto calculate top for lists."

This reverts commit 5ec1f2808c.
This commit is contained in:
Christopher Jeffrey 2013-06-03 20:06:58 -05:00
parent 5ec1f2808c
commit dbacb6f8ed
1 changed files with 6 additions and 82 deletions

View File

@ -245,12 +245,7 @@ Screen.prototype.draw = function(start, end) {
*/
function Element(options) {
options = options || {};
Node.call(this, options);
this.options = options;
this.screen = options.screen;
this.parent = options.parent || (function(){throw Error('No parent.')})();
this.position = {
@ -303,26 +298,13 @@ Element.prototype.__defineGetter__('left', function() {
left = (this.parent.width - len) * left | 0;
}
var opt = this.options;
if (opt.left == null && !left && opt.right != null && this.position.right) {
left = this.width - this.position.right;
}
return (this.parent.left || 0) + left;
});
Element.prototype.__defineSetter__('left', function(val) {
return this.position.left = val;
});
Element.prototype.__defineGetter__('right', function() {
return (this.parent.right || 0) + this.position.right;
});
Element.prototype.__defineSetter__('right', function(val) {
return this.position.right = val;
});
Element.prototype.__defineGetter__('top', function() {
var top = this.position.top;
@ -333,31 +315,13 @@ Element.prototype.__defineGetter__('top', function() {
top = (this.parent.height - len) * top | 0;
}
var opt = this.options;
if (opt.top == null && !top && opt.bottom != null && this.position.bottom) {
top = this.height - this.position.bottom;
}
if (this.parent.childBase != null && ~this.parent.items.indexOf(this)) {
top += this.parent.items.indexOf(this);
top -= this.parent.childBase;
}
return (this.parent.top || 0) + top;
});
Element.prototype.__defineSetter__('top', function() {
return this.position.top = val;
});
Element.prototype.__defineGetter__('bottom', function() {
return (this.parent.bottom || 0) + this.position.bottom;
});
Element.prototype.__defineSetter__('bottom', function(val) {
return this.position.bottom = val;
});
Element.prototype.__defineGetter__('width', function() {
var width = this.position.width;
if (typeof width === 'string') {
@ -378,10 +342,6 @@ Element.prototype.__defineGetter__('width', function() {
return width;
});
Element.prototype.__defineSetter__('width', function(val) {
return this.position.width = val;
});
Element.prototype.__defineGetter__('height', function() {
var height = this.position.height;
if (typeof height === 'string') {
@ -402,10 +362,6 @@ Element.prototype.__defineGetter__('height', function() {
return height;
});
Element.prototype.__defineSetter__('height', function(val) {
return this.position.height = val;
});
Element.prototype.__defineGetter__('rleft', function() {
var left = this.position.left;
@ -416,26 +372,13 @@ Element.prototype.__defineGetter__('rleft', function() {
left = len * left | 0;
}
var opt = this.options;
if (opt.left == null && !left && opt.right != null && this.position.right) {
left = this.width - this.position.right;
}
return left;
});
Element.prototype.__defineSetter__('rleft', function(val) {
return this.position.left = val;
});
Element.prototype.__defineGetter__('rright', function() {
return this.position.right;
});
Element.prototype.__defineSetter__('rright', function() {
return this.position.right = val;
});
Element.prototype.__defineGetter__('rtop', function() {
var top = this.position.top;
@ -446,31 +389,13 @@ Element.prototype.__defineGetter__('rtop', function() {
top = len * top | 0;
}
var opt = this.options;
if (opt.top == null && !top && opt.bottom != null && this.position.bottom) {
top = this.height - this.position.bottom;
}
if (this.parent.childBase != null && ~this.parent.items.indexOf(this)) {
top += this.parent.items.indexOf(this);
top -= this.parent.childBase;
}
return top;
});
Element.prototype.__defineSetter__('rtop', function() {
return this.position.top = val;
});
Element.prototype.__defineGetter__('rbottom', function() {
return this.position.bottom;
});
Element.prototype.__defineSetter__('rbottom', function() {
return this.position.bottom = val;
});
/**
* Border Measures
*/
@ -594,7 +519,6 @@ Box.prototype.render = function() {
function Text(options) {
Element.call(this, options);
this.full = options.full;
this.noOverflow = options.noOverflow;
}
Text.prototype.__proto__ = Element.prototype;
@ -624,15 +548,16 @@ Text.prototype.render = function() {
xl = xi + this.parent.width - (this.parent.border ? 2 : 0) - this.rleft - this.rright;
}
if (this.noOverflow) {
if (this.parent.childBase != null && ~this.parent.items.indexOf(this)) {
var rtop = this.rtop - (this.parent.border ? 1 : 0)
, visible = this.parent.height - (this.parent.border ? 2 : 0);
if (rtop < 0) {
yi -= this.parent.childBase;
if (rtop - this.parent.childBase < 0) {
return;
}
if (rtop >= visible) {
if (rtop - this.parent.childBase >= visible) {
return;
}
}
@ -711,10 +636,9 @@ List.prototype.add = function(item) {
fg: this.fg,
bg: this.bg,
content: item.content || item,
top: 0,
top: this.items.length + (this.border ? 1 : 0),
left: (this.border ? 1 : 0) + 1,
full: true,
noOverflow: true,
height: 1
});
this.append(item);