浏览代码

Merge branch 'master' of github.com:UnityTech/UIWidgets into xwzhu

/main
xingwei.zhu 6 年前
当前提交
be934460
共有 11 个文件被更改,包括 692 次插入7 次删除
  1. 2
      README-ZH.md
  2. 2
      README.md
  3. 2
      Runtime/material/toggleable.cs
  4. 35
      Runtime/rendering/flex.cs
  5. 7
      Runtime/rendering/shifted_box.cs
  6. 43
      Runtime/widgets/basic.cs
  7. 311
      Runtime/material/checkbox.cs
  8. 3
      Runtime/material/checkbox.cs.meta
  9. 275
      Runtime/rendering/debug_overflow_indicator.cs
  10. 11
      Runtime/rendering/debug_overflow_indicator.cs.meta
  11. 8
      scripts/node_modules.meta

2
README-ZH.md


#### 三、创建小部件
UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建应用程序并在Unity编辑器中播放。
1. 创建一个新C#脚本,命名为“ExampleCanvas.cs”,并将以下代码粘贴到其中。
1. 创建一个新C#脚本,命名为“UIWidgetsExample.cs”,并将以下代码粘贴到其中。
```none
using System.Collections.Generic;

2
README.md


UIWidgets is a plugin package for Unity Editor which helps developers to create, debug and deploy efficient,
cross-platform Apps using the Unity Engine.
UIWidgets is mainly derived from Flutter @https://github.com/flutter/flutter. However, taking advantage of
UIWidgets is mainly derived from [Flutter](https://github.com/flutter/flutter). However, taking advantage of
the powerful Unity Engine, it offers developers many new features to improve their Apps
as well as the develop workflow significantly.

2
Runtime/material/toggleable.cs


TickerProvider _vsync;
public bool? value {
public virtual bool? value {
get { return this._value; }
set {
D.assert(this.tristate || value != null);

35
Runtime/rendering/flex.cs


using System;
using System.Collections.Generic;
using UIWidgets.Runtime.rendering;
using Unity.UIWidgets.foundation;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public enum FlexFit {

}
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, this.defaultPaint);
D.assert(() => {
string debugOverflowHints =
$"The overflowing {this.GetType()} has an orientation of {this._direction}.\n" +
$"The edge of the {this.GetType()} that is overflowing has been marked " +
"in the rendering with a yellow and black striped pattern. This is " +
$"usually caused by the contents being too big for the {this.GetType()}. " +
"Consider applying a flex factor (e.g. using an Expanded widget) to " +
$"force the children of the {this.GetType()} to fit within the available " +
"space instead of being sized to their natural size.\n" +
"This is considered an error condition because it indicates that there " +
"is content that cannot be seen. If the content is legitimately bigger " +
"than the available space, consider clipping it with a ClipRect widget " +
"before putting it in the flex, or using a scrollable container rather " +
"than a Flex, like a ListView.";
Rect overflowChildRect;
switch (this._direction) {
case Axis.horizontal:
overflowChildRect = Rect.fromLTWH(0.0f, 0.0f, this.size.width + this._overflow, 0.0f);
break;
case Axis.vertical:
overflowChildRect = Rect.fromLTWH(0.0f, 0.0f, 0.0f, this.size.height + this._overflow);
break;
default:
throw new Exception("Unknown direction: " + this._direction);
}
DebugOverflowIndicatorMixin.paintOverflowIndicator(this, context, offset, Offset.zero & this.size,
overflowChildRect, overflowHints: debugOverflowHints);
return true;
});
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {

7
Runtime/rendering/shifted_box.cs


using Unity.UIWidgets.foundation;
using UIWidgets.Runtime.rendering;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

}
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, base.paint);
D.assert(() => {
DebugOverflowIndicatorMixin.paintOverflowIndicator(this, context, offset, this._overflowContainerRect, this._overflowChildRect);
return true;
});
}
}

43
Runtime/widgets/basic.cs


}
}
public class UnconstrainedBox : SingleChildRenderObjectWidget {
public UnconstrainedBox(
Key key = null,
Widget child = null,
Alignment alignment = null,
Axis? constrainedAxis = null
) : base(key: key, child: child) {
this.alignment = alignment ?? Alignment.center;
this.constrainedAxis = constrainedAxis;
}
public readonly Alignment alignment;
public readonly Axis? constrainedAxis;
public override void updateRenderObject(BuildContext context, RenderObject _renderObject) {
RenderUnconstrainedBox renderObject = _renderObject as RenderUnconstrainedBox;
renderObject.alignment = this.alignment;
renderObject.constrainedAxis = this.constrainedAxis;
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderUnconstrainedBox(
alignment: this.alignment,
constrainedAxis: this.constrainedAxis
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Alignment>("alignment", this.alignment));
properties.add(new DiagnosticsProperty<Axis>("constrainedAxis", null));
}
}
public class SliverToBoxAdapter : SingleChildRenderObjectWidget {
public SliverToBoxAdapter(
Key key = null,

((RenderFlex) renderObject).verticalDirection = this.verticalDirection;
((RenderFlex) renderObject).textBaseline = this.textBaseline ?? TextBaseline.alphabetic;
}
properties.add(new EnumProperty<MainAxisSize>("mainAxisSize", this.mainAxisSize, defaultValue: MainAxisSize.max));
properties.add(new EnumProperty<MainAxisSize>("mainAxisSize", this.mainAxisSize,
defaultValue: MainAxisSize.max));
properties.add(new EnumProperty<VerticalDirection>("verticalDirection", this.verticalDirection, defaultValue: VerticalDirection.down));
properties.add(new EnumProperty<VerticalDirection>("verticalDirection", this.verticalDirection,
defaultValue: VerticalDirection.down));
properties.add(new EnumProperty<TextBaseline?>("textBaseline", this.textBaseline, defaultValue: null));
}
}

311
Runtime/material/checkbox.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.material {
class CheckboxUtils {
public const float _kEdgeSize = Checkbox.width;
public static readonly Radius _kEdgeRadius = Radius.circular(1.0f);
public const float _kStrokeWidth = 2.0f;
}
public class Checkbox : StatefulWidget {
public Checkbox(
Key key = null,
bool? value = false,
bool tristate = false,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color checkColor = null,
MaterialTapTargetSize? materialTapTargetSize = null
) : base(key: key) {
D.assert(tristate || value != null);
this.value = value;
this.onChanged = onChanged;
this.activeColor = activeColor;
this.checkColor = checkColor;
this.tristate = tristate;
this.materialTapTargetSize = materialTapTargetSize;
}
public readonly bool? value;
public readonly ValueChanged<bool?> onChanged;
public readonly Color activeColor;
public readonly Color checkColor;
public readonly bool tristate;
public readonly MaterialTapTargetSize? materialTapTargetSize;
public const float width = 18.0f;
public override State createState() {
return new _CheckboxState();
}
}
class _CheckboxState : TickerProviderStateMixin<Checkbox> {
public override Widget build(BuildContext context) {
D.assert(MaterialD.debugCheckHasMaterial(context));
ThemeData themeData = Theme.of(context);
Size size;
switch (this.widget.materialTapTargetSize ?? themeData.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
size = new Size(2 * Constants.kRadialReactionRadius + 8.0f,
2 * Constants.kRadialReactionRadius + 8.0f);
break;
case MaterialTapTargetSize.shrinkWrap:
size = new Size(2 * Constants.kRadialReactionRadius, 2 * Constants.kRadialReactionRadius);
break;
default:
throw new Exception("Unknown target size: " + this.widget.materialTapTargetSize);
}
BoxConstraints additionalConstraints = BoxConstraints.tight(size);
return new _CheckboxRenderObjectWidget(
value: this.widget.value,
tristate: this.widget.tristate,
activeColor: this.widget.activeColor ?? themeData.toggleableActiveColor,
checkColor: this.widget.checkColor ?? new Color(0xFFFFFFFF),
inactiveColor: this.widget.onChanged != null
? themeData.unselectedWidgetColor
: themeData.disabledColor,
onChanged: this.widget.onChanged,
additionalConstraints: additionalConstraints,
vsync: this
);
}
}
class _CheckboxRenderObjectWidget : LeafRenderObjectWidget {
public _CheckboxRenderObjectWidget(
Key key = null,
bool? value = null,
bool tristate = false,
Color activeColor = null,
Color checkColor = null,
Color inactiveColor = null,
ValueChanged<bool?> onChanged = null,
TickerProvider vsync = null,
BoxConstraints additionalConstraints = null
) : base(key: key) {
D.assert(tristate != null);
D.assert(tristate || value != null);
D.assert(activeColor != null);
D.assert(inactiveColor != null);
D.assert(vsync != null);
this.value = value;
this.tristate = tristate;
this.activeColor = activeColor;
this.checkColor = checkColor;
this.inactiveColor = inactiveColor;
this.onChanged = onChanged;
this.vsync = vsync;
this.additionalConstraints = additionalConstraints;
}
public readonly bool? value;
public readonly bool tristate;
public readonly Color activeColor;
public readonly Color checkColor;
public readonly Color inactiveColor;
public readonly ValueChanged<bool?> onChanged;
public readonly TickerProvider vsync;
public readonly BoxConstraints additionalConstraints;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCheckbox(
value: this.value,
tristate: this.tristate,
activeColor: this.activeColor,
checkColor: this.checkColor,
inactiveColor: this.inactiveColor,
onChanged: this.onChanged,
vsync: this.vsync,
additionalConstraints: this.additionalConstraints
);
}
public override void updateRenderObject(BuildContext context, RenderObject _renderObject) {
_RenderCheckbox renderObject = _renderObject as _RenderCheckbox;
renderObject.value = this.value;
renderObject.tristate = this.tristate;
renderObject.activeColor = this.activeColor;
renderObject.checkColor = this.checkColor;
renderObject.inactiveColor = this.inactiveColor;
renderObject.onChanged = this.onChanged;
renderObject.additionalConstraints = this.additionalConstraints;
renderObject.vsync = this.vsync;
}
}
class _RenderCheckbox : RenderToggleable {
public _RenderCheckbox(
bool? value = null,
bool tristate = false,
Color activeColor = null,
Color checkColor = null,
Color inactiveColor = null,
BoxConstraints additionalConstraints = null,
ValueChanged<bool?> onChanged = null,
TickerProvider vsync = null
) : base(
value: value,
tristate: tristate,
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
additionalConstraints: additionalConstraints,
vsync: vsync
) {
this._oldValue = value;
this.checkColor = checkColor;
}
bool? _oldValue;
public Color checkColor;
public override bool? value {
set {
if (value == this.value) {
return;
}
this._oldValue = this.value;
base.value = value;
}
}
RRect _outerRectAt(Offset origin, float t) {
float inset = 1.0f - (t - 0.5f).abs() * 2.0f;
float size = CheckboxUtils._kEdgeSize - inset * CheckboxUtils._kStrokeWidth;
Rect rect = Rect.fromLTWH(origin.dx + inset, origin.dy + inset, size, size);
return RRect.fromRectAndRadius(rect, CheckboxUtils._kEdgeRadius);
}
Color _colorAt(float t) {
return this.onChanged == null
? this.inactiveColor
: (t >= 0.25f ? this.activeColor : Color.lerp(this.inactiveColor, this.activeColor, t * 4.0f));
}
void _initStrokePaint(Paint paint) {
paint.color = this.checkColor;
paint.style = PaintingStyle.stroke;
paint.strokeWidth = CheckboxUtils._kStrokeWidth;
}
void _drawBorder(Canvas canvas, RRect outer, float t, Paint paint) {
D.assert(t >= 0.0f && t <= 0.5f);
float size = outer.width;
RRect inner = outer.deflate(Mathf.Min(size / 2.0f, CheckboxUtils._kStrokeWidth + size * t));
canvas.drawDRRect(outer, inner, paint);
}
void _drawCheck(Canvas canvas, Offset origin, float t, Paint paint) {
D.assert(t >= 0.0f && t <= 1.0f);
Path path = new Path();
Offset start = new Offset(CheckboxUtils._kEdgeSize * 0.15f, CheckboxUtils._kEdgeSize * 0.45f);
Offset mid = new Offset(CheckboxUtils._kEdgeSize * 0.4f, CheckboxUtils._kEdgeSize * 0.7f);
Offset end = new Offset(CheckboxUtils._kEdgeSize * 0.85f, CheckboxUtils._kEdgeSize * 0.25f);
if (t < 0.5f) {
float strokeT = t * 2.0f;
Offset drawMid = Offset.lerp(start, mid, strokeT);
path.moveTo(origin.dx + start.dx, origin.dy + start.dy);
path.lineTo(origin.dx + drawMid.dx, origin.dy + drawMid.dy);
}
else {
float strokeT = (t - 0.5f) * 2.0f;
Offset drawEnd = Offset.lerp(mid, end, strokeT);
path.moveTo(origin.dx + start.dx, origin.dy + start.dy);
path.lineTo(origin.dx + mid.dx, origin.dy + mid.dy);
path.lineTo(origin.dx + drawEnd.dx, origin.dy + drawEnd.dy);
}
canvas.drawPath(path, paint);
}
void _drawDash(Canvas canvas, Offset origin, float t, Paint paint) {
D.assert(t >= 0.0f && t <= 1.0f);
Offset start = new Offset(CheckboxUtils._kEdgeSize * 0.2f, CheckboxUtils._kEdgeSize * 0.5f);
Offset mid = new Offset(CheckboxUtils._kEdgeSize * 0.5f, CheckboxUtils._kEdgeSize * 0.5f);
Offset end = new Offset(CheckboxUtils._kEdgeSize * 0.8f, CheckboxUtils._kEdgeSize * 0.5f);
Offset drawStart = Offset.lerp(start, mid, 1.0f - t);
Offset drawEnd = Offset.lerp(mid, end, t);
canvas.drawLine(origin + drawStart, origin + drawEnd, paint);
}
public override void paint(PaintingContext context, Offset offset) {
Canvas canvas = context.canvas;
this.paintRadialReaction(canvas, offset, this.size.center(Offset.zero));
Offset origin = offset + (this.size / 2.0f - Size.square(CheckboxUtils._kEdgeSize) / 2.0f);
AnimationStatus status = this.position.status;
float tNormalized = status == AnimationStatus.forward || status == AnimationStatus.completed
? this.position.value
: 1.0f - this.position.value;
if (this._oldValue == false || this.value == false) {
float t = this.value == false ? 1.0f - tNormalized : tNormalized;
RRect outer = this._outerRectAt(origin, t);
Paint paint = new Paint();
paint.color = this._colorAt(t);
if (t <= 0.5f) {
this._drawBorder(canvas, outer, t, paint);
}
else {
canvas.drawRRect(outer, paint);
this._initStrokePaint(paint);
float tShrink = (t - 0.5f) * 2.0f;
if (this._oldValue == null || this.value == null) {
this._drawDash(canvas, origin, tShrink, paint);
}
else {
this._drawCheck(canvas, origin, tShrink, paint);
}
}
}
else {
// Two cases: null to true, true to null
RRect outer = this._outerRectAt(origin, 1.0f);
Paint paint = new Paint();
paint.color = this._colorAt(1.0f);
canvas.drawRRect(outer, paint);
this._initStrokePaint(paint);
if (tNormalized <= 0.5f) {
float tShrink = 1.0f - tNormalized * 2.0f;
if (this._oldValue == true) {
this._drawCheck(canvas, origin, tShrink, paint);
}
else {
this._drawDash(canvas, origin, tShrink, paint);
}
}
else {
float tExpand = (tNormalized - 0.5f) * 2.0f;
if (this.value == true) {
this._drawCheck(canvas, origin, tExpand, paint);
}
else {
this._drawDash(canvas, origin, tExpand, paint);
}
}
}
}
}
}

3
Runtime/material/checkbox.cs.meta


fileFormatVersion: 2
guid: 3f506995b69c421cbdd95746b4ca2182
timeCreated: 1554213056

275
Runtime/rendering/debug_overflow_indicator.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Gradient = Unity.UIWidgets.ui.Gradient;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgets.Runtime.rendering {
enum _OverflowSide {
left,
top,
bottom,
right
}
class _OverflowRegionData {
public _OverflowRegionData(
Rect rect = null,
string label = "",
Offset labelOffset = null,
float rotation = 0.0f,
_OverflowSide? side = null
) {
this.rect = rect;
this.label = label;
this.labelOffset = labelOffset ?? Offset.zero;
this.rotation = rotation;
this.side = side;
}
public readonly Rect rect;
public readonly string label;
public readonly Offset labelOffset;
public readonly float rotation;
public readonly _OverflowSide? side;
}
public static class DebugOverflowIndicatorMixin {
static readonly Color _black = new Color(0xBF000000);
static readonly Color _yellow = new Color(0xBFFFFF00);
const float _indicatorFraction = 0.1f;
const float _indicatorFontSizePixels = 7.5f;
const float _indicatorLabelPaddingPixels = 1.0f;
static readonly TextStyle _indicatorTextStyle = new TextStyle(
color: new Color(0xFF900000),
fontSize: _indicatorFontSizePixels,
fontWeight: FontWeight.w800
);
static readonly Paint _indicatorPaint = new Paint();
static readonly Paint _labelBackgroundPaint = new Paint();
static readonly List<TextPainter> _indicatorLabel = new List<TextPainter>(4);
static DebugOverflowIndicatorMixin() {
_indicatorPaint.shader = Gradient.linear(
new Offset(0.0f, 0.0f),
new Offset(10.0f, 10.0f),
new List<Color> {_black, _yellow, _yellow, _black},
new List<float> {0.25f, 0.25f, 0.75f, 0.75f},
TileMode.repeated
);
_labelBackgroundPaint.color = new Color(0xFFFFFFFF);
for (int i = 0; i < 4; i++) {
_indicatorLabel.Add(new TextPainter(new TextSpan(""), textDirection: TextDirection.ltr));
}
}
static readonly Dictionary<RenderObject, bool> _overflowReportNeeded = new Dictionary<RenderObject, Boolean>();
static string _formatPixels(float value) {
D.assert(value > 0.0f);
string pixels;
if (value > 10.0f) {
pixels = value.ToString("0");
}
else if (value > 1.0f) {
pixels = value.ToString("0.0");
}
else {
pixels = value.ToString("0.000");
}
return pixels;
}
static List<_OverflowRegionData> _calculateOverflowRegions(RelativeRect overflow, Rect containerRect) {
List<_OverflowRegionData> regions = new List<_OverflowRegionData> { };
if (overflow.left > 0.0f) {
Rect markerRect = Rect.fromLTWH(
0.0f,
0.0f,
containerRect.width * _indicatorFraction,
containerRect.height
);
regions.Add(new _OverflowRegionData(
rect: markerRect,
label: "LEFT OVERFLOWED BY ${_formatPixels(overflow.left)} PIXELS",
labelOffset: markerRect.centerLeft +
new Offset(_indicatorFontSizePixels + _indicatorLabelPaddingPixels, 0.0f),
rotation: Mathf.PI / 2.0f,
side: _OverflowSide.left
));
}
if (overflow.right > 0.0f) {
Rect markerRect = Rect.fromLTWH(
containerRect.width * (1.0f - _indicatorFraction),
0.0f,
containerRect.width * _indicatorFraction,
containerRect.height
);
regions.Add(new _OverflowRegionData(
rect: markerRect,
label: $"RIGHT OVERFLOWED BY {_formatPixels(overflow.right)} PIXELS",
labelOffset: markerRect.centerRight -
new Offset(_indicatorFontSizePixels + _indicatorLabelPaddingPixels, 0.0f),
rotation: -Mathf.PI / 2.0f,
side: _OverflowSide.right
));
}
if (overflow.top > 0.0f) {
Rect markerRect = Rect.fromLTWH(
0.0f,
0.0f,
containerRect.width,
containerRect.height * _indicatorFraction
);
regions.Add(new _OverflowRegionData(
rect: markerRect,
label: $"TOP OVERFLOWED BY {_formatPixels(overflow.top)} PIXELS",
labelOffset: markerRect.topCenter + new Offset(0.0f, _indicatorLabelPaddingPixels),
rotation: 0.0f,
side: _OverflowSide.top
));
}
if (overflow.bottom > 0.0f) {
Rect markerRect = Rect.fromLTWH(
0.0f,
containerRect.height * (1.0f - _indicatorFraction),
containerRect.width,
containerRect.height * _indicatorFraction
);
regions.Add(new _OverflowRegionData(
rect: markerRect,
label: $"BOTTOM OVERFLOWED BY {_formatPixels(overflow.bottom)} PIXELS",
labelOffset: markerRect.bottomCenter -
new Offset(0.0f, _indicatorFontSizePixels + _indicatorLabelPaddingPixels),
rotation: 0.0f,
side: _OverflowSide.bottom
));
}
return regions;
}
static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, string overflowHints) {
overflowHints = overflowHints ?? $"The edge of the {renderObject.GetType()} that is " +
"overflowing has been marked in the rendering with a yellow and black " +
"striped pattern. This is usually caused by the contents being too big " +
$"for the {renderObject.GetType()}.\n" +
"This is considered an error condition because it indicates that there " +
"is content that cannot be seen. If the content is legitimately bigger " +
"than the available space, consider clipping it with a ClipRect widget " +
$"before putting it in the {renderObject.GetType()}, or using a scrollable " +
"container, like a ListView.";
List<string> overflows = new List<string> { };
if (overflow.left > 0.0f) {
overflows.Add($"{_formatPixels(overflow.left)} pixels on the left");
}
if (overflow.top > 0.0f) {
overflows.Add($"{_formatPixels(overflow.top)} pixels on the top");
}
if (overflow.bottom > 0.0f) {
overflows.Add($"{_formatPixels(overflow.bottom)} pixels on the bottom");
}
if (overflow.right > 0.0f) {
overflows.Add($"{_formatPixels(overflow.right)} pixels on the right");
}
string overflowText = "";
D.assert(overflows.isNotEmpty(),
$"Somehow {renderObject.GetType()} didn't actually overflow like it thought it did.");
switch (overflows.Count) {
case 1:
overflowText = overflows.first();
break;
case 2:
overflowText = $"{overflows.first()} and {overflows.last()}";
break;
default:
overflows[overflows.Count - 1] = $"and {overflows[overflows.Count - 1]}";
overflowText = string.Join(", ", overflow);
break;
}
UIWidgetsError.reportError(
new UIWidgetsErrorDetails(
exception: new Exception($"A {renderObject.GetType()} overflowed by {overflowText}."),
library: "rendering library",
context: "during layout",
informationCollector: (information) => {
information.AppendLine(overflowHints);
information.AppendLine($"The specific {renderObject.GetType()} in question is:");
information.AppendLine($" {renderObject.toStringShallow(joiner: "\n ")}");
information.AppendLine(string.Concat(Enumerable.Repeat("◢◤", 32)));
}
)
);
}
public static void paintOverflowIndicator(
RenderObject renderObject,
PaintingContext context,
Offset offset,
Rect containerRect,
Rect childRect,
string overflowHints = null
) {
RelativeRect overflow = RelativeRect.fromRect(containerRect, childRect);
if (overflow.left <= 0.0f &&
overflow.right <= 0.0f &&
overflow.top <= 0.0f &&
overflow.bottom <= 0.0f) {
return;
}
List<_OverflowRegionData> overflowRegions = _calculateOverflowRegions(overflow, containerRect);
foreach (_OverflowRegionData region in overflowRegions) {
context.canvas.drawRect(region.rect.shift(offset), _indicatorPaint);
if (_indicatorLabel[(int) region.side].text?.text != region.label) {
_indicatorLabel[(int) region.side].text = new TextSpan(
text: region.label,
style: _indicatorTextStyle
);
_indicatorLabel[(int) region.side].layout();
}
Offset labelOffset = region.labelOffset + offset;
Offset centerOffset = new Offset(-_indicatorLabel[(int) region.side].width / 2.0f, 0.0f);
Rect textBackgroundRect = centerOffset & _indicatorLabel[(int) region.side].size;
context.canvas.save();
context.canvas.translate(labelOffset.dx, labelOffset.dy);
context.canvas.rotate(region.rotation);
context.canvas.drawRect(textBackgroundRect, _labelBackgroundPaint);
_indicatorLabel[(int) region.side].paint(context.canvas, centerOffset);
context.canvas.restore();
}
bool containsKey = _overflowReportNeeded.TryGetValue(renderObject, out var overflowReportNeeded);
overflowReportNeeded |= !containsKey;
if (overflowReportNeeded) {
_overflowReportNeeded[renderObject] = false;
_reportOverflow(renderObject, overflow, overflowHints);
}
}
}
}

11
Runtime/rendering/debug_overflow_indicator.cs.meta


fileFormatVersion: 2
guid: 3d9d2d2974274fa39fc3caac8ee159d1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
scripts/node_modules.meta


fileFormatVersion: 2
guid: 7d78b565ea82c414a9c59aa6ccd9bd2c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存