mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Merge pull request #204 from dabingnn/add_Label_OverFlow
Add label over flow
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user