浏览代码

[1.5.4] Upgrade widgets. Add visible to TextOverflow.

/main
Yuncong Zhang 5 年前
当前提交
9a40d31e
共有 5 个文件被更改,包括 35 次插入15 次删除
  1. 29
      Runtime/rendering/paragraph.cs
  2. 10
      Runtime/widgets/fade_in_image.cs
  3. 2
      Runtime/widgets/icon.cs
  4. 4
      Runtime/widgets/nested_scroll_view.cs
  5. 5
      Tests/Editor/Paragraph.cs

29
Runtime/rendering/paragraph.cs


/// 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();
}
}

10
Runtime/widgets/fade_in_image.cs


) {
D.assert(placeholder != null);
D.assert(image != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);
D.assert(fadeInDuration != null);
D.assert(fadeInCurve != null);
D.assert(alignment != null);
fadeOutDuration = fadeOutDuration ?? new TimeSpan(0, 0, 0, 0, 300);
fadeOutCurve = fadeOutCurve ?? Curves.easeOut;
fadeInDuration = fadeInDuration ?? new TimeSpan(0, 0, 0, 0, 700);
fadeInCurve = Curves.easeIn;
alignment = alignment ?? Alignment.center;
var imageProvider = placeholderScale != null
? new ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale ?? 1.0f)
: (ImageProvider) new AssetImage(placeholder, bundle: bundle);

2
Runtime/widgets/icon.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

}
Widget iconWidget = new RichText(
overflow: TextOverflow.visible,
text: new TextSpan(
text: new string(new[] {(char) this.icon.codePoint}),
style: new TextStyle(

4
Runtime/widgets/nested_scroll_view.cs


ScrollPhysics physics = null,
NestedScrollViewHeaderSliversBuilder headerSliverBuilder = null,
Widget body = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
D.assert(headerSliverBuilder != null);
D.assert(body != null);

ScrollController controller,
List<Widget> slivers,
SliverOverlapAbsorberHandle handle,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(
scrollDirection: scrollDirection,
reverse: reverse,

5
Tests/Editor/Paragraph.cs


return null;
}
RenderBox box(RenderParagraph p, int width = 200, int height = 200) {
RenderBox box(RenderParagraph p, int width = 200, int height = 600) {
return new RenderConstrainedOverflowBox(
minWidth: width,
maxWidth: width,

child: p
)
;
);
}
RenderBox flexItemBox(RenderParagraph p, int width = 200, int height = 150) {

正在加载...
取消
保存