replace shrink padding code.

This commit is contained in:
Christopher Jeffrey 2013-07-17 05:30:42 -05:00
parent 8e81ef015b
commit e9f7d933bd
2 changed files with 23 additions and 30 deletions

View File

@ -1981,8 +1981,10 @@ Box.prototype._getShrinkBox = function(xi, xl, yi, yl) {
|| this.options.right == null)) {
if (this.options.left == null && this.options.right != null) {
xi = xl - (mxl - mxi);
xi -= this.padding * 2;
} else {
xl = mxl;
xl += this.padding * 2;
}
}
@ -1992,8 +1994,10 @@ Box.prototype._getShrinkBox = function(xi, xl, yi, yl) {
&& this.childBase == null) {
if (this.options.top == null && this.options.bottom != null) {
yi = yl - (myl - myi);
yi -= this.padding * 2;
} else {
yl = myl;
yl += this.padding * 2;
}
}
@ -2065,29 +2069,6 @@ Box.prototype._getShrink = function(xi, xl, yi, yl, content) {
yl += yll;
}
// Add padding, doesn't seem to be necessary.
if (0 && this.padding) {
if (this.options.width == null
&& (this.options.left == null
|| this.options.right == null)) {
if (this.options.left == null && this.options.right != null) {
xi -= this.padding * 2;
} else {
xl += this.padding * 2;
}
}
if (this.options.height == null
&& (this.options.top == null
|| this.options.bottom == null)
&& this.childBase == null) {
if (this.options.top == null && this.options.bottom != null) {
yi -= this.padding * 2;
} else {
yl += this.padding * 2;
}
}
}
return { xi: xi, xl: xl, yi: yi, yl: yl };
};
@ -2163,6 +2144,15 @@ Box.prototype.render = function(stop) {
xi = ret.xi, xl = ret.xl, yi = ret.yi, yl = ret.yl;
}
// TODO: Possibly do something like this, except more complex.
// if (this.parent.padding) {
// xi += this.parent.padding;
// xl += this.parent.padding;
// yi += this.parent.padding;
// yl += this.parent.padding;
// }
// if (this.parent.border) xi++, xl++, yi++, yl++;
ret = {
xi: xi,
xl: xl,
@ -4013,8 +4003,9 @@ function Checkbox(options) {
}
this.on('focus', function(old) {
if (!this.lpos) return;
self.screen.program.saveCursor();
self.screen.program.cup(this.top, this.left + 1);
self.screen.program.cup(this.lpos.yi, this.lpos.xi + 1);
self.screen.program.showCursor();
});

View File

@ -24,7 +24,8 @@ var set = blessed.radioset({
left: 0,
top: 0,
shrink: true,
height: 1,
//padding: 1,
//content: 'f',
bg: 'magenta'
});
@ -62,7 +63,7 @@ var text = blessed.textbox({
height: 1,
width: 20,
left: 1,
top: 1,
top: 2,
name: 'text'
});
@ -77,8 +78,8 @@ var check = blessed.checkbox({
shrink: true,
bg: 'magenta',
height: 1,
left: 24,
top: 1,
left: 28,
top: 0,
name: 'check',
content: 'check'
});
@ -87,9 +88,10 @@ var submit = blessed.button({
parent: form,
mouse: true,
keys: true,
height: 1,
shrink: true,
padding: 1,
left: 30,
top: 0,
top: 2,
shrink: true,
name: 'submit',
content: 'submit',