浏览代码

implement error render box

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
3c95a36b
共有 3 个文件被更改,包括 108 次插入21 次删除
  1. 11
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  2. 96
      com.unity.uiwidgets/Runtime/rendering/error.cs
  3. 22
      com.unity.uiwidgets/Runtime/widgets/framework.cs

11
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


_description = description;
_children = children ?? new List<DiagnosticsNode>();
_properties = properties ?? new List<DiagnosticsNode>();
this.level = level;
valueObject = value;
this.allowTruncate = allowTruncate;
}
readonly List<DiagnosticsNode> _children;

new readonly DiagnosticLevel level;
public override DiagnosticLevel level {
get;
}
readonly bool allowTruncate;
public readonly bool allowTruncate;
public override List<DiagnosticsNode> getChildren() => _children;

96
com.unity.uiwidgets/Runtime/rendering/error.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
public static partial class rendering_ {
public static float _kMaxWidth = 100000.0f;
public static float _kMaxHeight = 100000.0f;
}
public class RenderErrorBox : RenderBox {
const string _kLine = "\n\n────────────────────\n\n";

string message;
Paragraph _paragraph;
static TextStyle textStyle = new TextStyle(
color: new Color(0xFFFFFF66),
fontFamily: "monospace",
fontSize: 14.0f,
fontWeight: FontWeight.w700
);
protected override float computeMaxIntrinsicWidth(float height) {
return rendering_._kMaxWidth;
}
static ParagraphStyle paragraphStyle = new ParagraphStyle(
height: 1.0f
protected internal override float computeMaxIntrinsicHeight(float width) {
return rendering_._kMaxHeight;
}
protected override bool sizedByParent {
get => true;
}
protected override bool hitTestSelf(Offset position) => true;
protected override void performResize() {
size = constraints.constrain(new Size(rendering_._kMaxWidth, rendering_._kMaxHeight));
}
public static EdgeInsets padding = EdgeInsets.fromLTRB(64, 96, 64, 12);
public static float minimumWidth = 200;
public static Color backgroundColor = _initBackgroundColor();
public static Color _initBackgroundColor() {
Color result = new Color(0xF0C0C0C0);
D.assert(() => {
result = new Color(0xF0900000);
return true;
});
return result;
}
public static ui.TextStyle textStyle = _initTextStyle();
public static ui.TextStyle _initTextStyle() {
ui.TextStyle result = new ui.TextStyle(
color: new Color(0xFF303030),
fontFamily: "sans-serif",
fontSize: 18.0f
);
D.assert(() => {
result = new ui.TextStyle(
color: new Color(0xFFFFFF66),
fontFamily: "monospace",
fontSize: 14.0f,
fontWeight: FontWeight.bold
);
return true;
});
return result;
}
public static ParagraphStyle paragraphStyle = new ParagraphStyle(
textDirection: TextDirection.ltr,
textAlign: TextAlign.left
public override void paint(PaintingContext context, Offset offset) {
try {
context.canvas.drawRect(offset & size, new Paint() {color = backgroundColor});
if (_paragraph != null) {
float width = size.width;
float left = 0.0f;
float top = 0.0f;
if (width > padding.left + minimumWidth + padding.right) {
width -= padding.left + padding.right;
left += padding.left;
}
_paragraph.layout(new ui.ParagraphConstraints(width: width));
if (size.height > padding.top + _paragraph.height() + padding.bottom) {
top += padding.top;
}
context.canvas.drawParagraph(_paragraph, offset + new Offset(left, top));
}
}
catch (Exception e) {
// Intentionally left empty.
}
}
}
}

22
com.unity.uiwidgets/Runtime/widgets/framework.cs


readonly static Dictionary<Element, Dictionary<Element, GlobalKey>> _debugReservations =
new Dictionary<Element, Dictionary<Element, GlobalKey>>();
if (_debugReservations.ContainsKey(parent) && _debugReservations[parent].ContainsKey(child)) {
_debugReservations[parent]?.Remove(child);
}

DiagnosticsNode ownershipChain = null
);
public Type debugTypicalAncestorWidgetClass { get; }
public virtual Type debugTypicalAncestorWidgetClass { get; }
public abstract void applyParentData(RenderObject renderObject);

return renderObject.parentData is T;
}
public Type debugTypicalAncestorWidgetClass { get; }
public override Type debugTypicalAncestorWidgetClass { get; }
internal override string _debugDescribeIncorrectParentDataType(
ParentData parentData,

internal Widget _widget;
public bool debugDoingBuild { get; }
public virtual bool debugDoingBuild { get; }
public Widget widget {
get { return _widget; }

return ancestor.widget;
}
public InheritedWidget dependOnInheritedElement(InheritedElement ancestor, object aspect = null) {
public virtual InheritedWidget dependOnInheritedElement(InheritedElement ancestor, object aspect = null) {
D.assert(ancestor != null);
_dependencies = _dependencies ?? new HashSet<InheritedElement>();
_dependencies.Add(ancestor);

readonly UIWidgetsError _uiWidgetsError;
public override RenderObject createRenderObject(BuildContext context) {
return null;
// return new RenderErrorBox(message);
// return null;
return new RenderErrorBox(message);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

bool _debugDoingBuild = false;
new bool debugDoingBuild {
public override bool debugDoingBuild {
get => _debugDoingBuild;
}

return dependOnInheritedElement(ancestor, aspect);
}
public new InheritedWidget dependOnInheritedElement(InheritedElement ancestor, object aspect = null) {
public override InheritedWidget dependOnInheritedElement(InheritedElement ancestor, object aspect = null) {
D.assert(ancestor != null);
D.assert(() => {
Type targetType = ancestor.widget.GetType();

bool _debugDoingBuild = false;
new bool debugDoingBuild {
public override bool debugDoingBuild {
get { return _debugDoingBuild; }
}

正在加载...
取消
保存