浏览代码

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

/main
xingwei.zhu 5 年前
当前提交
ecc57ee8
共有 64 个文件被更改,包括 2958 次插入556 次删除
  1. 5
      README-ZH.md
  2. 5
      README.md
  3. 4
      Runtime/Unity.UIWidgets.asmdef
  4. 11
      Runtime/animation/tween.cs
  5. 9
      Runtime/engine/UIWidgetsPanel.cs
  6. 27
      Runtime/foundation/basic_types.cs
  7. 8
      Runtime/foundation/key.cs
  8. 2
      Runtime/gestures/constants.cs
  9. 4
      Runtime/gestures/converter.cs
  10. 1
      Runtime/material/mergeable_material.cs
  11. 232
      Runtime/material/slider.cs
  12. 213
      Runtime/material/slider_theme.cs
  13. 2
      Runtime/material/text_field.cs
  14. 2
      Runtime/material/user_accounts_drawer_header.cs
  15. 17
      Runtime/painting/basic_types.cs
  16. 5
      Runtime/rendering/editable.cs
  17. 4
      Runtime/rendering/paragraph.cs
  18. 5
      Runtime/service/text_formatter.cs
  19. 61
      Runtime/ui/matrix.cs
  20. 72
      Runtime/ui/painting/canvas_clip.cs
  21. 13
      Runtime/ui/painting/canvas_impl.cs
  22. 155
      Runtime/ui/painting/path.cs
  23. 2
      Runtime/ui/painting/shadow_utils.cs
  24. 14
      Runtime/ui/painting/tessellation_generator.cs
  25. 187
      Runtime/ui/painting/txt/font_manager.cs
  26. 12
      Runtime/ui/painting/txt/mesh_generator.cs
  27. 2
      Runtime/ui/text.cs
  28. 58
      Runtime/ui/txt/layout.cs
  29. 15
      Runtime/ui/txt/linebreaker.cs
  30. 4
      Runtime/ui/txt/paint_record.cs
  31. 7
      Runtime/ui/txt/paragraph.cs
  32. 4
      Runtime/ui/txt/text_buff.cs
  33. 2
      Runtime/ui/txt/wordbreaker.cs
  34. 34
      Runtime/widgets/basic.cs
  35. 11
      Runtime/widgets/drag_target.cs
  36. 34
      Runtime/widgets/form.cs
  37. 80
      Runtime/widgets/gesture_detector.cs
  38. 10
      Runtime/widgets/implicit_animations.cs
  39. 1
      Runtime/widgets/single_child_scroll_view.cs
  40. 12
      Samples/UIWidgetSample/MaterialSample.cs
  41. 8
      Samples/UIWidgetSample/txt/TextFieldSample.cs
  42. 8
      Runtime/InternalBridge.meta
  43. 110
      Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib.meta
  44. 1001
      Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib
  45. 110
      Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib.meta
  46. 412
      Runtime/gestures/scale.cs
  47. 11
      Runtime/gestures/scale.cs.meta
  48. 156
      Runtime/material/text_form_field.cs
  49. 3
      Runtime/material/text_form_field.cs.meta
  50. 127
      Runtime/rendering/rotated_box.cs
  51. 3
      Runtime/rendering/rotated_box.cs.meta
  52. 23
      Runtime/ui/painting/ArrayRef.cs
  53. 11
      Runtime/ui/painting/ArrayRef.cs.meta
  54. 64
      Samples/UIWidgetSample/ScaleGestureSample.cs
  55. 11
      Samples/UIWidgetSample/ScaleGestureSample.cs.meta
  56. 12
      Runtime/InternalBridge/InternalBridge.asmdef
  57. 7
      Runtime/InternalBridge/InternalBridge.asmdef.meta
  58. 35
      Runtime/InternalBridge/NoAllocHelpersBridge.cs
  59. 11
      Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta
  60. 37
      Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib.meta
  61. 8
      Runtime/utils.meta
  62. 0
      /Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib

5
README-ZH.md


#### 八、WebGL Canvas分辨率调整插件
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib`解决了这个问题。
如果您因为任何原因需要禁止此插件,请在Project面板中选中该插件,在Inspector面板中的Define Constraints参数中,输入任意(没有被Unity定义为宏)的字符串(例如`ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`),使得只有在Player Settings中定义了这个宏,此插件才会启用。
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib`(目前有2018.3和2019.1)解决了这个问题。
请根据您的项目的Unity版本选择对应的插件,并禁用此插件的其他版本。方法如下:在Project面板中选中该插件,在Inspector面板中的Select platforms for plugin中,去掉WebGL后面的对勾。
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
此插件覆盖了Unity WebGL构建模块中的如下参数:
```

5
README.md


#### WebGL Canvas Device Pixel Ratio Plugin
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
Therefore, the image may blur in the builded WebGL program.
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib` solves this issue.
If you need to disable this plugin for any reason, please select this plugin in the **Project** panel, and put an arbitrary string (that is not defined as a macro by Unity) in the **Define Constraints** field in the **Inspector** panel (for example, `ENABLE_CANVAS_DEVICE_PIXEL_RATIO_PLUGIN`), so that the plugin is enabled only if this macro is defined in **Player Settings**, which effectively disables the plugin.
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib` (2018.3 and 2019.1 for now) solves this issue.
Please select the plugin of the Unity version corresponding to your project, and disable other versions of this plugin, as follows: select this plugin in the **Project** panel, and uncheck **WebGL** under **Select platforms for plugin** in the **Inspector** panel.
If you need to disable this plugin for any reason, please disable all the versions of this plugin as described above.
This plugin overrides the following parameters in the Unity WebGL building module:
```

4
Runtime/Unity.UIWidgets.asmdef


{
"name": "Unity.UIWidgets",
"references": [],
"references": [
"Unity.InternalAPIEngineBridge.024"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],

11
Runtime/animation/tween.cs


}
}
public class NullableFloatTween : Tween<float?> {
public NullableFloatTween(float? begin = null, float? end = null) : base(begin: begin, end: end) {
}
public override float? lerp(float t) {
D.assert(this.begin != null);
D.assert(this.end != null);
return this.begin + (this.end - this.begin) * t;
}
}
public class FloatTween : Tween<float> {
public FloatTween(float begin, float end) : base(begin: begin, end: end) {
}

9
Runtime/engine/UIWidgetsPanel.cs


protected virtual Widget createWidget() {
return null;
}
public void recreateWidget() {
Widget root;
using (this._windowAdapter.getScope()) {
root = this.createWidget();
}
this._windowAdapter.attachRootWidget(root);
}
internal void applyRenderTexture(Rect screenRect, Texture texture, Material mat) {
this.texture = texture;

27
Runtime/foundation/basic_types.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.InternalBridge;
using UnityEngine;
using Object = UnityEngine.Object;

return "{ " + string.Join(", ", it.Select(item => item.ToString())) + " }";
}
public static void resize<T>(this List<T> list, int size, T value) {
int curSize = list.Count;
if (size < curSize) {
list.RemoveRange(size, curSize - size);
} else if(size > curSize) {
if (size > list.Capacity) {
list.Capacity = size;
}
list.AddRange(Enumerable.Repeat(value, size - curSize));
}
int remains = Math.Min(curSize, size);
for (int i = 0; i < remains; ++i) {
list[i] = value;
}
public static void reset<T>(this List<T> list, int size) {
NoAllocHelpersBridge<T>.EnsureListElemCount(list, size);
}
public static ref T refAt<T>(this List<T> list, int index) {
var array = NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
return ref array[index];
}
public static T[] array<T>(this List<T> list) {
return NoAllocHelpersBridge<T>.ExtractArrayFromListT(list);
}
}
}

8
Runtime/foundation/key.cs


public static Key key(string value) {
return new ValueKey<string>(value);
}
public static bool operator ==(Key left, Key right) {
return Equals(left, right);
}
public static bool operator !=(Key left, Key right) {
return !Equals(left, right);
}
}
public abstract class LocalKey : Key {

2
Runtime/gestures/constants.cs


public const float kPanSlop = kTouchSlop * 2.0f;
public const float kScaleSlop = kTouchSlop;
public static readonly TimeSpan kPressTimeout = new TimeSpan(0, 0, 0, 0, 100);
public static readonly TimeSpan kDoubleTapTimeout = new TimeSpan(0, 0, 0, 0, 300);

4
Runtime/gestures/converter.cs


switch (datum.change) {
case PointerChange.down: {
_PointerState state = _ensureStateForPointer(datum, position);
D.assert(!state.down);
if (state.down) {
break;
}
if (state.lastPosition != position) {
// a hover event to be here.
state.lastPosition = position;

1
Runtime/material/mergeable_material.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.utils;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {

232
Runtime/material/slider.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;

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;

}
class _RenderSlider : RenderBox {
static float _positionAnimationDurationMilliSeconds = 75;
static float _minimumInteractionTimeMilliSeconds = 500;
const float _minPreferredTrackWidth = 144.0f;
public _RenderSlider(
float? value = null,
int? divisions = null,

curve: Curves.easeInOut);
}
const float _positionAnimationDurationMilliSeconds = 75;
const float _overlayRadius = 16.0f;
const float _overlayDiameter = _overlayRadius * 2.0f;
const float _trackHeight = 2.0f;
const float _preferredTrackWidth = 144.0f;
const float _preferredTotalWidth = _preferredTrackWidth + _overlayDiameter;
const float _minimumInteractionTimeMilliSeconds = 500;
static readonly Animatable<float> _overlayRadiusTween = new FloatTween(begin: 0.0f, end: _overlayRadius);
float _maxSliderPartWidth {
get {
float maxValue = 0;
foreach (Size size in this._sliderPartSizes) {
if (size.width > maxValue) {
maxValue = size.width;
}
}
return maxValue;
}
}
float _maxSliderPartHeight {
get {
float maxValue = 0;
foreach (Size size in this._sliderPartSizes) {
if (size.width > maxValue) {
maxValue = size.width;
}
}
return maxValue;
}
}
List<Size> _sliderPartSizes {
get {
return new List<Size> {
this._sliderTheme.overlayShape.getPreferredSize(this.isInteractive, this.isDiscrete),
this._sliderTheme.thumbShape.getPreferredSize(this.isInteractive, this.isDiscrete),
this._sliderTheme.tickMarkShape.getPreferredSize(isEnabled: this.isInteractive,
sliderTheme: this.sliderTheme)
};
}
}
float _minPreferredTrackHeight {
get { return this._sliderTheme.trackHeight; }
}
_SliderState _state;
Animation<float> _overlayAnimation;

bool _active = false;
float _currentDragValue = 0.0f;
float _trackLength {
get { return this.size.width - _overlayDiameter; }
Rect _trackRect {
get {
return this._sliderTheme.trackShape.getPreferredRect(
parentBox: this,
offset: Offset.zero,
sliderTheme: this._sliderTheme,
isDiscrete: false
);
}
}
bool isInteractive {

float _getValueFromGlobalPosition(Offset globalPosition) {
float visualPosition =
(this.globalToLocal(globalPosition).dx - _overlayRadius) / this._trackLength;
(this.globalToLocal(globalPosition).dx - this._trackRect.left) / this._trackRect.width;
return this._getValueFromVisualPosition(visualPosition);
}

result = (result * this.divisions.Value).round() / this.divisions.Value;
result = (result * this.divisions.Value).round() * 1.0f / this.divisions.Value;
}
return result;

this._state.valueIndicatorController.status == AnimationStatus.completed) {
this._state.valueIndicatorController.reverse();
}
});
}
);
}
}
}

void _handleDragUpdate(DragUpdateDetails details) {
if (this.isInteractive) {
float valueDelta = details.primaryDelta.Value / this._trackLength;
float valueDelta = details.primaryDelta.Value / this._trackRect.width;
this._currentDragValue += valueDelta;
this.onChanged(this._discretize(this._currentDragValue));
}

protected override float computeMinIntrinsicWidth(float height) {
return Mathf.Max(_overlayDiameter,
this._sliderTheme.thumbShape.getPreferredSize(this.isInteractive, this.isDiscrete).width);
return _minPreferredTrackWidth + this._maxSliderPartWidth;
return _preferredTotalWidth;
return _minPreferredTrackWidth + this._maxSliderPartWidth;
return _overlayDiameter;
return Mathf.Max(this._minPreferredTrackHeight, this._maxSliderPartHeight);
return _overlayDiameter;
return Mathf.Max(this._minPreferredTrackHeight, this._maxSliderPartHeight);
}
protected override bool sizedByParent {

this.size = new Size(
this.constraints.hasBoundedWidth
? this.constraints.maxWidth
: _preferredTotalWidth,
: _minPreferredTrackWidth + this._maxSliderPartWidth,
: _overlayDiameter
: Mathf.Max(this._minPreferredTrackHeight, this._maxSliderPartHeight)
void _paintTickMarks(
Canvas canvas,
Rect trackLeft,
Rect trackRight,
Paint leftPaint,
Paint rightPaint) {
if (this.isDiscrete) {
const float tickRadius = _trackHeight / 2.0f;
float trackWidth = trackRight.right - trackLeft.left;
float dx = (trackWidth - _trackHeight) / this.divisions.Value;
if (dx >= 3.0 * _trackHeight) {
for (int i = 0; i <= this.divisions.Value; i += 1) {
float left = trackLeft.left + i * dx;
Offset center = new Offset(left + tickRadius, trackLeft.top + tickRadius);
if (trackLeft.contains(center)) {
canvas.drawCircle(center, tickRadius, leftPaint);
}
else if (trackRight.contains(center)) {
canvas.drawCircle(center, tickRadius, rightPaint);
}
}
}
}
}
void _paintOverlay(
Canvas canvas,
Offset center) {
Paint overlayPaint = new Paint {color = this._sliderTheme.overlayColor};
float radius = _overlayRadiusTween.evaluate(this._overlayAnimation);
canvas.drawCircle(center, radius, overlayPaint);
}
Canvas canvas = context.canvas;
float trackLength = this.size.width - 2 * _overlayRadius;
ColorTween activeTrackEnableColor = new ColorTween(begin: this._sliderTheme.disabledActiveTrackColor,
end: this._sliderTheme.activeTrackColor);
ColorTween inactiveTrackEnableColor = new ColorTween(begin: this._sliderTheme.disabledInactiveTrackColor,
end: this._sliderTheme.inactiveTrackColor);
ColorTween activeTickMarkEnableColor = new ColorTween(begin: this._sliderTheme.disabledActiveTickMarkColor,
end: this._sliderTheme.activeTickMarkColor);
ColorTween inactiveTickMarkEnableColor =
new ColorTween(begin: this._sliderTheme.disabledInactiveTickMarkColor,
end: this._sliderTheme.inactiveTickMarkColor);
Paint activeTrackPaint = new Paint {color = activeTrackEnableColor.evaluate(this._enableAnimation)};
Paint inactiveTrackPaint = new Paint {color = inactiveTrackEnableColor.evaluate(this._enableAnimation)};
Paint activeTickMarkPaint = new Paint {color = activeTickMarkEnableColor.evaluate(this._enableAnimation)};
Paint inactiveTickMarkPaint = new Paint
{color = inactiveTickMarkEnableColor.evaluate(this._enableAnimation)};
Paint leftTrackPaint = activeTrackPaint;
Paint rightTrackPaint = inactiveTrackPaint;
Paint leftTickMarkPaint = activeTickMarkPaint;
Paint rightTickMarkPaint = inactiveTickMarkPaint;
float trackRadius = _trackHeight / 2.0f;
float thumbGap = 2.0f;
Rect trackRect = this._sliderTheme.trackShape.getPreferredRect(
parentBox: this,
offset: offset,
sliderTheme: this._sliderTheme,
isDiscrete: this.isDiscrete
);
float trackVerticalCenter = offset.dy + (this.size.height) / 2.0f;
float trackLeft = offset.dx + _overlayRadius;
float trackTop = trackVerticalCenter - trackRadius;
float trackBottom = trackVerticalCenter + trackRadius;
float trackRight = trackLeft + trackLength;
float trackActive = trackLeft + trackLength * visualPosition;
float thumbRadius =
this._sliderTheme.thumbShape.getPreferredSize(this.isInteractive, this.isDiscrete).width / 2.0f;
float trackActiveLeft = Mathf.Max(0.0f,
trackActive - thumbRadius - thumbGap * (1.0f - this._enableAnimation.value));
float trackActiveRight =
Mathf.Min(trackActive + thumbRadius + thumbGap * (1.0f - this._enableAnimation.value), trackRight);
Rect trackLeftRect = Rect.fromLTRB(trackLeft, trackTop, trackActiveLeft, trackBottom);
Rect trackRightRect = Rect.fromLTRB(trackActiveRight, trackTop, trackRight, trackBottom);
Offset thumbCenter = new Offset(trackRect.left + visualPosition * trackRect.width, trackRect.center.dy);
Offset thumbCenter = new Offset(trackActive, trackVerticalCenter);
if (visualPosition > 0.0) {
canvas.drawRect(trackLeftRect, leftTrackPaint);
}
this._sliderTheme.trackShape.paint(
context,
offset,
parentBox: this,
sliderTheme: this._sliderTheme,
enableAnimation: this._enableAnimation,
thumbCenter: thumbCenter,
isDiscrete: this.isDiscrete,
isEnabled: this.isInteractive
);
if (visualPosition < 1.0) {
canvas.drawRect(trackRightRect, rightTrackPaint);
if (!this._overlayAnimation.isDismissed) {
this._sliderTheme.overlayShape.paint(
context,
thumbCenter,
activationAnimation: this._overlayAnimation,
enableAnimation: this._enableAnimation,
isDiscrete: this.isDiscrete,
labelPainter: this._labelPainter,
parentBox: this,
sliderTheme: this._sliderTheme,
value: this._value
);
this._paintOverlay(canvas, thumbCenter);
if (this.isDiscrete) {
float tickMarkWidth = this._sliderTheme.tickMarkShape.getPreferredSize(
isEnabled: this.isInteractive,
sliderTheme: this._sliderTheme
).width;
this._paintTickMarks(
canvas,
trackLeftRect,
trackRightRect,
leftTickMarkPaint,
rightTickMarkPaint
);
if ((trackRect.width - tickMarkWidth) / this.divisions.Value >= 3.0f * tickMarkWidth) {
for (int i = 0; i <= this.divisions; i++) {
float tickValue = i / this.divisions.Value;
float tickX = trackRect.left +
tickValue * (trackRect.width - tickMarkWidth) + tickMarkWidth / 2;
float tickY = trackRect.center.dy;
Offset tickMarkOffset = new Offset(tickX, tickY);
this._sliderTheme.tickMarkShape.paint(
context,
tickMarkOffset,
parentBox: this,
sliderTheme: this._sliderTheme,
enableAnimation: this._enableAnimation,
thumbCenter: thumbCenter,
isEnabled: this.isInteractive
);
}
}
}
if (this.isInteractive && this.label != null &&
this._valueIndicatorAnimation.status != AnimationStatus.dismissed) {
if (this.isInteractive && this.label != null && !this._valueIndicatorAnimation.isDismissed) {
if (this.showValueIndicator) {
this._sliderTheme.valueIndicatorShape.paint(
context,

213
Runtime/material/slider_theme.cs


public class SliderThemeData : Diagnosticable {
public SliderThemeData(
float? trackHeight = null,
Color activeTrackColor = null,
Color inactiveTrackColor = null,
Color disabledActiveTrackColor = null,

Color disabledThumbColor = null,
Color overlayColor = null,
Color valueIndicatorColor = null,
SliderTrackShape trackShape = null,
SliderTickMarkShape tickMarkShape = null,
SliderComponentShape overlayShape = null,
D.assert(trackHeight != null);
D.assert(activeTrackColor != null);
D.assert(inactiveTrackColor != null);
D.assert(disabledActiveTrackColor != null);

D.assert(disabledThumbColor != null);
D.assert(overlayColor != null);
D.assert(valueIndicatorColor != null);
D.assert(trackShape != null);
D.assert(tickMarkShape != null);
D.assert(overlayShape != null);
this.trackHeight = trackHeight.Value;
this.activeTrackColor = activeTrackColor;
this.inactiveTrackColor = inactiveTrackColor;
this.disabledActiveTrackColor = disabledActiveTrackColor;

this.disabledThumbColor = disabledThumbColor;
this.overlayColor = overlayColor;
this.valueIndicatorColor = valueIndicatorColor;
this.trackShape = trackShape;
this.tickMarkShape = tickMarkShape;
this.overlayShape = overlayShape;
this.valueIndicatorShape = valueIndicatorShape;
this.showValueIndicator = showValueIndicator.Value;
this.valueIndicatorTextStyle = valueIndicatorTextStyle;

const int overlayLightAlpha = 0x29;
return new SliderThemeData(
trackHeight: 2.0f,
activeTrackColor: primaryColor.withAlpha(activeTrackAlpha),
inactiveTrackColor: primaryColor.withAlpha(inactiveTrackAlpha),
disabledActiveTrackColor: primaryColorDark.withAlpha(disabledActiveTrackAlpha),

disabledThumbColor: primaryColorDark.withAlpha(disabledThumbAlpha),
overlayColor: primaryColor.withAlpha(overlayLightAlpha),
valueIndicatorColor: primaryColor.withAlpha(valueIndicatorAlpha),
trackShape: new RectangularSliderTrackShape(),
tickMarkShape: new RoundSliderTickMarkShape(),
overlayShape: new RoundSliderOverlayShape(),
public readonly float trackHeight;
public readonly Color activeTrackColor;

public readonly Color valueIndicatorColor;
public readonly SliderTrackShape trackShape;
public readonly SliderTickMarkShape tickMarkShape;
public readonly SliderComponentShape overlayShape;
public readonly SliderComponentShape thumbShape;
public readonly SliderComponentShape valueIndicatorShape;

TextStyle valueIndicatorTextStyle = null
) {
return new SliderThemeData(
trackHeight: trackHeight ?? this.trackHeight,
activeTrackColor: activeTrackColor ?? this.activeTrackColor,
inactiveTrackColor: inactiveTrackColor ?? this.inactiveTrackColor,
disabledActiveTrackColor: disabledActiveTrackColor ?? this.disabledActiveTrackColor,

disabledThumbColor: disabledThumbColor ?? this.disabledThumbColor,
overlayColor: overlayColor ?? this.overlayColor,
valueIndicatorColor: valueIndicatorColor ?? this.valueIndicatorColor,
trackShape: trackShape ?? this.trackShape,
tickMarkShape: tickMarkShape ?? this.tickMarkShape,
overlayShape: overlayShape ?? this.overlayShape,
valueIndicatorShape: valueIndicatorShape ?? this.valueIndicatorShape,
showValueIndicator: showValueIndicator ?? this.showValueIndicator,
valueIndicatorTextStyle: valueIndicatorTextStyle ?? this.valueIndicatorTextStyle

D.assert(a != null);
D.assert(b != null);
return new SliderThemeData(
trackHeight: MathUtils.lerpFloat(a.trackHeight, b.trackHeight, t),
activeTrackColor: Color.lerp(a.activeTrackColor, b.activeTrackColor, t),
inactiveTrackColor: Color.lerp(a.inactiveTrackColor, b.inactiveTrackColor, t),
disabledActiveTrackColor: Color.lerp(a.disabledActiveTrackColor, b.disabledActiveTrackColor, t),

disabledThumbColor: Color.lerp(a.disabledThumbColor, b.disabledThumbColor, t),
overlayColor: Color.lerp(a.overlayColor, b.overlayColor, t),
valueIndicatorColor: Color.lerp(a.valueIndicatorColor, b.valueIndicatorColor, t),
trackShape: t < 0.5 ? a.trackShape : b.trackShape,
tickMarkShape: t < 0.5 ? a.tickMarkShape : b.tickMarkShape,
overlayShape: t < 0.5 ? a.overlayShape : b.overlayShape,
valueIndicatorShape: t < 0.5 ? a.valueIndicatorShape : b.valueIndicatorShape,
showValueIndicator: t < 0.5 ? a.showValueIndicator : b.showValueIndicator,
valueIndicatorTextStyle: TextStyle.lerp(a.valueIndicatorTextStyle, b.valueIndicatorTextStyle, t)

return true;
}
return other.activeTrackColor == this.activeTrackColor
return other.trackHeight == this.trackHeight
&& other.activeTrackColor == this.activeTrackColor
&& other.inactiveTrackColor == this.inactiveTrackColor
&& other.disabledActiveTrackColor == this.disabledActiveTrackColor
&& other.disabledInactiveTrackColor == this.disabledInactiveTrackColor

&& other.disabledThumbColor == this.disabledThumbColor
&& other.overlayColor == this.overlayColor
&& other.valueIndicatorColor == this.valueIndicatorColor
&& other.trackShape == this.trackShape
&& other.tickMarkShape == this.tickMarkShape
&& other.overlayShape == this.overlayShape
&& other.valueIndicatorShape == this.valueIndicatorShape
&& other.showValueIndicator == this.showValueIndicator
&& other.valueIndicatorTextStyle == this.valueIndicatorTextStyle;

}
unchecked {
var hashCode = this.activeTrackColor.GetHashCode();
var hashCode = this.trackHeight.GetHashCode();
hashCode = (hashCode * 397) ^ this.activeTrackColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.inactiveTrackColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.disabledActiveTrackColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.disabledInactiveTrackColor.GetHashCode();

hashCode = (hashCode * 397) ^ this.disabledThumbColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.overlayColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.valueIndicatorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.trackShape.GetHashCode();
hashCode = (hashCode * 397) ^ this.tickMarkShape.GetHashCode();
hashCode = (hashCode * 397) ^ this.overlayShape.GetHashCode();
hashCode = (hashCode * 397) ^ this.valueIndicatorShape.GetHashCode();
hashCode = (hashCode * 397) ^ this.showValueIndicator.GetHashCode();
hashCode = (hashCode * 397) ^ this.valueIndicatorTextStyle.GetHashCode();

defaultValue: defaultData.overlayColor, level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<Color>("valueIndicatorColor", this.valueIndicatorColor,
defaultValue: defaultData.valueIndicatorColor));
properties.add(new DiagnosticsProperty<SliderTrackShape>("trackShape", this.trackShape,
defaultValue: defaultData.trackShape, level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<SliderTickMarkShape>("tickMarkShape", this.tickMarkShape,
defaultValue: defaultData.tickMarkShape, level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<SliderComponentShape>("overlayShape", this.overlayShape,
defaultValue: defaultData.overlayShape, level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<SliderComponentShape>("valueIndicatorShape",
this.valueIndicatorShape, defaultValue: defaultData.valueIndicatorShape, level: DiagnosticLevel.debug));
properties.add(new EnumProperty<ShowValueIndicator>("showValueIndicator", this.showValueIndicator,

public abstract void paint(
PaintingContext context,
Offset thumbCenter,
Offset center,
Animation<float> activationAnimation = null,
Animation<float> enableAnimation = null,
bool? isDiscrete = null,

public override void paint(
PaintingContext context,
Offset thumbCenter,
Offset center,
Animation<float> activationAnimation = null,
Animation<float> enableAnimation = null,
bool? isDiscrete = null,

}
}
public class RectangularSliderTrackShape : SliderTrackShape {
public RectangularSliderTrackShape(
float disabledThumbGapWidth = 2.0f) {
this.disabledThumbGapWidth = disabledThumbGapWidth;
}
public readonly float disabledThumbGapWidth;
public override Rect getPreferredRect(
RenderBox parentBox = null,
Offset offset = null,
SliderThemeData sliderTheme = null,
bool? isEnabled = null,
bool? isDiscrete = null) {
float overlayWidth = sliderTheme.overlayShape.getPreferredSize(isEnabled, isDiscrete).width;
float trackHeight = sliderTheme.trackHeight;
D.assert(overlayWidth >= 0);
D.assert(trackHeight >= 0);
D.assert(parentBox.size.width >= overlayWidth);
D.assert(parentBox.size.height >= trackHeight);
float trackLeft = offset.dx + overlayWidth / 2f;
float trackTop = offset.dy + (parentBox.size.height - trackHeight) / 2f;
float trackWidth = parentBox.size.width - overlayWidth;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
}
public override void paint(
PaintingContext context,
Offset offset,
RenderBox parentBox = null,
SliderThemeData sliderTheme = null,
Animation<float> enableAnimation = null,
Offset thumbCenter = null,
bool? isEnabled = null,
bool? isDiscrete = null) {
if (sliderTheme.trackHeight == 0) {
return;
}
ColorTween activeTrackColorTween = new ColorTween(begin: sliderTheme.disabledActiveTrackColor,
end: sliderTheme.activeTrackColor);
ColorTween inactiveTrackColorTween = new ColorTween(begin: sliderTheme.disabledInactiveTrackColor,
end: sliderTheme.inactiveTrackColor);
Paint activePaint = new Paint {color = activeTrackColorTween.evaluate(enableAnimation)};
Paint inactivePaint = new Paint {color = inactiveTrackColorTween.evaluate(enableAnimation)};
Paint leftTrackPaint = activePaint;
Paint rightTrackPaint = inactivePaint;
float horizontalAdjustment = 0.0f;
if (!isEnabled.Value) {
float disabledThumbRadius = sliderTheme.thumbShape.getPreferredSize(false, isDiscrete).width / 2.0f;
float gap = this.disabledThumbGapWidth * (1.0f - enableAnimation.value);
horizontalAdjustment = disabledThumbRadius + gap;
}
Rect trackRect = this.getPreferredRect(
parentBox: parentBox,
offset: offset,
sliderTheme: sliderTheme,
isEnabled: isEnabled,
isDiscrete: isDiscrete
);
Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, thumbCenter.dx - horizontalAdjustment,
trackRect.bottom);
context.canvas.drawRect(leftTrackSegment, leftTrackPaint);
Rect rightTrackSegment = Rect.fromLTRB(thumbCenter.dx + horizontalAdjustment, trackRect.top,
trackRect.right, trackRect.bottom);
context.canvas.drawRect(rightTrackSegment, rightTrackPaint);
}
}
public class RoundSliderTickMarkShape : SliderTickMarkShape {
public RoundSliderTickMarkShape(
float? tickMarkRadius = null) {
this.tickMarkRadius = tickMarkRadius;
}
public readonly float? tickMarkRadius;
public override Size getPreferredSize(
SliderThemeData sliderTheme = null,
bool? isEnabled = null
) {
return Size.fromRadius(this.tickMarkRadius ?? sliderTheme.trackHeight / 2f);
}
public override void paint(
PaintingContext context,
Offset center,
RenderBox parentBox = null,
SliderThemeData sliderTheme = null,
Animation<float> enableAnimation = null,
Offset thumbCenter = null,
bool? isEnabled = null
) {
Color begin;
Color end;
bool isTickMarkRightOfThumb = center.dx > thumbCenter.dx;
begin = isTickMarkRightOfThumb
? sliderTheme.disabledInactiveTickMarkColor
: sliderTheme.disabledActiveTickMarkColor;
end = isTickMarkRightOfThumb ? sliderTheme.inactiveTickMarkColor : sliderTheme.activeTickMarkColor;
Paint paint = new Paint {color = new ColorTween(begin: begin, end: end).evaluate(enableAnimation)};
float tickMarkRadius = this.getPreferredSize(
isEnabled: isEnabled,
sliderTheme: sliderTheme
).width / 2f;
context.canvas.drawCircle(center, tickMarkRadius, paint);
}
}
public class RoundSliderThumbShape : SliderComponentShape {
public RoundSliderThumbShape(
float enabledThumbRadius = 6.0f,

}
}
public class RoundSliderOverlayShape : SliderComponentShape {
public RoundSliderOverlayShape(
float overlayRadius = 16.0f) {
this.overlayRadius = overlayRadius;
}
public readonly float overlayRadius;
public override Size getPreferredSize(bool? isEnabled, bool? isDiscrete) {
return Size.fromRadius(this.overlayRadius);
}
public override void paint(
PaintingContext context,
Offset center,
Animation<float> activationAnimation = null,
Animation<float> enableAnimation = null,
bool? isDiscrete = null,
TextPainter labelPainter = null,
RenderBox parentBox = null,
SliderThemeData sliderTheme = null,
float? value = null
) {
Canvas canvas = context.canvas;
FloatTween radiusTween = new FloatTween(
begin: 0.0f,
end: this.overlayRadius
);
canvas.drawCircle(
center,
radiusTween.evaluate(activationAnimation),
new Paint {color = sliderTheme.overlayColor}
);
}
}
public class PaddleSliderValueIndicatorShape : SliderComponentShape {
public PaddleSliderValueIndicatorShape() {
}

const float _bottomLobeRadius = 6.0f;
const float _bottomLobeStartAngle = -1.1f * Mathf.PI / 4.0f;
const float _bottomLobeEndAngle = 1.1f * 5 * Mathf.PI / 4.0f;
const float _bottomLobeEndAngle = 1.1f * 5f * Mathf.PI / 4.0f;
const float _labelPadding = 8.0f;
const float _distanceBetweenTopBottomCenters = 40.0f;
static readonly Offset _topLobeCenter = new Offset(0.0f, -_distanceBetweenTopBottomCenters);

if (!_debuggingLabelLocation) {
return true;
}
Offset leftCenter = _topLobeCenter - new Offset(leftWidthNeeded, 0.0f) + neckStretch;
Offset rightCenter = _topLobeCenter + new Offset(rightWidthNeeded, 0.0f) + neckStretch;
Rect valueRect = Rect.fromLTRB(

2
Runtime/material/text_field.cs


properties.add(new EnumProperty<TextCapitalization>("textCapitalization", this.textCapitalization, defaultValue: TextCapitalization.none));
properties.add(new EnumProperty<TextAlign>("textAlign", this.textAlign, defaultValue: TextAlign.left));
properties.add(new EnumProperty<TextDirection>("textDirection", this.textDirection, defaultValue: null));
properties.add(new FloatProperty("cursorWidth", this.cursorWidth, defaultValue: 2.0));
properties.add(new FloatProperty("cursorWidth", this.cursorWidth, defaultValue: 2.0f));
properties.add(new DiagnosticsProperty<Radius>("cursorRadius", this.cursorRadius, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("cursorColor", this.cursorColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Brightness?>("keyboardAppearance", this.keyboardAppearance, defaultValue: null));

2
Runtime/material/user_accounts_drawer_header.cs


right: 0.0f,
child: new Row(
children: (this.otherAccountsPictures ?? new List<Widget> { })
.GetRange(0, Math.Min(3, this.otherAccountsPictures?.Count ?? 0))
.GetRange(0, Mathf.Min(3, this.otherAccountsPictures?.Count ?? 0))
.Select<Widget, Widget>(
(Widget picture) => {
return new Padding(

17
Runtime/painting/basic_types.cs


using System;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.painting {
public enum RenderComparison {

right,
down,
left,
}
public static class AxisDirectionUtils {
public static AxisDirection? getAxisDirectionFromAxisReverseAndDirectionality(
BuildContext context,
Axis axis,
bool reverse) {
switch (axis) {
case Axis.horizontal:
return reverse ? AxisDirection.left : AxisDirection.right;
case Axis.vertical:
return reverse ? AxisDirection.up : AxisDirection.down;
}
return null;
}
}
public static class AxisUtils {

5
Runtime/rendering/editable.cs


public TextPosition getParagraphBackward(TextPosition position, TextAffinity? affinity = null) {
var lineCount = this._textPainter.getLineCount();
Paragraph.LineRange line = null;
for (int i = lineCount - 1; i >= 0; --i) {
line = this._textPainter.getLineRange(i);

int baseOffset = fromPosition.offset;
int extentOffset = fromPosition.offset;
if (toPosition != null) {
baseOffset = Math.Min(fromPosition.offset, toPosition.offset);
extentOffset = Math.Max(fromPosition.offset, toPosition.offset);
baseOffset = Mathf.Min(fromPosition.offset, toPosition.offset);
extentOffset = Mathf.Max(fromPosition.offset, toPosition.offset);
}
TextSelection newSelection = new TextSelection(

4
Runtime/rendering/paragraph.cs


int baseOffset = fromPosition.offset;
int extentOffset = fromPosition.offset;
if (toPosition != null) {
baseOffset = Math.Min(fromPosition.offset, toPosition.offset);
extentOffset = Math.Max(fromPosition.offset, toPosition.offset);
baseOffset = Mathf.Min(fromPosition.offset, toPosition.offset);
extentOffset = Mathf.Max(fromPosition.offset, toPosition.offset);
}
TextSelection newSelection = new TextSelection(

5
Runtime/service/text_formatter.cs


using System;
using System.Text.RegularExpressions;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace Unity.UIWidgets.service {
public abstract class TextInputFormatter {

public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if (this.maxLength != null && this.maxLength > 0 && newValue.text.Length > this.maxLength) {
TextSelection newSelection = newValue.selection.copyWith(
baseOffset: Math.Min(newValue.selection.start, this.maxLength.Value),
extentOffset: Math.Min(newValue.selection.end, this.maxLength.Value)
baseOffset: Mathf.Min(newValue.selection.start, this.maxLength.Value),
extentOffset: Mathf.Min(newValue.selection.end, this.maxLength.Value)
);
string truncated = newValue.text.Substring(0, this.maxLength.Value);

61
Runtime/ui/matrix.cs


return true;
}
else {
var points = new[] {
this.mapXY(src.left, src.top),
this.mapXY(src.right, src.top),
this.mapXY(src.right, src.bottom),
this.mapXY(src.left, src.bottom),
};
float x1, y1, x2, y2, x3, y3, x4, y4;
this.mapXY(src.left, src.top, out x1, out y1);
this.mapXY(src.right, src.top, out x2, out y2);
this.mapXY(src.right, src.bottom, out x3, out y3);
this.mapXY(src.left, src.bottom, out x4, out y4);
var minX = x1;
var minY = y1;
var maxX = x1;
var maxY = y1;
if (x2 < minX) {
minX = x2;
}
if (x2 > maxX) {
maxX = x2;
}
if (y2 < minY) {
minY = y2;
}
if (y2 > maxY) {
maxY = y2;
}
var minX = points[0].dx;
var minY = points[0].dy;
var maxX = points[0].dx;
var maxY = points[0].dy;
if (x3 < minX) {
minX = x3;
}
if (x3 > maxX) {
maxX = x3;
}
if (y3 < minY) {
minY = y3;
}
if (y3 > maxY) {
maxY = y3;
}
for (int i = 1; i < 4; ++i) {
minX = Mathf.Min(minX, points[i].dx);
minY = Mathf.Min(minY, points[i].dy);
maxX = Mathf.Max(maxX, points[i].dx);
maxY = Mathf.Max(maxY, points[i].dy);
if (x4 < minX) {
minX = x4;
}
if (x4 > maxX) {
maxX = x4;
}
if (y4 < minY) {
minY = y4;
}
if (y4 > maxY) {
maxY = y4;
}
dst = Rect.fromLTRB(minX, minY, maxX, maxY);

72
Runtime/ui/painting/canvas_clip.cs


return this._genId;
}
// bool _convexContains(float x, float y) {
// if (this.mesh.vertices.Count <= 2) {
// return false;
// }
//
// if (this.mesh.matrix != null) {
// if (this._invMat == null) {
// this._invMat = Matrix3.I();
// this.mesh.matrix.invert(this._invMat); // ignore if not invertible for now.
// }
//
// var offset = this._invMat.mapXY(x, y);
// x = offset.dx;
// y = offset.dy;
// }
//
// for (var i = 0; i < this.mesh.vertices.Count; i++) {
// var p0 = this.mesh.vertices[i];
// var p1 = this.mesh.vertices[i == this.mesh.vertices.Count - 1 ? 0 : i + 1];
//
// if (PathUtils.triarea2(p0.x, p0.y, p1.x, p1.y, x, y) < 0.0f) {
// return false;
// }
// }
//
// return true;
// }
bool _convexContains(Rect rect) {
if (this.mesh.vertices.Count <= 2) {
return false;
}
for (var i = 0; i < this.mesh.vertices.Count; i++) {
var p1 = this.mesh.vertices[i];
var p0 = this.mesh.vertices[i == this.mesh.vertices.Count - 1 ? 0 : i + 1];
var v = p1 - p0;
if (v.x == 0.0 && v.y == 0.0) {
continue;
}
float yL = v.y * (rect.left - p0.x);
float xT = v.x * (rect.top - p0.y);
float yR = v.y * (rect.right - p0.x);
float xB = v.x * (rect.bottom - p0.y);
if ((xT < yL) || (xT < yR) || (xB < yL) || (xB < yR)) {
return false;
}
}
return true;
}
public bool contains(Rect rect) {
if (this.isRect) {

// this seems to be inefficient. disable it for now.
// if (this.convex) {
// return this._convexContains(rect.left, rect.top) &&
// this._convexContains(rect.left, rect.bottom) &&
// this._convexContains(rect.right, rect.top) &&
// this._convexContains(rect.right, rect.bottom);
// }
if (this.convex) {
if (this.mesh.matrix != null && !this.mesh.matrix.isIdentity()) {
if (this._invMat == null) {
this._invMat = Matrix3.I();
this.mesh.matrix.invert(this._invMat); // ignore if not invertible for now.
}
rect = this._invMat.mapRect(rect);
}
return this._convexContains(rect);
}
return false;
}

13
Runtime/ui/painting/canvas_impl.cs


// request font texture so text mesh could be generated correctly
var style = textBlob.style;
var font = FontManager.instance.getOrCreate(textBlob.style.fontFamily, style.fontWeight, style.fontStyle).font;
var font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font;
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * scale);
var subText = textBlob.text.Substring(textBlob.textOffset, textBlob.textSize);
font.RequestCharactersInTextureSafe(subText, fontSizeToLoad, style.UnityFontStyle);

D.assert(this._layers[0].states.Count == 1);
var layer = this._currentLayer;
if (layer.draws.Count == 0) {
D.assert(layer.layers.Count == 0);
return;
}
using (var cmdBuf = new CommandBuffer()) {
cmdBuf.name = "CommandBufferCanvas";

break;
}
}
if (toClear) {
this._setRenderTarget(cmdBuf, layer.rtID, ref toClear);
}
D.assert(!toClear);
foreach (var subLayer in layer.layers) {
cmdBuf.ReleaseTemporaryRT(subLayer.rtID);

155
Runtime/ui/painting/path.cs


return totalW != 0;
}
static int windingLine(float x0, float y0, float x1, float y1, float x, float y) {
if (y0 == y1) {
return 0;

innerBevel = 0x08,
}
class PathPoint {
struct PathPoint {
public float x, y;
public float dx, dy;
public float len;

class PathPath {
struct PathPath {
public int first;
public int count;
public bool closed;

readonly float _distTol;
readonly float _tessTol;
readonly List<PathPath> _paths = new List<PathPath>();
readonly List<PathPoint> _points = new List<PathPoint>();
readonly List<Vector3> _vertices = new List<Vector3>();
readonly ArrayRef<PathPath> _paths = new ArrayRef<PathPath>();
readonly ArrayRef<PathPoint> _points = new ArrayRef<PathPoint>();
List<Vector3> _vertices = null;
MeshMesh _fillMesh;
bool _fillConvex;

}
public void addPath() {
this._paths.Add(new PathPath {
first = this._points.Count,
this._paths.add(new PathPath {
first = this._points.length,
winding = PathWinding.counterClockwise
});
}

}
void _addPoint(PathPoint point) {
if (this._paths.Count == 0) {
if (this._paths.length == 0) {
var path = this._paths[this._paths.Count - 1];
ref var path = ref this._paths.array[this._paths.length - 1];
var pt = this._points[this._points.Count - 1];
ref var pt = ref this._points.array[this._points.length - 1];
if (PathUtils.ptEquals(pt.x, pt.y, point.x, point.y, this._distTol)) {
pt.flags |= point.flags;
return;

this._points.Add(point);
this._points.add(point);
path.count++;
}

PointFlags flags) {
float x1, y1;
if (this._points.Count == 0) {
if (this._points.length == 0) {
var pt = this._points[this._points.Count - 1];
ref var pt = ref this._points.array[this._points.length - 1];
x1 = pt.x;
y1 = pt.y;
}

}
public void closePath() {
if (this._paths.Count == 0) {
if (this._paths.length == 0) {
var path = this._paths[this._paths.Count - 1];
ref var path = ref this._paths.array[this._paths.length - 1];
if (this._paths.Count == 0) {
if (this._paths.length == 0) {
var path = this._paths[this._paths.Count - 1];
ref var path = ref this._paths.array[this._paths.length - 1];
for (var j = 0; j < this._paths.Count; j++) {
var path = this._paths[j];
var points = this._points;
var paths = this._paths;
for (var j = 0; j < paths.length; j++) {
ref var path = ref paths.array[j];
if (path.count <= 1) {
continue;
}

var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
if (PathUtils.ptEquals(p0.x, p0.y, p1.x, p1.y, this._distTol)) {
path.count--;
path.closed = true;

if (path.winding == PathWinding.clockwise) {
PathUtils.polyReverse(this._points, path.first, path.count);
PathUtils.polyReverse(points.array, path.first, path.count);
}
}
}

for (var j = 0; j < this._paths.Count; j++) {
var path = this._paths[j];
var points = this._points;
var paths = this._paths;
for (var j = 0; j < paths.length; j++) {
ref var path = ref paths.array[j];
if (path.count <= 2) {
continue;
}

for (var i = 0; i < path.count; i++) {
var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
p0.dx = p1.x - p0.x; // no need to normalize
p0.dy = p1.y - p0.y;
ip0 = ip1++;

ip0 = path.first + path.count - 1;
ip1 = path.first;
for (var i = 0; i < path.count; i++) {
var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
float cross = p1.dx * p0.dy - p0.dx * p1.dy;
if (cross < 0.0f) {

}
}
this._vertices.Clear();
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
var cvertices = 0;
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 2) {
continue;
}
cvertices += path.count;
}
this._vertices = new List<Vector3>(cvertices);
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 2) {
continue;
}

var p = this._points[path.first + j];
ref var p = ref points.array[path.first + j];
this._vertices.Add(new Vector2(p.x, p.y));
}

this._expandFill();
var paths = this._paths;
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 2) {
continue;
}

}
var indices = new List<int>(cindices);
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 2) {
continue;
}

this._fillMesh = mesh;
this._fillConvex = false;
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 2) {
continue;
}

void _calculateJoins(float w, StrokeJoin lineJoin, float miterLimit) {
float iw = w > 0.0f ? 1.0f / w : 0.0f;
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
var points = this._points;
var paths = this._paths;
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 1) {
continue;
}

for (var j = 0; j < path.count; j++) {
var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
p0.dx = p1.x - p0.x;
p0.dy = p1.y - p0.y;
p0.len = PathUtils.normalize(ref p0.dx, ref p0.dy);

ip0 = path.first + path.count - 1;
ip1 = path.first;
for (var j = 0; j < path.count; j++) {
var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
float dlx0 = p0.dy;
float dly0 = -p0.dx;
float dlx1 = p1.dy;

ncap = PathUtils.curveDivs(w, Mathf.PI, this._tessTol);
}
this._vertices.Clear();
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
var points = this._points;
var paths = this._paths;
var cvertices = 0;
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 1) {
continue;
}
cvertices += path.count * 2;
cvertices += 4;
}
this._vertices = new List<Vector3>(cvertices);
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 1) {
continue;
}

e = path.count - 1;
}
var p0 = this._points[ip0];
var p1 = this._points[ip1];
ref var p0 = ref points.array[ip0];
ref var p1 = ref points.array[ip1];
if (!path.closed) {
if (lineCap == StrokeCap.butt) {

}
for (var j = s; j < e; j++) {
p0 = this._points[ip0];
p1 = this._points[ip1];
p0 = ref points.array[ip0];
p1 = ref points.array[ip1];
if ((p1.flags & (PointFlags.bevel | PointFlags.innerBevel)) != 0) {
if (lineJoin == StrokeJoin.round) {

}
if (!path.closed) {
p0 = this._points[ip0];
p1 = this._points[ip1];
p0 = ref points.array[ip0];
p1 = ref points.array[ip1];
if (lineCap == StrokeCap.butt) {
this._vertices.buttCapEnd(p1, p0.dx, p0.dy, w, 0.0f);
}

this._expandStroke(strokeWidth, lineCap, lineJoin, miterLimit);
var paths = this._paths;
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 1) {
continue;
}

}
var indices = new List<int>(cindices);
for (var i = 0; i < this._paths.Count; i++) {
var path = this._paths[i];
for (var i = 0; i < paths.length; i++) {
ref var path = ref paths.array[i];
if (path.count <= 1) {
continue;
}

return area * 0.5f;
}
public static void polyReverse(List<PathPoint> pts, int s, int npts) {
public static void polyReverse(PathPoint[] pts, int s, int npts) {
int i = s, j = s + npts - 1;
while (i < j) {
var tmp = pts[i];

2
Runtime/ui/painting/shadow_utils.cs


namespace Unity.UIWidgets.ui {
static class ShadowUtils {
public static bool kUseFastShadow = true;
public static bool kUseFastShadow = false;
public const float kAmbientHeightFactor = 1.0f / 128.0f;
public const float kAmbientGeomFactor = 64.0f;

14
Runtime/ui/painting/tessellation_generator.cs


public int level;
}
static readonly Stack<_StackData> _stack = new Stack<_StackData>();
static List<Vector2> _tessellateBezier(
float x1, float y1, float x2, float y2,
float x3, float y3, float x4, float y4,

var points = new List<Vector2>();
var stack = new Stack<_StackData>();
stack.Push(new _StackData {
_stack.Clear();
_stack.Push(new _StackData {
while (stack.Count > 0) {
var stackData = stack.Pop();
while (_stack.Count > 0) {
var stackData = _stack.Pop();
x1 = stackData.x1;
y1 = stackData.y1;
x2 = stackData.x2;

float y1234 = (y123 + y234) * 0.5f;
if (level < 10) {
stack.Push(new _StackData {
_stack.Push(new _StackData {
stack.Push(new _StackData {
_stack.Push(new _StackData {
x1 = x1, y1 = y1, x2 = x12, y2 = y12, x3 = x123, y3 = y123, x4 = x1234, y4 = y1234,
level = level + 1,
});

187
Runtime/ui/painting/txt/font_manager.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;

}
}
class FontRef : IEquatable<FontRef> {
public readonly string familyName;
public readonly FontWeight fontWeight;
public readonly FontStyle fontStyle;
public FontRef(string familyName, FontWeight fontWeight, FontStyle fontStyle) {
this.familyName = familyName;
this.fontWeight = fontWeight;
this.fontStyle = fontStyle;
}
public bool Equals(FontRef other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return string.Equals(this.familyName, other.familyName) && this.fontWeight == other.fontWeight && this.fontStyle == other.fontStyle;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((FontRef) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (this.familyName != null ? this.familyName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.fontWeight != null ? this.fontWeight.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int) this.fontStyle;
return hashCode;
}
}
public static bool operator ==(FontRef left, FontRef right) {
return Equals(left, right);
}
public static bool operator !=(FontRef left, FontRef right) {
return !Equals(left, right);
}
public override string ToString() {
return $"{nameof(this.familyName)}: {this.familyName}, {nameof(this.fontWeight)}: {this.fontWeight}, {nameof(this.fontStyle)}: {this.fontStyle}";
}
}
readonly Dictionary<FontRef, FontInfo> _fonts = new Dictionary<FontRef, FontInfo>();
readonly Dictionary<string, FontInfo>[] _fonts =
new Dictionary<string, FontInfo>[9 * 2]; // max weight size x max style size
static readonly int defaultFontSize = 14;
public static readonly FontManager instance = new FontManager();

public void addFont(Font font, string familyName,
FontWeight fontWeight = null, FontStyle fontStyle = FontStyle.normal) {
if (fontWeight == null) {
fontWeight = FontWeight.normal;
}
fontWeight = fontWeight ?? FontWeight.normal;
FontRef fontRef = new FontRef(familyName, fontWeight, fontStyle);
FontInfo current;
this._fonts.TryGetValue(fontRef, out current);
D.assert(current == null || current.font == font, () => $"font with key {fontRef} already exists");
var fonts = this._getFonts(fontWeight.index, fontStyle);
fonts.TryGetValue(familyName, out var current);
D.assert(current == null || current.font == font,
() => $"font with key {familyName} {fontWeight} {fontStyle} already exists");
this._fonts[fontRef] = fontInfo;
fonts[familyName] = fontInfo;
}
Dictionary<string, FontInfo> _getFonts(int fontWeight, FontStyle fontStyle) {
var index = fontWeight * 2 + (int) fontStyle;
var fonts = this._fonts[index];
if (fonts == null) {
fonts = this._fonts[index] = new Dictionary<string, FontInfo>();
}
return fonts;
if (fontWeight == null) {
fontWeight = FontWeight.normal;
}
FontRef fontRef = new FontRef(familyName, fontWeight, fontStyle);
if (this._fonts.TryGetValue(fontRef, out var fontInfo)) {
fontWeight = fontWeight ?? FontWeight.normal;
var fonts = this._getFonts(fontWeight.index, fontStyle);
if (fonts.TryGetValue(familyName, out var fontInfo)) {
if (fontWeight != FontWeight.normal || fontStyle != FontStyle.normal) {
if (fontWeight.index != FontWeight.normal.index || fontStyle != FontStyle.normal) {
fontInfo = this.getOrCreate(familyName, FontWeight.normal, FontStyle.normal);
if (fontInfo != null) {
return fontInfo;

osFont.material.mainTexture.hideFlags = HideFlags.DontSave;
var newFont = new FontInfo(osFont);
fontRef = new FontRef(familyName, fontWeight, fontStyle);
this._fonts[fontRef] = newFont;
fonts[familyName] = newFont;
var entry = this._fonts.Values.FirstOrDefault(f => f.font == font);
if (entry != null) {
entry.onTextureRebuilt();
foreach (var fontInfos in this._fonts) {
if (fontInfos != null) {
foreach (var f in fontInfos.Values) {
if (f.font == font) {
f.onTextureRebuilt();
}
}
}
struct GlyphInfo {
public static readonly GlyphInfo empty = new GlyphInfo();
Rect _rect;
readonly CharacterInfo _info;
public GlyphInfo(CharacterInfo info) {
this._rect = null;
this._info = info;
}
public Rect rect {
get {
if (this._rect == null) {
this._rect = Rect.fromLTRB(this._info.minX, -this._info.maxY, this._info.maxX, -this._info.minY);
}
return this._rect;
}
}
public float advance {
get { return this._info.advance; }
}
public float glyphHeight {
get { return this._info.advance; }
}
public Vector2 uvTopLeft {
get { return this._info.uvTopLeft; }
}
public Vector2 uvTopRight {
get { return this._info.uvTopRight; }
}
public Vector2 uvBottomLeft {
get { return this._info.uvBottomLeft; }
}
public Vector2 uvBottomRight {
get { return this._info.uvBottomRight; }
}
}
internal static GlyphInfo getGlyphInfo(this Font font, char ch, int fontSize, UnityEngine.FontStyle fontStyle) {
internal static bool getGlyphInfo(this Font font, char ch, out CharacterInfo info, int fontSize,
UnityEngine.FontStyle fontStyle) {
return GlyphInfo.empty;
info = default;
return false;
CharacterInfo info;
Debug.LogWarning($"character info not found from the given font: character '{ch}' (code{(int)ch}) font: ${font.name}");
Debug.LogWarning(
$"character info not found from the given font: character '{ch}' (code{(int) ch}) font: ${font.name}");
return GlyphInfo.empty;
info = default;
return false;
return new GlyphInfo(info);
return true;
internal static void RequestCharactersInTextureSafe(this Font font, string text, int fontSize,
UnityEngine.FontStyle fontStyle = UnityEngine.FontStyle.Normal) {
if (fontSize <= 0) {

12
Runtime/ui/painting/txt/mesh_generator.cs


if (fontSizeToLoad == 0) {
continue;
}
var glyphInfo = font.getGlyphInfo(ch, fontSizeToLoad, style.UnityFontStyle);
var minX = glyphInfo.rect.left / this.scale;
var maxX = glyphInfo.rect.right / this.scale;
var minY = glyphInfo.rect.top / this.scale;
var maxY = glyphInfo.rect.bottom / this.scale;
font.getGlyphInfo(ch, out var glyphInfo, fontSizeToLoad, style.UnityFontStyle);
var minX = glyphInfo.minX / this.scale;
var maxX = glyphInfo.maxX / this.scale;
var minY = -glyphInfo.maxY / this.scale;
var maxY = -glyphInfo.minY / this.scale;
var baseIndex = vertices.Count;

2
Runtime/ui/text.cs


internal UnityEngine.FontStyle UnityFontStyle {
get {
bool isBold = this.fontWeight == FontWeight.bold;
bool isBold = this.fontWeight.index == FontWeight.bold.index;
if (this.fontStyle == FontStyle.italic) {
if (isBold) {
return UnityEngine.FontStyle.BoldAndItalic;

58
Runtime/ui/txt/layout.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace Unity.UIWidgets.ui {

List<float> _advances = new List<float>();
List<float> _positions = new List<float>();
float _advance;
Rect _bounds;
UnityEngine.Rect _bounds;
TabStops _tabStops;

public void doLayout(float offset, TextBuff buff, int start, int count, TextStyle style) {
this._start = start;
this._count = count;
this._advances.resize(count, 0);
this._positions.resize(count, 0);
this._advances.reset(count);
this._positions.reset(count);
this._bounds = null;
this._bounds = default;
var font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font;
font.RequestCharactersInTextureSafe(buff.text, style.UnityFontSize, style.UnityFontStyle);
int wordstart = start == buff.size
? start
: LayoutUtils.getPrevWordBreakForCache(buff, start + 1);

int wordCount = Math.Min(start + count, wordend) - iter;
int wordCount = Mathf.Min(start + count, wordend) - iter;
iter - wordstart, wordCount, style);
iter - wordstart, wordCount, style, font);
TextBuff buff, int start, int wordCount, TextStyle style) {
TextBuff buff, int start, int wordCount, TextStyle style, Font font) {
var font = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle).font;
font.RequestCharactersInTextureSafe(buff.subBuff(start, wordCount).getString(),
style.UnityFontSize,
style.UnityFontStyle);
float x = this._advance;
float letterSpace = style.letterSpacing;
float letterSpaceHalfLeft = letterSpace * 0.5f;

x += letterSpace;
}
var glyphInfo = font.getGlyphInfo(ch, style.UnityFontSize, style.UnityFontStyle);
var rect = glyphInfo.rect;
rect = rect.translate(x, 0);
if (this._bounds == null || this._bounds.isEmpty) {
this._bounds = rect;
}
else {
this._bounds = this._bounds.expandToInclude(rect);
if (font.getGlyphInfo(ch, out var glyphInfo, style.UnityFontSize, style.UnityFontStyle)) {
var minX = glyphInfo.minX + x;
var maxX = glyphInfo.maxX + x;
var minY = -glyphInfo.maxY;
var maxY = -glyphInfo.minY;
if (this._bounds.width <= 0 || this._bounds.height <= 0) {
this._bounds = UnityEngine.Rect.MinMaxRect(
minX, minY, maxX, maxY);
} else {
if (minX < this._bounds.x) {
this._bounds.x = minX;
}
if (minY < this._bounds.y) {
this._bounds.y = minY;
}
if (maxX > this._bounds.xMax) {
this._bounds.xMax = maxX;
}
if (maxY > this._bounds.yMax) {
this._bounds.yMax = maxY;
}
}
this._positions[i + layoutOffset] = x;
float advance = glyphInfo.advance;
if (ch == '\t') {

}
public Rect getBounds() {
return this._bounds;
return Rect.fromLTWH(this._bounds.x, this._bounds.y, this._bounds.width, this._bounds.height);
}
}
}

15
Runtime/ui/txt/linebreaker.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using Unity.UIWidgets.InternalBridge;
using UnityEngine;
namespace Unity.UIWidgets.ui {

}
if (this._tabWidth == int.MaxValue) {
this._font.RequestCharactersInTextureSafe(" ", this._fontSize);
var glyphInfo = this._font.getGlyphInfo(' ', this._fontSize, UnityEngine.FontStyle.Normal);
this._tabWidth = (int)Math.Round(glyphInfo.advance * kTabSpaceCount);
this._font.RequestCharactersInTextureSafe(" ", this._fontSize);
this._font.getGlyphInfo(' ', out var glyphInfo, this._fontSize, UnityEngine.FontStyle.Normal);
this._tabWidth = glyphInfo.advance * kTabSpaceCount;
}
}

public void resize(int size) {
if (this._charWidths.Count < size) {
this._charWidths.AddRange(Enumerable.Repeat(0.0f, size - this._charWidths.Count));
NoAllocHelpersBridge<float>.ResizeList(this._charWidths, size);
}
}

this._candidates.Clear();
this._widths.Clear();
this._breaks.Clear();
this._textBuf = null;
this._textBuf = default;
}
public List<float> getWidths() {

4
Runtime/ui/txt/paint_record.cs


namespace Unity.UIWidgets.ui {
class PaintRecord {
public PaintRecord(TextStyle style, Offset offset, TextBlob _text,
public PaintRecord(TextStyle style, Offset offset, TextBlob text,
this._text = _text;
this._text = text;
this._line = line;
this._runWidth = runWidth;
this._metrics = metrics;

7
Runtime/ui/txt/paragraph.cs


var ascent = -font.ascent * fontSize / font.fontSize;
var descent = (font.lineHeight - font.ascent) * fontSize / font.fontSize;
font.RequestCharactersInTextureSafe("x", fontSize, UnityEngine.FontStyle.Normal);
var glyphInfo = font.getGlyphInfo('x', fontSize, UnityEngine.FontStyle.Normal);
font.getGlyphInfo('x', out var glyphInfo, fontSize, UnityEngine.FontStyle.Normal);
float fxHeight = glyphInfo.glyphHeight;
return new FontMetrics(ascent, descent, fxHeight: fxHeight);

public readonly int endIncludingNewLine;
public readonly bool hardBreak;
}
const int TabSpaceCount = 4;
bool _needsLayout = true;

lineBreaker.finish();
}
return;
}
List<Range<int>> findWords(int start, int end) {

4
Runtime/ui/txt/text_buff.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.ui {
class TextBuff {
struct TextBuff {
public readonly string text;
public readonly int offset;
public readonly int size;

return new TextBuff(this.text, this.offset + shift, size);
}
public String getString() {
public override string ToString() {
return this.text.Substring(this.offset, this.size);
}
}

2
Runtime/ui/txt/wordbreaker.cs


}
public void finish() {
this._text = null;
this._text = default;
}
int _findNextBreakInEmailOrUrl() {

34
Runtime/widgets/basic.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UIWidgets.Runtime.rendering;
using Unity.UIWidgets.utils;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;

public readonly float? stepHeight;
float? _stepWidth {
get {
return this.stepWidth == 0.0f ? null : this.stepWidth;
}
get { return this.stepWidth == 0.0f ? null : this.stepWidth; }
get {
return this.stepHeight == 0.0f ? null : this.stepHeight;
}
get { return this.stepHeight == 0.0f ? null : this.stepHeight; }
}
public override RenderObject createRenderObject(BuildContext context) {

properties.add(new FloatProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class RotatedBox : SingleChildRenderObjectWidget {
public RotatedBox(
Key key = null,
int? quarterTurns = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(quarterTurns != null);
this.quarterTurns = quarterTurns;
}
public readonly int? quarterTurns;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderRotatedBox(this.quarterTurns ?? 0);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
(renderObject as RenderRotatedBox).quarterTurns = this.quarterTurns ?? 0;
}
}

11
Runtime/widgets/drag_target.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.utils;
namespace Unity.UIWidgets.widgets {
public delegate bool DragTargetWillAccept<T>(T data);

public enum DragAnchor {
child,
pointer
}
static class _DragUtils {
public static List<T> _mapAvatarsToData<T>(List<_DragAvatar<T>> avatars) {
return avatars.Select(avatar => avatar.data).ToList();
}
}
public class Draggable<T> : StatefulWidget {

return new MetaData(
metaData: this,
behavior: HitTestBehavior.translucent,
child: this.widget.builder(context, DragUtils._mapAvatarsToData(this._candidateAvatars),
DragUtils._mapAvatarsToData(this._rejectedAvatars)));
child: this.widget.builder(context, _DragUtils._mapAvatarsToData(this._candidateAvatars),
_DragUtils._mapAvatarsToData(this._rejectedAvatars)));
}
}

34
Runtime/widgets/form.cs


public class FormState : State<Form> {
int _generation = 0;
public readonly HashSet<FormFieldState<dynamic>> _fields = new HashSet<FormFieldState<dynamic>>();
readonly HashSet<FormFieldState> _fields = new HashSet<FormFieldState>();
public FormState() {
}

this.setState(() => { ++this._generation; });
}
public void _register(FormFieldState<dynamic> field) {
public void _register(FormFieldState field) {
public void _unregister(FormFieldState<dynamic> field) {
public void _unregister(FormFieldState field) {
this._fields.Remove(field);
}

);
}
void save() {
foreach (FormFieldState<dynamic> field in this._fields) {
public void save() {
foreach (FormFieldState field in this._fields) {
void reset() {
foreach (FormFieldState<dynamic> field in this._fields) {
public void reset() {
foreach (FormFieldState field in this._fields) {
field.reset();
}

bool validate() {
public bool validate() {
this._forceRebuild();
return this._validate();
}

foreach (FormFieldState<dynamic> field in this._fields) {
foreach (FormFieldState field in this._fields) {
hasError = !field.validate() || hasError;
}

}
}
public class FormFieldState<T> : State<FormField<T>> where T : class {
public interface FormFieldState {
void save();
bool validate();
void reset();
}
public class FormFieldState<T> : State<FormField<T>>, FormFieldState where T : class {
T _value;
string _errorText;

}
}
public void reset() {
public virtual void reset() {
this.setState(() => {
this._value = this.widget.initialValue;
this._errorText = null;

}
public override void deactivate() {
Form.of(this.context)?._unregister(this as FormFieldState<dynamic>);
Form.of(this.context)?._unregister(this);
base.deactivate();
}

}
Form.of(context)?._register(this as FormFieldState<dynamic>);
Form.of(context)?._register(this);
return this.widget.builder(this);
}
}

80
Runtime/widgets/gesture_detector.cs


GestureDragUpdateCallback onPanUpdate = null,
GestureDragEndCallback onPanEnd = null,
GestureDragCancelCallback onPanCancel = null,
GestureScaleStartCallback onScaleStart = null,
GestureScaleUpdateCallback onScaleUpdate = null,
GestureScaleEndCallback onScaleEnd = null,
HitTestBehavior behavior = HitTestBehavior.deferToChild,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key) {

onHorizontalDragStart != null || onHorizontalDragUpdate != null ||
onHorizontalDragEnd != null;
bool haveLongPress = onLongPress != null || onLongPressUp != null;
bool haveLongPressDrag = onLongPressDragStart != null || onLongPressDragUpdate != null || onLongPressDragUp != null;
bool haveLongPressDrag = onLongPressDragStart != null || onLongPressDragUpdate != null ||
onLongPressDragUp != null;
if (havePan) {
bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
if (havePan || haveScale) {
if (havePan && haveScale) {
throw new UIWidgetsError(
"Incorrect GestureDetector arguments.\n" +
"Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer."
);
}
string recognizer = havePan ? "pan" : "scale";
"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a pan gesture recognizer " +
"will result in the pan gesture recognizer being ignored, since the other two will catch all drags."
$"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a {recognizer} gesture recognizer " +
$"will result in the {recognizer} gesture recognizer being ignored, since the other two will catch all drags."
"Incorrect GestureDetector arguments.\n" +
"Having both a long press and a long press drag recognizer is " +
"redundant as the long press drag is a superset of long press. " +
"Except long press drag allows for drags after the long press is " +
"triggered."
);
"Incorrect GestureDetector arguments.\n" +
"Having both a long press and a long press drag recognizer is " +
"redundant as the long press drag is a superset of long press. " +
"Except long press drag allows for drags after the long press is " +
"triggered."
);
}
return true;

this.onPanUpdate = onPanUpdate;
this.onPanEnd = onPanEnd;
this.onPanCancel = onPanCancel;
this.onScaleStart = onScaleStart;
this.onScaleUpdate = onScaleUpdate;
this.onScaleEnd = onScaleEnd;
this.behavior = behavior;
this.dragStartBehavior = dragStartBehavior;
}

public readonly GestureDragUpdateCallback onPanUpdate;
public readonly GestureDragEndCallback onPanEnd;
public readonly GestureDragCancelCallback onPanCancel;
public readonly GestureScaleStartCallback onScaleStart;
public readonly GestureScaleUpdateCallback onScaleUpdate;
public readonly GestureScaleEndCallback onScaleEnd;
public readonly HitTestBehavior behavior;
public readonly DragStartBehavior dragStartBehavior;

instance => { instance.onLongPress = this.onLongPress; }
);
}
if (this.onLongPressDragStart != null || this.onLongPressDragUpdate != null || this.onLongPressDragUp != null) {
gestures[typeof(LongPressDragGestureRecognizer)] = new GestureRecognizerFactoryWithHandlers<LongPressDragGestureRecognizer>(
() => new LongPressDragGestureRecognizer(debugOwner: this),
(LongPressDragGestureRecognizer instance) => {
instance.onLongPressStart = this.onLongPressDragStart;
instance.onLongPressDragUpdate = this.onLongPressDragUpdate;
instance.onLongPressUp = this.onLongPressDragUp;
}
);
if (this.onLongPressDragStart != null || this.onLongPressDragUpdate != null ||
this.onLongPressDragUp != null) {
gestures[typeof(LongPressDragGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<LongPressDragGestureRecognizer>(
() => new LongPressDragGestureRecognizer(debugOwner: this),
(LongPressDragGestureRecognizer instance) => {
instance.onLongPressStart = this.onLongPressDragStart;
instance.onLongPressDragUpdate = this.onLongPressDragUpdate;
instance.onLongPressUp = this.onLongPressDragUp;
}
);
}
if (this.onVerticalDragDown != null ||

instance.onEnd = this.onPanEnd;
instance.onCancel = this.onPanCancel;
instance.dragStartBehavior = this.dragStartBehavior;
}
);
}
if (this.onScaleStart != null ||
this.onScaleUpdate != null ||
this.onScaleEnd != null) {
gestures[typeof(ScaleGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<ScaleGestureRecognizer>(
() => new ScaleGestureRecognizer(debugOwner: this),
instance => {
instance.onStart = this.onScaleStart;
instance.onUpdate = this.onScaleUpdate;
instance.onEnd = this.onScaleEnd;
}
);
}

: gestures[type].constructorRaw();
D.assert(this._recognizers[type].GetType() == type,
() => "GestureRecognizerFactory of type " + type + " created a GestureRecognizer of type " +
this._recognizers[type].GetType() +
". The GestureRecognizerFactory must be specialized with the type of the class that it returns from its constructor method.");
this._recognizers[type].GetType() +
". The GestureRecognizerFactory must be specialized with the type of the class that it returns from its constructor method.");
gestures[type].initializerRaw(this._recognizers[type]);
}

10
Runtime/widgets/implicit_animations.cs


}
class _AnimatedOpacityState : ImplicitlyAnimatedWidgetState<AnimatedOpacity> {
FloatTween _opacity;
NullableFloatTween _opacity;
this._opacity = (FloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
(float value) => new FloatTween(begin: value, end: 1.0f));
this._opacity = (NullableFloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
(float? value) => new NullableFloatTween(begin: value));
this._opacityAnimation = this.animation.drive(this._opacity);
float? endValue = this._opacity.end ?? this._opacity.begin ?? null;
D.assert(endValue != null);
this._opacityAnimation = this.animation.drive(new FloatTween(begin: this._opacity.begin.Value, end: endValue.Value));
}
public override Widget build(BuildContext context) {

1
Runtime/widgets/single_child_scroll_view.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.utils;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;

12
Samples/UIWidgetSample/MaterialSample.cs


namespace UIWidgetsSample {
public class MaterialSample : UIWidgetsSamplePanel {
const int testCaseId = 7;
const int testCaseId = 6;
readonly List<Widget> testCases = new List<Widget> {
new MaterialButtonWidget(),

public class MaterialSliderState : State<MaterialSliderWidget> {
float _value = 0.0f;
float _value = 0.8f;
void onChanged(float value) {
this.setState(() => { this._value = value; });

title: new Text("Slider and Indicators")),
body: new Column(
children: new List<Widget> {
new Container(
new Padding(
padding: EdgeInsets.only(top: 100.0f),
child: new Container(
divisions: 10,
min: 0.4f,
label: "Here",
)
}
)
);

8
Samples/UIWidgetSample/txt/TextFieldSample.cs


),
body: new Padding(
padding: EdgeInsets.all(16.0f),
child: new TextField(controller: this.myController)
child: new TextField(
controller: this.myController,
autofocus: true,
decoration: new InputDecoration(
hintText: "hinthere",
labelText: "pwd",
prefixIcon: new Icon(Unity.UIWidgets.material.Icons.search)))
),
floatingActionButton: new FloatingActionButton(
// When the user presses the button, show an alert dialog with the

8
Runtime/InternalBridge.meta


fileFormatVersion: 2
guid: 6692331a428d6455c97baf446a850594
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

110
Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib.meta


fileFormatVersion: 2
guid: eed39ef42fc8d4856874e03a2ae9c63a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: WebGL
second:
enabled: 1
settings: {}
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 0
settings: {}
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

1001
Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib
文件差异内容过多而无法显示
查看文件

110
Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib.meta


fileFormatVersion: 2
guid: fa7d598e002d745e487155c443ed56e4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: WebGL
second:
enabled: 1
settings: {}
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

412
Runtime/gestures/scale.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
enum _ScaleState {
ready,
possible,
accepted,
started
}
public class ScaleStartDetails {
public ScaleStartDetails(Offset focalPoint = null) {
this.focalPoint = focalPoint ?? Offset.zero;
}
public readonly Offset focalPoint;
public override string ToString() {
return $"ScaleStartDetails(focalPoint: {this.focalPoint}";
}
}
public class ScaleUpdateDetails {
public ScaleUpdateDetails(
Offset focalPoint = null,
float scale = 1.0f,
float horizontalScale = 1.0f,
float verticalScale = 1.0f,
float rotation = 0.0f
) {
focalPoint = focalPoint ?? Offset.zero;
D.assert(scale >= 0.0f);
D.assert(horizontalScale >= 0.0f);
D.assert(verticalScale >= 0.0f);
this.focalPoint = focalPoint;
this.scale = scale;
this.horizontalScale = horizontalScale;
this.verticalScale = verticalScale;
this.rotation = rotation;
}
public readonly Offset focalPoint;
public readonly float scale;
public readonly float horizontalScale;
public readonly float verticalScale;
public readonly float rotation;
public override string ToString() {
return
$"ScaleUpdateDetails(focalPoint: {this.focalPoint}, scale: {this.scale}, horizontalScale: {this.horizontalScale}, verticalScale: {this.verticalScale}, rotation: {this.rotation}";
}
}
public class ScaleEndDetails {
public ScaleEndDetails(Velocity velocity = null) {
this.velocity = velocity ?? Velocity.zero;
}
public readonly Velocity velocity;
public override string ToString() {
return $"ScaleEndDetails(velocity: {this.velocity}";
}
}
public delegate void GestureScaleStartCallback(ScaleStartDetails details);
public delegate void GestureScaleUpdateCallback(ScaleUpdateDetails details);
public delegate void GestureScaleEndCallback(ScaleEndDetails details);
static class _ScaleGestureUtils {
public static bool _isFlingGesture(Velocity velocity) {
D.assert(velocity != null);
float speedSquared = velocity.pixelsPerSecond.distanceSquared;
return speedSquared > Constants.kMinFlingVelocity * Constants.kMinFlingVelocity;
}
}
class _LineBetweenPointers {
public _LineBetweenPointers(
Offset pointerStartLocation = null,
int pointerStartId = 0,
Offset pointerEndLocation = null,
int pointerEndId = 1) {
pointerStartLocation = pointerStartLocation ?? Offset.zero;
pointerEndLocation = pointerEndLocation ?? Offset.zero;
D.assert(pointerStartId != pointerEndId);
this.pointerStartLocation = pointerStartLocation;
this.pointerStartId = pointerStartId;
this.pointerEndLocation = pointerEndLocation;
this.pointerEndId = pointerEndId;
}
public readonly Offset pointerStartLocation;
public readonly int pointerStartId;
public readonly Offset pointerEndLocation;
public readonly int pointerEndId;
}
public class ScaleGestureRecognizer : OneSequenceGestureRecognizer {
public ScaleGestureRecognizer(object debugOwner) : base(debugOwner: debugOwner) {
}
public GestureScaleStartCallback onStart;
public GestureScaleUpdateCallback onUpdate;
public GestureScaleEndCallback onEnd;
_ScaleState _state = _ScaleState.ready;
Offset _initialFocalPoint;
Offset _currentFocalPoint;
float _initialSpan;
float _currentSpan;
float _initialHorizontalSpan;
float _currentHorizontalSpan;
float _initialVerticalSpan;
float _currentVerticalSpan;
_LineBetweenPointers _initialLine;
_LineBetweenPointers _currentLine;
Dictionary<int, Offset> _pointerLocations;
List<int> _pointerQueue;
readonly Dictionary<int, VelocityTracker> _velocityTrackers = new Dictionary<int, VelocityTracker>();
float _scaleFactor {
get { return this._initialSpan > 0.0f ? this._currentSpan / this._initialSpan : 1.0f; }
}
float _horizontalScaleFactor {
get {
return this._initialHorizontalSpan > 0.0f
? this._currentHorizontalSpan / this._initialHorizontalSpan
: 1.0f;
}
}
float _verticalScaleFactor {
get {
return this._initialVerticalSpan > 0.0f ? this._currentVerticalSpan / this._initialVerticalSpan : 1.0f;
}
}
float _computeRotationFactor() {
if (this._initialLine == null || this._currentLine == null) {
return 0.0f;
}
float fx = this._initialLine.pointerStartLocation.dx;
float fy = this._initialLine.pointerStartLocation.dy;
float sx = this._initialLine.pointerEndLocation.dx;
float sy = this._initialLine.pointerEndLocation.dy;
float nfx = this._currentLine.pointerStartLocation.dx;
float nfy = this._currentLine.pointerStartLocation.dy;
float nsx = this._currentLine.pointerEndLocation.dx;
float nsy = this._currentLine.pointerEndLocation.dy;
float angle1 = Mathf.Atan2(fy - sy, fx - sx);
float angle2 = Mathf.Atan2(nfy - nsy, nfx - nsx);
return angle2 - angle1;
}
public override void addAllowedPointer(PointerDownEvent evt) {
this.startTrackingPointer(evt.pointer);
this._velocityTrackers[evt.pointer] = new VelocityTracker();
if (this._state == _ScaleState.ready) {
this._state = _ScaleState.possible;
this._initialSpan = 0.0f;
this._currentSpan = 0.0f;
this._initialHorizontalSpan = 0.0f;
this._currentHorizontalSpan = 0.0f;
this._initialVerticalSpan = 0.0f;
this._currentVerticalSpan = 0.0f;
this._pointerLocations = new Dictionary<int, Offset>();
this._pointerQueue = new List<int>();
}
}
protected override void handleEvent(PointerEvent evt) {
D.assert(this._state != _ScaleState.ready);
bool didChangeConfiguration = false;
bool shouldStartIfAccepted = false;
if (evt is PointerMoveEvent) {
VelocityTracker tracker = this._velocityTrackers[evt.pointer];
D.assert(tracker != null);
if (!evt.synthesized) {
tracker.addPosition(evt.timeStamp, evt.position);
}
this._pointerLocations[evt.pointer] = evt.position;
shouldStartIfAccepted = true;
}
else if (evt is PointerDownEvent) {
this._pointerLocations[evt.pointer] = evt.position;
this._pointerQueue.Add(evt.pointer);
didChangeConfiguration = true;
shouldStartIfAccepted = true;
}
else if (evt is PointerUpEvent || evt is PointerCancelEvent) {
this._pointerLocations.Remove(evt.pointer);
this._pointerQueue.Remove(evt.pointer);
didChangeConfiguration = true;
}
this._updateLines();
this._update();
if (!didChangeConfiguration || this._reconfigure(evt.pointer)) {
this._advanceStateMachine(shouldStartIfAccepted);
}
this.stopTrackingIfPointerNoLongerDown(evt);
}
void _update() {
int count = this._pointerLocations.Keys.Count;
Offset focalPoint = Offset.zero;
foreach (int pointer in this._pointerLocations.Keys) {
focalPoint += this._pointerLocations[pointer];
}
this._currentFocalPoint = count > 0 ? focalPoint / count : Offset.zero;
float totalDeviation = 0.0f;
float totalHorizontalDeviation = 0.0f;
float totalVerticalDeviation = 0.0f;
foreach (int pointer in this._pointerLocations.Keys) {
totalDeviation += (this._currentFocalPoint - this._pointerLocations[pointer]).distance;
totalHorizontalDeviation += (this._currentFocalPoint.dx - this._pointerLocations[pointer].dx).abs();
totalVerticalDeviation += (this._currentFocalPoint.dy - this._pointerLocations[pointer].dy).abs();
}
this._currentSpan = count > 0 ? totalDeviation / count : 0.0f;
this._currentHorizontalSpan = count > 0 ? totalHorizontalDeviation / count : 0.0f;
this._currentVerticalSpan = count > 0 ? totalVerticalDeviation / count : 0.0f;
}
void _updateLines() {
int count = this._pointerLocations.Keys.Count;
D.assert(this._pointerQueue.Count >= count);
if (count < 2) {
this._initialLine = this._currentLine;
}
else if (this._initialLine != null &&
this._initialLine.pointerStartId == this._pointerQueue[0] &&
this._initialLine.pointerEndId == this._pointerQueue[1]) {
this._currentLine = new _LineBetweenPointers(
pointerStartId: this._pointerQueue[0],
pointerStartLocation: this._pointerLocations[this._pointerQueue[0]],
pointerEndId: this._pointerQueue[1],
pointerEndLocation: this._pointerLocations[this._pointerQueue[1]]
);
}
else {
this._initialLine = new _LineBetweenPointers(
pointerStartId: this._pointerQueue[0],
pointerStartLocation: this._pointerLocations[this._pointerQueue[0]],
pointerEndId: this._pointerQueue[1],
pointerEndLocation: this._pointerLocations[this._pointerQueue[1]]
);
this._currentLine = null;
}
}
bool _reconfigure(int pointer) {
this._initialFocalPoint = this._currentFocalPoint;
this._initialSpan = this._currentSpan;
this._initialLine = this._currentLine;
this._initialHorizontalSpan = this._currentHorizontalSpan;
this._initialVerticalSpan = this._currentVerticalSpan;
if (this._state == _ScaleState.started) {
if (this.onEnd != null) {
VelocityTracker tracker = this._velocityTrackers[pointer];
D.assert(tracker != null);
Velocity velocity = tracker.getVelocity();
if (_ScaleGestureUtils._isFlingGesture(velocity)) {
Offset pixelsPerSecond = velocity.pixelsPerSecond;
if (pixelsPerSecond.distanceSquared >
Constants.kMaxFlingVelocity * Constants.kMaxFlingVelocity) {
velocity = new Velocity(
pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) *
Constants.kMaxFlingVelocity);
}
this.invokeCallback<object>("onEnd", () => {
this.onEnd(new ScaleEndDetails(velocity: velocity));
return null;
});
}
else {
this.invokeCallback<object>("onEnd", () => {
this.onEnd(new ScaleEndDetails(velocity: Velocity.zero));
return null;
});
}
}
this._state = _ScaleState.accepted;
return false;
}
return true;
}
void _advanceStateMachine(bool shouldStartIfAccepted) {
if (this._state == _ScaleState.ready) {
this._state = _ScaleState.possible;
}
if (this._state == _ScaleState.possible) {
float spanDelta = (this._currentSpan - this._initialSpan).abs();
float focalPointDelta = (this._currentFocalPoint - this._initialFocalPoint).distance;
if (spanDelta > Constants.kScaleSlop || focalPointDelta > Constants.kPanSlop) {
this.resolve(GestureDisposition.accepted);
}
}
else if (this._state >= _ScaleState.accepted) {
this.resolve(GestureDisposition.accepted);
}
if (this._state == _ScaleState.accepted && shouldStartIfAccepted) {
this._state = _ScaleState.started;
this._dispatchOnStartCallbackIfNeeded();
}
if (this._state == _ScaleState.started && this.onUpdate != null) {
this.invokeCallback<object>("onUpdate", () => {
this.onUpdate(new ScaleUpdateDetails(
scale: this._scaleFactor,
horizontalScale: this._horizontalScaleFactor,
verticalScale: this._verticalScaleFactor,
focalPoint: this._currentFocalPoint,
rotation: this._computeRotationFactor()
));
return null;
});
}
}
void _dispatchOnStartCallbackIfNeeded() {
D.assert(this._state == _ScaleState.started);
if (this.onStart != null) {
this.invokeCallback<object>("onStart", () => {
this.onStart(new ScaleStartDetails(focalPoint: this._currentFocalPoint));
return null;
});
}
}
public override void acceptGesture(int pointer) {
if (this._state == _ScaleState.possible) {
this._state = _ScaleState.started;
this._dispatchOnStartCallbackIfNeeded();
}
}
public override void rejectGesture(int pointer) {
this.stopTrackingPointer(pointer);
}
protected override void didStopTrackingLastPointer(int pointer) {
switch (this._state) {
case _ScaleState.possible:
this.resolve(GestureDisposition.rejected);
break;
case _ScaleState.ready:
D.assert(false);
break;
case _ScaleState.accepted:
break;
case _ScaleState.started:
D.assert(false);
break;
}
this._state = _ScaleState.ready;
}
public override void dispose() {
this._velocityTrackers.Clear();
base.dispose();
}
public override string debugDescription {
get { return "scale"; }
}
}
}

11
Runtime/gestures/scale.cs.meta


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

156
Runtime/material/text_form_field.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgets.Runtime.material {
public class TextFormField : FormField<string> {
public TextFormField(
Key key = null,
TextEditingController controller = null,
string initialValue = null,
FocusNode focusNode = null,
InputDecoration decoration = null,
TextInputType keyboardType = null,
TextCapitalization textCapitalization = TextCapitalization.none,
TextInputAction? textInputAction = null,
TextStyle style = null,
TextDirection? textDirection = null,
TextAlign textAlign = TextAlign.left,
bool autofocus = false,
bool obscureText = false,
bool autocorrect = true,
bool autovalidate = false,
bool maxLengthEnforced = true,
int maxLines = 1,
int? maxLength = null,
VoidCallback onEditingComplete = null,
ValueChanged<string> onFieldSubmitted = null,
FormFieldSetter<string> onSaved = null,
FormFieldValidator<string> validator = null,
List<TextInputFormatter> inputFormatters = null,
bool enabled = true,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
Color cursorColor = null,
Brightness? keyboardAppearance = null,
EdgeInsets scrollPadding = null,
bool enableInteractiveSelection = true,
InputCounterWidgetBuilder buildCounter = null
) : base(
key: key,
initialValue: controller != null ? controller.text : (initialValue ?? ""),
onSaved: onSaved,
validator: validator,
autovalidate: autovalidate,
enabled: enabled,
builder: (FormFieldState<string> field) => {
_TextFormFieldState state = (_TextFormFieldState) field;
InputDecoration effectiveDecoration = (decoration ?? new InputDecoration())
.applyDefaults(Theme.of(field.context).inputDecorationTheme);
return new TextField(
controller: state._effectiveController,
focusNode: focusNode,
decoration: effectiveDecoration.copyWith(errorText: field.errorText),
keyboardType: keyboardType,
textInputAction: textInputAction,
style: style,
textAlign: textAlign,
textDirection: textDirection ?? TextDirection.ltr,
textCapitalization: textCapitalization,
autofocus: autofocus,
obscureText: obscureText,
autocorrect: autocorrect,
maxLengthEnforced: maxLengthEnforced,
maxLines: maxLines,
maxLength: maxLength,
onChanged: field.didChange,
onEditingComplete: onEditingComplete,
onSubmitted: onFieldSubmitted,
inputFormatters: inputFormatters,
enabled: enabled,
cursorWidth: cursorWidth,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f),
keyboardAppearance: keyboardAppearance,
enableInteractiveSelection: enableInteractiveSelection,
buildCounter: buildCounter
);
}
) {
D.assert(initialValue == null || controller == null);
D.assert(maxLines > 0);
D.assert(maxLength == null || maxLength > 0);
this.controller = controller;
}
public readonly TextEditingController controller;
public override State createState() {
return new _TextFormFieldState();
}
}
class _TextFormFieldState : FormFieldState<string> {
TextEditingController _controller;
public TextEditingController _effectiveController {
get { return this.widget.controller ?? this._controller; }
}
public new TextFormField widget {
get { return (TextFormField) base.widget; }
}
public override void initState() {
base.initState();
if (this.widget.controller == null) {
this._controller = new TextEditingController(text: this.widget.initialValue);
}
else {
this.widget.controller.addListener(this._handleControllerChanged);
}
}
public override void didUpdateWidget(StatefulWidget _oldWidget) {
TextFormField oldWidget = _oldWidget as TextFormField;
base.didUpdateWidget(oldWidget);
if (this.widget.controller != oldWidget.controller) {
oldWidget.controller?.removeListener(this._handleControllerChanged);
this.widget.controller?.addListener(this._handleControllerChanged);
if (oldWidget.controller != null && this.widget.controller == null) {
this._controller = TextEditingController.fromValue(oldWidget.controller.value);
}
if (this.widget.controller != null) {
this.setValue(this.widget.controller.text);
if (oldWidget.controller == null) {
this._controller = null;
}
}
}
}
public override void dispose() {
this.widget.controller?.removeListener(this._handleControllerChanged);
base.dispose();
}
public override void reset() {
base.reset();
this.setState(() => { this._effectiveController.text = (string) this.widget.initialValue; });
}
void _handleControllerChanged() {
if (this._effectiveController.text != this.value) {
this.didChange(this._effectiveController.text);
}
}
}
}

3
Runtime/material/text_form_field.cs.meta


fileFormatVersion: 2
guid: 0a9f1467be1c4653b3dbf8a1c7209f70
timeCreated: 1557304128

127
Runtime/rendering/rotated_box.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace UIWidgets.Runtime.rendering {
class RotatedBoxUtils {
public const float _kQuarterTurnsInRadians = Mathf.PI / 2.0f;
}
public class RenderRotatedBox : RenderObjectWithChildMixinRenderBox<RenderBox> {
public RenderRotatedBox(
int quarterTurns,
RenderBox child = null
) {
this.child = child;
this._quarterTurns = quarterTurns;
}
public int quarterTurns {
get { return this._quarterTurns; }
set {
if (this._quarterTurns == value) {
return;
}
this._quarterTurns = value;
this.markNeedsLayout();
}
}
int _quarterTurns;
bool _isVertical {
get { return this.quarterTurns % 2 == 1; }
}
protected override float computeMinIntrinsicWidth(float height) {
if (this.child == null) {
return 0.0f;
}
return this._isVertical
? this.child.getMinIntrinsicHeight(height)
: this.child.getMinIntrinsicWidth(height);
}
protected override float computeMaxIntrinsicWidth(float height) {
if (this.child == null) {
return 0.0f;
}
return this._isVertical
? this.child.getMaxIntrinsicHeight(height)
: this.child.getMaxIntrinsicWidth(height);
}
protected override float computeMinIntrinsicHeight(float width) {
if (this.child == null) {
return 0.0f;
}
return this._isVertical ? this.child.getMinIntrinsicWidth(width) : this.child.getMinIntrinsicHeight(width);
}
protected override float computeMaxIntrinsicHeight(float width) {
if (this.child == null) {
return 0.0f;
}
return this._isVertical ? this.child.getMaxIntrinsicWidth(width) : this.child.getMaxIntrinsicHeight(width);
}
Matrix3 _paintTransform;
protected override void performLayout() {
this._paintTransform = null;
if (this.child != null) {
this.child.layout(this._isVertical ? this.constraints.flipped : this.constraints, parentUsesSize: true);
this.size = this._isVertical
? new Size(this.child.size.height, this.child.size.width)
: this.child.size;
this._paintTransform = Matrix3.I();
this._paintTransform.preTranslate(this.size.width / 2.0f, this.size.height / 2.0f);
this._paintTransform.preRotate(RotatedBoxUtils._kQuarterTurnsInRadians * (this.quarterTurns % 4));
this._paintTransform.preTranslate(-this.child.size.width / 2.0f, -this.child.size.height / 2.0f);
}
else {
this.performResize();
}
}
protected override bool hitTestChildren(
HitTestResult result,
Offset position = null
) {
D.assert(this._paintTransform != null || this.debugNeedsLayout || this.child == null);
if (this.child == null || this._paintTransform == null) {
return false;
}
Matrix3 inverse = Matrix3.I();
this._paintTransform.invert(inverse);
return this.child.hitTest(result, position: inverse.mapPoint(position));
}
void _paintChild(PaintingContext context, Offset offset) {
context.paintChild(this.child, offset);
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
context.pushTransform(this.needsCompositing, offset, this._paintTransform, this._paintChild);
}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
if (this._paintTransform != null) {
transform.preConcat(this._paintTransform);
}
base.applyPaintTransform(child, transform);
}
}
}

3
Runtime/rendering/rotated_box.cs.meta


fileFormatVersion: 2
guid: 057a0f3b94794fce9f9f3aa7bb624256
timeCreated: 1557210363

23
Runtime/ui/painting/ArrayRef.cs


using System;
namespace Unity.UIWidgets.ui {
public class ArrayRef<T> {
public T[] array;
public int length;
public ArrayRef() {
this.array = Array.Empty<T>();
this.length = 0;
}
public void add(T item) {
if (this.length == this.array.Length) {
int newCapacity = this.array.Length == 0 ? 4 : this.array.Length * 2;
Array.Resize(ref this.array, newCapacity);
}
this.array[this.length++] = item;
}
}
}

11
Runtime/ui/painting/ArrayRef.cs.meta


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

64
Samples/UIWidgetSample/ScaleGestureSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsSample {
public class ScaleGestureSample : UIWidgetsSamplePanel {
protected override Widget createWidget() {
return new MaterialApp(
showPerformanceOverlay: false,
home: new ScaleGesturePanel()
);
}
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons");
base.OnEnable();
}
}
class ScaleGesturePanel : StatefulWidget {
public override State createState() {
return new ScaleGesturePanelState();
}
}
class ScaleGesturePanelState : State<ScaleGesturePanel> {
float scaleValue = 1.0f;
public override Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Center(
child: new Text("Test Scale Gesture Widget")
)
),
body: new GestureDetector(
onScaleStart: scaleDetails => { Debug.Log("Scale Start !"); },
onScaleUpdate: scaleDetails => {
Debug.Log("Scale value = " + scaleDetails.scale);
this.setState(() => { this.scaleValue = scaleDetails.scale; });
},
onScaleEnd: scaleDetails => { Debug.Log("Scale End"); },
child: new Card(
color: Colors.white,
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: new List<Widget> {
new Icon(Unity.UIWidgets.material.Icons.ac_unit, size: 128.0f, color: Colors.black),
new RaisedButton(
child: new Text("Scale: " + this.scaleValue),
onPressed: () => { Debug.Log("Button Pressed"); })
}
)
))
)
);
}
}
}

11
Samples/UIWidgetSample/ScaleGestureSample.cs.meta


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

12
Runtime/InternalBridge/InternalBridge.asmdef


{
"name": "Unity.InternalAPIEngineBridge.024",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

7
Runtime/InternalBridge/InternalBridge.asmdef.meta


fileFormatVersion: 2
guid: 4c951e9ffe25e41eabcc32758a061e70
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

35
Runtime/InternalBridge/NoAllocHelpersBridge.cs


using System.Collections.Generic;
namespace Unity.UIWidgets.InternalBridge {
public static class NoAllocHelpersBridge<T> {
public static T[] ExtractArrayFromListT(List<T> list) {
return UnityEngine.NoAllocHelpers.ExtractArrayFromListT(list);
}
public static void ResizeList(List<T> list, int size) {
if (size < list.Count) {
list.RemoveRange(size, list.Count - size);
return;
}
if (size == list.Count) {
return;
}
if (list.Capacity < size) {
list.Capacity = size;
}
UnityEngine.NoAllocHelpers.ResizeList(list, size);
}
public static void EnsureListElemCount(List<T> list, int size) {
list.Clear();
if (list.Capacity < size) {
list.Capacity = size;
}
ResizeList(list, size);
}
}
}

11
Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta


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

37
Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib.meta


fileFormatVersion: 2
guid: 9e688991bb495461b8404d9fb47c6684
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Facebook: WebGL
second:
enabled: 1
settings: {}
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

8
Runtime/utils.meta


fileFormatVersion: 2
guid: 963d1b7d830374b3a915967d4721dc4a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib → /Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib

正在加载...
取消
保存