浏览代码

Merge branch 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into material

/main
xingwei.zhu 6 年前
当前提交
c2380e8e
共有 18 个文件被更改,包括 470 次插入114 次删除
  1. 39
      README.md
  2. 6
      Runtime/debugger/inpsector_panel.cs
  3. 128
      Runtime/debugger/inspector_window.cs
  4. 12
      Runtime/editor/editor_window.cs
  5. 68
      Runtime/foundation/debug.cs
  6. 2
      Runtime/material/material.cs
  7. 99
      Runtime/painting/colors.cs
  8. 56
      Runtime/rendering/box.cs
  9. 2
      Runtime/rendering/image.cs
  10. 22
      Runtime/rendering/object.cs
  11. 2
      Runtime/rendering/paragraph.cs
  12. 3
      Runtime/rendering/proxy_box.cs
  13. 109
      Runtime/rendering/shifted_box.cs
  14. 7
      Runtime/rendering/view.cs
  15. 7
      Runtime/rendering/viewport.cs
  16. 4
      Runtime/widgets/basic.cs
  17. 11
      Editor/editor/WidgetCanvasEditor.cs.meta
  18. 7
      UIWidgetCleanupPlugin.DotSettings.meta

39
README.md


First of all, please open or create a Unity Project and open it with Unity Editor.
And then open Project Settings, go to Player section and add "UIWidgets_DEBUG" to the Scripting Debug Symbols field.
This enables the debug mode of UIWidgets for your development. Remove this for your release build afterwards.
#### ii. Scene Build
A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a
UI Canvas in Unity.

namespace UIWidgetsSample {
public class ExampleCanvas : WidgetCanvas {
protected override void OnEnable() {
base.OnEnable();
// Application.targetFrameRate = 60; // or higher if you want a smoother scrolling experience.
// if you want to use your own font or font icons.
// use the font family name instead of the file name in FontStyle.fontFamily.
// you can get the font family name by clicking the font file and check its Inspector.
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"));
}
protected override Widget getWidget() {
return new ExampleApp();
}

1. Choose a target platform and click "Build". Then the Unity Editor will automatically assemble
all relevant resources and generate the final App package.
#### How to load images?
1. Put your images files in Resources folder. e.g. image1.png.
2. You can add image1@2.png and image1@3.png in the same folder to support HD screens.
3. Use Image.asset("image1") to load the image. Note: as in Unity, ".png" is not needed.
UIWidgets supports Gif as well!
1. Suppose you have loading1.gif. Rename it to loading1.gif.bytes and copy it to Resources folder.
2. You can add loading1@2.gif.bytes and loading1@3.gif.bytes in the same folder to support HD screens.
3. Use Image.asset("loading1.gif") to load the gif images.
## Debug UIWidgets Application
#### Define UIWidgets_DEBUG
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this:
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
and add **UIWidgets_DEBUG**.
The symbol is for debug purpose, please remove it from your release build.
#### UIWidgets Inspector
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
via *Window/Analysis/UIWidgets* inspector in Editor menu.
**Note**
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
## Learn

6
Runtime/debugger/inpsector_panel.cs


this.m_TreeView.node = node;
}
public void MarkNeedReload() {
this.m_TreeView.node = null;
this.m_NeedSelectionUpdate = true;
}
public void Update() {
if (!this.m_VisibleToUser) {
return;

item = this.m_TreeView.getTreeItemByValueRef(diagnosticsNode.valueRef);
}
this.m_TreeView.CollapseAll();
if (item != null) {
this.m_TreeView.SetSelection(new List<int> {item.id}, TreeViewSelectionOptions.RevealAndFrame);
}

128
Runtime/debugger/inspector_window.cs


#if UNITY_EDITOR
using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
using UnityEditor;
using UnityEngine;

const float debugPaintToggleGroupWidth = 120;
const float debugPaintToggleGroupHeight = 100;
[SerializeField]
bool m_DebugPaint;
[SerializeField]
bool m_DebugPaintSize;
[SerializeField]
bool m_DebugPaintBaseline;
[SerializeField]
bool m_DebugPaintPointer;
[SerializeField]
bool m_DebugPaintLayer;
bool m_ShowDebugPaintToggles;
Rect m_DebugPaintTogglesRect;
List<Action> m_UpdateActions = new List<Action>();
[MenuItem("Window/Analysis/UIWidgets Inspector")]
public static void Init() {
WidgetsInpsectorWindow window =

void OnGUI() {
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
this.DoSelectDropDown();
bool needDebugPaintUpdate = false;
if (GUILayout.Button("Refersh", EditorStyles.toolbarButton)) {
foreach (var panel in this.m_Panels) {
panel.MarkNeedReload();
}
}
EditorGUI.BeginChangeCheck();
var newShowInspect = GUILayout.Toggle(this.m_ShowInspect, new GUIContent("Inspect Element"),
EditorStyles.toolbarButton);

var style = (GUIStyle) "GV Gizmo DropDown";
Rect r = GUILayoutUtility.GetRect(new GUIContent("Debug Paint"), style);
Rect rightRect = new Rect(r.xMax - style.border.right, r.y, style.border.right, r.height);
if (EditorGUI.DropdownButton(rightRect, GUIContent.none, FocusType.Passive, GUIStyle.none))
{
this.ScheduleUpdateAction(() => {
this.m_ShowDebugPaintToggles = !this.m_ShowDebugPaintToggles;
this.Repaint();
});
}
if (Event.current.type == EventType.Repaint) {
this.m_DebugPaintTogglesRect = new Rect(r.xMax - debugPaintToggleGroupWidth, r.yMax + 2,
debugPaintToggleGroupWidth, debugPaintToggleGroupHeight);
}
EditorGUI.BeginChangeCheck();
this.m_DebugPaint = GUI.Toggle(r, this.m_DebugPaint, new GUIContent("Debug Paint"), style);
if (EditorGUI.EndChangeCheck()) {
if (this.m_DebugPaint) {
if (!this.m_DebugPaintSize && !this.m_DebugPaintLayer
&& !this.m_DebugPaintPointer && !this.m_DebugPaintBaseline) {
this.m_DebugPaintSize = true;
}
}
needDebugPaintUpdate = true;
}
}
EditorGUILayout.EndHorizontal();

});
EditorGUILayout.EndHorizontal();
this.m_Panels[this.m_PanelIndex].OnGUI();
bool shouldHandleGUI = true;
if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp) {
if (this.m_ShowDebugPaintToggles && this.m_DebugPaintTogglesRect.Contains(Event.current.mousePosition)) {
shouldHandleGUI = false;
}
}
if (shouldHandleGUI) {
this.m_Panels[this.m_PanelIndex].OnGUI();
}
if (this.m_ShowDebugPaintToggles) {
this.DebugPaintToggles(ref needDebugPaintUpdate);
}
if (needDebugPaintUpdate) {
D.setDebugPaint(
debugPaintSizeEnabled: this.m_DebugPaint && this.m_DebugPaintSize,
debugPaintBaselinesEnabled: this.m_DebugPaint && this.m_DebugPaintBaseline,
debugPaintPointersEnabled: this.m_DebugPaint && this.m_DebugPaintPointer,
debugPaintLayerBordersEnabled: this.m_DebugPaint && this.m_DebugPaintLayer,
debugRepaintRainbowEnabled: this.m_DebugPaint && this.m_DebugPaintLayer
);
}
void DebugPaintToggles(ref bool needUpdate) {
GUILayout.BeginArea(this.m_DebugPaintTogglesRect, GUI.skin.box);
GUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
GUILayout.Space(4);
this.m_DebugPaintSize = GUILayout.Toggle(this.m_DebugPaintSize, new GUIContent("Paint Size"));
this.m_DebugPaintBaseline = GUILayout.Toggle(this.m_DebugPaintBaseline, new GUIContent("Paint Baseline"));
this.m_DebugPaintPointer = GUILayout.Toggle(this.m_DebugPaintPointer, new GUIContent("Paint Pointer"));
this.m_DebugPaintLayer = GUILayout.Toggle(this.m_DebugPaintLayer, new GUIContent("Paint Layer"));
if (EditorGUI.EndChangeCheck()) {
needUpdate = true;
}
GUILayout.EndVertical();
GUILayout.EndArea();
if (Event.current.type == EventType.MouseDown &&
!this.m_DebugPaintTogglesRect.Contains(Event.current.mousePosition)) {
this.ScheduleUpdateAction(() => {
this.m_ShowDebugPaintToggles = false;
this.Repaint();
});
}
}
if (currentWindow != null && !currentWindow.alive) {
currentWindow = null;
}
var selectTitle = currentWindow != null ? currentWindow.titleContent : new GUIContent("<Please Select>");
if (GUILayout.Button(selectTitle, EditorStyles.toolbarDropDown)) {
var windows = new List<WindowAdapter>(WindowAdapter.windowAdapters.Where(w => {

this.m_Panels.Clear();
this.m_ShowInspect = false;
this.m_ShowDebugPaintToggles = false;
}
void ScheduleUpdateAction(Action action) {
this.m_UpdateActions.Add(action);
}
void Update() {

if (this.m_Panels.Count > 0) {
this.m_PanelStates = this.m_Panels.Select(p => p.PanelState).ToList();
}
while (this.m_UpdateActions.Count > 0) {
this.m_UpdateActions[0]();
this.m_UpdateActions.RemoveAt(0);
}
}

12
Runtime/editor/editor_window.cs


if (this._binding == null) {
this._binding = new WidgetsBinding();
}
WidgetsBinding.instance = this._binding;
return new WindowDisposable(this);

public override TextInput textInput {
get { return this._textInput; }
}
internal void _forceRepaint() {
using (this.getScope()) {
RenderObjectVisitor visitor = null;
visitor = (child) => {
child.markNeedsPaint();
child.visitChildren(visitor);
};
this._binding.renderView?.visitChildren(visitor);
}
}
}
}

68
Runtime/foundation/debug.cs


using System;
using System.Diagnostics;
using System.Linq;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Debug = UnityEngine.Debug;

public static bool debugRepaintRainbowEnabled = false;
public static bool debugRepaintTextRainbowEnabled = false;
public static bool debugPaintLayerBordersEnabled = false;
public static bool debugPrintMarkNeedsLayoutStacks = false;

public static bool debugCheckIntrinsicSizes = false;
// public static Color debugCurrentRepaintColor = Color.fromfromAHSV(0.4, 60.0, 1.0, 1.0);;
public static HSVColor debugCurrentRepaintColor =
HSVColor.fromAHSV(0.4f, 60.0f, 1.0f, 1.0f);
// final Path path = new Path()
// ..fillType = PathFillType.evenOdd
// ..addRect(outerRect)
// ..addRect(innerRect);
// final Paint paint = new Paint()
// ..color = color;
// canvas.drawPath(path, paint);
Path path = new Path();
path.addRect(outerRect);
path.addRect(innerRect);
path.winding(PathWinding.clockwise);
var paint = new Paint {
color = color
};
canvas.drawPath(path, paint);
}
public static void debugPaintPadding(Canvas canvas, Rect outerRect, Rect innerRect, float outlineWidth = 2.0f) {

_debugDrawDoubleRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect,
new Color(0xFF0090FF));
_debugDrawDoubleRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect,
new Color(0xFF0090FF));
// canvas.drawRect(outerRect, BorderWidth.zero, BorderRadius.zero, paint);
canvas.drawRect(outerRect, paint);
public static void setDebugPaint(bool? debugPaintSizeEnabled = null,
bool? debugPaintBaselinesEnabled = null,
bool? debugPaintPointersEnabled= null,
bool? debugPaintLayerBordersEnabled = null,
bool? debugRepaintRainbowEnabled = null ) {
bool needRepaint = false;
if (debugPaintSizeEnabled != null && debugPaintSizeEnabled != D.debugPaintSizeEnabled) {
D.debugPaintSizeEnabled = debugPaintSizeEnabled.Value;
needRepaint = true;
}
if (debugPaintBaselinesEnabled != null && debugPaintBaselinesEnabled != D.debugPaintBaselinesEnabled) {
D.debugPaintBaselinesEnabled = debugPaintBaselinesEnabled.Value;
needRepaint = true;
}
if (debugPaintPointersEnabled != null && debugPaintPointersEnabled != D.debugPaintPointersEnabled) {
D.debugPaintPointersEnabled = debugPaintPointersEnabled.Value;
needRepaint = true;
}
if (debugPaintLayerBordersEnabled != null && debugPaintLayerBordersEnabled != D.debugPaintLayerBordersEnabled) {
D.debugPaintLayerBordersEnabled = debugPaintLayerBordersEnabled.Value;
needRepaint = true;
}
if (debugRepaintRainbowEnabled != null && debugRepaintRainbowEnabled != D.debugRepaintRainbowEnabled) {
D.debugRepaintRainbowEnabled = debugRepaintRainbowEnabled.Value;
needRepaint = true;
}
if (needRepaint) {
foreach (var adapter in WindowAdapter.windowAdapters) {
adapter._forceRepaint();
}
}
}
}
[Serializable]

return string.Join("\n", strippedLines);
}
}
}
}

2
Runtime/material/material.cs


public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<MaterialType>("type", this.type));
properties.add(new FloatProperty("elevation", this.elevation, defaultValue: 0.0));
properties.add(new FloatProperty("elevation", this.elevation, defaultValue: 0.0f));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor,
defaultValue: new Color(0xFF000000)));

99
Runtime/painting/colors.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
public class HSVColor {
HSVColor(float alpha, float hue, float saturation, float value) {
D.assert(this.alpha >= 0);
D.assert(this.alpha <= 1);
D.assert(hue >= 0);
D.assert(hue <= 360);
D.assert(saturation >= 0);
D.assert(saturation <= 1);
D.assert(value >= 0);
D.assert(value <= 1);
this.alpha = alpha;
this.hue = hue;
this.saturation = saturation;
this.value = value;
}
public static HSVColor fromAHSV(float alpha, float hue, float saturation, float value) {
return new HSVColor(alpha, hue, saturation, value);
}
public HSVColor withAlpha(float alpha) {
return fromAHSV(alpha, this.hue, this.saturation, this.value);
}
public HSVColor withHue(float hue) {
return fromAHSV(this.alpha, hue, this.saturation, this.value);
}
public HSVColor withSaturation(float saturation) {
return fromAHSV(this.alpha, this.hue, saturation, this.value);
}
public HSVColor withValue(float value) {
return fromAHSV(this.alpha, this.hue, this.saturation, value);
}
public Color toColor() {
float chroma = this.saturation * this.value;
float secondary = chroma * (1.0f - (((this.hue / 60.0f) % 2.0f) - 1.0f).abs());
float match = this.value - chroma;
return ColorUtils._colorFromHue(this.alpha, this.hue, chroma, secondary, match);
}
public readonly float alpha;
public readonly float hue;
public readonly float saturation;
public readonly float value;
}
public class ColorSwatch<T> : Color {
public ColorSwatch(
long primary,

public override string ToString() {
return this.GetType() + "(primary value: " + base.ToString() + ")";
}
}
public static class ColorUtils {
internal static Color _colorFromHue(
float alpha,
float hue,
float chroma,
float secondary,
float match
) {
float red;
float green;
float blue;
if (hue < 60.0) {
red = chroma;
green = secondary;
blue = 0.0f;
}
else if (hue < 120.0) {
red = secondary;
green = chroma;
blue = 0.0f;
}
else if (hue < 180.0) {
red = 0.0f;
green = chroma;
blue = secondary;
}
else if (hue < 240.0) {
red = 0.0f;
green = secondary;
blue = chroma;
}
else if (hue < 300.0) {
red = secondary;
green = 0.0f;
blue = chroma;
}
else {
red = chroma;
green = 0.0f;
blue = secondary;
}
return Color.fromARGB((alpha * 0xFF).round(),
((red + match) * 0xFF).round(),
((green + match) * 0xFF).round(), ((blue + match) * 0xFF).round());
}
}
}

56
Runtime/rendering/box.cs


D.assert(() => {
var paint = new Paint {
color = new Color(0xFF00FFFF),
strokeWidth = 1,
style = PaintingStyle.stroke,
// context.canvas.drawRect((offset & this.size).deflate(0.5),
// BorderWidth.all(1), BorderRadius.zero, paint);
context.canvas.drawRect((offset & this.size).deflate(0.5f), paint);
return true;
});
}

// final Paint paint = Paint()
// ..style = PaintingStyle.stroke
// ..strokeWidth = 0.25;
// Path path;
// // ideographic baseline
// final float baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
// if (baselineI != null) {
// paint.color = const Color (0xFFFFD000);
// path = Path();
// path.moveTo(offset.dx, offset.dy + baselineI);
// path.lineTo(offset.dx + size.width, offset.dy + baselineI);
// context.canvas.drawPath(path, paint);
// }
//
// // alphabetic baseline
// final float baselineA = getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
// if (baselineA != null) {
// paint.color = const Color (0xFF00FF00);
// path = Path();
// path.moveTo(offset.dx, offset.dy + baselineA);
// path.lineTo(offset.dx + size.width, offset.dy + baselineA);
// context.canvas.drawPath(path, paint);
// }
Paint paint = new Paint {
style = PaintingStyle.stroke,
strokeWidth = 0.25f
};
Path path;
// ideographic baseline
float? baselineI = this.getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
if (baselineI != null) {
paint.color = new Color(0xFFFFD000);
path = new Path();
path.moveTo(offset.dx, offset.dy + baselineI.Value);
path.lineTo(offset.dx + this.size.width, offset.dy + baselineI.Value);
context.canvas.drawPath(path, paint);
}
// alphabetic baseline
float? baselineA = this.getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
if (baselineA != null) {
paint.color = new Color (0xFF00FF00);
path = new Path();
path.moveTo(offset.dx, offset.dy + baselineA.Value);
path.lineTo(offset.dx + this.size.width, offset.dy + baselineA.Value);
context.canvas.drawPath(path, paint);
}
return true;
});

var paint = new Paint {
color = new Color(0x00BBBB | ((0x04000000 * this.depth) & 0xFF000000)),
};
// context.canvas.drawRect(offset & this.size, BorderWidth.zero, BorderRadius.zero, paint);
context.canvas.drawRect(offset & this.size, paint);
}
return true;

2
Runtime/rendering/image.cs


properties.add(new DiagnosticsProperty<Image>("image", this.image));
properties.add(new FloatProperty("width", this.width, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new FloatProperty("height", this.height, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new FloatProperty("scale", this.scale, defaultValue: 1.0));
properties.add(new FloatProperty("scale", this.scale, defaultValue: 1.0f));
properties.add(new DiagnosticsProperty<Color>("color", this.color,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", this.colorBlendMode,

22
Runtime/rendering/object.cs


D.assert(() => {
if (D.debugRepaintRainbowEnabled) {
// var Paint paint = Paint()
// ..style = PaintingStyle.stroke
// ..strokeWidth = 6.0
// ..color = debugCurrentRepaintColor.toColor();
// this.canvas.drawRect(this.estimatedBounds.deflate(3.0), paint);
var paint = new Paint {
style = PaintingStyle.stroke,
strokeWidth = 6.0f,
color = D.debugCurrentRepaintColor.toColor()
};
this.canvas.drawRect(this.estimatedBounds.deflate(3.0f), paint);
// final Paint paint = Paint()
// ..style = PaintingStyle.stroke
// ..strokeWidth = 1.0
// ..color = const Color(0xFFFF9800);
// this.canvas.drawRect(estimatedBounds, paint);
Paint paint = new Paint {
style = PaintingStyle.stroke,
strokeWidth = 1.0f,
color = new ui.Color(0xFFFF9800),
};
this.canvas.drawRect(this.estimatedBounds, paint);
}
return true;

2
Runtime/rendering/paragraph.cs


properties.add(new FlagProperty("softWrap", value: this.softWrap, ifTrue: "wrapping at box width",
ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextOverflow>("overflow", this.overflow));
properties.add(new FloatProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0));
properties.add(new FloatProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0f));
properties.add(new IntProperty("maxLines", this.maxLines, ifNull: "unlimited"));
}
}

3
Runtime/rendering/proxy_box.cs


var paint = new Paint {
color = new Color(0x90909090)
};
// context.canvas.drawRect(offset & this.size, BorderWidth.zero, BorderRadius.zero, paint);
context.canvas.drawRect(offset & this.size, paint);
return true;
});
}

109
Runtime/rendering/shifted_box.cs


}
protected override void debugPaintSize(PaintingContext context, Offset offset) {
base.debugPaintSize(context, offset);
base.debugPaintSize(context, offset);
// Path path;
// paint = Paint()
// ..style = PaintingStyle.stroke
// ..strokeWidth = 1.0
// ..color = const Color(0xFFFFFF00);
// path = Path();
// final BoxParentData childParentData = child.parentData;
// if (childParentData.offset.dy > 0.0) {
// // vertical alignment arrows
// final float headSize = math.min(childParentData.offset.dy * 0.2, 10.0);
// path
// ..moveTo(offset.dx + size.width / 2.0, offset.dy)
// ..relativeLineTo(0.0, childParentData.offset.dy - headSize)
// ..relativeLineTo(headSize, 0.0)
// ..relativeLineTo(-headSize, headSize)
// ..relativeLineTo(-headSize, -headSize)
// ..relativeLineTo(headSize, 0.0)
// ..moveTo(offset.dx + size.width / 2.0, offset.dy + size.height)
// ..relativeLineTo(0.0, -childParentData.offset.dy + headSize)
// ..relativeLineTo(headSize, 0.0)
// ..relativeLineTo(-headSize, -headSize)
// ..relativeLineTo(-headSize, headSize)
// ..relativeLineTo(headSize, 0.0);
// context.canvas.drawPath(path, paint);
// }
// if (childParentData.offset.dx > 0.0) {
// // horizontal alignment arrows
// final float headSize = math.min(childParentData.offset.dx * 0.2, 10.0);
// path
// ..moveTo(offset.dx, offset.dy + size.height / 2.0)
// ..relativeLineTo(childParentData.offset.dx - headSize, 0.0)
// ..relativeLineTo(0.0, headSize)
// ..relativeLineTo(headSize, -headSize)
// ..relativeLineTo(-headSize, -headSize)
// ..relativeLineTo(0.0, headSize)
// ..moveTo(offset.dx + size.width, offset.dy + size.height / 2.0)
// ..relativeLineTo(-childParentData.offset.dx + headSize, 0.0)
// ..relativeLineTo(0.0, headSize)
// ..relativeLineTo(-headSize, -headSize)
// ..relativeLineTo(headSize, -headSize)
// ..relativeLineTo(0.0, headSize);
// context.canvas.drawPath(path, paint);
// }
}
else {
// paint = Paint()
// ..color = const Color(0x90909090);
// context.canvas.drawRect(offset & size, paint);
Path path;
paint = new Paint {
style = PaintingStyle.stroke,
strokeWidth = 1.0f,
color = new ui.Color(0xFFFFFF00)
};
BoxParentData childParentData = (BoxParentData) this.child.parentData;
if (childParentData.offset.dy > 0) {
float headSize = Mathf.Min(childParentData.offset.dy * 0.2f, 10.0f);
float x = offset.dx + this.size.width / 2.0f;
float y = offset.dy;
path = new Path();
path.moveTo(x, y);
path.lineTo(x += 0.0f, y += childParentData.offset.dy - headSize);
path.lineTo(x += headSize, y += 0.0f);
path.lineTo(x += -headSize, y += headSize);
path.lineTo(x += -headSize, y += -headSize);
path.lineTo(x += headSize, y += 0.0f);
x = offset.dx + this.size.width / 2.0f;
y = offset.dy + this.size.height;
path.moveTo(x, y);
path.lineTo(x += 0.0f, y += -childParentData.offset.dy + headSize);
path.lineTo(x += headSize, y += 0.0f);
path.lineTo(x += -headSize, y += -headSize);
path.lineTo(x += -headSize, y += headSize);
path.lineTo(x += headSize, y += 0.0f);
context.canvas.drawPath(path, paint);
}
if (childParentData.offset.dx > 0.0) {
float headSize = Mathf.Min(childParentData.offset.dx * 0.2f, 10.0f);
float x = offset.dx;
float y = offset.dy + this.size.height / 2.0f;
path = new Path();
path.moveTo(x, y);
path.lineTo(x += childParentData.offset.dx - headSize, y += 0.0f);
path.lineTo(x += 0.0f, y += headSize);
path.lineTo(x += headSize, y += -headSize);
path.lineTo(x += -headSize, y += -headSize);
path.lineTo(x += 0.0f, y += headSize);
path.moveTo(x = offset.dx + this.size.width, y = offset.dy + this.size.height / 2.0f);
path.lineTo(x += -childParentData.offset.dx + headSize, y += 0.0f);
path.lineTo(x += 0.0f, y += headSize);
path.lineTo(x += -headSize, y += -headSize);
path.lineTo(x += headSize, y += -headSize);
path.lineTo(x += 0.0f, y += headSize);
path.close();
context.canvas.drawPath(path, paint);
}
} else {
paint = new Paint {
color = new ui.Color(0x90909090),
};
context.canvas.drawRect(offset & this.size, paint);
}
return true;

7
Runtime/rendering/view.cs


}
D.assert(() => {
// if (D.debugRepaintRainbowEnabled || D.debugRepaintTextRainbowEnabled) {
// debugCurrentRepaintColor =
// debugCurrentRepaintColor.withHue((debugCurrentRepaintColor.hue + 2.0) % 360.0);
// }
if (D.debugRepaintRainbowEnabled || D.debugRepaintTextRainbowEnabled) {
D.debugCurrentRepaintColor = D.debugCurrentRepaintColor.withHue((D.debugCurrentRepaintColor.hue + 2.0f) % 360.0f);
}
return true;
});

7
Runtime/rendering/viewport.cs


base.debugPaintSize(context, offset);
Paint paint = new Paint {
color = new Color(0xFF00FF00)
color = new Color(0xFF00FF00),
strokeWidth = 1.0f,
style = PaintingStyle.stroke,
};
Canvas canvas = context.canvas;

}
D.assert(size != null);
// canvas.drawRect(((offset + this.paintOffsetOf(child)) & size).deflate(0.5),
// BorderWidth.all(1), BorderRadius.zero, paint);
canvas.drawRect(((offset + this.paintOffsetOf(child)) & size).deflate(0.5f), paint);
child = this.childAfter(child);
}

4
Runtime/widgets/basic.cs


properties.add(new FlagProperty("softWrap", value: this.softWrap, ifTrue: "wrapping at box width",
ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextOverflow>("overflow", this.overflow, defaultValue: TextOverflow.clip));
properties.add(new FloatProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0));
properties.add(new FloatProperty("textScaleFactor", this.textScaleFactor, defaultValue: 1.0f));
properties.add(new IntProperty("maxLines", this.maxLines, ifNull: "unlimited"));
properties.add(new StringProperty("text", this.text.toPlainText()));
}

properties.add(new DiagnosticsProperty<ui.Image>("image", this.image));
properties.add(new FloatProperty("width", this.width, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new FloatProperty("height", this.height, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new FloatProperty("scale", this.scale, defaultValue: 1.0));
properties.add(new FloatProperty("scale", this.scale, defaultValue: 1.0f));
properties.add(new DiagnosticsProperty<Color>("color", this.color,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", this.colorBlendMode,

11
Editor/editor/WidgetCanvasEditor.cs.meta


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

7
UIWidgetCleanupPlugin.DotSettings.meta


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