|
|
|
|
|
|
|
|
|
|
/// Use an ellipsis to indicate that the text has overflowed.
|
|
|
|
ellipsis, |
|
|
|
|
|
|
|
/// Render overflowing text outside of its container.
|
|
|
|
visible, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextOverflow _overflow; |
|
|
|
readonly TextPainter _textPainter; |
|
|
|
bool _hasVisualOverflow = false; |
|
|
|
bool _needsClipping = false; |
|
|
|
|
|
|
|
List<TextBox> _selectionRects; |
|
|
|
|
|
|
|
|
|
|
protected override void performLayout() { |
|
|
|
this._layoutTextWithConstraints(this.constraints); |
|
|
|
var textSize = this._textPainter.size; |
|
|
|
var didOverflowHeight = this._textPainter.didExceedMaxLines; |
|
|
|
var textDidExceedMaxLines = this._textPainter.didExceedMaxLines; |
|
|
|
var didOverflowHeight = this.size.height < textSize.height || textDidExceedMaxLines; |
|
|
|
this._hasVisualOverflow = didOverflowWidth || didOverflowHeight; |
|
|
|
var hasVisualOverflow = didOverflowWidth || didOverflowHeight; |
|
|
|
if (hasVisualOverflow) { |
|
|
|
switch (this._overflow) { |
|
|
|
case TextOverflow.visible: |
|
|
|
this._needsClipping = false; |
|
|
|
break; |
|
|
|
case TextOverflow.clip: |
|
|
|
case TextOverflow.ellipsis: |
|
|
|
case TextOverflow.fade: |
|
|
|
this._needsClipping = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
this._needsClipping = false; |
|
|
|
} |
|
|
|
|
|
|
|
this._selectionRects = null; |
|
|
|
} |
|
|
|
|
|
|
this._layoutTextWithConstraints(this.constraints); |
|
|
|
var canvas = context.canvas; |
|
|
|
|
|
|
|
if (this._hasVisualOverflow) { |
|
|
|
if (this._needsClipping) { |
|
|
|
var bounds = offset & this.size; |
|
|
|
canvas.save(); |
|
|
|
canvas.clipRect(bounds); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this._textPainter.paint(canvas, offset); |
|
|
|
if (this._hasVisualOverflow) { |
|
|
|
if (this._needsClipping) { |
|
|
|
canvas.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|