浏览代码

Merge branch 'master' into siyao/skia/base

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
2a6b7284
共有 67 个文件被更改,包括 3969 次插入959 次删除
  1. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/Widgets.cs
  2. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/animation/widgets.cs
  3. 37
      com.unity.uiwidgets/Runtime/cupertino/action_sheet.cs
  4. 33
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  5. 9
      com.unity.uiwidgets/Runtime/cupertino/text_selection.cs
  6. 1
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  7. 2
      com.unity.uiwidgets/Runtime/gestures/binding.cs
  8. 16
      com.unity.uiwidgets/Runtime/gestures/drag_details.cs
  9. 632
      com.unity.uiwidgets/Runtime/gestures/events.cs
  10. 49
      com.unity.uiwidgets/Runtime/gestures/hit_test.cs
  11. 50
      com.unity.uiwidgets/Runtime/gestures/long_press.cs
  12. 153
      com.unity.uiwidgets/Runtime/gestures/monodrag.cs
  13. 95
      com.unity.uiwidgets/Runtime/gestures/multitap.cs
  14. 81
      com.unity.uiwidgets/Runtime/gestures/pointer_router.cs
  15. 4
      com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs
  16. 132
      com.unity.uiwidgets/Runtime/gestures/recognizer.cs
  17. 8
      com.unity.uiwidgets/Runtime/gestures/tap.cs
  18. 4
      com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs
  19. 8
      com.unity.uiwidgets/Runtime/material/chip.cs
  20. 4
      com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs
  21. 8
      com.unity.uiwidgets/Runtime/material/ink_decoration.cs
  22. 8
      com.unity.uiwidgets/Runtime/material/ink_highlight.cs
  23. 8
      com.unity.uiwidgets/Runtime/material/ink_ripple.cs
  24. 12
      com.unity.uiwidgets/Runtime/material/ink_splash.cs
  25. 107
      com.unity.uiwidgets/Runtime/material/input_decorator.cs
  26. 18
      com.unity.uiwidgets/Runtime/material/list_tile.cs
  27. 4
      com.unity.uiwidgets/Runtime/material/material.cs
  28. 4
      com.unity.uiwidgets/Runtime/material/text_selection.cs
  29. 136
      com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
  30. 124
      com.unity.uiwidgets/Runtime/rendering/box.cs
  31. 23
      com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs
  32. 4
      com.unity.uiwidgets/Runtime/rendering/custom_layout.cs
  33. 4
      com.unity.uiwidgets/Runtime/rendering/custom_paint.cs
  34. 4
      com.unity.uiwidgets/Runtime/rendering/flex.cs
  35. 151
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  36. 4
      com.unity.uiwidgets/Runtime/rendering/list_body.cs
  37. 10
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  38. 27
      com.unity.uiwidgets/Runtime/rendering/object.cs
  39. 256
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  40. 8
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs
  41. 42
      com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
  42. 28
      com.unity.uiwidgets/Runtime/rendering/shifted_box.cs
  43. 141
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  44. 10
      com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs
  45. 18
      com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs
  46. 10
      com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs
  47. 86
      com.unity.uiwidgets/Runtime/rendering/stack.cs
  48. 40
      com.unity.uiwidgets/Runtime/rendering/table.cs
  49. 21
      com.unity.uiwidgets/Runtime/rendering/view.cs
  50. 45
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  51. 4
      com.unity.uiwidgets/Runtime/rendering/wrap.cs
  52. 16
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  53. 14
      com.unity.uiwidgets/Runtime/widgets/container.cs
  54. 3
      com.unity.uiwidgets/Runtime/widgets/heroes.cs
  55. 54
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  56. 4
      com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
  57. 4
      com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
  58. 500
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  59. 35
      com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs
  60. 8
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  61. 19
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  62. 125
      Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample/LocalPositionSample.cs
  63. 11
      Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample/LocalPositionSample.cs.meta
  64. 536
      Samples/UIWidgetsSamples_2019_4/Assets/Scenes/LocalPosition.unity
  65. 7
      Samples/UIWidgetsSamples_2019_4/Assets/Scenes/LocalPosition.unity.meta
  66. 892
      com.unity.uiwidgets/Runtime/ui/Matrix4.cs
  67. 11
      com.unity.uiwidgets/Runtime/ui/Matrix4.cs.meta

3
Samples/UIWidgetsSamples_2019_4/Assets/Editor/Widgets.cs


var mediaQueryData = MediaQuery.of(context);
var px = mediaQueryData.size.width / 2;
var py = mediaQueryData.size.width / 2;
transform: Matrix3.makeRotate(Mathf.PI / 180 * 5, px, py),
transform: new Matrix4().rotationZ(Mathf.PI / 180 * 5, px, py),
child:
new Column(
children: new List<Widget> {

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/animation/widgets.cs


);
public override Widget build(BuildContext context) {
var scale = this.scale ?? 1.0f;
transform: Matrix3.makeScale(this.scale ?? 1.0f),
transform: new Matrix4().diagonal3Values(scale, scale, scale),
alignment: Alignment.center,
child: new Stack(
children: new List<Widget> {

37
com.unity.uiwidgets/Runtime/cupertino/action_sheet.cs


}
class _CupertinoAlertRenderElement : RenderObjectElement {
public _CupertinoAlertRenderElement(_CupertinoAlertRenderWidget widget) : base(widget) { }
public _CupertinoAlertRenderElement(_CupertinoAlertRenderWidget widget) : base(widget) {
}
Element _contentElement;
Element _actionsElement;

);
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
bool isHit = false;
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
actionsSection.parentData as MultiChildLayoutParentData;
;
if (contentSection.hitTest(result, position: position - contentSectionParentData.offset)) {
isHit = true;
}
else if (actionsSection.hitTest(result,
position: position - actionsSectionParentData.offset)) {
isHit = true;
}
return isHit;
this.actionsSection.parentData as MultiChildLayoutParentData;
return result.addWithPaintOffset(
offset: contentSectionParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - contentSectionParentData.offset);
return this.contentSection.hitTest(resultIn, position: transformed);
}
) || result.addWithPaintOffset(
offset: actionsSectionParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - actionsSectionParentData.offset);
return this.actionsSection.hitTest(resultIn, position: transformed);
}
);
}
}

}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.defaultHitTestChildren(result, position: position);
}
}
}

33
com.unity.uiwidgets/Runtime/cupertino/dialog.cs


);
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null
bool isHit = false;
BoxParentData contentSectionParentData = contentSection.parentData as BoxParentData;
BoxParentData actionsSectionParentData = actionsSection.parentData as BoxParentData;
;
if (contentSection.hitTest(result, position: position - contentSectionParentData.offset)) {
isHit = true;
}
else if (actionsSection.hitTest(result, position: position - actionsSectionParentData.offset)) {
isHit = true;
}
return isHit;
BoxParentData contentSectionParentData = this.contentSection.parentData as BoxParentData;
BoxParentData actionsSectionParentData = this.actionsSection.parentData as BoxParentData;
return result.addWithPaintOffset(
offset: contentSectionParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - contentSectionParentData.offset);
return this.contentSection.hitTest(resultIn, position: transformed);
}
) || result.addWithPaintOffset(
offset: actionsSectionParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - actionsSectionParentData.offset);
return this.actionsSection.hitTest(resultIn, position: transformed);
}
);
}
}

}
}
protected override bool hitTestChildren(HitTestResult result,
protected override bool hitTestChildren(BoxHitTestResult result,
Offset position = null
) {
return defaultHitTestChildren(result, position: position);

9
com.unity.uiwidgets/Runtime/cupertino/text_selection.cs


switch (type) {
case TextSelectionHandleType.left:
Matrix3 matrix = Matrix3.makeRotate(Mathf.PI);
matrix.preTranslate(-CupertinoTextSelectionUtils._kHandlesPadding,
Matrix4 matrix = new Matrix4().rotationZ(Mathf.PI);
matrix.translate(-CupertinoTextSelectionUtils._kHandlesPadding,
-CupertinoTextSelectionUtils._kHandlesPadding);
return new Transform(

case TextSelectionHandleType.right:
return new Transform(
transform: Matrix3.makeTrans(
transform:new Matrix4().translationValues(
-(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding)
-(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding),
0
),
child: handle
);

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


transition,
whitespace,
singleLine,
errorProperty,
}
public class TextTreeConfiguration {

2
com.unity.uiwidgets/Runtime/gestures/binding.cs


foreach (HitTestEntry entry in hitTestResult.path) {
try {
entry.target.handleEvent(evt, entry);
entry.target.handleEvent(evt.transformed(entry.transform), entry);
}
catch (Exception ex) {
D.logError("Error while dispatching a pointer event: ", ex);

16
com.unity.uiwidgets/Runtime/gestures/drag_details.cs


namespace Unity.UIWidgets.gestures {
public class DragDownDetails {
public DragDownDetails(
Offset globalPosition = null
Offset globalPosition = null,
Offset localPosition = null
this.localPosition = localPosition ?? this.globalPosition;
public readonly Offset localPosition;
public override string ToString() {
return GetType() + "(" + globalPosition + ")";

public delegate void GestureDragDownCallback(DragDownDetails details);
public class DragStartDetails {
public DragStartDetails(TimeSpan sourceTimeStamp, Offset globalPosition = null) {
public DragStartDetails(
TimeSpan sourceTimeStamp,
Offset globalPosition = null,
Offset localPosition = null
) {
this.localPosition = localPosition ?? this.globalPosition;
public readonly Offset localPosition;
public override string ToString() {
return GetType() + "(" + globalPosition + ")";

Offset delta = null,
float? primaryDelta = null,
Offset globalPosition = null,
Offset localPosition = null,
this.localPosition = localPosition ?? this.globalPosition;
this.isScroll = isScroll;
D.assert(primaryDelta == null
|| primaryDelta == this.delta.dx && this.delta.dy == 0.0

public readonly float? primaryDelta;
public readonly Offset globalPosition;
public readonly Offset localPosition;
public readonly bool isScroll;

632
com.unity.uiwidgets/Runtime/gestures/events.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Unity.UIWidgets.gestures {

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
Offset localDelta = null,
int buttons = 0,
bool down = false,
bool obscured = false,

float orientation = 0.0f,
float tilt = 0.0f,
int platformData = 0,
bool synthesized = false
bool synthesized = false,
Matrix4 transform = null,
PointerEvent original = null
) {
this.timeStamp = timeStamp;
this.pointer = pointer;

this.localPosition = localPosition ?? this.position;
this.localDelta = delta ?? this.delta;
this.buttons = buttons;
this.down = down;
this.obscured = obscured;

this.tilt = tilt;
this.platformData = platformData;
this.synthesized = synthesized;
this.transform = transform;
this.original = original;
}
public readonly TimeSpan timeStamp;

public readonly Offset position;
public readonly Offset localPosition;
public readonly Offset localDelta;
public readonly int buttons;

public readonly bool synthesized;
public readonly Matrix4 transform;
public readonly PointerEvent original;
public abstract PointerEvent transformed(Matrix4 transform);
properties.add(new DiagnosticsProperty<Offset>("position", position));
properties.add(new DiagnosticsProperty<Offset>("delta", delta, defaultValue: Offset.zero,
properties.add(new DiagnosticsProperty<Offset>("position", this.position));
properties.add(new DiagnosticsProperty<Offset>("localPosition", this.localPosition));
properties.add(new DiagnosticsProperty<Offset>("delta", this.delta, defaultValue: Offset.zero,
level: DiagnosticLevel.debug));
properties.add(new DiagnosticsProperty<Offset>("localDelta", this.localDelta, defaultValue: Offset.zero,
properties.add(new DiagnosticsProperty<TimeSpan>("timeStamp", timeStamp, defaultValue: TimeSpan.Zero,
properties.add(new DiagnosticsProperty<TimeSpan>("timeStamp", this.timeStamp, defaultValue: TimeSpan.Zero,
level: DiagnosticLevel.debug));
properties.add(new IntProperty("pointer", pointer, level: DiagnosticLevel.debug));
properties.add(new EnumProperty<PointerDeviceKind>("kind", kind, level: DiagnosticLevel.debug));

properties.add(new FlagProperty("synthesized", value: synthesized, ifTrue: "synthesized",
level: DiagnosticLevel.debug));
}
public static Offset transformPosition(Matrix4 transform, Offset position) {
if (transform == null) {
return position;
}
Vector3 position3 = new Vector3(position.dx, position.dy, 0.0f);
Vector3 transformed3 = transform.perspectiveTransform(position3);
return new Offset(transformed3.x, transformed3.y);
}
public static Offset transformDeltaViaPositions(
Offset untransformedEndPosition,
Offset untransformedDelta,
Matrix4 transform,
Offset transformedEndPosition = null
) {
if (transform == null) {
return untransformedDelta;
}
transformedEndPosition = transformedEndPosition ?? transformPosition(transform, untransformedEndPosition);
Offset transformedStartPosition =
transformPosition(transform, untransformedEndPosition - untransformedDelta);
return transformedEndPosition - transformedStartPosition;
}
public static Matrix4 removePerspectiveTransform(Matrix4 transform) {
Vector4 vector = new Vector4(0, 0, 1, 0);
var result = transform.clone();
result.setColumn(2, vector);
result.setRow(2, vector);
return result;
}
}
public class PointerAddedEvent : PointerEvent {

int device = 0,
Offset position = null,
Offset localPosition = null,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,

float radiusMin = 0.0f,
float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f
float tilt = 0.0f,
Matrix4 transform = null,
PointerAddedEvent original = null
localPosition: localPosition,
obscured: obscured,
pressure: pressure,
pressureMin: pressureMin,

radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
tilt: tilt
tilt: tilt,
transform: transform,
original: original
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerAddedEvent(
timeStamp: this.timeStamp,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
transform: this.transform,
original: this.original as PointerAddedEvent ?? this
);
}
}
public class PointerRemovedEvent : PointerEvent {

int device = 0,
Offset position = null,
Offset localPosition = null,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,

float radiusMax = 0.0f
float radiusMax = 0.0f,
Matrix4 transform = null,
PointerRemovedEvent original = null
position: position,
localPosition: localPosition,
device: device,
obscured: obscured,
pressure: pressure,

radiusMin: radiusMin,
radiusMax: radiusMax
radiusMax: radiusMax,
transform: transform,
original: original
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerRemovedEvent(
timeStamp: this.timeStamp,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distanceMax: this.distanceMax,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
transform: transform,
original: this.original as PointerRemovedEvent ?? this
);
}
}
public class PointerHoverEvent : PointerEvent {

int device = 0,
Offset position = null,
Offset localPosition = null,
Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f,
bool synthesized = false) : base(
bool synthesized = false,
Matrix4 transform = null,
PointerHoverEvent original = null) : base(
localPosition: localDelta,
localDelta: localDelta,
buttons: buttons,
obscured: obscured,
pressure: pressure,

radiusMax: radiusMax,
orientation: orientation,
tilt: tilt,
synthesized: synthesized) {
synthesized: synthesized,
transform: transform,
original: original) {
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
Offset transformedPosition = PointerEvent.transformPosition(transform, this.position);
return new PointerHoverEvent(
timeStamp: this.timeStamp,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: transformedPosition,
delta: this.delta,
localDelta: PointerEvent.transformDeltaViaPositions(
transform: transform,
untransformedDelta: this.delta,
untransformedEndPosition: this.position,
transformedEndPosition: transformedPosition
),
buttons: this.buttons,
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
synthesized: this.synthesized,
transform: transform,
original: this.original as PointerHoverEvent ?? this);
}
}

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float orientation = 0.0f,
float tilt = 0.0f,
bool synthesized = false,
bool down = false) : base(
bool down = false,
Matrix4 transform = null,
PointerEnterEvent original = null) : base(
localPosition: localPosition,
localDelta: localDelta,
buttons: buttons,
down: down,
obscured: obscured,

radiusMax: radiusMax,
orientation: orientation,
tilt: tilt,
synthesized: synthesized) {
synthesized: synthesized,
transform: transform,
original: original) {
}
public static PointerEnterEvent fromHoverEvent(PointerHoverEvent e) {

kind: hover?.kind ?? PointerDeviceKind.touch,
device: hover?.device ?? 0,
position: hover?.position,
localPosition: hover?.localPosition,
localDelta: hover?.localDelta,
buttons: hover?.buttons ?? 0,
down: hover?.down ?? false,
obscured: hover?.obscured ?? false,

radiusMax: hover?.radiusMax ?? 0.0f,
orientation: hover?.orientation ?? 0.0f,
tilt: hover?.tilt ?? 0.0f,
synthesized: hover?.synthesized ?? false
synthesized: hover?.synthesized ?? false,
transform: hover?.transform,
original: hover?.original as PointerEnterEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
Offset transformedPosition = PointerEvent.transformPosition(transform, this.position);
return new PointerEnterEvent(
timeStamp: this.timeStamp,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: transformedPosition,
delta: this.delta,
localDelta: PointerEvent.transformDeltaViaPositions(
transform: transform,
untransformedDelta: this.delta,
untransformedEndPosition: this.position,
transformedEndPosition: transformedPosition
),
buttons: this.buttons,
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
down: this.down,
synthesized: this.synthesized,
transform: transform,
original: this.original as PointerEnterEvent ?? this
);
}
}

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float orientation = 0.0f,
float tilt = 0.0f,
bool synthesized = false,
bool down = false) : base(
bool down = false,
Matrix4 transform = null,
PointerExitEvent original = null) : base(
localPosition: localPosition,
localDelta: localDelta,
buttons: buttons,
down: down,
obscured: obscured,

radiusMax: radiusMax,
orientation: orientation,
tilt: tilt,
synthesized: synthesized) {
synthesized: synthesized,
transform: transform,
original: original) {
public static PointerExitEvent fromHoverEvent(PointerHoverEvent e) {
return fromMouseEvent(e);

kind: hover?.kind ?? PointerDeviceKind.touch,
device: hover?.device ?? 0,
position: hover?.position,
localPosition: hover?.localPosition,
localDelta: hover?.localDelta,
buttons: hover?.buttons ?? 0,
down: hover?.down ?? false,
obscured: hover?.obscured ?? false,

radiusMax: hover?.radiusMax ?? 0.0f,
orientation: hover?.orientation ?? 0.0f,
tilt: hover?.tilt ?? 0.0f,
synthesized: hover?.synthesized ?? false
synthesized: hover?.synthesized ?? false,
transform: hover?.transform,
original: hover?.original as PointerExitEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
Offset transformedPosition = PointerEvent.transformPosition(transform, this.position);
return new PointerExitEvent(
timeStamp: this.timeStamp,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: transformedPosition,
delta: this.delta,
localDelta: PointerEvent.transformDeltaViaPositions(
transform: transform,
untransformedDelta: this.delta,
untransformedEndPosition: this.position,
transformedEndPosition: transformedPosition
),
buttons: this.buttons,
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
down: this.down,
synthesized: this.synthesized,
transform: transform,
original: this.original as PointerExitEvent ?? this
);
}
}

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float radiusMin = 0.0f,
float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f
float tilt = 0.0f,
Matrix4 transform = null,
PointerDownEvent original = null
) : base(
timeStamp: timeStamp,
pointer: pointer,

localPosition: localPosition,
buttons: buttons,
down: true,
obscured: obscured,

radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
tilt: tilt) {
tilt: tilt,
transform: transform,
original: original) {
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerDownEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
buttons: this.buttons,
obscured: this.obscured,
pressure: this.pressure,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
transform: transform,
original: this.original as PointerDownEvent ?? this
);
}
}

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float orientation = 0.0f,
float tilt = 0.0f,
int platformdData = 0,
bool synthesized = false
bool synthesized = false,
Matrix4 transform = null,
PointerMoveEvent original = null
) : base(
timeStamp: timeStamp,
pointer: pointer,

localPosition: localPosition,
localDelta: localDelta,
buttons: buttons,
down: true,
obscured: obscured,

orientation: orientation,
tilt: tilt,
platformData: platformdData,
synthesized: synthesized) {
synthesized: synthesized,
transform: transform,
original: original) {
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
Offset transformedPosition = PointerEvent.transformPosition(transform, this.position);
return new PointerMoveEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: transformedPosition,
delta: this.delta,
localDelta: PointerEvent.transformDeltaViaPositions(
transform: transform,
untransformedDelta: this.delta,
untransformedEndPosition: this.position,
transformedEndPosition: transformedPosition
),
buttons: this.buttons,
obscured: this.obscured,
pressure: this.pressure,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
// platformData: platformData,
synthesized: this.synthesized,
transform: transform,
original: this.original as PointerMoveEvent ?? this
);
}
}

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float radiusMin = 0.0f,
float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f
float tilt = 0.0f,
Matrix4 transform = null,
PointerUpEvent original = null
) : base(
timeStamp: timeStamp,
pointer: pointer,

localPosition: localPosition,
buttons: buttons,
down: false,
obscured: obscured,

radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
tilt: tilt) {
tilt: tilt,
transform: transform,
original: original) {
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerUpEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
buttons: this.buttons,
obscured: this.obscured,
pressure: this.pressure,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
transform: transform,
original: this.original as PointerUpEvent ?? this
);
public class PointerSignalEvent : PointerEvent {
public abstract class PointerSignalEvent : PointerEvent {
Offset position = null
Offset position = null,
Offset localPosition = null,
Matrix4 transform = null,
PointerSignalEvent original = null
position: position
position: position,
localPosition: localPosition,
transform: transform,
original: original
) {
}
}

PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null,
Offset scrollDelta = null)
Offset localPosition = null,
Offset scrollDelta = null,
Matrix4 transform = null,
PointerScrollEvent original = null)
position: position) {
position: position,
localPosition: localPosition,
transform: transform,
original: original) {
D.assert(position != null);
D.assert(scrollDelta != null);
this.scrollDelta = scrollDelta;

public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerScrollEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
scrollDelta: this.scrollDelta,
transform: transform,
original: this.original as PointerScrollEvent ?? this
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Offset>("scrollDelta", scrollDelta));

PointerDeviceKind kind = PointerDeviceKind.touch,
int device = 0,
Offset position = null,
Offset localPosition = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,

float radiusMin = 0.0f,
float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f
float tilt = 0.0f,
Matrix4 transform = null,
PointerCancelEvent original = null
) : base(
timeStamp: timeStamp,
pointer: pointer,

localPosition: localPosition,
buttons: buttons,
down: false,
obscured: obscured,

radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
tilt: tilt) {
tilt: tilt,
transform: transform,
original: original) {
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerCancelEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
buttons: this.buttons,
obscured: this.obscured,
pressureMin: this.pressureMin,
pressureMax: this.pressureMax,
distance: this.distance,
distanceMax: this.distanceMax,
size: this.size,
radiusMajor: this.radiusMajor,
radiusMinor: this.radiusMinor,
radiusMin: this.radiusMin,
radiusMax: this.radiusMax,
orientation: this.orientation,
tilt: this.tilt,
transform: transform,
original: this.original as PointerCancelEvent ?? this
);
}
}

int pointer = 0,
PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null
Offset position = null,
Offset localPosition = null,
Matrix4 transform = null,
PointerDragFromEditorEnterEvent original = null
position: position
position: position,
localPosition: localPosition,
transform: transform,
original: original
) {
}

pointer: evt.pointer,
kind: evt.kind,
device: evt.device,
position: evt.position
position: evt.position,
localPosition: evt.localPosition,
transform: evt.transform,
original: evt.original as PointerDragFromEditorEnterEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerDragFromEditorEnterEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
transform: transform,
original: this.original as PointerDragFromEditorEnterEvent ?? this
);
}
}

int pointer = 0,
PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null
Offset position = null,
Offset localPosition = null,
Matrix4 transform = null,
PointerDragFromEditorExitEvent original = null
position: position
position: position,
localPosition: localPosition,
transform: transform,
original: original
) {
}

pointer: evt.pointer,
kind: evt.kind,
device: evt.device,
position: evt.position
position: evt.position,
localPosition: evt.localPosition,
transform: evt.transform,
original: evt.original as PointerDragFromEditorExitEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerDragFromEditorExitEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
transform: transform,
original: this.original as PointerDragFromEditorExitEvent ?? this
);
}
}

int pointer = 0,
PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null
Offset position = null,
Offset localPosition = null,
Matrix4 transform = null,
PointerDragFromEditorHoverEvent original = null
position: position
position: position,
localPosition: localPosition,
transform: transform,
original: original
) {
}

pointer: evt.pointer,
kind: evt.kind,
device: evt.device,
position: evt.position
position: evt.position,
localPosition: evt.localPosition,
transform: evt.transform,
original: evt.original as PointerDragFromEditorHoverEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerDragFromEditorHoverEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
transform: this.transform,
original: this.original as PointerDragFromEditorHoverEvent ?? this
);
}
}

PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null,
Object[] objectReferences = null
Offset localPosition = null,
Object[] objectReferences = null,
Matrix4 transform = null,
PointerDragFromEditorReleaseEvent original = null
position: position
position: position,
localPosition: localPosition,
transform: transform,
original: original
) {
this.objectReferences = objectReferences;
}

kind: evt.kind,
device: evt.device,
position: evt.position,
objectReferences: objectReferences
localPosition: evt.localPosition,
objectReferences: objectReferences,
transform: evt.transform,
original: evt.original as PointerDragFromEditorReleaseEvent
);
}
public override PointerEvent transformed(Matrix4 transform) {
if (transform == null || transform == this.transform) {
return this;
}
return new PointerDragFromEditorReleaseEvent(
timeStamp: this.timeStamp,
pointer: this.pointer,
kind: this.kind,
device: this.device,
position: this.position,
localPosition: PointerEvent.transformPosition(transform, this.position),
objectReferences: this.objectReferences,
transform: this.transform,
original: this.original as PointerDragFromEditorReleaseEvent ?? this
);
}
}

49
com.unity.uiwidgets/Runtime/gestures/hit_test.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
public interface HitTestable {

public override string ToString() {
return _target.ToString();
}
public Matrix4 transform {
get { return this._transform; }
}
internal Matrix4 _transform;
public HitTestResult(List<HitTestEntry> path = null) {
_path = path ?? new List<HitTestEntry>();
public HitTestResult() {
this._path = new List<HitTestEntry>();
this._transforms = new LinkedList<Matrix4>();
}
public HitTestResult(HitTestResult result) {
this._path = result._path;
this._transforms = result._transforms;
}
public IList<HitTestEntry> path {

readonly List<HitTestEntry> _path;
readonly LinkedList<Matrix4> _transforms;
_path.Add(entry);
D.assert(entry.transform == null);
entry._transform = this._transforms.isEmpty() ? null : this._transforms.Last();
this._path.Add(entry);
}
protected void pushTransform(Matrix4 transform) {
D.assert(transform != null);
D.assert(
this._debugVectorMoreOrLessEquals(transform.getRow(2), new Vector4(0, 0, 1, 0)) &&
this._debugVectorMoreOrLessEquals(transform.getColumn(2), new Vector4(0, 0, 1, 0))
);
this._transforms.AddLast(this._transforms.isEmpty()
? transform
: (transform * this._transforms.Last() as Matrix4));
}
protected void popTransform() {
D.assert(this._transforms.isNotEmpty);
this._transforms.RemoveLast();
}
bool _debugVectorMoreOrLessEquals(Vector4 a, Vector4 b,
double epsilon = SliverGeometry.precisionErrorTolerance) {
bool result = true;
D.assert(() => {
Vector4 difference = a - b;
return difference.SqrMagnitude() < epsilon;
});
return result;
}
public override string ToString() {

50
com.unity.uiwidgets/Runtime/gestures/long_press.cs


public class LongPressStartDetails {
public LongPressStartDetails(
Offset globalPosition = null
Offset globalPosition = null,
Offset localPosition = null
this.localPosition = localPosition ?? this.globalPosition;
public readonly Offset localPosition;
Offset offsetFromOrigin = null
Offset localPosition = null,
Offset offsetFromOrigin = null,
Offset localOffsetFromOrigin = null
this.localPosition = localPosition ?? this.globalPosition;
this.localOffsetFromOrigin = localOffsetFromOrigin ?? this.offsetFromOrigin;
public readonly Offset localPosition;
public readonly Offset localOffsetFromOrigin;
Offset globalPosition = null
Offset globalPosition = null,
Offset localPosition = null
this.localPosition = localPosition ?? this.globalPosition;
this.velocity = Velocity.zero;
public readonly Offset localPosition;
public readonly Velocity velocity;
TimeSpan? duration = null,
deadline: Constants.kLongPressTimeout,
deadline: duration ?? Constants.kLongPressTimeout,
postAcceptSlopTolerance: postAcceptSlopTolerance,
kind: kind,
debugOwner: debugOwner) { }

Offset _longPressOrigin;
OffsetPair _longPressOrigin;
int _initialButtons;
public GestureLongPressCallback onLongPress;

public GestureLongPressEndCallback onLongPressEnd;
VelocityTracker _velocityTracker;
protected override void didExceedDeadline() {
resolve(GestureDisposition.accepted);
_longPressAccepted = true;

if (onLongPressStart != null) {
invokeCallback<object>("onLongPressStart",
() => {
onLongPressStart(new LongPressStartDetails(globalPosition: _longPressOrigin));
this.onLongPressStart(new LongPressStartDetails(
globalPosition: this._longPressOrigin.global,
localPosition:this._longPressOrigin.local
));
return null;
});
}

});
}
if (onLongPressEnd != null) {
invokeCallback<object>("onLongPressEnd", () => {
onLongPressEnd(new LongPressEndDetails(globalPosition: evt.position));
if (this.onLongPressEnd != null) {
this.invokeCallback<object>("onLongPressEnd", () => {
this.onLongPressEnd(new LongPressEndDetails(
globalPosition: evt.position,
localPosition: evt.localPosition));
return null;
});
}

}
}
else if (evt is PointerDownEvent || evt is PointerCancelEvent) {
_longPressAccepted = false;
_longPressOrigin = evt.position;
this._longPressAccepted = false;
this._longPressOrigin = OffsetPair.fromEventPosition(evt);
offsetFromOrigin: evt.position - _longPressOrigin
localPosition: evt.localPosition,
offsetFromOrigin: evt.position - this._longPressOrigin.global,
localOffsetFromOrigin: evt.localPosition - this._longPressOrigin.local
));
return null;
});

153
com.unity.uiwidgets/Runtime/gestures/monodrag.cs


public float? maxFlingVelocity;
_DragState _state = _DragState.ready;
Offset _initialPosition;
protected Offset _pendingDragOffset;
OffsetPair _initialPosition;
protected OffsetPair _pendingDragOffset;
Matrix4 _lastTransform;
protected float _globalDistanceMoved;
protected abstract bool _hasSufficientPendingDragDeltaToAccept { get; }
protected abstract bool _hasSufficientGlobalDistanceToAccept { get; }
startTrackingScrollerPointer(evt.pointer);
if (_state == _DragState.ready) {
_state = _DragState.possible;
_initialPosition = evt.position;
if (onStart != null) {
invokeCallback<object>("onStart", () => {
onStart(new DragStartDetails(
this.startTrackingScrollerPointer(evt.pointer);
if (this._state == _DragState.ready) {
this._state = _DragState.possible;
this._initialPosition = new OffsetPair(global: evt.position, local: evt.localPosition);
if (this.onStart != null) {
this.invokeCallback<object>("onStart", () => {
this.onStart(new DragStartDetails(
globalPosition: _initialPosition
globalPosition: this._initialPosition.global,
localPosition: this._initialPosition.local
));
return null;
});

public override void addAllowedPointer(PointerDownEvent evt) {
startTrackingPointer(evt.pointer);
_velocityTrackers[evt.pointer] = new VelocityTracker();
if (_state == _DragState.ready) {
_state = _DragState.possible;
_initialPosition = evt.position;
_pendingDragOffset = Offset.zero;
_lastPendingEventTimestamp = evt.timeStamp;
if (onDown != null) {
invokeCallback<object>("onDown",
this.startTrackingPointer(evt.pointer, evt.transform);
this._velocityTrackers[evt.pointer] = new VelocityTracker();
if (this._state == _DragState.ready) {
this._state = _DragState.possible;
this._initialPosition = new OffsetPair(global: evt.position, local: evt.localPosition);
this._pendingDragOffset = OffsetPair.zero;
this._globalDistanceMoved = 0f;
this._lastPendingEventTimestamp = evt.timeStamp;
this._lastTransform = evt.transform;
if (this.onDown != null) {
this.invokeCallback<object>("onDown",
onDown(new DragDownDetails(globalPosition: _initialPosition));
this.onDown(new DragDownDetails(
globalPosition: this._initialPosition.global,
localPosition: this._initialPosition.local));
return null;
});
}

delta: _getDeltaForDetails(delta),
primaryDelta: _getPrimaryValueFromOffset(delta),
globalPosition: evt.position,
localPosition: evt.localPosition,
isScroll: true
));
return null;

&& (evt is PointerDownEvent || evt is PointerMoveEvent)) {
var tracker = _velocityTrackers[evt.pointer];
D.assert(tracker != null);
tracker.addPosition(evt.timeStamp, evt.position);
tracker.addPosition(evt.timeStamp, evt.localPosition);
Offset delta = evt.delta;
if (_state == _DragState.accepted) {
if (onUpdate != null) {
invokeCallback<object>("onUpdate", () => {
onUpdate(new DragUpdateDetails(
if (this._state == _DragState.accepted) {
if (this.onUpdate != null) {
this.invokeCallback<object>("onUpdate", () => {
this.onUpdate(new DragUpdateDetails(
delta: _getDeltaForDetails(delta),
primaryDelta: _getPrimaryValueFromOffset(delta),
globalPosition: evt.position
delta: this._getDeltaForDetails(evt.localDelta),
primaryDelta: this._getPrimaryValueFromOffset(evt.localDelta),
globalPosition: evt.position,
localPosition: evt.localPosition
));
return null;
});

_pendingDragOffset += delta;
_lastPendingEventTimestamp = evt.timeStamp;
if (_hasSufficientPendingDragDeltaToAccept) {
resolve(GestureDisposition.accepted);
this._pendingDragOffset += new OffsetPair(local: evt.localDelta, global: evt.delta);
this._lastPendingEventTimestamp = evt.timeStamp;
this._lastTransform = evt.transform;
Offset movedLocally = this._getDeltaForDetails(evt.localDelta);
Matrix4 localToGlobalTransform = evt.transform == null ? null : Matrix4.tryInvert(evt.transform);
this._globalDistanceMoved += PointerEvent.transformDeltaViaPositions(
transform: localToGlobalTransform,
untransformedDelta: movedLocally,
untransformedEndPosition: evt.localPosition
).distance * (this._getPrimaryValueFromOffset(movedLocally) ?? 1).sign();
if (this._hasSufficientGlobalDistanceToAccept) {
this.resolve(GestureDisposition.accepted);
}
}
}

public override void acceptGesture(int pointer) {
if (_state != _DragState.accepted) {
_state = _DragState.accepted;
Offset delta = _pendingDragOffset;
var timestamp = _lastPendingEventTimestamp;
if (this._state != _DragState.accepted) {
this._state = _DragState.accepted;
OffsetPair delta = this._pendingDragOffset;
var timestamp = this._lastPendingEventTimestamp;
Matrix4 transform = this._lastTransform;
Offset updateDelta = null;
switch (dragStartBehavior) {
Offset localUpdateDelta = null;
switch (this.dragStartBehavior) {
_initialPosition = _initialPosition + delta;
updateDelta = Offset.zero;
this._initialPosition = this._initialPosition + delta;
localUpdateDelta = Offset.zero;
updateDelta = _getDeltaForDetails(delta);
localUpdateDelta = this._getDeltaForDetails(delta.local);
D.assert(updateDelta != null);
D.assert(localUpdateDelta != null);
_pendingDragOffset = Offset.zero;
_lastPendingEventTimestamp = default(TimeSpan);
if (onStart != null) {
invokeCallback<object>("onStart", () => {
onStart(new DragStartDetails(
this._pendingDragOffset = OffsetPair.zero;
this._lastPendingEventTimestamp = default(TimeSpan);
this._lastTransform = null;
if (this.onStart != null) {
this.invokeCallback<object>("onStart", () => {
this.onStart(new DragStartDetails(
globalPosition: _initialPosition
globalPosition: this._initialPosition.global,
localPosition: this._initialPosition.local
if (updateDelta != Offset.zero && onUpdate != null) {
invokeCallback<object>("onUpdate", () => {
onUpdate(new DragUpdateDetails(
if (localUpdateDelta != Offset.zero && this.onUpdate != null) {
Matrix4 localToGlobal = transform != null ? Matrix4.tryInvert(transform) : null;
Offset correctedLocalPosition = this._initialPosition.local + localUpdateDelta;
Offset globalUpdateDelta = PointerEvent.transformDeltaViaPositions(
untransformedEndPosition: correctedLocalPosition,
untransformedDelta: localUpdateDelta,
transform: localToGlobal
);
OffsetPair updateDelta = new OffsetPair(local: localUpdateDelta, global: globalUpdateDelta);
OffsetPair correctedPosition = this._initialPosition + updateDelta; // Only adds delta for down behaviour
this.invokeCallback<object>("onUpdate", () => {
this.onUpdate(new DragUpdateDetails(
delta: updateDelta,
primaryDelta: _getPrimaryValueFromOffset(updateDelta),
globalPosition: _initialPosition + updateDelta
delta: localUpdateDelta,
primaryDelta: this._getPrimaryValueFromOffset(localUpdateDelta),
globalPosition: this._initialPosition.global,
localPosition: this._initialPosition.local
));
return null;
});

return Mathf.Abs(estimate.pixelsPerSecond.dy) > minVelocity && Mathf.Abs(estimate.offset.dy) > minDistance;
}
protected override bool _hasSufficientPendingDragDeltaToAccept {
get { return Mathf.Abs(_pendingDragOffset.dy) > Constants.kTouchSlop; }
protected override bool _hasSufficientGlobalDistanceToAccept {
get { return Mathf.Abs(this._globalDistanceMoved) > Constants.kTouchSlop; }
}
protected override Offset _getDeltaForDetails(Offset delta) {

return Mathf.Abs(estimate.pixelsPerSecond.dx) > minVelocity && Mathf.Abs(estimate.offset.dx) > minDistance;
}
protected override bool _hasSufficientPendingDragDeltaToAccept {
get { return Mathf.Abs(_pendingDragOffset.dx) > Constants.kTouchSlop; }
protected override bool _hasSufficientGlobalDistanceToAccept {
get { return Mathf.Abs(this._globalDistanceMoved) > Constants.kTouchSlop; }
}
protected override Offset _getDeltaForDetails(Offset delta) {

&& estimate.offset.distanceSquared > minDistance * minDistance;
}
protected override bool _hasSufficientPendingDragDeltaToAccept {
get { return _pendingDragOffset.distance > Constants.kPanSlop; }
protected override bool _hasSufficientGlobalDistanceToAccept {
get { return Math.Abs(this._globalDistanceMoved) > Constants.kPanSlop; }
}
protected override Offset _getDeltaForDetails(Offset delta) {

95
com.unity.uiwidgets/Runtime/gestures/multitap.cs


TimeSpan doubleTapMinTime,
GestureArenaEntry entry = null
) {
pointer = evt.pointer;
_initialPosition = evt.position;
_doubleTapMinTimeCountdown = new _CountdownZoned(duration: doubleTapMinTime);
this.pointer = evt.pointer;
this._initialGlobalPosition = evt.position;
this._doubleTapMinTimeCountdown = new _CountdownZoned(duration: doubleTapMinTime);
internal readonly Offset _initialPosition;
internal readonly Offset _initialGlobalPosition;
public void startTrackingPointer(PointerRoute route) {
if (!_isTrackingPointer) {
_isTrackingPointer = true;
GestureBinding.instance.pointerRouter.addRoute(pointer, route);
public void startTrackingPointer(PointerRoute route, Matrix4 transform) {
if (!this._isTrackingPointer) {
this._isTrackingPointer = true;
GestureBinding.instance.pointerRouter.addRoute(this.pointer, route, transform);
}
}

}
}
public bool isWithinTolerance(PointerEvent evt, float tolerance) {
Offset offset = evt.position - _initialPosition;
public bool isWithinGlobalTolerance(PointerEvent evt, float tolerance) {
Offset offset = evt.position - this._initialGlobalPosition;
return offset.distance <= tolerance;
}

public class DoubleTapGestureRecognizer : GestureRecognizer {
public DoubleTapGestureRecognizer(object debugOwner = null, PointerDeviceKind? kind = null)
: base(debugOwner: debugOwner, kind: kind) { }
: base(debugOwner: debugOwner, kind: kind) {
}
public GestureDoubleTapCallback onDoubleTap;

public override void addAllowedPointer(PointerDownEvent evt) {
if (_firstTap != null &&
!_firstTap.isWithinTolerance(evt, Constants.kDoubleTapSlop)) {
if (this._firstTap != null &&
!this._firstTap.isWithinGlobalTolerance(evt, Constants.kDoubleTapSlop)) {
return;
}

entry: GestureBinding.instance.gestureArena.add(evt.pointer, this),
doubleTapMinTime: Constants.kDoubleTapMinTime
);
_trackers[evt.pointer] = tracker;
tracker.startTrackingPointer(_handleEvent);
this._trackers[evt.pointer] = tracker;
tracker.startTrackingPointer(this._handleEvent, evt.transform);
}
void _handleEvent(PointerEvent evt) {

}
}
else if (evt is PointerMoveEvent) {
if (!tracker.isWithinTolerance(evt, Constants.kDoubleTapTouchSlop)) {
_reject(tracker);
if (!tracker.isWithinGlobalTolerance(evt, Constants.kDoubleTapTouchSlop)) {
this._reject(tracker);
}
}
else if (evt is PointerCancelEvent) {

public override void acceptGesture(int pointer) { }
public override void acceptGesture(int pointer) {
}
public override void rejectGesture(int pointer) {
_TapTracker tracker;

}
void _registerSecondTap(_TapTracker tracker) {
var initialPosition = tracker._initialPosition;
_firstTap.entry.resolve(GestureDisposition.accepted);
var initialPosition = tracker._initialGlobalPosition;
this._firstTap.entry.resolve(GestureDisposition.accepted);
tracker.entry.resolve(GestureDisposition.accepted);
_freezeTracker(tracker);
_trackers.Remove(tracker.pointer);

doubleTapMinTime: Constants.kDoubleTapMinTime
) {
this.gestureRecognizer = gestureRecognizer;
_lastPosition = evt.position;
startTrackingPointer(handleEvent);
this._lastPosition = OffsetPair.fromEventPosition(evt);
this.startTrackingPointer(this.handleEvent, evt.transform);
if (longTapDelay > TimeSpan.Zero) {
_timer = Window.instance.run(longTapDelay, () => {
_timer = null;

bool _wonArena = false;
Timer _timer;
Offset _lastPosition;
Offset _finalPosition;
OffsetPair _lastPosition;
OffsetPair _finalPosition;
if (!isWithinTolerance(evt, Constants.kTouchSlop)) {
cancel();
if (!this.isWithinGlobalTolerance(evt, Constants.kTouchSlop)) {
this.cancel();
_lastPosition = evt.position;
this._lastPosition = OffsetPair.fromEventPosition(evt);
}
}
else if (evt is PointerCancelEvent) {

stopTrackingPointer(handleEvent);
_finalPosition = evt.position;
_check();
this.stopTrackingPointer(this.handleEvent);
this._finalPosition = OffsetPair.fromEventPosition(evt);
this._check();
}
}

evt: evt,
longTapDelay: longTapDelay
);
if (onTapDown != null) {
invokeCallback<object>("onTapDown", () => {
onTapDown(evt.pointer, new TapDownDetails(globalPosition: evt.position));
if (this.onTapDown != null) {
this.invokeCallback<object>("onTapDown", () => {
this.onTapDown(evt.pointer, new TapDownDetails(
globalPosition: evt.position,
localPosition: evt.localPosition,
kind: evt.kind));
return null;
});
}

}
}
public void _dispatchTap(int pointer, Offset globalPosition) {
D.assert(_gestureMap.ContainsKey(pointer));
_gestureMap.Remove(pointer);
if (onTapUp != null) {
invokeCallback<object>("onTapUp",
public void _dispatchTap(int pointer, OffsetPair position) {
D.assert(this._gestureMap.ContainsKey(pointer));
this._gestureMap.Remove(pointer);
if (this.onTapUp != null) {
this.invokeCallback<object>("onTapUp",
onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition));
this.onTapUp(pointer, new TapUpDetails(globalPosition: position.global, localPosition: position.local));
return null;
});
}

}
}
public void _dispatchLongTap(int pointer, Offset lastPosition) {
D.assert(_gestureMap.ContainsKey(pointer));
if (onLongTapDown != null) {
invokeCallback<object>("onLongTapDown",
public void _dispatchLongTap(int pointer, OffsetPair lastPosition) {
D.assert(this._gestureMap.ContainsKey(pointer));
if (this.onLongTapDown != null) {
this.invokeCallback<object>("onLongTapDown",
onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition));
this.onLongTapDown(pointer, new TapDownDetails(
globalPosition: lastPosition.global,
localPosition: lastPosition.local));
return null;
});
}

81
com.unity.uiwidgets/Runtime/gestures/pointer_router.cs


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

readonly Dictionary<int, HashSet<PointerRoute>> _routeMap = new Dictionary<int, HashSet<PointerRoute>>();
readonly Dictionary<int, Dictionary<PointerRoute, Matrix4>> _routeMap = new Dictionary<int, Dictionary<PointerRoute, Matrix4>>();
readonly HashSet<PointerRoute> _globalRoutes = new HashSet<PointerRoute>();
readonly Dictionary<PointerRoute, Matrix4> _globalRoutes = new Dictionary<PointerRoute, Matrix4>();
public void addRoute(int pointer, PointerRoute route) {
var routes = _routeMap.putIfAbsent(pointer, () => new HashSet<PointerRoute>());
D.assert(!routes.Contains(route));
routes.Add(route);
public void addRoute(int pointer, PointerRoute route, Matrix4 transform = null) {
var routes = this._routeMap.putIfAbsent(
pointer,
() => new Dictionary<PointerRoute, Matrix4>()
);
D.assert(!routes.ContainsKey(route));
routes[route] = transform;
public void removeRoute(int pointer, PointerRoute route) {
D.assert(_routeMap.ContainsKey(pointer));
var routes = _routeMap[pointer];

}
}
public void addGlobalRoute(PointerRoute route, Matrix4 transform = null) {
D.assert(!this._globalRoutes.ContainsKey(route));
this._globalRoutes[route] = transform;
}
public void removeGlobalRoute(PointerRoute route) {
D.assert(this._globalRoutes.ContainsKey(route));
this._globalRoutes.Remove(route);
}
public bool acceptScroll() {
return _routeMap.Count == 0;
}

}
}
public void addGlobalRoute(PointerRoute route) {
D.assert(!_globalRoutes.Contains(route));
_globalRoutes.Add(route);
}
public void removeGlobalRoute(PointerRoute route) {
D.assert(_globalRoutes.Contains(route));
_globalRoutes.Remove(route);
}
void _dispatch(PointerEvent evt, PointerRoute route) {
void _dispatch(PointerEvent evt, PointerRoute route, Matrix4 transform) {
evt = evt.transformed(transform);
route(evt);
}
catch (Exception ex) {

public void route(PointerEvent evt) {
HashSet<PointerRoute> routes;
_routeMap.TryGetValue(evt.pointer, out routes);
// TODO: update this to latest version
Dictionary<PointerRoute, Matrix4> routes;
this._routeMap.TryGetValue(evt.pointer, out routes);
Dictionary<PointerRoute, Matrix4> copiedGlobalRoutes = new Dictionary<PointerRoute, Matrix4>(this._globalRoutes);
foreach (PointerRoute route in new List<PointerRoute>(routes)) {
if (routes.Contains(route)) {
_dispatch(evt, route);
}
}
this._dispatchEventToRoutes(
evt,
routes,
new Dictionary<PointerRoute, Matrix4>(routes)
);
foreach (PointerRoute route in new List<PointerRoute>(_globalRoutes)) {
if (_globalRoutes.Contains(route)) {
_dispatch(evt, route);
this._dispatchEventToRoutes(evt, this._globalRoutes, copiedGlobalRoutes);
}
public void _dispatchEventToRoutes(
PointerEvent evt,
Dictionary<PointerRoute, Matrix4> referenceRoutes,
Dictionary<PointerRoute, Matrix4> copiedRoutes
) {
foreach (var item in copiedRoutes) {
var route = item.Key;
var transform = item.Value;
if (referenceRoutes.ContainsKey(route)) {
this._dispatch(evt, route, transform);
}
}
// TODO: FlutterErrorDetailsForPointerRouter

4
com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs


return;
}
D.assert(_currentEvent == evt);
D.assert((_currentEvent.original ?? this._currentEvent) == evt);
_firstRegisteredCallback(evt);
this._firstRegisteredCallback(_currentEvent);
}
catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(

132
com.unity.uiwidgets/Runtime/gestures/recognizer.cs


public abstract class GestureRecognizer : DiagnosticableTree, GestureArenaMember {
protected GestureRecognizer(object debugOwner = null, PointerDeviceKind? kind = null) {
this.debugOwner = debugOwner;
_kind = kind;
this._kindFilter = kind;
readonly PointerDeviceKind? _kind;
readonly PointerDeviceKind? _kindFilter;
readonly Dictionary<int, PointerDeviceKind> _pointerToKind = new Dictionary<int, PointerDeviceKind>{};
if (isPointerAllowed(evt)) {
addAllowedPointer(evt);
this._pointerToKind[evt.pointer] = evt.kind;
if (this.isPointerAllowed(evt)) {
this.addAllowedPointer(evt);
}
else {
handleNonAllowedPointer(evt);

}
protected virtual bool isPointerAllowed(PointerDownEvent evt) {
return _kind == null || _kind == evt.kind;
return this._kindFilter == null || this._kindFilter == evt.kind;
}
protected virtual PointerDeviceKind getKindForPointer(int pointer) {
D.assert(this._pointerToKind.ContainsKey(pointer));
return this._pointerToKind[pointer];
}
public virtual void addScrollPointer(PointerScrollEvent evt) {

}
}
protected virtual void resolvePointer(int pointer, GestureDisposition disposition) {
GestureArenaEntry entry = _entries[pointer];
if (entry != null) {
entry.resolve(disposition);
_entries.Remove(pointer);
}
}
public override void dispose() {
resolve(GestureDisposition.rejected);
foreach (int pointer in _trackedPointers) {

}
}
protected void startTrackingPointer(int pointer) {
GestureBinding.instance.pointerRouter.addRoute(pointer, handleEvent);
_trackedPointers.Add(pointer);
D.assert(!_entries.ContainsKey(pointer));
_entries[pointer] = _addPointerToArena(pointer);
protected void startTrackingPointer(int pointer, Matrix4 transform = null) {
GestureBinding.instance.pointerRouter.addRoute(pointer, this.handleEvent, transform);
this._trackedPointers.Add(pointer);
D.assert(!this._entries.ContainsKey(pointer));
this._entries[pointer] = this._addPointerToArena(pointer);
}
protected void stopTrackingPointer(int pointer) {

public int primaryPointer;
public Offset initialPosition;
public OffsetPair initialPosition;
startTrackingPointer(evt.pointer);
if (state == GestureRecognizerState.ready) {
state = GestureRecognizerState.possible;
primaryPointer = evt.pointer;
initialPosition = evt.position;
if (deadline != null) {
_timer = Window.instance.run(deadline.Value, didExceedDeadline);
this.startTrackingPointer(evt.pointer, evt.transform);
if (this.state == GestureRecognizerState.ready) {
this.state = GestureRecognizerState.possible;
this.primaryPointer = evt.pointer;
this.initialPosition = new OffsetPair(local: evt.localPosition, global: evt.position);
if (this.deadline != null) {
this._timer = Window.instance.run(this.deadline.Value, () => didExceedDeadlineWithEvent(evt));
}
}
}

if (evt.pointer == primaryPointer) {
bool isPreAcceptSlopPastTolerance = state == GestureRecognizerState.possible &&
preAcceptSlopTolerance != null &&
_getDistance(evt) > preAcceptSlopTolerance;
bool isPostAcceptSlopPastTolerance = state == GestureRecognizerState.accepted &&
postAcceptSlopTolerance != null &&
_getDistance(evt) > postAcceptSlopTolerance;
if (evt.pointer == this.primaryPointer) {
bool isPreAcceptSlopPastTolerance = this.state == GestureRecognizerState.possible &&
this.preAcceptSlopTolerance != null &&
this._getGlobalDistance(evt) > this.preAcceptSlopTolerance;
bool isPostAcceptSlopPastTolerance = this.state == GestureRecognizerState.accepted &&
this.postAcceptSlopTolerance != null &&
this._getGlobalDistance(evt) > this.postAcceptSlopTolerance;
if (evt is PointerMoveEvent && (isPreAcceptSlopPastTolerance || isPostAcceptSlopPastTolerance)) {
resolve(GestureDisposition.rejected);

D.assert(deadline == null);
}
protected virtual void didExceedDeadlineWithEvent(PointerDownEvent evt) {
this.didExceedDeadline();
}
if (pointer == primaryPointer && state == GestureRecognizerState.possible) {
state = GestureRecognizerState.accepted;
if (pointer == this.primaryPointer && this.state == GestureRecognizerState.possible) {
this._stopTimer();
this.state = GestureRecognizerState.accepted;
}
}

}
}
float _getDistance(PointerEvent evt) {
Offset offset = evt.position - initialPosition;
float _getGlobalDistance(PointerEvent evt) {
Offset offset = evt.position - this.initialPosition.global;
return offset.distance;
}

}
}
public class OffsetPair {
/// Creates a [OffsetPair] combining a [local] and [global] [Offset].
public OffsetPair(
Offset local = null,
Offset global = null
) {
this.local = local;
this.global = global;
}
/// Creates a [OffsetPair] from [PointerEvent.localPosition] and
/// [PointerEvent.position].
public static OffsetPair fromEventPosition(PointerEvent evt) {
return new OffsetPair(local: evt.localPosition, global: evt.position);
}
/// Creates a [OffsetPair] from [PointerEvent.localDelta] and
/// [PointerEvent.delta].
public static OffsetPair fromEventDelta(PointerEvent evt) {
return new OffsetPair(local: evt.localDelta, global: evt.delta);
}
/// A [OffsetPair] where both [Offset]s are [Offset.zero].
public readonly static OffsetPair zero = new OffsetPair(local: Offset.zero, global: Offset.zero);
/// The [Offset] in the local coordinate space.
public readonly Offset local;
/// The [Offset] in the global coordinate space after conversion to logical
/// pixels.
public readonly Offset global;
/// Adds the `other.global` to [global] and `other.local` to [local].
public static OffsetPair operator +(OffsetPair current, OffsetPair other) {
return new OffsetPair(
local: current.local + other.local,
global: current.global + other.global
);
}
/// Subtracts the `other.global` from [global] and `other.local` from [local].
public static OffsetPair operator -(OffsetPair current, OffsetPair other) {
return new OffsetPair(
local: current.local - other.local,
global: current.global - other.global
);
}
public override string ToString() {
return $"runtimeType(local: ${this.local}, global: ${this.global})";
}
}
}

8
com.unity.uiwidgets/Runtime/gestures/tap.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.gestures {
public class TapDownDetails {

}
protected override void handleTapDown(PointerDownEvent down) {
if (onTapDown != null) {
if (this.onTapDown != null) {
globalPosition: down.position,
globalPosition: down.position,
localPosition: down.localPosition,
kind: down.kind,
device: down.device
);

protected override void handleTapUp(PointerDownEvent down, PointerUpEvent up) {
TapUpDetails details = new TapUpDetails(
globalPosition: up.position,
localPosition: up.localPosition,
kind: up.kind,
device: up.device
);

4
com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs


color: colorTween.evaluate(animation)
),
child: new Transform(
transform: Matrix3.makeAll(t, 0, 0,
0, t, 0,
0, 0, 1),
transform: new Matrix4().diagonal3Values(t, t, t),
alignment: Alignment.bottomCenter,
child: item.title
)

8
com.unity.uiwidgets/Runtime/material/chip.cs


additionalConstraints: additionalConstraints) {
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (!size.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (!this.size.contains(position)) {
return false;
}

return new Size(deleteIconWidth, deleteIconHeight);
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (!size.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (!this.size.contains(position)) {
return false;
}

4
com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs


bottom: 16.0f
);
float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
Matrix3 scaleTransform = Matrix3.makeScale(scaleValue, scaleValue);
Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);
Matrix4 scaleTransform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
Alignment titleAlignment = this._getTitleAlignment(effectiveCenterTitle);
children.Add(new Container(
padding: padding,

8
com.unity.uiwidgets/Runtime/material/ink_decoration.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
if (_painter == null) {
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
if (this._painter == null) {
return;
}

if (originOffset == null) {
canvas.save();
canvas.concat(transform);
_painter.paint(canvas, Offset.zero, sizedConfiguration);
canvas.concat(transform.toMatrix3());
this._painter.paint(canvas, Offset.zero, sizedConfiguration);
canvas.restore();
}
else {

8
com.unity.uiwidgets/Runtime/material/ink_highlight.cs


canvas.restore();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint {color = color.withAlpha(_alpha.value)};
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
Paint paint = new Paint {color = this.color.withAlpha(this._alpha.value)};
canvas.concat(transform);
_paintHighlight(canvas, rect, paint);
canvas.concat(transform.toMatrix3());
this._paintHighlight(canvas, rect, paint);
canvas.restore();
}
else {

8
com.unity.uiwidgets/Runtime/material/ink_ripple.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
int alpha = _fadeInController.isAnimating ? _fadeIn.value : _fadeOut.value;
Paint paint = new Paint {color = color.withAlpha(alpha)};
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
int alpha = this._fadeInController.isAnimating ? this._fadeIn.value : this._fadeOut.value;
Paint paint = new Paint {color = this.color.withAlpha(alpha)};
Offset center = Offset.lerp(
_position,
referenceBox.size.center(Offset.zero),

canvas.save();
if (originOffset == null) {
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
}
else {
canvas.translate(originOffset.dx, originOffset.dy);

12
com.unity.uiwidgets/Runtime/material/ink_splash.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint {color = color.withAlpha(_alpha.value)};
Offset center = _position;
if (_repositionToReferenceBox) {
center = Offset.lerp(center, referenceBox.size.center(Offset.zero), _radiusController.value);
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
Paint paint = new Paint {color = this.color.withAlpha(this._alpha.value)};
Offset center = this._position;
if (this._repositionToReferenceBox) {
center = Offset.lerp(center, this.referenceBox.size.center(Offset.zero), this._radiusController.value);
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
}
else {
canvas.translate(originOffset.dx, originOffset.dy);

107
com.unity.uiwidgets/Runtime/material/input_decorator.cs


protected internal override Widget build(BuildContext context) {
return new Transform(
transform: Matrix3.makeTrans(translateX, 0.0f),
child: child
transform: new Matrix4().translationValues(this.translateX, 0, 0),
child: this.child
);
}
}

if (prefix != null) {
boxToBaseline[prefix] = _layoutLineBox(prefix, boxConstraints);
}
if (suffix != null) {
boxToBaseline[suffix] = _layoutLineBox(suffix, boxConstraints);
if (this.suffix != null) {
boxToBaseline[this.suffix] = this._layoutLineBox(this.suffix, boxConstraints);
if (icon != null) {
boxToBaseline[icon] = _layoutLineBox(icon, boxConstraints);
if (this.icon != null) {
boxToBaseline[this.icon] = this._layoutLineBox(this.icon, boxConstraints);
if (prefixIcon != null) {
boxToBaseline[prefixIcon] = _layoutLineBox(prefixIcon, boxConstraints);
if (this.prefixIcon != null) {
boxToBaseline[this.prefixIcon] = this._layoutLineBox(this.prefixIcon, boxConstraints);
if (suffixIcon != null) {
boxToBaseline[suffixIcon] = _layoutLineBox(suffixIcon, boxConstraints);
if (this.suffixIcon != null) {
boxToBaseline[this.suffixIcon] = this._layoutLineBox(this.suffixIcon, boxConstraints);
float inputWidth = Math.Max(0.0f, constraints.maxWidth - (
_boxSize(icon).width
+ contentPadding.left
+ _boxSize(prefixIcon).width
+ _boxSize(prefix).width
+ _boxSize(suffix).width
+ _boxSize(suffixIcon).width
+ contentPadding.right));
if (label != null) {
boxToBaseline[label] = _layoutLineBox(label,
float inputWidth = Math.Max(0.0f, this.constraints.maxWidth - (
_boxSize(this.icon).width
+ this.contentPadding.left
+ _boxSize(this.prefixIcon).width
+ _boxSize(this.prefix).width
+ _boxSize(this.suffix).width
+ _boxSize(this.suffixIcon).width
+ this.contentPadding.right));
if (this.label != null) {
boxToBaseline[this.label] = this._layoutLineBox(this.label,
boxConstraints.copyWith(maxWidth: inputWidth)
);
}

return _boxParentData(input).offset.dy + input.getDistanceToActualBaseline(baseline);
}
Matrix3 _labelTransform;
Matrix4 _labelTransform;
protected override void performLayout() {
_labelTransform = null;

float right = overallWidth - contentPadding.right;
height = layout.containerHeight ?? 0.0f;
baseline = (decoration.isCollapsed || !decoration.border.isOutline
? layout.inputBaseline
: layout.outlineBaseline) ?? 0.0f;
baseline = (this.decoration.isCollapsed || !this.decoration.border.isOutline
? layout.inputBaseline
: layout.outlineBaseline) ?? 0.0f;
if (icon != null) {
float x = 0.0f;

float scale = MathUtils.lerpFloat(1.0f, 0.75f, t);
float dx = labelOffset.dx;
float dy = MathUtils.lerpFloat(0.0f, floatingY - labelOffset.dy, t);
_labelTransform = Matrix3.I();
_labelTransform.preTranslate(dx, labelOffset.dy + dy);
_labelTransform.preScale(scale, scale);
context.pushTransform(needsCompositing, offset, _labelTransform, _paintLabel);
this._labelTransform = new Matrix4().identity();
this._labelTransform.translate(dx, labelOffset.dy + dy);
this._labelTransform.scale(scale, scale, 1);
context.pushTransform(this.needsCompositing, offset, this._labelTransform, this._paintLabel);
}
doPaint(icon);

return true;
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
foreach (RenderBox child in _children) {
if (child.hitTest(result, position: position - _boxParentData(child).offset)) {
foreach (RenderBox child in this._children) {
Offset offset = _boxParentData(child).offset;
bool isHit = result.addWithPaintOffset(
offset: offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - offset);
return child.hitTest(resultIn, position: transformed);
}
);
if (isHit) {
return true;
}
}

public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
if (child == label && _labelTransform != null) {
Offset labelOffset = _boxParentData(label).offset;
transform.preConcat(_labelTransform);
transform.preTranslate(-labelOffset.dx, -labelOffset.dy);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
if (child == this.label && this._labelTransform != null) {
Offset labelOffset = _boxParentData(this.label).offset;
transform.multiply(this._labelTransform);
transform.translate(-labelOffset.dx, -labelOffset.dy);
}
base.applyPaintTransform(child, transform);

public readonly TextAlign? textAlign;
public readonly bool isFocused;
public readonly bool expands;
public readonly bool isEmpty;

public InputDecoration decoration {
get {
_effectiveDecoration = _effectiveDecoration ?? widget.decoration.applyDefaults(
Theme.of(context).inputDecorationTheme
);
return _effectiveDecoration;
this._effectiveDecoration = this._effectiveDecoration ?? this.widget.decoration.applyDefaults(
Theme.of(this.context).inputDecorationTheme
);
return this._effectiveDecoration;
}
}

(4.0f + 0.75f * inlineLabelStyle.fontSize) * MediaQuery.textScaleFactorOf(context);
if (decoration.filled == true) {
contentPadding = decorationContentPadding ?? (decorationIsDense
? EdgeInsets.fromLTRB(12.0f, 8.0f, 12.0f, 8.0f)
: EdgeInsets.fromLTRB(12.0f, 12.0f, 12.0f, 12.0f));
? EdgeInsets.fromLTRB(12.0f, 8.0f, 12.0f, 8.0f)
: EdgeInsets.fromLTRB(12.0f, 12.0f, 12.0f, 12.0f));
? EdgeInsets.fromLTRB(0.0f, 8.0f, 0.0f, 8.0f)
: EdgeInsets.fromLTRB(0.0f, 12.0f, 0.0f, 12.0f));
? EdgeInsets.fromLTRB(0.0f, 8.0f, 0.0f, 8.0f)
: EdgeInsets.fromLTRB(0.0f, 12.0f, 0.0f, 12.0f));
? EdgeInsets.fromLTRB(12.0f, 20.0f, 12.0f, 12.0f)
: EdgeInsets.fromLTRB(12.0f, 24.0f, 12.0f, 16.0f));
? EdgeInsets.fromLTRB(12.0f, 20.0f, 12.0f, 12.0f)
: EdgeInsets.fromLTRB(12.0f, 24.0f, 12.0f, 16.0f));
}
return new _Decorator(

18
com.unity.uiwidgets/Runtime/material/list_tile.cs


bool isTwoLine = !isThreeLine && hasSubtitle;
bool isOneLine = !isThreeLine && !hasSubtitle;
BoxConstraints maxIconHeightConstrains = new BoxConstraints(
maxHeight: isDense ? 48.0f: 56.0f
maxHeight: this.isDense ? 48.0f : 56.0f
);
BoxConstraints looseConstraints = constraints.loosen();
BoxConstraints iconConstraints = looseConstraints.enforce(maxIconHeightConstrains);

return true;
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
foreach (RenderBox child in _children) {
BoxParentData parentData = (BoxParentData) child.parentData;
if (child.hitTest(result, position: position - parentData.offset)) {
foreach (RenderBox child in this._children) {
BoxParentData parentData = child.parentData as BoxParentData;
bool isHit = result.addWithPaintOffset(
offset: parentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - parentData.offset);
return child.hitTest(resultIn, position: transformed);
}
);
if (isHit) {
return true;
}
}

4
com.unity.uiwidgets/Runtime/material/material.cs


descendants.Add(node);
}
Matrix3 transform = Matrix3.I();
Matrix4 transform = new Matrix4().identity();
D.assert(descendants.Count >= 2);
for (int index = descendants.Count - 1; index > 0; index -= 1) {
descendants[index].applyPaintTransform(descendants[index - 1], transform);

}
protected abstract void paintFeature(Canvas canvas, Matrix3 transform);
protected abstract void paintFeature(Canvas canvas, Matrix4 transform);
public override string ToString() {
return GetType() + "";

4
com.unity.uiwidgets/Runtime/material/text_selection.cs


switch (type) {
case TextSelectionHandleType.left: // points up-right
return new Transform(
transform: Matrix3.makeRotate(Mathf.PI / 2),
transform: new Matrix4().rotationZ(Mathf.PI / 2),
child: handle
);
case TextSelectionHandleType.right: // points up-left

transform: Matrix3.makeRotate(Mathf.PI / 4),
transform: new Matrix4().rotationZ(Mathf.PI / 4),
child: handle
);
}

136
com.unity.uiwidgets/Runtime/painting/matrix_utils.cs


namespace Unity.UIWidgets.painting {
public static class MatrixUtils {
public static Offset getAsTranslation(this Matrix3 matrix3) {
return matrix3.isTranslate() ? new Offset(matrix3[Matrix3.kMTransX], matrix3[Matrix3.kMTransY]) : null;
public static float dot(this Vector3 left, Vector3 right) {
return left.x * right.x + left.y * right.y + left.z * right.z;
}
public static Offset getAsTranslation(this Matrix4 values) {
if (values[0] == 1 && // col 1
values[1] == 0 &&
values[2] == 0 &&
values[3] == 0 &&
values[4] == 0 && // col 2
values[5] == 1 &&
values[6] == 0 &&
values[7] == 0 &&
values[8] == 0 && // col 3
values[9] == 0 &&
values[10] == 1 &&
values[11] == 0 &&
values[14] == 0 && // bottom of col 4 (values 12 and 13 are the x and y offsets)
values[15] == 1) {
return new Offset(values[12], values[13]);
}
else {
return null;
}
}
public static void QuaternionFromMatrix(this Matrix4 m, ref Quaternion q) {
q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) + m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) - m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) + m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) - m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x *= Mathf.Sign( q.x * ( m.entry(2,1) - m.entry(1,2) ) );
q.y *= Mathf.Sign( q.y * ( m.entry(0,2) - m.entry(2,0) ) );
q.z *= Mathf.Sign( q.z * ( m.entry(1,0) - m.entry(0,1) ) );
public static List<string> debugDescribeTransform(Matrix3 transform) {
public static Quaternion scaled(this Quaternion lhs, float scale) {
lhs.x *= scale;
lhs.y *= scale;
lhs.z *= scale;
lhs.w *= scale;
return lhs;
}
public static Quaternion add(this Quaternion lhs, Quaternion rhs) {
lhs.x += rhs.x;
lhs.y += rhs.y;
lhs.z += rhs.z;
lhs.w += rhs.w;
return lhs;
}
public static List<string> debugDescribeTransform(Matrix4 transform) {
if (transform == null) {
return new List<string> {"null"};
}

return result;
}
public static Vector3 perspectiveTransform(this Matrix4x4 m4, Vector3 arg) {
List<float> argStorage = new List<float> {arg[0], arg[1], arg[2]};
float x_ = (m4[0] * argStorage[0]) +
(m4[4] * argStorage[1]) +
(m4[8] * argStorage[2]) +
m4[12];
float y_ = (m4[1] * argStorage[0]) +
(m4[5] * argStorage[1]) +
(m4[9] * argStorage[2]) +
m4[13];
float z_ = (m4[2] * argStorage[0]) +
(m4[6] * argStorage[1]) +
(m4[10] * argStorage[2]) +
m4[14];
float w_ = 1.0f /
((m4[3] * argStorage[0]) +
(m4[7] * argStorage[1]) +
(m4[11] * argStorage[2]) +
m4[15]);
argStorage[0] = x_ * w_;
argStorage[1] = y_ * w_;
argStorage[2] = z_ * w_;
return arg;
}
public static Offset transformPoint(Matrix4x4 transform, Offset point) {
Vector3 position3 = new Vector3(point.dx, point.dy, 0.0f);
public static Offset transformPoint(Matrix4 transform, Offset point) {
Vector3 position3 = new Vector3(point.dx, point.dy, 0);
public static Rect transformRect(Matrix4x4 transform, Rect rect) {
public static Rect transformRect(Matrix4 transform, Rect rect) {
Offset point1 = transformPoint(transform, rect.topLeft);
Offset point2 = transformPoint(transform, rect.topRight);
Offset point3 = transformPoint(transform, rect.bottomLeft);

);
}
static bool isIdentity(Matrix4 a) {
D.assert(a != null);
return a[0] == 1.0 // col 1
&& a[1] == 0.0
&& a[2] == 0.0
&& a[3] == 0.0
&& a[4] == 0.0 // col 2
&& a[5] == 1.0
&& a[6] == 0.0
&& a[7] == 0.0
&& a[8] == 0.0 // col 3
&& a[9] == 0.0
&& a[10] == 1.0
&& a[11] == 0.0
&& a[12] == 0.0 // col 4
&& a[13] == 0.0
&& a[14] == 0.0
&& a[15] == 1.0;
}
public static Rect inverseTransformRect(Matrix4 transform, Rect rect) {
D.assert(rect != null);
D.assert(transform.determinant() != 0.0);
if (isIdentity(transform))
return rect;
transform = Matrix4.tryInvert(transform);
return transformRect(transform, rect);
}
static float _min4(float a, float b, float c, float d) {
return Mathf.Min(a, Mathf.Min(b, Mathf.Min(c, d)));
}

return matrix;
}
public static Matrix3 toMatrix3(this Matrix4 matrix4) {
var matrix = Matrix3.I();
matrix[0] = matrix4.entry(0, 0);
matrix[1] = matrix4.entry(0, 1);
matrix[2] = matrix4.entry(0, 3);
matrix[3] = matrix4.entry(1, 0);
matrix[4] = matrix4.entry(1, 1);
matrix[5] = matrix4.entry(1, 3);
matrix[6] = matrix4.entry(3, 0);
matrix[7] = matrix4.entry(3, 1);
matrix[8] = matrix4.entry(3, 3);
return matrix;
}
public class TransformProperty : DiagnosticsProperty<Matrix3> {
public TransformProperty(string name, Matrix3 value,
public class TransformProperty : DiagnosticsProperty<Matrix4> {
public TransformProperty(string name, Matrix4 value,
bool showName = true,
object defaultValue = null,
DiagnosticLevel level = DiagnosticLevel.info

124
com.unity.uiwidgets/Runtime/rendering/box.cs


}
}
public delegate bool BoxHitTest(BoxHitTestResult result, Offset position);
public class BoxHitTestResult : HitTestResult {
public BoxHitTestResult() : base() {
}
public BoxHitTestResult(HitTestResult result) : base(result) {
}
public bool addWithPaintTransform(
Matrix4 transform,
Offset position,
BoxHitTest hitTest
) {
D.assert(hitTest != null);
if (transform != null) {
transform = Matrix4.tryInvert(PointerEvent.removePerspectiveTransform(transform));
if (transform == null) {
// Objects are not visible on screen and cannot be hit-tested.
return false;
}
}
return this.addWithRawTransform(
transform: transform,
position: position,
hitTest: hitTest
);
}
public bool addWithPaintOffset(
Offset offset,
Offset position,
BoxHitTest hitTest
) {
D.assert(hitTest != null);
return this.addWithRawTransform(
transform: offset != null ? new Matrix4().translationValues(-offset.dx, -offset.dy, 0) : null,
position: position,
hitTest: hitTest
);
}
public bool addWithRawTransform(
Matrix4 transform,
Offset position,
BoxHitTest hitTest
) {
D.assert(hitTest != null);
Offset transformedPosition = position == null || transform == null
? position
: MatrixUtils.transformPoint(transform, position);
if (transform != null) {
this.pushTransform(transform);
}
bool isHit = hitTest(this, transformedPosition);
if (transform != null) {
this.popTransform();
}
return isHit;
}
}
public Offset offset = Offset.zero;
public Offset offset {
get { return this._offset; }
set { this._offset = value; }
}
Offset _offset = Offset.zero;
public override string ToString() {
return "offset=" + offset;

public float? getDistanceToBaseline(TextBaseline baseline, bool onlyReal = false) {
D.assert(!_debugDoingBaseline,
() => "Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
D.assert(!debugNeedsLayout);
() =>
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
D.assert(!this.debugNeedsLayout);
D.assert(() => {
RenderObject parent = (RenderObject) this.parent;
if (owner.debugDoingLayout) {

public virtual float? getDistanceToActualBaseline(TextBaseline baseline) {
D.assert(_debugDoingBaseline,
() => "Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
() =>
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
_cachedBaselines = _cachedBaselines ?? new Dictionary<TextBaseline, float?>();
return _cachedBaselines.putIfAbsent(baseline, () => computeDistanceToActualBaseline(baseline));

D.assert(_debugDoingBaseline,
() => "Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
() =>
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");
return null;
}

});
}
public virtual bool hitTest(HitTestResult result, Offset position = null) {
public virtual bool hitTest(BoxHitTestResult result, Offset position = null) {
D.assert(position != null);
D.assert(() => {
if (!hasSize) {

return false;
}
protected virtual bool hitTestChildren(HitTestResult result, Offset position = null) {
protected virtual bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child.parent == this);
D.assert(() => {

var childParentData = (BoxParentData) child.parentData;
var offset = childParentData.offset;
transform.preTranslate(offset.dx, offset.dy);
transform.translate(offset.dx, offset.dy);
var transform = getTransformTo(ancestor);
var transform = this.getTransformTo(ancestor);
float det = transform.invert();
if (det == 0) {
return Offset.zero;
}
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
return invertible ? inverse.mapPoint(point) : Offset.zero;
Vector3 n = new Vector3(0, 0, 1);
Vector3 i = transform.perspectiveTransform(new Vector3(0, 0, 0));
Vector3 d = transform.perspectiveTransform(new Vector3(0, 0, 1)) - i;
Vector3 s = transform.perspectiveTransform(new Vector3(point.dx, point.dy, 0));
Vector3 p = s - d * (n.dot(s) / n.dot(d));
return new Offset(p.x, p.y);
return getTransformTo(ancestor).mapPoint(point);
return MatrixUtils.transformPoint(this.getTransformTo(ancestor), point);
}
public override Rect paintBounds {

return result;
}
public bool defaultHitTestChildren(HitTestResult result, Offset position = null) {
ChildType child = lastChild;
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position = null) {
ChildType child = this.lastChild;
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset)) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(resultIn, position: transformed);
}
);
if (isHit) {
return true;
}

23
com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;

}
}
public bool defaultHitTestChildren(HitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin
ChildType child = lastChild;
while (child != null)
{
ParentDataType childParentData = (ParentDataType) child.parentData;
if (child.hitTest(result, position: position - childParentData.offset)) {
return true;
public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
// the x, y parameters have the top left of the node's box as the origin4
ChildType child = this.lastChild;
while (child != null) {
ParentDataType childParentData = child.parentData as ParentDataType;
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
);
if (isHit)
return true;
child = childParentData.previousSibling;
}
return false;

4
com.unity.uiwidgets/Runtime/rendering/custom_layout.cs


defaultPaint(context, offset);
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
return this.defaultHitTestChildren(result, position: position);
}
}
}

4
com.unity.uiwidgets/Runtime/rendering/custom_paint.cs


base.detach();
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
if (_foregroundPainter != null && ((_foregroundPainter.hitTest(position)) ?? false)) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
if (this._foregroundPainter != null && ((this._foregroundPainter.hitTest(position)) ?? false)) {
return true;
}

4
com.unity.uiwidgets/Runtime/rendering/flex.cs


});
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.defaultHitTestChildren(result, position: position);
}
}
}

151
com.unity.uiwidgets/Runtime/rendering/layer.cs


using System.Linq;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;

}
}
public virtual void applyTransform(Layer child, Matrix3 transform) {
public virtual void applyTransform(Layer child, Matrix4 transform) {
D.assert(child != null);
D.assert(transform != null);
}

return base.find<S>(regionOffset - offset);
}
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
transform.preTranslate((float) offset.dx, (float) offset.dy);
transform.translate(this.offset.dx, this.offset.dy);
}
public Scene buildScene(SceneBuilder builder) {

}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix3 transform = null, Offset offset = null) : base(offset) {
_transform = transform ?? Matrix3.I();
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {
this._transform = transform ?? new Matrix4().identity();
public Matrix3 transform {
get { return _transform; }
set {
_transform = value;
_inverseDirty = true;
}
public Matrix4 transform {
get { return this._transform; }
Matrix3 _transform;
Matrix3 _lastEffectiveTransform;
Matrix4 _transform;
Matrix4 _lastEffectiveTransform;
readonly Matrix3 _invertedTransform = Matrix3.I();
Matrix4 _invertedTransform;
if (_inverseDirty) {
this.transform.invert(_invertedTransform);
_inverseDirty = false;
if (this._inverseDirty) {
this._invertedTransform = Matrix4.tryInvert(
PointerEvent.removePerspectiveTransform(this.transform)
);
this._inverseDirty = false;
Offset transform = _invertedTransform.mapXY(regionOffset.dx, regionOffset.dy);
return base.find<S>(transform);
Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0, 1);
Vector4 result = this._invertedTransform.transform(vector);
return base.find<S>(new Offset(result[0], result[1]));
}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {

var totalOffset = offset + layerOffset;
if (totalOffset != Offset.zero) {
_lastEffectiveTransform = Matrix3.makeTrans(totalOffset.dx, totalOffset.dy);
_lastEffectiveTransform.preConcat(_transform);
this._lastEffectiveTransform = new Matrix4().translationValues(totalOffset.dx, totalOffset.dy, 0);
this._lastEffectiveTransform.multiply(this.transform);
builder.pushTransform(_lastEffectiveTransform);
addChildrenToScene(builder);
builder.pushTransform(this._lastEffectiveTransform.toMatrix3());
this.addChildrenToScene(builder);
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
D.assert(_lastEffectiveTransform != null || this.transform != null);
if (_lastEffectiveTransform == null) {
transform.preConcat(this.transform);
D.assert(this._lastEffectiveTransform != null || this.transform != null);
if (this._lastEffectiveTransform == null) {
transform.multiply(this.transform);
transform.preConcat(_lastEffectiveTransform);
transform.multiply(this._lastEffectiveTransform);
properties.add(new DiagnosticsProperty<Matrix3>("transform", transform));
properties.add(new DiagnosticsProperty<Matrix4>("transform", this.transform));
}
}

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
D.assert(offset != null);
_lastOffset = offset + layerOffset;
if (_lastOffset != Offset.zero) {
builder.pushTransform(Matrix3.makeTrans(_lastOffset));
D.assert(this.offset != null);
this._lastOffset = this.offset + layerOffset;
if (this._lastOffset != Offset.zero) {
builder.pushTransform(new Matrix4()
.translationValues(this._lastOffset.dx, this._lastOffset.dy,0)
.toMatrix3());
}
addChildrenToScene(builder, Offset.zero);

return null;
}
public override void applyTransform(Layer child, Matrix3 transform) {
D.assert(_lastOffset != null);
if (_lastOffset != Offset.zero) {
transform.preTranslate(_lastOffset.dx, _lastOffset.dy);
public override void applyTransform(Layer child, Matrix4 transform) {
D.assert(this._lastOffset != null);
if (this._lastOffset != Offset.zero) {
transform.translate(this._lastOffset.dx, this._lastOffset.dy);
}
}

public Offset linkedOffset;
Offset _lastOffset;
Matrix3 _lastTransform;
Matrix4 _lastTransform;
readonly Matrix3 _invertedTransform = Matrix3.I();
Matrix4 _invertedTransform = new Matrix4().identity();
bool _inverseDirty = true;
internal override S find<S>(Offset regionOffset) {

if (_inverseDirty) {
getLastTransform().invert(_invertedTransform);
_inverseDirty = false;
if (this._inverseDirty) {
this._invertedTransform = Matrix4.tryInvert(this.getLastTransform());
this._inverseDirty = false;
}
if (_invertedTransform == null) {

Offset transform = _invertedTransform.mapXY(regionOffset.dx, regionOffset.dy);
return base.find<S>(transform - linkedOffset);
Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0, 1);
Vector4 result = this._invertedTransform.transform(vector);
return base.find<S>(new Offset(result[0] - this.linkedOffset.dx, result[1] - this.linkedOffset.dy));
public Matrix3 getLastTransform() {
if (_lastTransform == null) {
public Matrix4 getLastTransform() {
if (this._lastTransform == null) {
Matrix3 result = Matrix3.makeTrans(-_lastOffset.dx, -_lastOffset.dy);
result.preConcat(_lastTransform);
Matrix4 result = new Matrix4().translationValues(-this._lastOffset.dx, -this._lastOffset.dy,0 );
result.multiply(this._lastTransform);
Matrix3 _collectTransformForLayerChain(List<ContainerLayer> layers) {
Matrix3 result = Matrix3.I();
Matrix4 _collectTransformForLayerChain(List<ContainerLayer> layers) {
Matrix4 result = new Matrix4().identity();
for (int index = layers.Count - 1; index > 0; index -= 1) {
layers[index].applyTransform(layers[index - 1], result);
}

inverseLayers.Add(layer);
} while (layer != ancestor);
Matrix3 forwardTransform = _collectTransformForLayerChain(forwardLayers);
Matrix3 inverseTransform = _collectTransformForLayerChain(inverseLayers);
var inverse = Matrix3.I();
var invertible = inverseTransform.invert(inverse);
if (!invertible) {
Matrix4 forwardTransform = this._collectTransformForLayerChain(forwardLayers);
Matrix4 inverseTransform = this._collectTransformForLayerChain(inverseLayers);
if (inverseTransform.invert() == 0) {
inverseTransform = inverse;
inverseTransform.preConcat(forwardTransform);
inverseTransform.preTranslate(linkedOffset.dx, linkedOffset.dy);
_lastTransform = inverseTransform;
_inverseDirty = true;
inverseTransform.multiply(forwardTransform);
inverseTransform.translate(this.linkedOffset.dx, this.linkedOffset.dy);
this._lastTransform = inverseTransform;
this._inverseDirty = true;
}
protected override bool alwaysNeedsAddToScene {

return null;
}
_establishTransform();
if (_lastTransform != null) {
builder.pushTransform(_lastTransform);
addChildrenToScene(builder);
this._establishTransform();
if (this._lastTransform != null) {
builder.pushTransform(this._lastTransform.toMatrix3());
this.addChildrenToScene(builder);
_lastOffset = null;
var matrix = Matrix3.makeTrans(unlinkedOffset.dx, unlinkedOffset.dy);
builder.pushTransform(matrix);
addChildrenToScene(builder);
this._lastOffset = null;
var matrix = new Matrix4().translationValues(this.unlinkedOffset.dx, this.unlinkedOffset.dy, 0);
builder.pushTransform(matrix.toMatrix3());
this.addChildrenToScene(builder);
builder.pop();
}

public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
if (_lastTransform != null) {
transform.preConcat(_lastTransform);
if (this._lastTransform != null) {
transform.multiply(this._lastTransform);
transform.preConcat(Matrix3.makeTrans(unlinkedOffset.dx, unlinkedOffset.dy));
transform.multiply(new Matrix4().translationValues(this.unlinkedOffset.dx, this.unlinkedOffset.dy, 0));
}
}

internal Path _debugTransformedClipPath {
get {
ContainerLayer ancestor = parent;
Matrix3 matrix = Matrix3.I();
ContainerLayer ancestor = this.parent;
Matrix4 matrix = new Matrix4().identity();
return clipPath.transform(matrix);
return this.clipPath.transform(matrix.toMatrix3());
}
}

4
com.unity.uiwidgets/Runtime/rendering/list_body.cs


}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.defaultHitTestChildren(result, position: position);
}
}
}

10
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


var radius = size.height * _diameterRatio / 2.0f;
var deltaY = radius * Mathf.Sin(angle);
Matrix3 transform = Matrix3.I();
Matrix4 transform = new Matrix4().identity();
// Matrix4x4 transform2 = MatrixUtils.createCylindricalProjectionTransform(
// radius: this.size.height * this._diameterRatio / 2.0f,
// angle: angle,

Offset offset,
RenderBox child,
// Matrix4x4 cylindricalTransform,
Matrix3 cylindricalTransform,
Matrix4 cylindricalTransform,
Offset offsetToCenter,
Offset untransformedPaintingCoordinates
) {

Offset offset,
RenderBox child,
// Matrix4x4 cylindricalTransform,
Matrix3 cylindricalTransform,
Matrix4 cylindricalTransform,
Offset offsetToCenter
) {
context.pushTransform(

return null;
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null
) {
return false;
}

ListWheelParentData parentData = (ListWheelParentData) child.parentData;
float targetOffset = parentData.offset.dy;
Matrix4x4 transform = target.getTransformTo(this).toMatrix4x4();
Matrix4 transform = target.getTransformTo(this);
Rect bounds = MatrixUtils.transformRect(transform, rect);
Rect targetRect = bounds.translate(0.0f, (size.height - itemExtent) / 2);

27
com.unity.uiwidgets/Runtime/rendering/object.cs


}
}
public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transform,
public void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform,
Matrix3 effectiveTransform;
Matrix4 effectiveTransform;
effectiveTransform = Matrix3.makeTrans(offset.dx, offset.dy);
effectiveTransform.preConcat(transform);
effectiveTransform.preTranslate(-offset.dx, -offset.dy);
effectiveTransform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
effectiveTransform.multiply(transform);
effectiveTransform.translate(-offset.dx, -offset.dy);
var inverse = Matrix3.I();
var invertible = effectiveTransform.invert(inverse);
// it could just be "scale == 0", ignore the assertion.
// D.assert(invertible);

offset,
childPaintBounds: inverse.mapRect(estimatedBounds)
childPaintBounds: MatrixUtils.inverseTransformRect(effectiveTransform, this.estimatedBounds)
canvas.save();
canvas.concat(effectiveTransform);
this.canvas.save();
this.canvas.concat(effectiveTransform.toMatrix3());
painter(this, offset);
canvas.restore();
}

public virtual void paint(PaintingContext context, Offset offset) {
}
public virtual void applyPaintTransform(RenderObject child, Matrix3 transform) {
public virtual void applyPaintTransform(RenderObject child, Matrix4 transform) {
public Matrix3 getTransformTo(RenderObject ancestor) {
D.assert(attached);
public Matrix4 getTransformTo(RenderObject ancestor) {
D.assert(this.attached);
if (ancestor == null) {
var rootNode = owner.rootNode;

renderers.Add(renderer);
}
var transform = Matrix3.I();
var transform = new Matrix4().identity();
for (int index = renderers.Count - 1; index > 0; index -= 1) {
renderers[index].applyPaintTransform(renderers[index - 1], transform);
}

256
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


public HitTestBehavior behavior;
public override bool hitTest(HitTestResult result, Offset position = null) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
bool hitTarget = false;
if (size.contains(position)) {
hitTarget = hitTestChildren(result, position: position) || hitTestSelf(position);

get { return Offset.zero & size; }
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (_clipper != null) {
_updateClip();
D.assert(_clip != null);
if (!_clip.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}

get { return _borderRadius.toRRect(Offset.zero & size); }
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (_clipper != null) {
_updateClip();
D.assert(_clip != null);
if (!_clip.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}

get { return Offset.zero & size; }
}
public override bool hitTest(HitTestResult result,
public override bool hitTest(BoxHitTestResult result,
Offset position = null
) {
_updateClip();

}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
D.assert(position != null);
if (_clipper != null) {

}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (_clipper != null) {
_updateClip();
D.assert(_clip != null);
if (!_clip.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}

}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (_clipper != null) {
_updateClip();
D.assert(_clip != null);
if (!_clip.contains(position)) {
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}

public class RenderTransform : RenderProxyBox {
public RenderTransform(
Matrix3 transform,
Matrix4 transform,
Offset origin = null,
Alignment alignment = null,
bool transformHitTests = true,

public bool transformHitTests;
public Matrix3 transform {
public Matrix4 transform {
set {
if (_transform == value) {
return;

}
}
Matrix3 _transform;
Matrix4 _transform;
_transform = Matrix3.I();
markNeedsPaint();
this._transform = new Matrix4().identity();
this.markNeedsPaint();
}
public void rotateX(float degrees) {

}
public void rotateZ(float degrees) {
_transform.preRotate(degrees);
markNeedsPaint();
this._transform.rotateZ(degrees);
this.markNeedsPaint();
_transform.preTranslate(x, y);
markNeedsPaint();
this._transform.translationValues(x, y, 0);
this.markNeedsPaint();
_transform.preScale(x, y);
markNeedsPaint();
this._transform.scale(x, y, 1);
this.markNeedsPaint();
Matrix3 _effectiveTransform {
Matrix4 _effectiveTransform {
get {
Alignment resolvedAlignment = alignment;
if (_origin == null && resolvedAlignment == null) {

var result = Matrix3.I();
if (_origin != null) {
result.preTranslate(_origin.dx, _origin.dy);
var result = new Matrix4().identity();
if (this._origin != null) {
result.translate(this._origin.dx, this._origin.dy);
translation = resolvedAlignment.alongSize(size);
result.preTranslate(translation.dx, translation.dy);
translation = resolvedAlignment.alongSize(this.size);
result.translate(translation.dx, translation.dy);
result.preConcat(_transform);
result.multiply(this._transform);
result.preTranslate(-translation.dx, -translation.dy);
result.translate(-translation.dx, -translation.dy);
if (_origin != null) {
result.preTranslate(-_origin.dx, -_origin.dy);
if (this._origin != null) {
result.translate(-this._origin.dx, -this._origin.dy);
}
return result;

public override bool hitTest(HitTestResult result, Offset position = null) {
return hitTestChildren(result, position: position);
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
return this.hitTestChildren(result, position: position);
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (transformHitTests) {
var transform = _effectiveTransform;
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
if (!invertible) {
return false;
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
D.assert(!this.transformHitTests || this._effectiveTransform != null);
return result.addWithPaintTransform(
transform: this.transformHitTests ? this._effectiveTransform : null,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
return base.hitTestChildren(resultIn, position: positionIn);
position = inverse.mapPoint(position);
}
return base.hitTestChildren(result, position: position);
);
}
public override void paint(PaintingContext context, Offset offset) {

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(_effectiveTransform);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this._effectiveTransform);
properties.add(new DiagnosticsProperty<Matrix3>("transform matrix", _transform));
properties.add(new DiagnosticsProperty<Offset>("origin", origin));
properties.add(new DiagnosticsProperty<Alignment>("alignment", alignment));
properties.add(new DiagnosticsProperty<bool>("transformHitTests", transformHitTests));
properties.add(new DiagnosticsProperty<Matrix4>("transform matrix", this._transform));
properties.add(new DiagnosticsProperty<Offset>("origin", this.origin));
properties.add(new DiagnosticsProperty<Alignment>("alignment", this.alignment));
properties.add(new DiagnosticsProperty<bool>("transformHitTests", this.transformHitTests));
}
}

}
bool? _hasVisualOverflow;
Matrix3 _transform;
Matrix4 _transform;
void _clearPaintData() {
_hasVisualOverflow = null;

return;
}
if (child == null) {
_hasVisualOverflow = false;
_transform = Matrix3.I();
if (this.child == null) {
this._hasVisualOverflow = false;
this._transform = new Matrix4().identity();
}
else {
_resolve();

float scaleY = sizes.destination.height / sizes.source.height;
Rect sourceRect = _resolvedAlignment.inscribe(sizes.source, Offset.zero & childSize);
Rect destinationRect = _resolvedAlignment.inscribe(sizes.destination, Offset.zero & size);
_hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.height;
_transform = Matrix3.makeTrans(destinationRect.left, destinationRect.top);
_transform.postScale(scaleX, scaleY);
_transform.postTranslate(-sourceRect.left, -sourceRect.top);
Rect sourceRect = this._resolvedAlignment.inscribe(sizes.source, Offset.zero & childSize);
Rect destinationRect = this._resolvedAlignment.inscribe(sizes.destination, Offset.zero & this.size);
this._hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.height;
this._transform = new Matrix4().translationValues(destinationRect.left, destinationRect.top, 0);
this._transform.scale(scaleX, scaleY, 1);
this._transform.translate(-sourceRect.left, -sourceRect.top);
}
}

}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (size.isEmpty) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (this.size.isEmpty || this.child?.size?.isEmpty == true)
}
_updatePaintData();
Matrix3 inverse = Matrix3.I();
if (!_transform.invert(inverse)) {
return false;
}
position = inverse.mapPoint(position);
return base.hitTestChildren(result, position: position);
this._updatePaintData();
return result.addWithPaintTransform(
transform: this._transform,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
return base.hitTestChildren(resultIn, position: positionIn);
}
);
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
if (size.isEmpty) {
transform.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
if (this.size.isEmpty) {
transform.setZero();
_updatePaintData();
transform.postConcat(_transform);
this._updatePaintData();
transform.multiply(this._transform);
}
}

Offset _translation;
public override bool hitTest(HitTestResult result, Offset position) {
return hitTestChildren(result, position: position);
public override bool hitTest(BoxHitTestResult result, Offset position) {
return this.hitTestChildren(result, position: position);
protected override bool hitTestChildren(HitTestResult result, Offset position) {
D.assert(!debugNeedsLayout);
if (transformHitTests) {
position = new Offset(
position.dx - translation.dx * size.width,
position.dy - translation.dy * size.height
);
}
return base.hitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
D.assert(!this.debugNeedsLayout);
return result.addWithPaintOffset(
offset: this.transformHitTests
? new Offset(this.translation.dx * this.size.width, this.translation.dy * this.size.height)
: null,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
return base.hitTestChildren(resultIn, position: positionIn);
}
);
}
public override void paint(PaintingContext context, Offset offset) {

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate(translation.dx * size.width,
translation.dy * size.height);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.translate(this.translation.dx * this.size.width,
this.translation.dy * this.size.height);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

onPointerSignal((PointerSignalEvent) evt);
return;
}
if (onPointerScroll != null && evt is PointerScrollEvent) {
onPointerScroll((PointerScrollEvent) evt);
if (this.onPointerScroll != null && evt is PointerScrollEvent) {
this.onPointerScroll((PointerScrollEvent) evt);
}
}

bool _ignoring;
public override bool hitTest(HitTestResult result, Offset position = null) {
return ignoring ? false : base.hitTest(result, position: position);
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
return this.ignoring ? false : base.hitTest(result, position: position);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

}
}
public override bool hitTest(HitTestResult result, Offset position) {
return !offstage && base.hitTest(result, position: position);
public override bool hitTest(BoxHitTestResult result, Offset position) {
return !this.offstage && base.hitTest(result, position: position);
}
public override void paint(PaintingContext context, Offset offset) {

bool _absorbing;
public override bool hitTest(HitTestResult result, Offset position) {
return absorbing
? size.contains(position)
public override bool hitTest(BoxHitTestResult result, Offset position) {
return this.absorbing
? this.size.contains(position)
: base.hitTest(result, position: position);
}

new FollowerLayer _layer;
Matrix3 getCurrentTransform() {
return _layer?.getLastTransform() ?? Matrix3.I();
Matrix4 getCurrentTransform() {
return this._layer?.getLastTransform() ?? new Matrix4().identity();
public override bool hitTest(HitTestResult result, Offset position) {
return hitTestChildren(result, position: position);
public override bool hitTest(BoxHitTestResult result, Offset position) {
return this.hitTestChildren(result, position: position);
protected override bool hitTestChildren(HitTestResult result, Offset position) {
Matrix3 inverse = Matrix3.I();
if (!getCurrentTransform().invert(inverse)) {
return false;
}
position = inverse.mapPoint(position);
return base.hitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
return result.addWithPaintTransform(
transform: this.getCurrentTransform(),
position: position,
hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
return base.hitTestChildren(resultIn, position: positionIn);
}
);
}
public override void paint(PaintingContext context, Offset offset) {

);
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(getCurrentTransform());
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this.getCurrentTransform());
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

8
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs


}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (child != null) {
return child.hitTest(result, position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (this.child != null) {
return this.child.hitTest(result, position);
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
}
public override void paint(PaintingContext context, Offset offset) {

42
com.unity.uiwidgets/Runtime/rendering/rotated_box.cs


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

return _isVertical ? child.getMaxIntrinsicWidth(width) : child.getMaxIntrinsicHeight(width);
}
Matrix3 _paintTransform;
Matrix4 _paintTransform;
_paintTransform = null;
if (child != null) {
child.layout(_isVertical ? constraints.flipped : constraints, parentUsesSize: true);
size = _isVertical
? new Size(child.size.height, child.size.width)
: child.size;
_paintTransform = Matrix3.I();
_paintTransform.preTranslate(size.width / 2.0f, size.height / 2.0f);
_paintTransform.preRotate(RotatedBoxUtils._kQuarterTurnsInRadians * (quarterTurns % 4));
_paintTransform.preTranslate(-child.size.width / 2.0f, -child.size.height / 2.0f);
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 = new Matrix4().identity();
this._paintTransform.translate(this.size.width / 2.0f, this.size.height / 2.0f);
this._paintTransform.rotateZ(RotatedBoxUtils._kQuarterTurnsInRadians * (this.quarterTurns % 4));
this._paintTransform.translate(-this.child.size.width / 2.0f, -this.child.size.height / 2.0f);
}
else {
performResize();

protected override bool hitTestChildren(
HitTestResult result,
BoxHitTestResult result,
Offset position = null
) {
D.assert(_paintTransform != null || debugNeedsLayout || child == null);

Matrix3 inverse = Matrix3.I();
_paintTransform.invert(inverse);
return child.hitTest(result, position: inverse.mapPoint(position));
return result.addWithPaintTransform(
transform: this._paintTransform,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
return this.child.hitTest(resultIn, position: positionIn);
}
);
}
void _paintChild(PaintingContext context, Offset offset) {

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
if (_paintTransform != null) {
transform.preConcat(_paintTransform);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
if (this._paintTransform != null) {
transform.multiply(this._paintTransform);
}
base.applyPaintTransform(child, transform);

28
com.unity.uiwidgets/Runtime/rendering/shifted_box.cs


}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (child != null) {
var childParentData = (BoxParentData) child.parentData;
return child.hitTest(result, position - childParentData.offset);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (this.child != null) {
var childParentData = (BoxParentData) this.child.parentData;
return result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return this.child.hitTest(resultIn, position: transformed);
}
);
}
return false;

}
protected override void debugPaintSize(PaintingContext context, Offset offset) {
base.debugPaintSize(context, offset);
base.debugPaintSize(context, offset);
D.assert(() => {
Paint paint;
if (child != null && !child.size.isEmpty) {

}
if (childParentData.offset.dx > 0.0) {
float headSize = Mathf.Min(childParentData.offset.dx * 0.2f, 10.0f);
float x = offset.dx;
float y = offset.dy + size.height / 2.0f;

path.lineTo(x += headSize, y += -headSize);
path.lineTo(x += -headSize, y += -headSize);
path.lineTo(x += 0.0f, y += headSize);
path.moveTo(x = offset.dx + size.width, y = offset.dy + size.height / 2.0f);
path.moveTo(x = offset.dx + this.size.width, y = offset.dy + this.size.height / 2.0f);
path.lineTo(x += -childParentData.offset.dx + headSize, y += 0.0f);
path.lineTo(x += 0.0f, y += headSize);
path.lineTo(x += -headSize, y += -headSize);

context.canvas.drawPath(path, paint);
}
} else {
}
else {
paint = new Paint {
color = new ui.Color(0x90909090),
};

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

141
com.unity.uiwidgets/Runtime/rendering/sliver.cs


}
}
public class SliverHitTestResult : HitTestResult {
public delegate bool SliverHitTest(SliverHitTestResult result, float mainAxisPosition, float crossAxisPosition);
public SliverHitTestResult() : base() {
}
public SliverHitTestResult(HitTestResult result) : base(result) {
}
public bool addWithAxisOffset(
Offset paintOffset,
float mainAxisOffset,
float crossAxisOffset,
float mainAxisPosition,
float crossAxisPosition,
SliverHitTest hitTest
) {
D.assert(mainAxisOffset != null);
D.assert(crossAxisOffset != null);
D.assert(mainAxisPosition != null);
D.assert(crossAxisPosition != null);
D.assert(hitTest != null);
if (paintOffset != null) {
this.pushTransform(new Matrix4().translationValues(-paintOffset.dx, -paintOffset.dy, 0));
}
bool isHit = hitTest(
this,
mainAxisPosition: mainAxisPosition - mainAxisOffset,
crossAxisPosition: crossAxisPosition - crossAxisOffset
);
if (paintOffset != null) {
this.popTransform();
}
return isHit;
}
}
public class SliverHitTestEntry : HitTestEntry {
public SliverHitTestEntry(RenderSliver target,
float mainAxisPosition = 0.0f,

this.crossAxisPosition = crossAxisPosition;
}
public new RenderSliver target {
get { return (RenderSliver) base.target; }
}

public class SliverPhysicalParentData : ParentData {
public Offset paintOffset = Offset.zero;
public void applyPaintTransform(Matrix3 transform) {
transform.preTranslate(paintOffset.dx, paintOffset.dy);
public void applyPaintTransform(Matrix4 transform) {
transform.translate(this.paintOffset.dx, this.paintOffset.dy);
}
public override string ToString() {

get { return 0.0f; }
}
public bool hitTest(HitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
if (mainAxisPosition >= 0.0f && mainAxisPosition < geometry.hitTestExtent &&
crossAxisPosition >= 0.0f && crossAxisPosition < constraints.crossAxisExtent) {
if (hitTestChildren(result, mainAxisPosition: mainAxisPosition,
public bool hitTest(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
if (mainAxisPosition >= 0.0f && mainAxisPosition < this.geometry.hitTestExtent &&
crossAxisPosition >= 0.0f && crossAxisPosition < this.constraints.crossAxisExtent) {
if (this.hitTestChildren(result, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition) ||
hitTestSelf(mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition)) {
result.add(new SliverHitTestEntry(

return false;
}
protected virtual bool hitTestChildren(HitTestResult result, float mainAxisPosition = 0,
protected virtual bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0,
float crossAxisPosition = 0) {
return false;
}

return 0.0f;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
D.assert(() => { throw new UIWidgetsError(GetType() + " does not implement applyPaintTransform."); });
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(() => { throw new UIWidgetsError(this.GetType() + " does not implement applyPaintTransform."); });
}
internal Size getAbsoluteSizeRelativeToOrigin() {

return null;
}
protected Size getAbsoluteSize() {
D.assert(this.geometry != null);
D.assert(!this.debugNeedsLayout);
switch (this.constraints.axisDirection) {
case AxisDirection.up:
case AxisDirection.down:
return new Size(this.constraints.crossAxisExtent, this.geometry.paintExtent);
case AxisDirection.right:
case AxisDirection.left:
return new Size(this.geometry.paintExtent, this.constraints.crossAxisExtent);
}
return null;
}
void _debugDrawArrow(Canvas canvas, Paint paint, Offset p0, Offset p1, GrowthDirection direction) {
D.assert(() => {
if (p0 == p1) {

return rightWayUp;
}
public static bool hitTestBoxChild(this RenderSliver it, HitTestResult result, RenderBox child,
public static bool hitTestBoxChild(this RenderSliver it, BoxHitTestResult result, RenderBox child,
float absolutePosition = mainAxisPosition - it.childMainAxisPosition(child);
float absoluteCrossAxisPosition = crossAxisPosition - it.childCrossAxisPosition(child);
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);
float absolutePosition = mainAxisPosition - delta;
float absoluteCrossAxisPosition = crossAxisPosition - crossAxisDelta;
Offset paintOffset = null;
Offset transformedPosition = null;
D.assert(it.constraints.axis != null);
case Axis.horizontal:
if (!rightWayUp) {
absolutePosition = child.size.width - absolutePosition;
}
return child.hitTest(result,
position: new Offset(absolutePosition, absoluteCrossAxisPosition));
case Axis.vertical:
if (!rightWayUp) {
absolutePosition = child.size.height - absolutePosition;
}
return child.hitTest(result,
position: new Offset(absoluteCrossAxisPosition, absolutePosition));
case Axis.horizontal:
if (!rightWayUp) {
absolutePosition = child.size.width - absolutePosition;
delta = it.geometry.paintExtent - child.size.width - delta;
}
paintOffset = new Offset(delta, crossAxisDelta);
transformedPosition = new Offset(absolutePosition, absoluteCrossAxisPosition);
break;
case Axis.vertical:
if (!rightWayUp) {
absolutePosition = child.size.height - absolutePosition;
delta = it.geometry.paintExtent - child.size.height - delta;
}
paintOffset = new Offset(crossAxisDelta, delta);
transformedPosition = new Offset(absoluteCrossAxisPosition, absolutePosition);
break;
return false;
D.assert(paintOffset != null);
D.assert(transformedPosition != null);
return result.addWithPaintOffset(
offset: paintOffset,
position: null, // Manually adapting from sliver to box position above.
hitTest: (BoxHitTestResult boxHitTestResult, Offset _) => {
return child.hitTest(boxHitTestResult, position: transformedPosition);
}
);
Matrix3 transform) {
Matrix4 transform) {
bool rightWayUp = _getRightWayUp(it.constraints);
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);

delta = it.geometry.paintExtent - child.size.width - delta;
}
transform.preTranslate(delta, crossAxisDelta);
transform.translate(delta, crossAxisDelta);
break;
case Axis.vertical:
if (!rightWayUp) {

transform.preTranslate(crossAxisDelta, delta);
transform.translate(crossAxisDelta, delta);
break;
}
}

}
}
protected override bool hitTestChildren(HitTestResult result, float mainAxisPosition = 0.0f,
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
D.assert(geometry.hitTestExtent > 0.0f);
if (child != null) {
return this.hitTestBoxChild(result, child, mainAxisPosition: mainAxisPosition,
D.assert(this.geometry.hitTestExtent > 0.0f);
if (this.child != null) {
return this.hitTestBoxChild(new BoxHitTestResult(result), this.child, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition);
}

return -constraints.scrollOffset;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);

10
com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs


return 0.0f;
}
protected override bool hitTestChildren(HitTestResult result, float mainAxisPosition = 0.0f,
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
RenderBox child = lastChild;
RenderBox child = this.lastChild;
BoxHitTestResult boxResult = new BoxHitTestResult(result);
if (this.hitTestBoxChild(result, child, mainAxisPosition: mainAxisPosition,
if (this.hitTestBoxChild(boxResult, child, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition)) {
return true;
}

return childParentData.layoutOffset;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
this.applyPaintTransformForBoxChild((RenderBox) child, transform);
}

18
com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs


D.assert(crossAxisPadding == this.crossAxisPadding);
}
protected override bool hitTestChildren(HitTestResult result, float mainAxisPosition = 0.0f,
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
if (child != null && child.geometry.hitTestExtent > 0.0) {
return child.hitTest(result,
mainAxisPosition: mainAxisPosition - childMainAxisPosition(child),
crossAxisPosition: crossAxisPosition - childCrossAxisPosition(child));
if (this.child != null && this.child.geometry.hitTestExtent > 0.0) {
SliverPhysicalParentData childParentData = this.child.parentData as SliverPhysicalParentData;
result.addWithAxisOffset(
mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition,
mainAxisOffset: this.childMainAxisPosition(this.child),
crossAxisOffset: this.childCrossAxisPosition(this.child),
paintOffset: childParentData.paintOffset,
hitTest: this.child.hitTest
);
}
return false;

return beforePadding;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);

10
com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs


return base.childMainAxisPosition(this.child);
}
protected override bool hitTestChildren(HitTestResult result, float mainAxisPosition, float crossAxisPosition) {
D.assert(geometry.hitTestExtent > 0.0f);
if (child != null) {
return RenderSliverHelpers.hitTestBoxChild(this, result, child, mainAxisPosition: mainAxisPosition,
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition, float crossAxisPosition) {
D.assert(this.geometry.hitTestExtent > 0.0f);
if (this.child != null) {
return RenderSliverHelpers.hitTestBoxChild(this, new BoxHitTestResult(result), this.child, mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition);
}

public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);
RenderSliverHelpers.applyPaintTransformForBoxChild(this, this.child, transform);

86
com.unity.uiwidgets/Runtime/rendering/stack.cs


}
}
public static float getIntrinsicDimension(RenderBox firstChild, mainChildSizeGetter getter) {
float extent = 0;
RenderBox child = firstChild;
while (child != null) {
StackParentData childParentData = child.parentData as StackParentData;
if (!childParentData.isPositioned)
extent = Math.Max(extent, getter(child));
D.assert(child.parentData == childParentData);
child = childParentData.nextSibling;
}
return extent;
}
public delegate float mainChildSizeGetter(RenderBox child);
float _getIntrinsicDimension(mainChildSizeGetter getter) {

return defaultComputeDistanceToHighestActualBaseline(baseline);
}
public static bool layoutPositionedChild(RenderBox child, StackParentData childParentData, Size size,
Alignment alignment) {
D.assert(childParentData.isPositioned);
D.assert(child.parentData == childParentData);
bool hasVisualOverflow = false;
BoxConstraints childConstraints = new BoxConstraints();
if (childParentData.left != null && childParentData.right != null)
childConstraints =
childConstraints.tighten(width: size.width - childParentData.right - childParentData.left);
else if (childParentData.width != null)
childConstraints = childConstraints.tighten(width: childParentData.width);
if (childParentData.top != null && childParentData.bottom != null)
childConstraints =
childConstraints.tighten(height: size.height - childParentData.bottom - childParentData.top);
else if (childParentData.height != null)
childConstraints = childConstraints.tighten(height: childParentData.height);
child.layout(childConstraints, parentUsesSize: true);
float? x;
if (childParentData.left != null) {
x = childParentData.left;
}
else if (childParentData.right != null) {
x = size.width - childParentData.right - child.size.width;
}
else {
x = alignment.alongOffset(size - child.size as Offset).dx;
}
if (x < 0.0 || x + child.size.width > size.width)
hasVisualOverflow = true;
float? y;
if (childParentData.top != null) {
y = childParentData.top;
}
else if (childParentData.bottom != null) {
y = size.height - childParentData.bottom - child.size.height;
}
else {
y = alignment.alongOffset(size - child.size as Offset).dy;
}
if (y < 0.0 || y + child.size.height > size.height)
hasVisualOverflow = true;
childParentData.offset = new Offset(x ?? 0, y ?? 0);
return hasVisualOverflow;
}
protected override void performLayout() {
_hasVisualOverflow = false;
bool hasNonPositionedChildren = false;

}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.defaultHitTestChildren(result, position: position);
}
public virtual void paintStack(PaintingContext context, Offset offset) {

return child;
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
if (firstChild == null || index == null) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position) {
if (this.firstChild == null || this.index == null) {
return false;
}

return child.hitTest(result, position: position - childParentData.offset);
return result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(resultIn, position: transformed);
}
);
}
public override void paintStack(PaintingContext context, Offset offset) {

40
com.unity.uiwidgets/Runtime/rendering/table.cs


if (tableWidth > maxWidthConstraint) {
float deficit = tableWidth - maxWidthConstraint;
int availableColumns = columns;
int availableColumns = this.columns;
//(Xingwei Zhu) this deficit is double and set to be 0.00000001f in flutter.
//since we use float by default, making it larger should make sense in most cases
float minimumDeficit = 0.0001f;

if (flexes[x] != null) {
//(Xingwei Zhu) in case deficit * flexes[x].Value / totalFlex => 0 if deficit is really small, leading to dead loop,
//we amend it with a default larger value to ensure that this loop will eventually end
float newWidth = widths[x] - Mathf.Max(minimumDeficit, deficit * flexes[x].Value / totalFlex);
float newWidth =
widths[x] - Mathf.Max(minimumDeficit, deficit * flexes[x].Value / totalFlex);
D.assert(newWidth.isFinite());
if (newWidth <= minWidths[x]) {
deficit -= widths[x] - minWidths[x];

D.assert(_rowTops.Count == rows + 1);
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
D.assert(_children.Count == rows * columns);
for (int index = _children.Count - 1; index >= 0; index--) {
RenderBox child = _children[index];
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
D.assert(this._children.Count == this.rows * this.columns);
for (int index = this._children.Count - 1; index >= 0; index--) {
RenderBox child = this._children[index];
if (child.hitTest(result, position: position - childParentData.offset)) {
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(resultIn, position: transformed);
}
);
if (isHit) {
return true;
}
}

}
}
D.assert(_rows == _rowTops.Count - 1);
D.assert(_columns == _columnLefts.Count);
if (border != null) {
Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, size.width, _rowTops[_rowTops.Count - 1]);
List<float> rows = _rowTops.GetRange(1, _rowTops.Count - 2);
List<float> columns = _columnLefts.GetRange(1, _columnLefts.Count - 1);
border.paint(context.canvas, borderRect, rows: rows, columns: columns);
D.assert(this._rows == this._rowTops.Count - 1);
D.assert(this._columns == this._columnLefts.Count);
if (this.border != null) {
Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, this.size.width,
this._rowTops[this._rowTops.Count - 1]);
List<float> rows = this._rowTops.GetRange(1, this._rowTops.Count - 2);
List<float> columns = this._columnLefts.GetRange(1, this._columnLefts.Count - 1);
this.border.paint(context.canvas, borderRect, rows: rows, columns: columns);
}
}

21
com.unity.uiwidgets/Runtime/rendering/view.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class ViewConfiguration {

public readonly float devicePixelRatio;
public Matrix3 toMatrix() {
return Matrix3.I();
public Matrix4 toMatrix() {
// return new Matrix4().diagonal3Values(this.devicePixelRatio, this.devicePixelRatio, 0);
return new Matrix4().identity();
}
public override string ToString() {

owner.requestVisualUpdate();
}
Matrix3 _rootTransform;
Matrix4 _rootTransform;
public Layer _updateMatricesAndCreateNewRootLayer() {
_rootTransform = configuration.toMatrix();

}
public bool hitTest(HitTestResult result, Offset position = null) {
if (child != null) {
child.hitTest(result, position: position);
if (this.child != null) {
this.child.hitTest(new BoxHitTestResult(result), position: position);
}
result.add(new HitTestEntry(this));

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(_rootTransform);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this._rootTransform);
base.applyPaintTransform(child, transform);
}

public override Rect semanticBounds {
get {
D.assert(_rootTransform != null);
return _rootTransform.mapRect(Offset.zero & size);
D.assert(this._rootTransform != null);
return MatrixUtils.transformRect(this._rootTransform, Offset.zero & this.size);
}
}

45
com.unity.uiwidgets/Runtime/rendering/viewport.cs


});
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
D.assert(position != null);
float mainAxisPosition = 0, crossAxisPosition = 0;

break;
}
foreach (RenderSliver child in childrenInHitTestOrder) {
if (child.geometry.visible && child.hitTest(
result,
mainAxisPosition: computeChildMainAxisPosition(child, mainAxisPosition),
crossAxisPosition: crossAxisPosition
)) {
SliverHitTestResult sliverResult = new SliverHitTestResult(result);
foreach (RenderSliver child in this.childrenInHitTestOrder) {
if (!child.geometry.visible) {
continue;
}
Matrix4 transform = new Matrix4().identity();
this.applyPaintTransform(child, transform);
bool isHit = result.addWithPaintTransform(
transform: transform,
position: null, // Manually adapting from box to sliver position below.
hitTest: (BoxHitTestResult resultIn, Offset _) => {
return child.hitTest(
sliverResult,
mainAxisPosition: this.computeChildMainAxisPosition(child, mainAxisPosition),
crossAxisPosition: crossAxisPosition
);
}
);
if (isHit) {
return true;
}
}

float targetMainAxisExtent = 0.0f;
rect = rect ?? target.paintBounds;
Matrix3 transform;
Matrix4 transform;
RenderObject child = target;
RenderBox pivot = null;

RenderSliver pivotParent = (RenderSliver) pivot.parent;
transform = target.getTransformTo(pivot);
Rect bounds = transform.mapRect(rect);
Rect bounds = MatrixUtils.transformRect(transform, rect);
float offset = 0.0f;

float offsetDifference = this.offset.pixels - targetOffset;
transform = target.getTransformTo(this);
applyPaintTransform(child, transform);
Rect targetRect = transform.mapRect(rect);
this.applyPaintTransform(child, transform);
Rect targetRect = MatrixUtils.transformRect(transform, rect);
switch (axisDirection) {
case AxisDirection.down:

}
else {
var transform = descendant.getTransformTo(viewport.parent);
return transform.mapRect(rect ?? descendant.paintBounds);
return MatrixUtils.transformRect(transform, rect ?? descendant.paintBounds);
}
D.assert(targetOffset != null);

return 0.0f;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
var childParentData = (SliverPhysicalParentData) child.parentData;

return pinnedExtent;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
Offset offset = paintOffsetOf((RenderSliver) child);
transform.preTranslate(offset.dx, offset.dy);
Offset offset = this.paintOffsetOf((RenderSliver) child);
transform.translate(offset.dx, offset.dy);
}
protected override float computeChildMainAxisPosition(RenderSliver child, float parentMainAxisPosition) {

4
com.unity.uiwidgets/Runtime/rendering/wrap.cs


}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return defaultHitTestChildren(result, position: position);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.defaultHitTestChildren(result, position: position);
}
public override void paint(PaintingContext context, Offset offset) {

16
com.unity.uiwidgets/Runtime/widgets/basic.cs


public class Transform : SingleChildRenderObjectWidget {
public Transform(
Key key = null,
Matrix3 transform = null,
Matrix4 transform = null,
Offset origin = null,
Alignment alignment = null,
bool transformHitTests = true,

this.transform = new Matrix3(transform);
this.transform = new Matrix4(transform);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

Widget child = null,
float degree = 0.0f
) : base(key: key, child: child) {
transform = Matrix3.makeRotate(degree);
this.transform = new Matrix4().rotationZ(degree);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

Widget child = null
) : base(key: key, child: child) {
D.assert(offset != null);
transform = Matrix3.makeTrans(offset.dx, offset.dy);
origin = null;
alignment = null;
this.transform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
this.origin = null;
this.alignment = null;
this.transformHitTests = transformHitTests;
}

bool transformHitTests = true,
Widget child = null
) : base(key: key, child: child) {
transform = Matrix3.makeScale(scale, scale);
this.transform = new Matrix4().translationValues(scale, scale, scale);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

return new Transform(key, scale, origin, alignment, transformHitTests, child);
}
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public readonly Offset origin;
public readonly Alignment alignment;
public readonly bool transformHitTests;

14
com.unity.uiwidgets/Runtime/widgets/container.cs


float? height = null,
BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix3 transfrom = null,
Matrix4 transfrom = null,
Widget child = null
) : base(key) {
D.assert(margin == null || margin.isNonNegative);

public readonly Decoration foregroundDecoration;
public readonly BoxConstraints constraints;
public readonly EdgeInsets margin;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
EdgeInsets _paddingIncludingDecoration {
get {

current = new Padding(padding: margin, child: current);
}
if (transform != null) {
current = new Transform(transform: new Matrix3(transform), child: current);
if (this.transform != null) {
current = new Transform(transform: new Matrix4(this.transform), child: current);
}
return current;

properties.add(new DiagnosticsProperty<BoxConstraints>("constraints",
constraints, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin",
margin, defaultValue: foundation_.kNullDefaultValue));
properties.add(ObjectFlagProperty<Matrix3>.has("transform",
transform));
this.margin, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(ObjectFlagProperty<Matrix4>.has("transform",
this.transform));
}
}
}

3
com.unity.uiwidgets/Runtime/widgets/heroes.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

public static Rect _globalBoundingBoxFor(BuildContext context) {
RenderBox box = (RenderBox) context.findRenderObject();
D.assert(box != null && box.hasSize);
return box.getTransformTo(null).mapRect(Offset.zero & box.size);
return MatrixUtils.transformRect( box.getTransformTo(null), Offset.zero & box.size);
}
}

54
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.widgets {

}
public class Matrix3Tween : Tween<Matrix3> {
public Matrix3Tween(
Matrix3 begin = null,
Matrix3 end = null) : base(begin: begin, end: end) {
public class Matrix4Tween : Tween<Matrix4> {
public Matrix4Tween(
Matrix4 begin = null,
Matrix4 end = null) : base(begin: begin, end: end) {
//todo:xingwei.zhu implement full matrix3 lerp
public override Matrix3 lerp(float t) {
D.assert(begin != null);
D.assert(end != null);
public override Matrix4 lerp(float t) {
D.assert(this.begin != null);
D.assert(this.end != null);
return t < 0.5 ? begin : end;
Vector3 beginTranslation = Vector3.zero;
Vector3 endTranslation = Vector3.zero;
Quaternion beginRotation = Quaternion.identity;
Quaternion endRotation = Quaternion.identity;
Vector3 beginScale = Vector3.zero;
Vector3 endScale = Vector3.zero;
this.begin.decompose(ref beginTranslation, ref beginRotation, ref beginScale);
this.end.decompose(ref endTranslation, ref endRotation, ref endScale);
Vector3 lerpTranslation =
beginTranslation * (1.0f - t) + endTranslation * t;
// TODO(alangardner): Implement slerp for constant rotation
Quaternion lerpRotation =
beginRotation
.scaled(1.0f - t)
.add(endRotation.scaled(t)).normalized;
Vector3 lerpScale = beginScale * (1.0f - t) + endScale * t;
return new Matrix4().compose(lerpTranslation, lerpRotation, lerpScale);
}
}

float? height = null,
BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix3 transform = null,
Matrix4 transform = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null

public readonly EdgeInsets margin;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public override State createState() {

properties.add(new DiagnosticsProperty<BoxConstraints>("constraints", constraints,
defaultValue: null,
showName: false));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin", margin, defaultValue: null));
properties.add(ObjectFlagProperty<Matrix3>.has("transform", transform));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin", this.margin, defaultValue: null));
properties.add(ObjectFlagProperty<Matrix4>.has("transform", this.transform));
}
}

DecorationTween _foregroundDecoration;
BoxConstraintsTween _constraints;
EdgeInsetsTween _margin;
Matrix3Tween _transform;
Matrix4Tween _transform;
protected override void forEachTween(TweenVisitor visitor) {

(BoxConstraints value) => new BoxConstraintsTween(begin: value));
_margin = (EdgeInsetsTween) visitor.visit(this, _margin, widget.margin,
(EdgeInsets value) => new EdgeInsetsTween(begin: value));
_transform = (Matrix3Tween) visitor.visit(this, _transform, widget.transform,
(Matrix3 value) => new Matrix3Tween(begin: value));
this._transform = (Matrix4Tween) visitor.visit(this, this._transform, this.widget.transform,
(Matrix4 value) => new Matrix4Tween(begin: value));
}

new DiagnosticsProperty<DecorationTween>("fg", _foregroundDecoration, defaultValue: null));
description.add(new DiagnosticsProperty<BoxConstraintsTween>("constraints", _constraints,
showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsTween>("margin", _margin, defaultValue: null));
description.add(ObjectFlagProperty<Matrix3Tween>.has("transform", _transform));
description.add(new DiagnosticsProperty<EdgeInsetsTween>("margin", this._margin, defaultValue: null));
description.add(ObjectFlagProperty<Matrix4Tween>.has("transform", this._transform));
}
}

4
com.unity.uiwidgets/Runtime/widgets/layout_builder.cs


}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return child?.hitTest(result, position: position) ?? false;
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return this.child?.hitTest(result, position: position) ?? false;
}
public override void paint(PaintingContext context, Offset offset) {

4
com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs


childLayoutGeometry.maxScrollObstructionExtent);
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
HitTestResult result,
SliverHitTestResult result,
float mainAxisPosition = 0,
float crossAxisPosition = 0
) {

500
com.unity.uiwidgets/Runtime/widgets/overlay.cs


using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class OverlayEntry {

return;
}
_opaque = value;
D.assert(_overlay != null);
_overlay._didChangeEntryOpacity();
this._opaque = value;
this._overlay?._didChangeEntryOpacity();
}
}

internal OverlayState _overlay;
internal readonly GlobalKey<_OverlayEntryState> _key = new LabeledGlobalKey<_OverlayEntryState>();
internal readonly GlobalKey<_OverlayEntryWidgetState> _key = new LabeledGlobalKey<_OverlayEntryWidgetState>();
public void remove() {
D.assert(_overlay != null);

}
class _OverlayEntry : StatefulWidget {
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key) {
class _OverlayEntryWidget : StatefulWidget {
internal _OverlayEntryWidget(Key key, OverlayEntry entry, bool tickerEnabled = true) : base(key: key) {
D.assert(key != null);
this.tickerEnabled = tickerEnabled;
public readonly bool tickerEnabled;
return new _OverlayEntryState();
return new _OverlayEntryWidgetState();
class _OverlayEntryState : State<_OverlayEntry> {
class _OverlayEntryWidgetState : State<_OverlayEntryWidget> {
public override Widget build(BuildContext context) {
return widget.entry.builder(context);
}

entry._overlay = this;
}
setState(() => {
_entries.InsertRange(_insertionIndex(below, above), entries);
});
this.setState(() => { this._entries.InsertRange(this._insertionIndex(below, above), entries); });
public void rearrange(IEnumerable<OverlayEntry> newEntries, OverlayEntry below = null, OverlayEntry above = null) {
public void rearrange(IEnumerable<OverlayEntry> newEntries, OverlayEntry below = null,
OverlayEntry above = null) {
newEntries is List<OverlayEntry> ?(newEntries as List<OverlayEntry>) : newEntries.ToList();
newEntries is List<OverlayEntry> ? (newEntries as List<OverlayEntry>) : newEntries.ToList();
D.assert(above == null || below == null, () => "Only one of `above` and `below` may be specified.");
D.assert(above == null || (above._overlay == this && _entries.Contains(above)),
() => "The provided entry for `above` is not present in the Overlay.");

return;
}
HashSet<OverlayEntry> old = new HashSet<OverlayEntry>(_entries);
foreach(OverlayEntry entry in newEntriesList) {
HashSet<OverlayEntry> old = new HashSet<OverlayEntry>(this._entries);
foreach (OverlayEntry entry in newEntriesList) {
setState(() => {
_entries.Clear();
_entries.AddRange(newEntriesList);
this.setState(() => {
this._entries.Clear();
this._entries.AddRange(newEntriesList);
foreach (OverlayEntry entry in newEntriesList) {
old.Remove(entry);
}

}
public override Widget build(BuildContext context) {
var onstageChildren = new List<Widget>();
var offstageChildren = new List<Widget>();
var children = new List<Widget>();
int onstageCount = 0;
onstageChildren.Add(new _OverlayEntry(entry));
onstageCount += 1;
children.Add(new _OverlayEntryWidget(entry._key, entry));
offstageChildren.Add(new TickerMode(enabled: false, child: new _OverlayEntry(entry)));
children.Add(new _OverlayEntryWidget(
key: entry._key,
entry: entry,
tickerEnabled: false
));
onstageChildren.Reverse();
children.Reverse();
onstage: new Stack(
fit: StackFit.expand,
children: onstageChildren
),
offstage: offstageChildren
skipCount: children.Count - onstageCount,
children: children.ToList()
// onstage: new Stack(
// fit: StackFit.expand,
// children: onstageChildren
// ),
// offstage: offstageChildren
class _Theatre : RenderObjectWidget {
internal _Theatre(Stack onstage = null, List<Widget> offstage = null) {
D.assert(offstage != null);
D.assert(!offstage.Any((child) => child == null));
this.onstage = onstage;
this.offstage = offstage;
class _Theatre : MultiChildRenderObjectWidget {
internal _Theatre(Key key = null,
int skipCount = 0,
List<Widget> children = null) : base(key, children) {
D.assert(skipCount != null);
D.assert(skipCount >= 0);
D.assert(children != null);
D.assert(children.Count() >= skipCount);
this.skipCount = skipCount;
public readonly int skipCount;
public readonly Stack onstage;

}
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderTheatre();
return new _RenderTheatre(
skipCount: this.skipCount,
textDirection: Directionality.of(context));
}
public void updateRenderObject(BuildContext context, _RenderTheatre renderObject) {
renderObject.skipCount = this.skipCount;
renderObject.textDirection = Directionality.of(context);
class _TheatreElement : RenderObjectElement {
public _TheatreElement(RenderObjectWidget widget) : base(widget) {
D.assert(!WidgetsD.debugChildrenHaveDuplicateKeys(widget, ((_Theatre) widget).offstage));
class _TheatreElement : MultiChildRenderObjectElement {
public _TheatreElement(_Theatre widget) : base(widget) {
}
public new _Theatre widget {

get { return (_RenderTheatre) base.renderObject; }
}
Element _onstage;
static readonly object _onstageSlot = new object();
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
D.assert(this.children.Count() >= this.widget.skipCount);
foreach (var item in this.children.Skip(this.widget.skipCount)) {
visitor(item);
}
}
}
List<Element> _offstage;
readonly HashSet<Element> _forgottenOffstageChildren = new HashSet<Element>();
// Element _onstage;
// static readonly object _onstageSlot = new object();
//
// List<Element> _offstage;
// readonly HashSet<Element> _forgottenOffstageChildren = new HashSet<Element>();
//
// protected override void insertChildRenderObject(RenderObject child, object slot) {
// D.assert(this.renderObject.debugValidateChild(child));
// if (slot == _onstageSlot) {
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
//
// protected override void moveChildRenderObject(RenderObject child, object slot) {
// if (slot == _onstageSlot) {
// this.renderObject.remove((RenderBox) child);
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// else {
// this.renderObject.move((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
// }
//
// protected override void removeChildRenderObject(RenderObject child) {
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// }
// else {
// this.renderObject.remove((RenderBox) child);
// }
// }
//
// public override void visitChildren(ElementVisitor visitor) {
// if (this._onstage != null) {
// visitor(this._onstage);
// }
//
// foreach (var child in this._offstage) {
// if (!this._forgottenOffstageChildren.Contains(child)) {
// visitor(child);
// }
// }
// }
//
// // public override void debugVisitOnstageChildren(ElementVisitor visitor) {
// // if (this._onstage != null) {
// // visitor(this._onstage);
// // }
// // }
//
//
// protected override void forgetChild(Element child) {
// if (child == this._onstage) {
// this._onstage = null;
// }
// else {
// D.assert(this._offstage.Contains(child));
// D.assert(!this._forgottenOffstageChildren.Contains(child));
// this._forgottenOffstageChildren.Add(child);
// }
// }
//
// public override void mount(Element parent, object newSlot) {
// base.mount(parent, newSlot);
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = new List<Element>(this.widget.offstage.Count);
// Element previousChild = null;
// for (int i = 0; i < this._offstage.Count; i += 1) {
// var newChild = this.inflateWidget(this.widget.offstage[i], previousChild);
// this._offstage[i] = newChild;
// previousChild = newChild;
// }
// }
//
// public override void update(Widget newWidget) {
// base.update(newWidget);
// D.assert(Equals(this.widget, newWidget));
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = this.updateChildren(this._offstage, this.widget.offstage,
// forgottenChildren: this._forgottenOffstageChildren);
// this._forgottenOffstageChildren.Clear();
// }
// }
class _RenderTheatre :
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData> {
internal _RenderTheatre(
TextDirection textDirection,
List<RenderBox> children = null,
int skipCount = 0
) {
D.assert(skipCount != null);
D.assert(skipCount >= 0);
D.assert(textDirection != null);
this._textDirection = textDirection;
this._skipCount = skipCount;
this.addAll(children);
}
protected override void insertChildRenderObject(RenderObject child, object slot) {
D.assert(renderObject.debugValidateChild(child));
if (slot == _onstageSlot) {
D.assert(child is RenderStack);
renderObject.child = (RenderStack) child;
}
else {
D.assert(slot == null || slot is Element);
renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
bool _hasVisualOverflow = false;
Alignment _resolvedAlignment;
void _resolve() {
if (this._resolvedAlignment != null)
return;
// TODO: AlignmentDirectional
Alignment al = Alignment.topLeft;
switch (this.textDirection) {
case TextDirection.rtl:
this._resolvedAlignment = new Alignment(-1, -1);
break;
case TextDirection.ltr:
this._resolvedAlignment = new Alignment(1, -1);
break;
protected override void moveChildRenderObject(RenderObject child, object slot) {
if (slot == _onstageSlot) {
renderObject.remove((RenderBox) child);
D.assert(child is RenderStack);
renderObject.child = (RenderStack) child;
}
else {
D.assert(slot == null || slot is Element);
if (renderObject.child == child) {
renderObject.child = null;
renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
}
else {
renderObject.move((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
}
}
void _markNeedResolution() {
this._resolvedAlignment = null;
this.markNeedsLayout();
protected override void removeChildRenderObject(RenderObject child) {
if (renderObject.child == child) {
renderObject.child = null;
}
else {
renderObject.remove((RenderBox) child);
public TextDirection textDirection {
get { return this._textDirection; }
set {
if (this._textDirection == value)
return;
this._textDirection = value;
this._markNeedResolution();
public override void visitChildren(ElementVisitor visitor) {
if (_onstage != null) {
visitor(_onstage);
}
TextDirection _textDirection;
foreach (var child in _offstage) {
if (!_forgottenOffstageChildren.Contains(child)) {
visitor(child);
public int skipCount {
get { return this._skipCount; }
set {
D.assert(value != null);
if (this._skipCount != value) {
this._skipCount = value;
this.markNeedsLayout();
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
if (_onstage != null) {
visitor(_onstage);
}
}
int _skipCount;
RenderBox _firstOnstageChild {
get {
if (this.skipCount == base.childCount) {
return null;
}
protected override void forgetChild(Element child) {
if (child == _onstage) {
_onstage = null;
}
else {
D.assert(_offstage.Contains(child));
D.assert(!_forgottenOffstageChildren.Contains(child));
_forgottenOffstageChildren.Add(child);
}
}
RenderBox child = base.firstChild;
for (int toSkip = this.skipCount; toSkip > 0; toSkip--) {
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
D.assert(child != null);
}
public override void mount(Element parent, object newSlot) {
base.mount(parent, newSlot);
_onstage = updateChild(_onstage, widget.onstage, _onstageSlot);
_offstage = new List<Element>(widget.offstage.Count);
Element previousChild = null;
for (int i = 0; i < _offstage.Count; i += 1) {
var newChild = inflateWidget(widget.offstage[i], previousChild);
_offstage[i] = newChild;
previousChild = newChild;
return child;
public override void update(Widget newWidget) {
base.update(newWidget);
D.assert(Equals(widget, newWidget));
_onstage = updateChild(_onstage, widget.onstage, _onstageSlot);
_offstage = updateChildren(_offstage, widget.offstage,
forgottenChildren: _forgottenOffstageChildren);
_forgottenOffstageChildren.Clear();
}
}
class _RenderTheatre :
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData> {
public override void setupParentData(RenderObject child) {
if (!(child.parentData is StackParentData)) {
child.parentData = new StackParentData();

}
return children;
}
RenderBox _lastOnstageChild {
get { return this.skipCount == this.childCount ? null : this.lastChild; }
}
int _onstageChildCount {
get { return this.childCount - this.skipCount; }
}
protected override float computeMinIntrinsicWidth(float height) {
return RenderStack.getIntrinsicDimension(this._firstOnstageChild,
(RenderBox child) => child.getMinIntrinsicWidth(height));
}
protected override float computeMaxIntrinsicWidth(float height) {
return RenderStack.getIntrinsicDimension(this._firstOnstageChild,
(RenderBox child) => child.getMaxIntrinsicWidth(height));
}
protected override float computeMinIntrinsicHeight(float width) {
return RenderStack.getIntrinsicDimension(this._firstOnstageChild,
(RenderBox child) => child.getMinIntrinsicHeight(width));
}
protected internal override float computeMaxIntrinsicHeight(float width) {
return RenderStack.getIntrinsicDimension(this._firstOnstageChild,
(RenderBox child) => child.getMaxIntrinsicHeight(width));
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(!this.debugNeedsLayout);
float? result = null;
RenderBox child = this._firstOnstageChild;
while (child != null) {
D.assert(!child.debugNeedsLayout);
StackParentData childParentData = child.parentData as StackParentData;
float? candidate = child.getDistanceToActualBaseline(baseline);
if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
}
else {
result = candidate;
}
}
child = childParentData.nextSibling;
}
return result;
}
protected override bool sizedByParent {
get { return true; }
}
protected override void performResize() {
this.size = this.constraints.biggest;
D.assert(this.size.isFinite);
}
protected override void performLayout() {
this._hasVisualOverflow = false;
if (this._onstageChildCount == 0) {
return;
}
this._resolve();
D.assert(this._resolvedAlignment != null);
// Same BoxConstraints as used by RenderStack for StackFit.expand.
BoxConstraints nonPositionedConstraints = BoxConstraints.tight(this.constraints.biggest);
RenderBox child = this._firstOnstageChild;
while (child != null) {
StackParentData childParentData = child.parentData as StackParentData;
if (!childParentData.isPositioned) {
child.layout(nonPositionedConstraints, parentUsesSize: true);
childParentData.offset = this._resolvedAlignment.alongOffset(this.size - child.size as Offset);
}
else {
this._hasVisualOverflow =
RenderStack.layoutPositionedChild(child, childParentData, this.size, this._resolvedAlignment) ||
_hasVisualOverflow;
}
D.assert(child.parentData == childParentData);
child = childParentData.nextSibling;
}
}
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
RenderBox child = this._lastOnstageChild;
for (int i = 0; i < this._onstageChildCount; i++) {
D.assert(child != null);
StackParentData childParentData = child.parentData as StackParentData;
if (childParentData.offset.dx != 0 || childParentData.offset.dy != 0) {
i = i;
}
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(resultIn, position: transformed);
}
);
if (isHit)
return true;
child = childParentData.previousSibling;
}
return false;
}
void paintStack(PaintingContext context, Offset offset) {
RenderBox child = this._firstOnstageChild;
while (child != null) {
StackParentData childParentData = child.parentData as StackParentData;
context.paintChild(child, childParentData.offset + offset);
child = childParentData.nextSibling;
}
}
public override void paint(PaintingContext context, Offset offset) {
if (this._hasVisualOverflow) {
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, this.paintStack);
}
else {
this.paintStack(context, offset);
}
}
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
RenderBox child = this._firstOnstageChild;
while (child != null) {
visitor(child);
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
}
}
public override Rect describeApproximatePaintClip(RenderObject child) =>
this._hasVisualOverflow ? Offset.zero & this.size : null;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("skipCount", this.skipCount));
properties.add(new EnumProperty<TextDirection>("textDirection", this.textDirection));
}
}
}

35
com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs


DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
D.assert(!(controller != null && primary == true),
() => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
"You cannot both set primary to true and pass an explicit controller.");
() =>
"Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
"You cannot both set primary to true and pass an explicit controller.");
this.scrollDirection = scrollDirection;
this.reverse = reverse;
this.padding = padding;

public readonly DragStartBehavior dragStartBehavior;
AxisDirection _getDirection(BuildContext context) {
return AxisDirectionUtils.getAxisDirectionFromAxisReverseAndDirectionality(context, scrollDirection,
reverse) ?? AxisDirection.down;
return AxisDirectionUtils.getAxisDirectionFromAxisReverseAndDirectionality(context, this.scrollDirection,
this.reverse) ?? AxisDirection.down;
}
public override Widget build(BuildContext context) {

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
Offset paintOffset = _paintOffset;
transform.preTranslate(paintOffset.dx, paintOffset.dy);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
Offset paintOffset = this._paintOffset;
transform.translate(paintOffset.dx, paintOffset.dy);
}
public override Rect describeApproximatePaintClip(RenderObject child) {

return null;
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (child != null) {
Offset transformed = position + (-_paintOffset);
return child.hitTest(result, position: transformed);
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
if (this.child != null) {
return result.addWithPaintOffset(
offset: this._paintOffset,
position: position,
hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
D.assert(transformed == position + (-this._paintOffset));
return this.child.hitTest(result, position: transformed);
}
);
}
return false;

}
RenderBox targetBox = (RenderBox) target;
Matrix3 transform = targetBox.getTransformTo(this);
Rect bounds = transform.mapRect(rect);
Size contentSize = child.size;
Matrix4 transform = targetBox.getTransformTo(this);
Rect bounds = MatrixUtils.transformRect(transform, rect);
Size contentSize = this.child.size;
float leadingScrollOffset = 0.0f;
float targetMainAxisExtent = 0.0f;

8
com.unity.uiwidgets/Runtime/widgets/transitions.cs


public readonly Widget child;
protected internal override Widget build(BuildContext context) {
float scaleValue = scale.value;
Matrix3 transform = Matrix3.makeScale(scaleValue, scaleValue);
float scaleValue = this.scale.value;
Matrix4 transform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
return new Transform(
transform: transform,
alignment: alignment,

public readonly Widget child;
protected internal override Widget build(BuildContext context) {
float turnsValue = turns.value;
Matrix3 transform = Matrix3.makeRotate((turnsValue * Mathf.PI * 2.0f));
float turnsValue = this.turns.value;
Matrix4 transform = new Matrix4().rotationZ((turnsValue * Mathf.PI * 2.0f));
return new Transform(
transform: transform,
alignment: alignment,

19
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


using RSG;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;

List<RenderObject> edgeHits,
Offset position,
RenderObject renderObject,
Matrix3 transform
Matrix4 transform
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
if (!invertible) {
var inverse = new Matrix4().inverted(transform);
if (inverse == null) {
var localPosition = inverse.mapPoint(position);
var localPosition = MatrixUtils.transformPoint(inverse, position);
List<DiagnosticsNode> children = renderObject.debugDescribeChildren();
for (int i = children.Count - 1; i >= 0; --i) {

continue;
}
var childTransform = new Matrix3(transform);
var childTransform = new Matrix4(transform);
renderObject.applyPaintTransform(child, childTransform);
if (_hitTestHelper(hits, edgeHits, position, child, childTransform)) {
hit = true;

class _TransformedRect : IEquatable<_TransformedRect> {
public readonly Rect rect;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public _TransformedRect(RenderObject obj) {
rect = obj.semanticBounds;

};
Rect selectedPaintRect = state.selected.rect.deflate(0.5f);
canvas.save();
canvas.setMatrix(state.selected.transform);
canvas.setMatrix(state.selected.transform.toMatrix3());
canvas.drawRect(selectedPaintRect, fillPaint);
canvas.drawRect(selectedPaintRect, borderPaint);
canvas.restore();

canvas.setMatrix(transformedRect.transform);
canvas.setMatrix(transformedRect.transform.toMatrix3());
canvas.drawRect(transformedRect.rect.deflate(0.5f), borderPaint);
canvas.restore();
}

125
Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample/LocalPositionSample.cs


using System;
using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
public class LocalPositionSample : UIWidgetsPanel
{
protected override void OnEnable()
{
base.OnEnable();
}
protected override Widget createWidget()
{
{
return new MaterialApp(
title: "Flutter Demo",
theme: new ThemeData(
primarySwatch: Colors.blue
),
home: new MyHomePage(title: "Local Position Test"));
}
}
public class MyHomePage : StatefulWidget
{
public MyHomePage(string title, Key key = null) : base(key: key)
{
this.title = title;
}
public readonly string title;
public override State createState()
{
return new _MyHomePageState();
}
}
public class _MyHomePageState : State<MyHomePage>
{
Offset _globalPostion = Offset.zero;
Offset _localPostion = Offset.zero;
void _checkPosition(TapUpDetails tapUpDetails)
{
setState(() =>
{
_globalPostion = tapUpDetails.globalPosition;
_localPostion = tapUpDetails.localPosition;
});
}
void _checkPosition(TapDownDetails tapUpDetails)
{
setState(() =>
{
_globalPostion = tapUpDetails.globalPosition;
_localPostion = tapUpDetails.localPosition;
});
}
public override Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title)
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget>()
{
new Text(
"Tap to get global position and local position:"
),
new Text(
$"global position: {_globalPostion}",
style: Theme.of(context).textTheme.headline
),
new Text(
$"local position: {_localPostion}",
style: Theme.of(context).textTheme.headline
),
new GestureDetector(
onTapUp: _checkPosition,
child: new Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
decoration: new BoxDecoration(color: Colors.red),
child: new Text("On Tap Up")
)
),
new GestureDetector(
onTapDown: _checkPosition,
child: new Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(30),
decoration: new BoxDecoration(Colors.orange),
child: new Text("on Tap Down")
)
),
new GestureDetector(
onTapDown: _checkPosition,
child: new Container(
padding: EdgeInsets.all(30),
decoration: new BoxDecoration(Colors.pink),
child: new Text("on Tap Down with 0 margin")
)
)
}
)
)
);
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample/LocalPositionSample.cs.meta


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

536
Samples/UIWidgetsSamples_2019_4/Assets/Scenes/LocalPosition.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &166246262
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 166246265}
- component: {fileID: 166246264}
- component: {fileID: 166246263}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &166246263
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 166246262}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &166246264
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 166246262}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &166246265
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 166246262}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1173156216
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1173156217}
- component: {fileID: 1173156219}
- component: {fileID: 1173156218}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1173156217
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1173156216}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1656596898}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 626.3, y: 431.9}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1173156218
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1173156216}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4c6d96aaa15e54a47a53543e4c7ab81b, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0
--- !u!222 &1173156219
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1173156216}
m_CullTransparentMesh: 0
--- !u!1 &1514114434
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1514114436}
- component: {fileID: 1514114435}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1514114435
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1514114434}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1514114436
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1514114434}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1656596894
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1656596898}
- component: {fileID: 1656596897}
- component: {fileID: 1656596896}
- component: {fileID: 1656596895}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1656596895
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656596894}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1656596896
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656596894}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &1656596897
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656596894}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1656596898
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656596894}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1173156217}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1824294904
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1824294907}
- component: {fileID: 1824294906}
- component: {fileID: 1824294905}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1824294905
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824294904}
m_Enabled: 1
--- !u!20 &1824294906
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824294904}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1824294907
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824294904}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

7
Samples/UIWidgetsSamples_2019_4/Assets/Scenes/LocalPosition.unity.meta


fileFormatVersion: 2
guid: 16f587e6d84ea4240b2a20ef51388ade
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

892
com.unity.uiwidgets/Runtime/ui/Matrix4.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public class Matrix4 : IEquatable<Matrix4> {
internal readonly float[] _m4storage;
int dimension {
get { return 4; }
}
public Matrix4() {
this._m4storage = new float[16];
}
public Matrix4(Matrix4 other) {
this._m4storage = new float[16];
this.setFrom(other);
}
public static Matrix4 tryInvert(Matrix4 other) {
Matrix4 r = new Matrix4();
float determinant = r.copyInverse(other);
if (determinant == 0) {
return null;
}
return r;
}
public Matrix4(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this._m4storage = new float[16];
this.setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
arg10, arg11, arg12, arg13, arg14, arg15);
}
public Matrix4 fromList(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this.setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
arg10, arg11, arg12, arg13, arg14, arg15);
return this;
}
public Matrix4 identity() {
this.setIdentity();
return this;
}
public Matrix4 inverted(Matrix4 other) {
double determinant = this.copyInverse(other);
if (determinant == 0) {
// throw new Exception("input matrix cannot be inverted");
return null;
}
return this;
}
public Matrix4 copy(Matrix4 other) {
this.setFrom(other);
return this;
}
public Matrix4 compose(Vector3 translation, Quaternion rotation, Vector3 scale) {
this.setFromTranslationRotationScale(translation, rotation, scale);
return this;
}
public void setColumn(int column, Vector4 arg) {
int entry = column * 4;
this._m4storage[entry + 3] = arg[3];
this._m4storage[entry + 2] = arg[2];
this._m4storage[entry + 1] = arg[1];
this._m4storage[entry + 0] = arg[0];
}
public Vector4 getColumn(int column) {
Vector4 r = new Vector4();
int entry = column * 4;
r[3] = this._m4storage[entry + 3];
r[2] = this._m4storage[entry + 2];
r[1] = this._m4storage[entry + 1];
r[0] = this._m4storage[entry + 0];
return r;
}
public void setRow(int row, Vector4 arg) {
this._m4storage[this.index(row, 0)] = arg[0];
this._m4storage[this.index(row, 1)] = arg[1];
this._m4storage[this.index(row, 2)] = arg[2];
this._m4storage[this.index(row, 3)] = arg[3];
}
public Vector4 getRow(int row) {
Vector4 r = new Vector4();
r[0] = this._m4storage[this.index(row, 0)];
r[1] = this._m4storage[this.index(row, 1)];
r[2] = this._m4storage[this.index(row, 2)];
r[3] = this._m4storage[this.index(row, 3)];
return r;
}
public Matrix4 clone() => new Matrix4().copy(this);
public static Matrix4 operator *(Matrix4 a, Matrix4 b) {
var result = a.clone();
result.multiply(b);
return result;
}
void setFromTranslationRotationScale(
Vector3 translation, Quaternion rotation, Vector3 scale) {
this.setFromTranslationRotation(translation, rotation);
this.scale(scale);
}
void setFromTranslationRotation(Vector3 arg0, Quaternion arg1) {
float x = arg1[0];
float y = arg1[1];
float z = arg1[2];
float w = arg1[3];
float x2 = x + x;
float y2 = y + y;
float z2 = z + z;
float xx = x * x2;
float xy = x * y2;
float xz = x * z2;
float yy = y * y2;
float yz = y * z2;
float zz = z * z2;
float wx = w * x2;
float wy = w * y2;
float wz = w * z2;
this._m4storage[0] = 1.0f - (yy + zz);
this._m4storage[1] = xy + wz;
this._m4storage[2] = xz - wy;
this._m4storage[3] = 0;
this._m4storage[4] = xy - wz;
this._m4storage[5] = 1.0f - (xx + zz);
this._m4storage[6] = yz + wx;
this._m4storage[7] = 0;
this._m4storage[8] = xz + wy;
this._m4storage[9] = yz - wx;
this._m4storage[10] = 1.0f - (xx + yy);
this._m4storage[11] = 0;
this._m4storage[12] = arg0[0];
this._m4storage[13] = arg0[1];
this._m4storage[14] = arg0[2];
this._m4storage[15] = 1.0f;
}
void setFrom(Matrix4 arg) {
this._m4storage[15] = arg[15];
this._m4storage[14] = arg[14];
this._m4storage[13] = arg[13];
this._m4storage[12] = arg[12];
this._m4storage[11] = arg[11];
this._m4storage[10] = arg[10];
this._m4storage[9] = arg[9];
this._m4storage[8] = arg[8];
this._m4storage[7] = arg[7];
this._m4storage[6] = arg[6];
this._m4storage[5] = arg[5];
this._m4storage[4] = arg[4];
this._m4storage[3] = arg[3];
this._m4storage[2] = arg[2];
this._m4storage[1] = arg[1];
this._m4storage[0] = arg[0];
}
void setValues(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this._m4storage[15] = arg15;
this._m4storage[14] = arg14;
this._m4storage[13] = arg13;
this._m4storage[12] = arg12;
this._m4storage[11] = arg11;
this._m4storage[10] = arg10;
this._m4storage[9] = arg9;
this._m4storage[8] = arg8;
this._m4storage[7] = arg7;
this._m4storage[6] = arg6;
this._m4storage[5] = arg5;
this._m4storage[4] = arg4;
this._m4storage[3] = arg3;
this._m4storage[2] = arg2;
this._m4storage[1] = arg1;
this._m4storage[0] = arg0;
}
public void setZero() {
this._m4storage[0] = 0;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[3] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = 0;
this._m4storage[6] = 0;
this._m4storage[7] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 0;
this._m4storage[11] = 0;
this._m4storage[12] = 0;
this._m4storage[13] = 0;
this._m4storage[14] = 0;
this._m4storage[15] = 0;
}
void setIdentity() {
this._m4storage[0] = 1;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[3] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = 1;
this._m4storage[6] = 0;
this._m4storage[7] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1;
this._m4storage[11] = 0;
this._m4storage[12] = 0;
this._m4storage[13] = 0;
this._m4storage[14] = 0;
this._m4storage[15] = 1;
}
Matrix4 absolute() {
Matrix4 r = new Matrix4();
this[0] = this._m4storage[0].abs();
this[1] = this._m4storage[1].abs();
this[2] = this._m4storage[2].abs();
this[3] = this._m4storage[3].abs();
this[4] = this._m4storage[4].abs();
this[5] = this._m4storage[5].abs();
this[6] = this._m4storage[6].abs();
this[7] = this._m4storage[7].abs();
this[8] = this._m4storage[8].abs();
this[9] = this._m4storage[9].abs();
this[10] = this._m4storage[10].abs();
this[11] = this._m4storage[11].abs();
this[12] = this._m4storage[12].abs();
this[13] = this._m4storage[13].abs();
this[14] = this._m4storage[14].abs();
this[15] = this._m4storage[15].abs();
return r;
}
public float determinant() {
float det2_01_01 =
this._m4storage[0] * this._m4storage[5] - this._m4storage[1] * this._m4storage[4];
float det2_01_02 =
this._m4storage[0] * this._m4storage[6] - this._m4storage[2] * this._m4storage[4];
float det2_01_03 =
this._m4storage[0] * this._m4storage[7] - this._m4storage[3] * this._m4storage[4];
float det2_01_12 =
this._m4storage[1] * this._m4storage[6] - this._m4storage[2] * this._m4storage[5];
float det2_01_13 =
this._m4storage[1] * this._m4storage[7] - this._m4storage[3] * this._m4storage[5];
float det2_01_23 =
this._m4storage[2] * this._m4storage[7] - this._m4storage[3] * this._m4storage[6];
float det3_201_012 = this._m4storage[8] * det2_01_12 -
this._m4storage[9] * det2_01_02 +
this._m4storage[10] * det2_01_01;
float det3_201_013 = this._m4storage[8] * det2_01_13 -
this._m4storage[9] * det2_01_03 +
this._m4storage[11] * det2_01_01;
float det3_201_023 = this._m4storage[8] * det2_01_23 -
this._m4storage[10] * det2_01_03 +
this._m4storage[11] * det2_01_02;
float det3_201_123 = this._m4storage[9] * det2_01_23 -
this._m4storage[10] * det2_01_13 +
this._m4storage[11] * det2_01_12;
return -det3_201_123 * this._m4storage[12] +
det3_201_023 * this._m4storage[13] -
det3_201_013 * this._m4storage[14] +
det3_201_012 * this._m4storage[15];
}
float invertRotation() {
float det = this.determinant();
if (det == 0) {
return 0;
}
float invDet = 1.0f / det;
float ix;
float iy;
float iz;
float jx;
float jy;
float jz;
float kx;
float ky;
float kz;
ix = invDet *
(this._m4storage[5] * this._m4storage[10] - this._m4storage[6] * this._m4storage[9]);
iy = invDet *
(this._m4storage[2] * this._m4storage[9] - this._m4storage[1] * this._m4storage[10]);
iz = invDet *
(this._m4storage[1] * this._m4storage[6] - this._m4storage[2] * this._m4storage[5]);
jx = invDet *
(this._m4storage[6] * this._m4storage[8] - this._m4storage[4] * this._m4storage[10]);
jy = invDet *
(this._m4storage[0] * this._m4storage[10] - this._m4storage[2] * this._m4storage[8]);
jz = invDet *
(this._m4storage[2] * this._m4storage[4] - this._m4storage[0] * this._m4storage[6]);
kx = invDet *
(this._m4storage[4] * this._m4storage[9] - this._m4storage[5] * this._m4storage[8]);
ky = invDet *
(this._m4storage[1] * this._m4storage[8] - this._m4storage[0] * this._m4storage[9]);
kz = invDet *
(this._m4storage[0] * this._m4storage[5] - this._m4storage[1] * this._m4storage[4]);
this._m4storage[0] = ix;
this._m4storage[1] = iy;
this._m4storage[2] = iz;
this._m4storage[4] = jx;
this._m4storage[5] = jy;
this._m4storage[6] = jz;
this._m4storage[8] = kx;
this._m4storage[9] = ky;
this._m4storage[10] = kz;
return det;
}
public Vector4 transform(Vector4 arg) {
float x_ = (this._m4storage[0] * arg[0]) +
(this._m4storage[4] * arg[1]) +
(this._m4storage[8] * arg[2]) +
(this._m4storage[12] * arg[3]);
float y_ = (this._m4storage[1] * arg[0]) +
(this._m4storage[5] * arg[1]) +
(this._m4storage[9] * arg[2]) +
(this._m4storage[13] * arg[3]);
float z_ = (this._m4storage[2] * arg[0]) +
(this._m4storage[6] * arg[1]) +
(this._m4storage[10] * arg[2]) +
(this._m4storage[14] * arg[3]);
float w_ = (this._m4storage[3] * arg[0]) +
(this._m4storage[7] * arg[1]) +
(this._m4storage[11] * arg[2]) +
(this._m4storage[15] * arg[3]);
arg[0] = x_;
arg[1] = y_;
arg[2] = z_;
arg[3] = w_;
return arg;
}
public Vector3 perspectiveTransform(Vector3 arg) {
float x_ = (this._m4storage[0] * arg[0]) +
(this._m4storage[4] * arg[1]) +
(this._m4storage[8] * arg[2]) +
this._m4storage[12];
float y_ = (this._m4storage[1] * arg[0]) +
(this._m4storage[5] * arg[1]) +
(this._m4storage[9] * arg[2]) +
this._m4storage[13];
float z_ = (this._m4storage[2] * arg[0]) +
(this._m4storage[6] * arg[1]) +
(this._m4storage[10] * arg[2]) +
this._m4storage[14];
float w_ = 1.0f /
((this._m4storage[3] * arg[0]) +
(this._m4storage[7] * arg[1]) +
(this._m4storage[11] * arg[2]) +
this._m4storage[15]);
arg[0] = x_ * w_;
arg[1] = y_ * w_;
arg[2] = z_ * w_;
return arg;
}
public void translate(float tx, float ty = 0, float tz = 0, float tw = 1) {
float t1 = this._m4storage[0] * tx +
this._m4storage[4] * ty +
this._m4storage[8] * tz +
this._m4storage[12] * tw;
float t2 = this._m4storage[1] * tx +
this._m4storage[5] * ty +
this._m4storage[9] * tz +
this._m4storage[13] * tw;
float t3 = this._m4storage[2] * tx +
this._m4storage[6] * ty +
this._m4storage[10] * tz +
this._m4storage[14] * tw;
float t4 = this._m4storage[3] * tx +
this._m4storage[7] * ty +
this._m4storage[11] * tz +
this._m4storage[15] * tw;
this._m4storage[12] = t1;
this._m4storage[13] = t2;
this._m4storage[14] = t3;
this._m4storage[15] = t4;
}
public Matrix4 rotationX(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationX(radians);
return this;
}
public Matrix4 rotationY(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationY(radians);
return this;
}
public Matrix4 rotationZ(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationZ(radians);
return this;
}
public Matrix4 rotationZ(float radians, float px, float py) {
this._m4storage[15] = 1.0f;
this.setRotationZ(radians, px, py);
return this;
}
public Matrix4 diagonal3Values(float x, float y, float z) {
this._m4storage[15] = 1;
this._m4storage[10] = z;
this._m4storage[5] = y;
this._m4storage[0] = x;
return this;
}
public void scale(float sx, float sy, float sz, float sw = 1) {
this._m4storage[0] *= sx;
this._m4storage[1] *= sx;
this._m4storage[2] *= sx;
this._m4storage[3] *= sx;
this._m4storage[4] *= sy;
this._m4storage[5] *= sy;
this._m4storage[6] *= sy;
this._m4storage[7] *= sy;
this._m4storage[8] *= sz;
this._m4storage[9] *= sz;
this._m4storage[10] *= sz;
this._m4storage[11] *= sz;
this._m4storage[12] *= sw;
this._m4storage[13] *= sw;
this._m4storage[14] *= sw;
this._m4storage[15] *= sw;
}
public void scale(Vector3 s) {
float sx = s.x;
float sy = s.y;
float sz = s.z;
float sw = 1;
this._m4storage[0] *= sx;
this._m4storage[1] *= sx;
this._m4storage[2] *= sx;
this._m4storage[3] *= sx;
this._m4storage[4] *= sy;
this._m4storage[5] *= sy;
this._m4storage[6] *= sy;
this._m4storage[7] *= sy;
this._m4storage[8] *= sz;
this._m4storage[9] *= sz;
this._m4storage[10] *= sz;
this._m4storage[11] *= sz;
this._m4storage[12] *= sw;
this._m4storage[13] *= sw;
this._m4storage[14] *= sw;
this._m4storage[15] *= sw;
}
Matrix4 scaled(float sx, float sy, float sz, float sw = 1) {
var result = this.clone();
result.scale(sx, sy, sz, sw);
return result;
}
public Matrix4 translationValues(float x, float y, float z) {
this.identity();
this.setTranslationRaw(x, y, z);
return this;
}
public void rotateX(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[4] * cosAngle + this._m4storage[8] * sinAngle;
float t2 = this._m4storage[5] * cosAngle + this._m4storage[9] * sinAngle;
float t3 = this._m4storage[6] * cosAngle + this._m4storage[10] * sinAngle;
float t4 = this._m4storage[7] * cosAngle + this._m4storage[11] * sinAngle;
float t5 = this._m4storage[4] * -sinAngle + this._m4storage[8] * cosAngle;
float t6 = this._m4storage[5] * -sinAngle + this._m4storage[9] * cosAngle;
float t7 = this._m4storage[6] * -sinAngle + this._m4storage[10] * cosAngle;
float t8 = this._m4storage[7] * -sinAngle + this._m4storage[11] * cosAngle;
this._m4storage[4] = t1;
this._m4storage[5] = t2;
this._m4storage[6] = t3;
this._m4storage[7] = t4;
this._m4storage[8] = t5;
this._m4storage[9] = t6;
this._m4storage[10] = t7;
this._m4storage[11] = t8;
}
public void rotateY(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[0] * cosAngle + this._m4storage[8] * -sinAngle;
float t2 = this._m4storage[1] * cosAngle + this._m4storage[9] * -sinAngle;
float t3 = this._m4storage[2] * cosAngle + this._m4storage[10] * -sinAngle;
float t4 = this._m4storage[3] * cosAngle + this._m4storage[11] * -sinAngle;
float t5 = this._m4storage[0] * sinAngle + this._m4storage[8] * cosAngle;
float t6 = this._m4storage[1] * sinAngle + this._m4storage[9] * cosAngle;
float t7 = this._m4storage[2] * sinAngle + this._m4storage[10] * cosAngle;
float t8 = this._m4storage[3] * sinAngle + this._m4storage[11] * cosAngle;
this._m4storage[0] = t1;
this._m4storage[1] = t2;
this._m4storage[2] = t3;
this._m4storage[3] = t4;
this._m4storage[8] = t5;
this._m4storage[9] = t6;
this._m4storage[10] = t7;
this._m4storage[11] = t8;
}
public void rotateZ(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[0] * cosAngle + this._m4storage[4] * sinAngle;
float t2 = this._m4storage[1] * cosAngle + this._m4storage[5] * sinAngle;
float t3 = this._m4storage[2] * cosAngle + this._m4storage[6] * sinAngle;
float t4 = this._m4storage[3] * cosAngle + this._m4storage[7] * sinAngle;
float t5 = this._m4storage[0] * -sinAngle + this._m4storage[4] * cosAngle;
float t6 = this._m4storage[1] * -sinAngle + this._m4storage[5] * cosAngle;
float t7 = this._m4storage[2] * -sinAngle + this._m4storage[6] * cosAngle;
float t8 = this._m4storage[3] * -sinAngle + this._m4storage[7] * cosAngle;
this._m4storage[0] = t1;
this._m4storage[1] = t2;
this._m4storage[2] = t3;
this._m4storage[3] = t4;
this._m4storage[4] = t5;
this._m4storage[5] = t6;
this._m4storage[6] = t7;
this._m4storage[7] = t8;
}
public void multiply(Matrix4 arg) {
float m00 = this._m4storage[0];
float m01 = this._m4storage[4];
float m02 = this._m4storage[8];
float m03 = this._m4storage[12];
float m10 = this._m4storage[1];
float m11 = this._m4storage[5];
float m12 = this._m4storage[9];
float m13 = this._m4storage[13];
float m20 = this._m4storage[2];
float m21 = this._m4storage[6];
float m22 = this._m4storage[10];
float m23 = this._m4storage[14];
float m30 = this._m4storage[3];
float m31 = this._m4storage[7];
float m32 = this._m4storage[11];
float m33 = this._m4storage[15];
float[] argStorage = arg._m4storage;
float n00 = argStorage[0];
float n01 = argStorage[4];
float n02 = argStorage[8];
float n03 = argStorage[12];
float n10 = argStorage[1];
float n11 = argStorage[5];
float n12 = argStorage[9];
float n13 = argStorage[13];
float n20 = argStorage[2];
float n21 = argStorage[6];
float n22 = argStorage[10];
float n23 = argStorage[14];
float n30 = argStorage[3];
float n31 = argStorage[7];
float n32 = argStorage[11];
float n33 = argStorage[15];
this._m4storage[0] = (m00 * n00) + (m01 * n10) + (m02 * n20) + (m03 * n30);
this._m4storage[4] = (m00 * n01) + (m01 * n11) + (m02 * n21) + (m03 * n31);
this._m4storage[8] = (m00 * n02) + (m01 * n12) + (m02 * n22) + (m03 * n32);
this._m4storage[12] = (m00 * n03) + (m01 * n13) + (m02 * n23) + (m03 * n33);
this._m4storage[1] = (m10 * n00) + (m11 * n10) + (m12 * n20) + (m13 * n30);
this._m4storage[5] = (m10 * n01) + (m11 * n11) + (m12 * n21) + (m13 * n31);
this._m4storage[9] = (m10 * n02) + (m11 * n12) + (m12 * n22) + (m13 * n32);
this._m4storage[13] = (m10 * n03) + (m11 * n13) + (m12 * n23) + (m13 * n33);
this._m4storage[2] = (m20 * n00) + (m21 * n10) + (m22 * n20) + (m23 * n30);
this._m4storage[6] = (m20 * n01) + (m21 * n11) + (m22 * n21) + (m23 * n31);
this._m4storage[10] = (m20 * n02) + (m21 * n12) + (m22 * n22) + (m23 * n32);
this._m4storage[14] = (m20 * n03) + (m21 * n13) + (m22 * n23) + (m23 * n33);
this._m4storage[3] = (m30 * n00) + (m31 * n10) + (m32 * n20) + (m33 * n30);
this._m4storage[7] = (m30 * n01) + (m31 * n11) + (m32 * n21) + (m33 * n31);
this._m4storage[11] = (m30 * n02) + (m31 * n12) + (m32 * n22) + (m33 * n32);
this._m4storage[15] = (m30 * n03) + (m31 * n13) + (m32 * n23) + (m33 * n33);
}
public void decompose(ref Vector3 translation, ref Quaternion rotation, ref Vector3 scale) {
Vector3 v = Vector3.zero;
v.Set(this._m4storage[0], this._m4storage[1], this._m4storage[2]);
float sx = v.sqrMagnitude;
v.Set(this._m4storage[4], this._m4storage[5], this._m4storage[6]);
float sy = v.sqrMagnitude;
v.Set(this._m4storage[8], this._m4storage[9], this._m4storage[10]);
float sz = v.sqrMagnitude;
if (this.determinant() < 0) {
sx = -sx;
}
translation[0] = this._m4storage[12];
translation[1] = this._m4storage[13];
translation[2] = this._m4storage[14];
float invSX = 1.0f / sx;
float invSY = 1.0f / sy;
float invSZ = 1.0f / sz;
Matrix4 m = new Matrix4().copy(this);
m._m4storage[0] *= invSX;
m._m4storage[1] *= invSX;
m._m4storage[2] *= invSX;
m._m4storage[4] *= invSY;
m._m4storage[5] *= invSY;
m._m4storage[6] *= invSY;
m._m4storage[8] *= invSZ;
m._m4storage[9] *= invSZ;
m._m4storage[10] *= invSZ;
m.QuaternionFromMatrix(ref rotation);
scale[0] = sx;
scale[1] = sy;
scale[2] = sz;
}
void setTranslationRaw(float x, float y, float z) {
this._m4storage[14] = z;
this._m4storage[13] = y;
this._m4storage[12] = x;
}
void setRotationX(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = 1.0f;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = c;
this._m4storage[6] = s;
this._m4storage[8] = 0;
this._m4storage[9] = -s;
this._m4storage[10] = c;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationY(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = 0;
this._m4storage[2] = -s;
this._m4storage[4] = 0;
this._m4storage[5] = 1.0f;
this._m4storage[6] = 0;
this._m4storage[8] = s;
this._m4storage[9] = 0;
this._m4storage[10] = c;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationZ(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = s;
this._m4storage[2] = 0;
this._m4storage[4] = -s;
this._m4storage[5] = c;
this._m4storage[6] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1.0f;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationZ(float radians, float px, float py) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = s;
this._m4storage[2] = 0;
this._m4storage[4] = -s;
this._m4storage[5] = c;
this._m4storage[6] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1.0f;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
this._m4storage[12] = s * py + (1 - c) * px;
this._m4storage[13] = -s * px + (1 - c) * py;
}
public float invert() => this.copyInverse(this);
float copyInverse(Matrix4 arg) {
float a00 = arg[0];
float a01 = arg[1];
float a02 = arg[2];
float a03 = arg[3];
float a10 = arg[4];
float a11 = arg[5];
float a12 = arg[6];
float a13 = arg[7];
float a20 = arg[8];
float a21 = arg[9];
float a22 = arg[10];
float a23 = arg[11];
float a30 = arg[12];
float a31 = arg[13];
float a32 = arg[14];
float a33 = arg[15];
float b00 = a00 * a11 - a01 * a10;
float b01 = a00 * a12 - a02 * a10;
float b02 = a00 * a13 - a03 * a10;
float b03 = a01 * a12 - a02 * a11;
float b04 = a01 * a13 - a03 * a11;
float b05 = a02 * a13 - a03 * a12;
float b06 = a20 * a31 - a21 * a30;
float b07 = a20 * a32 - a22 * a30;
float b08 = a20 * a33 - a23 * a30;
float b09 = a21 * a32 - a22 * a31;
float b10 = a21 * a33 - a23 * a31;
float b11 = a22 * a33 - a23 * a32;
float det =
(b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
if (det == 0) {
this.setFrom(arg);
return 0;
}
float invDet = 1.0f / det;
this._m4storage[0] = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
this._m4storage[1] = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
this._m4storage[2] = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
this._m4storage[3] = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
this._m4storage[4] = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
this._m4storage[5] = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
this._m4storage[6] = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
this._m4storage[7] = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
this._m4storage[8] = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
this._m4storage[9] = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
this._m4storage[10] = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
this._m4storage[11] = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
this._m4storage[12] = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
this._m4storage[13] = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
this._m4storage[14] = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
this._m4storage[15] = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
return det;
}
public int index(int row, int col) => (col * 4) + row;
public float entry(int row, int col) {
D.assert((row >= 0) && (row < this.dimension));
D.assert((col >= 0) && (col < this.dimension));
return this._m4storage[this.index(row, col)];
}
public float this[int index] {
get {
D.assert((uint) index < 16);
return this._m4storage[index];
}
set {
D.assert((uint) index < 16);
this._m4storage[index] = value;
}
}
public bool Equals(Matrix4 other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return (this._m4storage[0] == other._m4storage[0]) &&
(this._m4storage[1] == other._m4storage[1]) &&
(this._m4storage[2] == other._m4storage[2]) &&
(this._m4storage[3] == other._m4storage[3]) &&
(this._m4storage[4] == other._m4storage[4]) &&
(this._m4storage[5] == other._m4storage[5]) &&
(this._m4storage[6] == other._m4storage[6]) &&
(this._m4storage[7] == other._m4storage[7]) &&
(this._m4storage[8] == other._m4storage[8]) &&
(this._m4storage[9] == other._m4storage[9]) &&
(this._m4storage[10] == other._m4storage[10]) &&
(this._m4storage[11] == other._m4storage[11]) &&
(this._m4storage[12] == other._m4storage[12]) &&
(this._m4storage[13] == other._m4storage[13]) &&
(this._m4storage[14] == other._m4storage[14]) &&
(this._m4storage[15] == other._m4storage[15]);
}
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((Matrix4) obj);
}
public override int GetHashCode() {
return (this._m4storage != null ? this._m4storage.GetHashCode() : 0);
}
}
}

11
com.unity.uiwidgets/Runtime/ui/Matrix4.cs.meta


fileFormatVersion: 2
guid: 9b1bb0f304684e3faa19f8d70942198d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存