Merge pull request #204 from dabingnn/add_Label_OverFlow

Add label over flow
This commit is contained in:
pandamicro
2016-01-08 13:49:57 +08:00
3 changed files with 9 additions and 3 deletions
+1 -2
View File
@@ -144,8 +144,7 @@ var Label = cc.Class({
notify: function () {
var sgNode = this._sgNode;
if (sgNode) {
//FIXME change this hack if _ccsg.Label.Overflow.NONE is implemented
sgNode.setOverflow( (this.overflow === _ccsg.Label.Overflow.NONE) ? _ccsg.Label.Overflow.CLAMP : this.overflow);
sgNode.setOverflow(this.overflow);
}
}
},
-1
View File
@@ -1098,7 +1098,6 @@ _ccsg.Label.Type = cc.Enum({
SystemFont: 2
});
_ccsg.Label.Overflow = cc.Enum({
//TODO: NONE is not implemented yet
NONE: 0,
CLAMP: 1,
SHRINK: 2,
@@ -250,6 +250,14 @@
fontDesc = this._drawFontsize.toString() + "px " + fontFamily;
this._splitedStrings = paragraphedStrings;
}
} else if(_ccsg.Label.Overflow.NONE == node._overFlow) {
this._splitedStrings = paragraphedStrings;
for (var i = 0; i < paragraphedStrings.length; ++i) {
var paraLength = ctx.measureText(paragraphedStrings[i]).width;
canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength;
}
canvasSizeY = this._splitedStrings.length * this._getLineHeight();
node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
} else {
//others treat it as clamp
if (node._isWrapText) {