浏览代码

Merge branch 'shiyun/skia' into constrainedlayoutbuildermixin

/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
11e45c2d
共有 71 个文件被更改,包括 5363 次插入1875 次删除
  1. 42
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
  2. 10
      com.unity.uiwidgets/Runtime/animation/animation.cs
  3. 61
      com.unity.uiwidgets/Runtime/animation/animation_controller.cs
  4. 466
      com.unity.uiwidgets/Runtime/animation/curves.cs
  5. 171
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs
  6. 44
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk
  7. 14
      com.unity.uiwidgets/Runtime/animation/tween.cs
  8. 2
      com.unity.uiwidgets/Runtime/animation/tween_sequence.cs
  9. 2
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs
  10. 3
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  11. 30
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  12. 392
      com.unity.uiwidgets/Runtime/gestures/converter.cs
  13. 75
      com.unity.uiwidgets/Runtime/gestures/events.cs
  14. 94
      com.unity.uiwidgets/Runtime/gestures/multitap.cs
  15. 14
      com.unity.uiwidgets/Runtime/gestures/pointer_router.cs
  16. 8
      com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs
  17. 4
      com.unity.uiwidgets/Runtime/gestures/recognizer.cs
  18. 32
      com.unity.uiwidgets/Runtime/gestures/scale.cs
  19. 3
      com.unity.uiwidgets/Runtime/gestures/tap.cs
  20. 2
      com.unity.uiwidgets/Runtime/painting/text_painter.cs
  21. 10
      com.unity.uiwidgets/Runtime/rendering/box.mixin.gen.cs
  22. 8
      com.unity.uiwidgets/Runtime/rendering/box.mixin.njk
  23. 1
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  24. 90
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  25. 185
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  26. 31
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  27. 29
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk
  28. 12
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  29. 66
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  30. 29
      com.unity.uiwidgets/Runtime/rendering/stack.cs
  31. 7
      com.unity.uiwidgets/Runtime/services/asset_bundle.cs
  32. 2
      com.unity.uiwidgets/Runtime/services/binding.cs
  33. 986
      com.unity.uiwidgets/Runtime/services/keyboard_key.cs
  34. 12
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  35. 2
      com.unity.uiwidgets/Runtime/widgets/disposable_build_context.cs
  36. 2
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  37. 655
      com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs
  38. 642
      com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
  39. 472
      com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs
  40. 332
      com.unity.uiwidgets/Runtime/widgets/image.cs
  41. 101
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  42. 4
      com.unity.uiwidgets/Runtime/widgets/orientation_builder.cs
  43. 2
      com.unity.uiwidgets/Runtime/widgets/page_view.cs
  44. 6
      com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.njk
  45. 6
      com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
  46. 13
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  47. 92
      com.unity.uiwidgets/Runtime/services/text_editing.cs
  48. 28
      com.unity.uiwidgets/Runtime/services/text_formatter.cs
  49. 324
      com.unity.uiwidgets/Runtime/services/text_input.cs
  50. 73
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs
  51. 11
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs.meta
  52. 537
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity
  53. 7
      Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity.meta
  54. 117
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs
  55. 98
      com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk
  56. 72
      com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.gen.cs
  57. 66
      com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.njk
  58. 313
      com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs
  59. 310
      com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.njk
  60. 8
      com.unity.uiwidgets/Runtime/material.meta
  61. 8
      com.unity.uiwidgets/Runtime/ui33.meta
  62. 0
      /com.unity.uiwidgets/Runtime/services/text_editing.cs
  63. 0
      /com.unity.uiwidgets/Runtime/services/clipboard.cs
  64. 0
      /com.unity.uiwidgets/Runtime/services/system_chrome.cs
  65. 0
      /com.unity.uiwidgets/Runtime/services/keyboard.cs
  66. 0
      /com.unity.uiwidgets/Runtime/services/raw_keyboard.cs
  67. 0
      /com.unity.uiwidgets/Runtime/services/text_formatter.cs
  68. 0
      /com.unity.uiwidgets/Runtime/services/platform_channel.cs
  69. 0
      /com.unity.uiwidgets/Runtime/services/system_channels.cs
  70. 0
      /com.unity.uiwidgets/Runtime/services/text_input.cs

42
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs


{
public override Widget build(BuildContext context)
{
return new CupertinoPageScaffold(
child: new Center(
child: new CupertinoButton(
child: new Text(
"THIS IS TAB #"
),
onPressed: () =>
{
Navigator.of(context).push(
new CupertinoPageRoute(builder: (contex3) =>
{
return
new CupertinoAlertDemo();
})
);
}
)
//new Text("hello world!", style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
)
//backgroundColor: Colors.brown
);
// return new CupertinoPageScaffold(
// child: new Center(
// child: new CupertinoButton(
// child: new Text(
// "THIS IS TAB #"
// ),
// onPressed: () =>
// {
// Navigator.of(context).push(
// new CupertinoPageRoute(builder: (contex3) =>
// {
// return
// new CupertinoAlertDemo();
// })
// );
// }
// )
// //new Text("hello world!", style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
// )
// //backgroundColor: Colors.brown
// );
List<BottomNavigationBarItem> items = new List<BottomNavigationBarItem>();
items.Add(new BottomNavigationBarItem(

10
com.unity.uiwidgets/Runtime/animation/animation.cs


get { return status == AnimationStatus.completed; }
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<float>);
return child.animate(this as Animation<float>);
}
public override string ToString() {
return $"{foundation_.describeIdentity(this)}({toStringDetails()})";
}

D.assert(icon != null);
return icon;
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<float>);
return child.animate(this as Animation<float>);
}
}
}

61
com.unity.uiwidgets/Runtime/animation/animation_controller.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.physics;
using Unity.UIWidgets.scheduler2;

AnimationController(
float value = 0.0f,
TimeSpan? duration = null,
TimeSpan? reverseDuration = null,
string debugLabel = null,
TickerProvider vsync = null
) {

_direction = _AnimationDirection.forward;
this.duration = duration;
this.reverseDuration = reverseDuration;
this.debugLabel = debugLabel;
_ticker = vsync.createTicker(_tick);

public static AnimationController unbounded(
float value = 0.0f,
TimeSpan? duration = null,
TimeSpan? reverseDuration = null,
return new AnimationController(value, duration, debugLabel, vsync);
return new AnimationController(value, duration, reverseDuration, debugLabel, vsync);
}
public readonly float lowerBound;

D.assert(() => {
if (duration == null) {
throw new UIWidgetsError(
"AnimationController.forward() called with no default Duration.\n" +
"AnimationController.forward() called with no default duration.\n" +
"The \"duration\" property should be set, either in the constructor or later, before " +
"calling the forward() function."
);

public TickerFuture reverse(float? from = null) {
D.assert(() => {
if (duration == null) {
if (duration == null && reverseDuration == null) {
"AnimationController.reverse() called with no default Duration.\n" +
"The \"duration\" property should be set, either in the constructor or later, before " +
"AnimationController.reverse() called with no default duration or reverseDuration.\n" +
"The \"duration\" or \"reverseDuration\" property should be set, either in the constructor or later, before " +
"calling the reverse() function."
);
}

TimeSpan? simulationDuration = duration;
if (simulationDuration == null) {
D.assert(() => {
if (this.duration == null) {
if ((this.duration == null && _direction == _AnimationDirection.reverse && reverseDuration == null) ||
(this.duration == null && _direction == _AnimationDirection.forward)) {
"AnimationController.animateTo() called with no explicit Duration and no default Duration.\n" +
"AnimationController.animateTo() called with no explicit Duration and no default duration or reverseDuration.\n" +
"\"duration\" property should be set, either in the constructor or later, before " +
"\"duration\" and/or \"reverseDuration\" property should be set, either in the constructor or later, before " +
"calling the animateTo() function."
);
}

float range = upperBound - lowerBound;
float remainingFraction = range.isFinite() ? (target - _value).abs() / range : 1.0f;
simulationDuration = TimeSpan.FromTicks((long) (this.duration.Value.Ticks * remainingFraction));
TimeSpan directionDuration = (_direction == _AnimationDirection.reverse && reverseDuration != null)
? reverseDuration.Value
: this.duration.Value;
simulationDuration = TimeSpan.FromTicks((long) (directionDuration.Ticks * remainingFraction));
}
else if (target == value) {
simulationDuration = TimeSpan.Zero;

D.assert(max >= min);
D.assert(max <= upperBound && min >= lowerBound);
return animateWith(new _RepeatingSimulation(_value, min.Value, max.Value, reverse, period.Value));
stop();
return _startSimulation(new _RepeatingSimulation(_value, min.Value, max.Value, reverse, period.Value, _directionSetter));
}
void _directionSetter(_AnimationDirection direction) {
_direction = direction;
_status = (_direction == _AnimationDirection.forward) ? AnimationStatus.forward : AnimationStatus.reverse;
_checkStatusChanged();
}
public TickerFuture fling(float velocity = 1.0f) {

Simulation simulation = new SpringSimulation(_kFlingSpringDescription, value,
target, velocity);
simulation.tolerance = _kFlingTolerance;
return animateWith(simulation);
stop();
return _startSimulation(simulation);
}

"AnimationController methods should not be used after calling dispose."
);
stop();
_direction = _AnimationDirection.forward;
return _startSimulation(simulation);
}

public override void dispose() {
D.assert(() => {
if (_ticker == null) {
throw new UIWidgetsError(
"AnimationController.dispose() called more than once.\n" +
"A given " + GetType() + " cannot be disposed more than once.\n" +
"The following " + GetType() + " object was disposed multiple times:\n" +
" " + this);
throw new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary("AnimationController.dispose() called more than once."),
new ErrorDescription($"A given {GetType()} cannot be disposed more than once.\n"),
new DiagnosticsProperty<AnimationController>(
$"The following {GetType()} object was disposed multiple times",
this,
style: DiagnosticsTreeStyle.errorProperty)
});
}
return true;

}
}
delegate void _DirectionSetter(_AnimationDirection direction);
internal _RepeatingSimulation(float initialValue, float min, float max, bool reverse, TimeSpan period) {
internal _RepeatingSimulation(float initialValue, float min, float max, bool reverse, TimeSpan period, _DirectionSetter directionSetter) {
_min = min;
_max = max;
_periodInSeconds = (float) period.Ticks / TimeSpan.TicksPerSecond;

this.directionSetter = directionSetter;
D.assert(_periodInSeconds > 0.0f);
D.assert(_initialT >= 0.0f);
}

readonly float _periodInSeconds;
readonly bool _reverse;
readonly float _initialT;
readonly _DirectionSetter directionSetter;
public override float x(float timeInSeconds) {
D.assert(timeInSeconds >= 0.0f);

if (_reverse && _isPlayingReverse) {
directionSetter(_AnimationDirection.reverse);
directionSetter(_AnimationDirection.forward);
return MathUtils.lerpFloat(_min, _max, t);
}
}

466
com.unity.uiwidgets/Runtime/animation/curves.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Random = System.Random;
public abstract class Curve {
public float transform(float t) {
D.assert(t >= 0.0f && t <= 1.0f);
public abstract class ParametricCurve<T> {
public virtual T transform(float t) {
D.assert(t >= 0.0f && t <= 1.0f, () => $"parametric value {t} is outside of [0, 1] range.");
return transformInternal(t);
}
protected virtual T transformInternal(float t) {
throw new NotImplementedException();
}
public override string ToString() {
return $"{GetType()}";
}
}
public abstract class Curve : ParametricCurve<float> {
public override float transform(float t) {
return transformInternal(t);
}
protected virtual float transformInternal(float t) {
throw new NotImplementedException();
return base.transform(t);
}
public override string ToString() {
return GetType().ToString();
}
}

public override string ToString() {
return $"{GetType()}({a:F2}, {b:F2}, {c:F2}, {d:F2})";
}
}
public abstract class Curve2D : ParametricCurve<Offset> {
internal IEnumerable<Curve2DSample> generateSamples(
float start = 0.0f,
float end = 1.0f,
float tolerance = 1e-10f) {
D.assert(end > start);
Random rand = new Random(samplingSeed);
bool isFlat(Offset p, Offset q, Offset r) {
Offset pr = p - r;
Offset qr = q - r;
float z = pr.dx * qr.dy - qr.dx * pr.dy;
return z * z < tolerance;
}
Curve2DSample first = new Curve2DSample(start, transform(start));
Curve2DSample last = new Curve2DSample(end, transform(end));
List<Curve2DSample> samples = new List<Curve2DSample>(){first};
void sample(Curve2DSample p, Curve2DSample q, bool forceSubdivide = false) {
float t = p.t + (0.45f + 0.1f * (float)rand.NextDouble() * (q.t - p.t));
Curve2DSample r = new Curve2DSample(t, transform(t));
if (!forceSubdivide && isFlat(p.value, q.value, r.value)) {
samples.Add(q);
}
else {
sample(p, r);
sample(r, q);
}
}
sample(first, last,
forceSubdivide: (first.value.dx - last.value.dx).abs() < tolerance &&
(first.value.dy - last.value.dy).abs() < tolerance);
return samples;
}
protected virtual int samplingSeed {
get { return 0; }
}
public float findInverse(float x) {
float start = 0.0f;
float end = 1.0f;
float mid = 0f;
float offsetToOrigin(float pos) {
return x - transform(pos).dx;
}
const float errorLimit = 1e-6f;
int count = 100;
float startValue = offsetToOrigin(start);
while ((end - start / 2.0f) > errorLimit && count > 0) {
mid = (end + start) / 2.0f;
float value = offsetToOrigin(mid);
if (value.sign() == startValue.sign()) {
start = mid;
}
else {
end = mid;
}
count--;
}
return mid;
}
}
internal class Curve2DSample {
public Curve2DSample(float t, Offset value) {
this.t = t;
this.value = value;
}
public readonly float t;
public readonly Offset value;
public override string ToString() {
return $"[{value.dx:F2}, {value.dy:F2}, {t:F2}]";
}
}
class CatmullRomSpline : Curve2D {
CatmullRomSpline(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null
) {
D.assert(controlPoints != null);
D.assert(tension != null);
D.assert(tension <= 1.0f, () => $"tension {tension} must not be greater than 1.0.");
D.assert(tension >= 0.0f, () => $"tension {tension} must not be negative.");
D.assert(controlPoints.Count > 3, () => "There must be at least four control points to create a CatmullRomSpline.");
_controlPoints = controlPoints;
_startHandle = startHandle;
_endHandle = endHandle;
_tension = tension;
_cubicSegments = new List<List<Offset>>();
}
internal CatmullRomSpline(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null,
List<List<Offset>> cubicSegments = null
) {
D.assert(cubicSegments != null);
_controlPoints = controlPoints;
_startHandle = startHandle;
_endHandle = endHandle;
_tension = tension;
_cubicSegments = new List<List<Offset>>();
}
public static CatmullRomSpline precompute(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null
) {
D.assert(controlPoints != null);
D.assert(tension != null);
D.assert(tension <= 1.0f, () => $"tension {tension} must not be greater than 1.0.");
D.assert(tension >= 0.0f, () => $"tension {tension} must not be negative.");
D.assert(controlPoints.Count > 3, () => "There must be at least four control points to create a CatmullRomSpline.");
return new CatmullRomSpline(
controlPoints: null,
tension: null,
startHandle: null,
endHandle: null,
cubicSegments: _computeSegments(controlPoints, tension, startHandle: startHandle, endHandle: endHandle)
);
}
static List<List<Offset>> _computeSegments(
List<Offset> controlPoints,
float? tension,
Offset startHandle,
Offset endHandle) {
startHandle = startHandle ?? controlPoints[0] * 2.0f - controlPoints[1];
endHandle = endHandle ?? controlPoints.last() * 2.0f - controlPoints[controlPoints.Count - 2];
List<Offset> allPoints = new List<Offset>();
allPoints.Add(startHandle);
allPoints.AddRange(controlPoints);
allPoints.Add(endHandle);
const float alpha = 0.5f;
float reverseTension = 1.0f - tension.Value;
List<List<Offset>> result = new List<List<Offset>>();
for (int i = 0; i < allPoints.Count - 3; ++i) {
List<Offset> curve = new List<Offset>{allPoints[i], allPoints[i + 1], allPoints[i + 2], allPoints[i + 3]};
Offset diffCurve10 = curve[1] - curve[0];
Offset diffCurve21 = curve[2] - curve[1];
Offset diffCurve32 = curve[3] - curve[2];
float t01 = Mathf.Pow(diffCurve10.distance, alpha);
float t12 = Mathf.Pow(diffCurve21.distance, alpha);
float t23 = Mathf.Pow(diffCurve32.distance, alpha);
Offset m1 = (diffCurve21 + (diffCurve10 / t01 - (curve[2] - curve[0]) / (t01 + t12)) * t12) * reverseTension;
Offset m2 = (diffCurve21 + (diffCurve32 / t23 - (curve[3] - curve[1]) / (t12 + t23)) * t12) * reverseTension;
Offset sumM12 = m1 + m2;
List<Offset> segment = new List<Offset> {
diffCurve21 * -2.0f + sumM12,
diffCurve21 * 3.0f - m1 - sumM12,
m1,
curve[1]
};
result.Add(segment);
}
return result;
}
readonly List<List<Offset>> _cubicSegments;
readonly List<Offset> _controlPoints;
readonly Offset _startHandle;
readonly Offset _endHandle;
readonly float? _tension;
void _initializeIfNeeded() {
if (_cubicSegments.isNotEmpty()) {
return;
}
_cubicSegments.AddRange(_computeSegments(_controlPoints, _tension, startHandle: _startHandle, endHandle: _endHandle));
}
protected override int samplingSeed {
get {
_initializeIfNeeded();
Offset seedPoint = _cubicSegments[0][1];
return ((seedPoint.dx + seedPoint.dy) * 10000).round();
}
}
protected override Offset transformInternal(float t) {
_initializeIfNeeded();
float length = _cubicSegments.Count;
float position;
float localT;
int index;
if (t < 1.0f) {
position = t * length;
localT = position - position.floor();
index = position.floor();
} else {
position = length;
localT = 1.0f;
index = _cubicSegments.Count - 1;
}
List<Offset> cubicControlPoints = _cubicSegments[index];
float localT2 = localT * localT;
return cubicControlPoints[0] * localT2 * localT
+ cubicControlPoints[1] * localT2
+ cubicControlPoints[2] * localT
+ cubicControlPoints[3];
}
}
public class CatmullRomCurve : Curve {
public CatmullRomCurve(
List<Offset> controlPoints,
float? tension = 0.0f) {
D.assert(tension != null);
this.controlPoints = controlPoints;
this.tension = tension;
D.assert(() => {
_debugAssertReasons.Clear();
return validateControlPoints(controlPoints,
tension: tension,
reasons: _debugAssertReasons);
}, () => $"control points {controlPoints} could not be validated:\n {string.Join("\n ", _debugAssertReasons)}");
_precomputedSamples = new List<Curve2DSample>();
}
internal CatmullRomCurve(
List<Offset> controlPoints,
float? tension = 0.0f,
List<Curve2DSample> precomputedSamples = null) {
D.assert(precomputedSamples != null);
D.assert(tension != null);
this.controlPoints = controlPoints;
this.tension = tension;
D.assert(() => {
_debugAssertReasons.Clear();
return validateControlPoints(controlPoints,
tension: tension,
reasons: _debugAssertReasons);
}, () => $"control points {controlPoints} could not be validated:\n {string.Join("\n ", _debugAssertReasons)}");
_precomputedSamples = precomputedSamples;
}
public static CatmullRomCurve precompute(
List<Offset> controlPoints, float? tension = 0.0f) {
return new CatmullRomCurve(
controlPoints,
tension,
_computeSamples(controlPoints, tension));
}
static List<Curve2DSample> _computeSamples(List<Offset> controlPoints, float? tension) {
List<Offset> _controlPoints = new List<Offset>();
_controlPoints.Add(Offset.zero);
_controlPoints.AddRange(controlPoints);
_controlPoints.Add(new Offset(1.0f, 1.0f));
return CatmullRomSpline.precompute(_controlPoints, tension: tension).generateSamples(
start: 0.0f, end: 1.0f, tolerance: 1e-12f).ToList();
}
static readonly List<String> _debugAssertReasons = new List<String>();
readonly List<Curve2DSample> _precomputedSamples;
public readonly List<Offset> controlPoints;
public readonly float? tension;
static bool validateControlPoints(
List<Offset> controlPoints,
float? tension = 0.0f,
List<string> reasons = null) {
D.assert(tension != null);
if (controlPoints == null) {
D.assert(() => {
reasons?.Add("Supplied control points cannot be null");
return true;
});
return false;
}
if (controlPoints.Count < 2) {
D.assert(() => {
reasons?.Add("There must be at least two points supplied to create a valid curve.");
return true;
});
return false;
}
List<Offset> _controlPoints = new List<Offset>();
_controlPoints.AddRange(controlPoints);
_controlPoints.Insert(0, Offset.zero);
_controlPoints.Add(new Offset(1.0f, 1.0f));
Offset startHandle = _controlPoints[0] * 2.0f - _controlPoints[1];
Offset endHandle = _controlPoints.last() * 2.0f - _controlPoints[_controlPoints.Count - 2];
_controlPoints.Insert(0, startHandle);
_controlPoints.Add(endHandle);
float lastX = -float.PositiveInfinity;
for (int i = 0; i < _controlPoints.Count; ++i) {
if (i > 1 &&
i < _controlPoints.Count - 2 &&
(_controlPoints[i].dx <= 0.0f || _controlPoints[i].dx >= 1.0f)) {
D.assert(() => {
reasons?.Add("Control points must have X values between 0.0 and 1.0, exclusive. " +
$"Point {i} has an x value ({_controlPoints[i].dx}) which is outside the range.");
return true;
});
return false;
}
if (_controlPoints[i].dx <= lastX) {
D.assert(() => {
reasons?.Add("Each X coordinate must be greater than the preceding X coordinate " +
$"(i.e. must be monotonically increasing in X). Point {i} has an x value of " +
$"{_controlPoints[i].dx}, which is not greater than {lastX}");
return true;
});
return false;
}
lastX = _controlPoints[i].dx;
}
bool success = true;
lastX = -float.PositiveInfinity;
const float tolerance = 1e-3f;
CatmullRomSpline testSpline = new CatmullRomSpline(_controlPoints, tension: tension);
float start = testSpline.findInverse(0.0f);
float end = testSpline.findInverse(1.0f);
IEnumerable<Curve2DSample> samplePoints = testSpline.generateSamples(start: start, end: end);
if (samplePoints.First().value.dy.abs() > tolerance ||
(1.0f - samplePoints.Last().value.dy).abs() > tolerance) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The curve has more than one Y value at X = {samplePoints.First().value.dx}. " +
"Try moving some control points further away from this value of X, or increasing " +
"the tension.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
foreach (Curve2DSample sample in samplePoints) {
Offset point = sample.value;
float t = sample.t;
float x = point.dx;
if (t >= start && t <= end && (x < -1e-3f || x > 1.0f + 1e-3f)) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The resulting curve has an X value ({x}) which is outside " +
"the range [0.0, 1.0], inclusive.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
if (x < lastX) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The curve has more than one Y value at x = {x}. Try moving " +
"some control points further apart in X, or increasing the tension.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
lastX = x;
}
return success;
}
protected override float transformInternal(float t) {
if (_precomputedSamples.isEmpty()) {
// Compute the samples now if we were constructed lazily.
_precomputedSamples.AddRange(_computeSamples(controlPoints, tension));
}
int start = 0;
int end = _precomputedSamples.Count - 1;
int mid;
Offset value;
Offset startValue = _precomputedSamples[start].value;
Offset endValue = _precomputedSamples[end].value;
while (end - start > 1) {
mid = (end + start) / 2;
value = _precomputedSamples[mid].value;
if (t >= value.dx) {
start = mid;
startValue = value;
} else {
end = mid;
endValue = value;
}
}
float t2 = (t - startValue.dx) / (endValue.dx - startValue.dx);
return Mathf.Lerp(startValue.dy, endValue.dy, t2);
}
}

171
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.animation {
int _listenerCounter = 0;
int _listenerCounter;
protected void didRegisterListener() {
D.assert(_listenerCounter >= 0);

}
public abstract class AnimationEagerListenerMixinAnimation<T> : Animation<T> {
protected void didRegisterListener() {
}

}
public abstract class
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

public void notifyListeners() {
var localListeners = new List<VoidCallback>(_listeners);
foreach (VoidCallback listener in localListeners) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
} catch (Exception exception) {
informationCollector: infoCollector
informationCollector: collector
));
}
}

public abstract class
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
public abstract class AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

public void notifyListeners() {
var localListeners = new List<VoidCallback>(_listeners);
foreach (VoidCallback listener in localListeners) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
} catch (Exception exception) {
informationCollector: infoCollector
informationCollector: collector
));
}
}

public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
} catch (Exception exception) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
informationCollector: infoCollector
informationCollector: collector
));
}
}

public abstract class
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T
> {
public abstract class AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
} catch (Exception exception) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
informationCollector: infoCollector
informationCollector: collector
));
}
}

public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
} catch (Exception exception) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
informationCollector: infoCollector
informationCollector: collector
}

44
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk


public void notifyListeners() {
var localListeners = new List<VoidCallback>(this._listeners);
foreach (VoidCallback listener in localListeners) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
informationCollector: infoCollector
informationCollector: collector
));
}
}

listener(status);
}
} catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying status listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
informationCollector: infoCollector
informationCollector: collector
));
}
}

14
com.unity.uiwidgets/Runtime/animation/tween.cs


return lerp(t);
}
/*public override T evaluate(Animation<float> animation) {
float t = animation.value;
if (t == 0.0) {
return begin;
}
if (t == 1.0) {
return end;
}
return lerp(t);
}*/
public override string ToString() {
return $"{GetType()}({begin} \u2192 {end})";
}

2
com.unity.uiwidgets/Runtime/animation/tween_sequence.cs


if (_intervals[index].contains(t))
return _evaluateAt(t, index);
}
D.assert(false, ()=>$"TweenSequence.evaluate() could not find an interval for {t}");
D.assert(false, ()=> $"TweenSequence.evaluate() could not find an interval for {t}");
return default(T);
}
public override string ToString(){

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


textScaleFactor: Mathf.Max(textScaleFactor, 1.0f)
),
child: new LayoutBuilder(
builder: (BuildContext _context, BoxConstraints constraints) => {
builder: (BuildContext _context, Constraints constraints) => {
return new Center(
child: new Container(
margin: EdgeInsets.symmetric(vertical: CupertinoDialogUtils._kEdgePadding),

3
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


public TextFont[] fonts;
static object fontsToObject(TextFont[] textFont) {
if (textFont == null || textFont.Length == 0) {
return null;
}
var result = new object[textFont.Length];
for (int i = 0; i < textFont.Length; i++) {
var font = new Dictionary<string, object>();

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


}
}
class DiagnosticableTreeNode : DiagnosticableNode<DiagnosticableTree> {
class DiagnosticableTreeNode : DiagnosticableNode<DiagnosticableTreeMixin> {
DiagnosticableTree value,
DiagnosticableTreeMixin value,
DiagnosticsTreeStyle style
) : base(
name: name,

}
public override List<DiagnosticsNode> getChildren() {
if (value != null) {

public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}
}
public abstract class DiagnosticableTree : Diagnosticable {
public interface DiagnosticableTreeMixin : IDiagnosticable{
public string toString(DiagnosticLevel minLevel = DiagnosticLevel.info);
public string toStringShallow(
string joiner = ", ",
DiagnosticLevel minLevel = DiagnosticLevel.debug
);
public string toStringDeep(
string prefixLineOne = "",
string prefixOtherLines = null,
DiagnosticLevel minLevel = DiagnosticLevel.debug);
public string toStringShort();
public DiagnosticsNode toDiagnosticsNode(string name = null, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse);
public List<DiagnosticsNode> debugDescribeChildren();
public void debugFillProperties(DiagnosticPropertiesBuilder properties);
}
public abstract class DiagnosticableTree : Diagnosticable,DiagnosticableTreeMixin {
protected DiagnosticableTree() {
}

392
com.unity.uiwidgets/Runtime/gestures/converter.cs


using UnityEngine;
namespace Unity.UIWidgets.gestures {
class _PointerState {
public _PointerState(Offset lastPosition) {
this.lastPosition = lastPosition ?? Offset.zero;
}
public int pointer {
get { return _pointer; }
}
int _pointer;
// pointers 0 ~ 9 are preserved for special unique inputs
static int _pointerCount = 10;
// special pointer id:
// mouse scroll
const int scrollPointer = 5;
public void initScrollPointer() {
_pointer = scrollPointer;
}
public void startNewPointer() {
_pointerCount += 1;
_pointer = _pointerCount;
}
public bool down {
get { return _down; }
}
bool _down = false;
public void setDown() {
D.assert(!_down);
_down = true;
}
public void setUp() {
D.assert(_down);
_down = false;
}
public Offset lastPosition;
public Offset deltaTo(Offset to) {
return to - lastPosition;
}
public override string ToString() {
return $"_PointerState(pointer: {pointer}, down: {down}, lastPosition: {lastPosition})";
}
public partial class gesture_ {
case PointerDeviceKind.mouse:
return buttons;
return buttons;
case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus:
return buttons | kPrimaryButton;
return buttons;
// We have no information about the device but we know we never want
// buttons to be 0 when the pointer is down.
return buttons == 0 ? kPrimaryButton : buttons;
}
}
}

static readonly Dictionary<int, _PointerState> _pointers = new Dictionary<int, _PointerState>();
static void clearPointers() {
_pointers.Clear();
}
static _PointerState _ensureStateForPointer(PointerData datum, Offset position) {
return _pointers.putIfAbsent(
datum.device,
() => new _PointerState(position));
}
Offset delta = new Offset(datum.physicalDeltaX, datum.physicalDeltaY) / devicePixelRatio;
var radiusMinor = _toLogicalPixels(datum.radiusMinor, devicePixelRatio);
var radiusMajor = _toLogicalPixels(datum.radiusMajor, devicePixelRatio);
var radiusMin = _toLogicalPixels(datum.radiusMin, devicePixelRatio);

switch (datum.change) {
case PointerChange.add: {
D.assert(!_pointers.ContainsKey(datum.device));
_PointerState state = _ensureStateForPointer(datum, position);
D.assert(state.lastPosition == position);
yield return new PointerAddedEvent(
timeStamp: timeStamp,
kind: kind,
device: datum.device,
position: position,
obscured: datum.obscured,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
break;
}
case PointerChange.down: {
_PointerState state = _ensureStateForPointer(datum, position);
if (state.down) {
if (datum.signalKind == null || datum.signalKind == ui.PointerSignalKind.none) {
switch (datum.change) {
case PointerChange.add: {
yield return new PointerAddedEvent(
timeStamp: timeStamp,
kind: kind,
device: datum.device,
position: position,
obscured: datum.obscured,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
if (state.lastPosition != position) {
// a hover event to be here.
state.lastPosition = position;
}
state.startNewPointer();
state.setDown();
yield return new PointerDownEvent(
timeStamp: timeStamp,
pointer: state.pointer,
kind: kind,
device: datum.device,
position: position
);
}
break;
case PointerChange.move: {
bool alreadyAdded = _pointers.ContainsKey(datum.device);
if (!alreadyAdded) {
case PointerChange.hover: {
yield return new PointerHoverEvent(
timeStamp: timeStamp,
kind: kind,
device: datum.device,
position: position,
delta: delta,
buttons: datum.buttons,
obscured: datum.obscured,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
size: datum.size,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt,
synthesized: datum.synthesized
);
D.assert(_pointers.ContainsKey(datum.device));
_PointerState state = _pointers[datum.device];
if (!state.down) {
break;
case PointerChange.down: {
yield return new PointerDownEvent(
timeStamp: timeStamp,
pointer: datum.pointerIdentifier,
kind: kind,
device: datum.device,
position: position,
buttons: gesture_._synthesiseDownButtons(datum.buttons, kind),
obscured: datum.obscured,
pressure: datum.pressure,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
size: datum.size,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
D.assert(state.down);
Offset offset = position - state.lastPosition;
state.lastPosition = position;
yield return new PointerMoveEvent(
timeStamp: timeStamp,
pointer: state.pointer,
kind: kind,
device: datum.device,
position: position,
delta: offset
);
}
break;
case PointerChange.hover: {
yield return new PointerHoverEvent(
timeStamp: timeStamp,
kind: kind,
device: datum.device,
position: position
);
break;
}
// case PointerChange.scroll: {
// var _scrollData = (ScrollData) datum;
// _PointerState state = _ensureStateForPointer(datum, position);
// state.initScrollPointer();
//
// if (state.lastPosition != position) {
// state.lastPosition = position;
// }
//
// Offset scrollDelta = new Offset(_scrollData.scrollX, _scrollData.scrollY) / devicePixelRatio;
// yield return new PointerScrollEvent(
// timeStamp: timeStamp,
// pointer: state.pointer,
// kind: kind,
// device: _scrollData.device,
// position: position,
// scrollDelta: scrollDelta
// );
// break;
// }
case PointerChange.up:
case PointerChange.cancel: {
_PointerState state = _pointers.getOrDefault(datum.device);
if (state == null || !state.down) {
}
D.assert(state.down);
if (position != state.lastPosition) {
Offset offset = position - state.lastPosition;
state.lastPosition = position;
case PointerChange.move: {
pointer: state.pointer,
pointer: datum.pointerIdentifier,
delta: offset,
synthesized: true
delta: delta,
buttons: gesture_._synthesiseDownButtons(datum.buttons, kind),
obscured: datum.obscured,
pressure: datum.pressure,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
size: datum.size,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt,
platformData: datum.platformData,
synthesized: datum.synthesized
D.assert(position == state.lastPosition);
state.setUp();
if (datum.change == PointerChange.up) {
break;
case PointerChange.up:
pointer: state.pointer,
pointer: datum.pointerIdentifier,
position: position
position: position,
buttons: datum.buttons,
obscured: datum.obscured,
pressure: datum.pressure,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
size: datum.size,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
}
else {
break;
case PointerChange.cancel: {
pointer: state.pointer,
pointer: datum.pointerIdentifier,
position: position
position: position,
buttons: datum.buttons,
obscured: datum.obscured,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
size: datum.size,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
}
break;
case PointerChange.remove: {
D.assert(_pointers.ContainsKey(datum.device));
_PointerState state = _pointers[datum.device];
if (state.down) {
yield return new PointerCancelEvent(
break;
case ui.PointerChange.remove:
yield return new PointerRemovedEvent(
pointer: state.pointer,
position: position
position: position,
obscured: datum.obscured,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
radiusMin: radiusMin,
radiusMax: radiusMax
}
if (position != state.lastPosition) {
yield return new PointerHoverEvent(
break;
}
}
else {
switch (datum.signalKind) {
case ui.PointerSignalKind.scroll:
Offset scrollDelta =
new Offset(datum.scrollDeltaX, datum.scrollDeltaY) / devicePixelRatio;
yield return new PointerScrollEvent(
position: position
position: position,
scrollDelta: scrollDelta
}
_pointers.Remove(datum.device);
yield return new PointerRemovedEvent(
timeStamp: timeStamp,
kind: kind,
device: datum.device,
position: position
);
break;
break;
case ui.PointerSignalKind.none:
D.assert(false); // This branch should already have 'none' filtered out.
break;
case ui.PointerSignalKind.unknown:
// Ignore unknown signals.
break;
#if UNITY_EDITOR
// case PointerChange.dragFromEditorMove: {
// _PointerState state = _ensureStateForPointer(datum, position);
// state.startNewPointer();
// yield return new PointerDragFromEditorHoverEvent(
// timeStamp: timeStamp,
// pointer: state.pointer,
// kind: kind,
// device: datum.device,
// position: position
// );
// }
// break;
// case PointerChange.dragFromEditorRelease: {
// _PointerState state = _ensureStateForPointer(datum, position);
// state.startNewPointer();
// yield return new PointerDragFromEditorReleaseEvent(
// timeStamp: timeStamp,
// pointer: state.pointer,
// kind: kind,
// device: datum.device,
// position: position
// );
// }
// break;
#endif
}
}
}

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


using Object = UnityEngine.Object;
namespace Unity.UIWidgets.gestures {
public partial class gesture_ {
public const int kPrimaryButton = 0x01;
public const int kSecondaryButton = 0x02;
public const int kPrimaryMouseButton = kPrimaryButton;
public const int kSecondaryMouseButton = kSecondaryButton;
public const int kStylusContact = kPrimaryButton;
public const int kPrimaryStylusButton = kSecondaryButton;
public const int kMiddleMouseButton = 0x04;
public const int kSecondaryStylusButton = 0x04;
public const int kBackMouseButton = 0x08;
public const int kForwardMouseButton = 0x10;
public const int kTouchContact = kPrimaryButton;
public static int kMaxUnsignedSMI {
get {
Debug.LogError("Update this for io and web");
return -1;
}
}
public int nthMouseButton(int number) => (kPrimaryMouseButton << (number - 1)) & kMaxUnsignedSMI;
public int nthStylusButton(int number) => (kPrimaryStylusButton << (number - 1)) & kMaxUnsignedSMI;
public int smallestButton(int buttons) => buttons & (-buttons);
public bool isSingleButton(int buttons) => buttons != 0 && (smallestButton(buttons) == buttons);
}
public abstract class PointerEvent : Diagnosticable {
public PointerEvent(
TimeSpan timeStamp,

Offset position = null,
Offset localPosition = null,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,
float pressureMax = 1.0f,
float distance = 0.0f,

position: position,
localPosition: localPosition,
obscured: obscured,
pressure: pressure,
pressure: 0,
pressureMin: pressureMin,
pressureMax: pressureMax,
distance: distance,

Offset position = null,
Offset localPosition = null,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,
float pressureMax = 1.0f,
float distanceMax = 0.0f,

localPosition: localPosition,
device: device,
obscured: obscured,
pressure: pressure,
pressureMin: pressureMin,
pressureMax: pressureMax,
distanceMax: distanceMax,

Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,
float pressureMax = 1.0f,
float distance = 0.0f,

localDelta: localDelta,
buttons: buttons,
obscured: obscured,
pressure: pressure,
pressure: 0,
pressureMin: pressureMin,
pressureMax: pressureMax,
size: size,

Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,
float pressureMax = 1.0f,
float distance = 0.0f,

buttons: buttons,
down: down,
obscured: obscured,
pressure: pressure,
pressure: 0,
pressureMin: pressureMin,
pressureMax: pressureMax,
size: size,

buttons: hover?.buttons ?? 0,
down: hover?.down ?? false,
obscured: hover?.obscured ?? false,
pressure: hover?.pressure ?? 0.0f,
pressureMin: hover?.pressureMin ?? 1.0f,
pressureMax: hover?.pressureMax ?? 1.0f,
distance: hover?.distance ?? 0.0f,

Offset localDelta = null,
int buttons = 0,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,
float pressureMax = 1.0f,
float distance = 0.0f,

buttons: buttons,
down: down,
obscured: obscured,
pressure: pressure,
pressure: 0,
pressureMin: pressureMin,
pressureMax: pressureMax,
size: size,

buttons: hover?.buttons ?? 0,
down: hover?.down ?? false,
obscured: hover?.obscured ?? false,
pressure: hover?.pressure ?? 0.0f,
pressureMin: hover?.pressureMin ?? 1.0f,
pressureMax: hover?.pressureMax ?? 1.0f,
distance: hover?.distance ?? 0.0f,

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

Offset localPosition = null,
Offset delta = null,
Offset localDelta = null,
int buttons = 0,
int buttons = gesture_.kPrimaryButton,
bool obscured = false,
float pressure = 0.0f,
float pressureMin = 1.0f,

float radiusMax = 0.0f,
float orientation = 0.0f,
float tilt = 0.0f,
int platformdData = 0,
int platformData = 0,
bool synthesized = false,
Matrix4 transform = null,
PointerMoveEvent original = null

radiusMax: radiusMax,
orientation: orientation,
tilt: tilt,
platformData: platformdData,
platformData: platformData,
synthesized: synthesized,
transform: transform,
original: original) {

radiusMax: radiusMax,
orientation: orientation,
tilt: tilt,
// platformData: platformData,
platformData: platformData,
synthesized: synthesized,
transform: transform,
original: original as PointerMoveEvent ?? this

public class PointerScrollEvent : PointerSignalEvent {
public PointerScrollEvent(
TimeSpan timeStamp,
int pointer,
TimeSpan? timeStamp = null,
PointerDeviceKind kind = PointerDeviceKind.mouse,
int device = 0,
Offset position = null,

PointerScrollEvent original = null)
: base(
timeStamp,
timeStamp ?? TimeSpan.Zero,
pointer: pointer,
device: device,
position: position,
localPosition: localPosition,

if (transform == null || transform == this.transform) {
return this;
}
pointer: pointer,
kind: kind,
device: device,
position: position,

int device = 0,
Offset position = null,
Offset localPosition = null,
Object[] objectReferences = null,
Object[] objectReferences = null,
Matrix4 transform = null,
PointerDragFromEditorReleaseEvent original = null
) : base(

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


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.gestures {
public delegate void GestureDoubleTapCallback(DoubleTapDetails details);
public delegate void GestureDoubleTapCallback();
public delegate void GestureMultiTapDownCallback(int pointer, TapDownDetails details);

TimeSpan doubleTapMinTime,
GestureArenaEntry entry = null
) {
D.assert(evt != null);
initialButtons = evt.buttons;
_doubleTapMinTimeCountdown = new _CountdownZoned(duration: doubleTapMinTime);
this.entry = entry;
}

internal readonly Offset _initialGlobalPosition;
internal readonly int initialButtons;
internal readonly _CountdownZoned _doubleTapMinTimeCountdown;
bool _isTrackingPointer = false;

public bool hasElapsedMinTime() {
return _doubleTapMinTimeCountdown.timeout;
}
public bool hasSameButton(PointerDownEvent evt) {
return evt.buttons == initialButtons;
}
}

}
public GestureDoubleTapCallback onDoubleTap;
protected override bool isPointerAllowed(PointerDownEvent evt) {
if (_firstTap == null) {
switch (evt.buttons) {
case gesture_.kPrimaryButton:
if (onDoubleTap == null)
return false;
break;
default:
return false;
}
}
return base.isPointerAllowed(evt as PointerDownEvent);
}
Timer _doubleTapTimer;
_TapTracker _firstTap;

if (_firstTap != null &&
!_firstTap.isWithinGlobalTolerance(evt, Constants.kDoubleTapSlop)) {
return;
if (_firstTap != null) {
if (!_firstTap.isWithinGlobalTolerance(evt, Constants.kDoubleTapSlop)) {
// Ignore out-of-bounds second taps.
return;
}
else if (!_firstTap.hasElapsedMinTime() ||
!_firstTap.hasSameButton(evt as PointerDownEvent)) {
// Restart when the second tap is too close to the first, or when buttons
// mismatch.
_reset();
_trackFirstTap(evt);
return;
}
_trackFirstTap(evt);
}
void _trackFirstTap(PointerEvent evt) {
evt: evt,
evt: evt as PointerDownEvent,
entry: GestureBinding.instance.gestureArena.add(evt.pointer, this),
doubleTapMinTime: Constants.kDoubleTapMinTime
);

}
void _registerSecondTap(_TapTracker tracker) {
var initialPosition = tracker._initialGlobalPosition;
if (onDoubleTap != null) {
invokeCallback<object>("onDoubleTap", () => {
onDoubleTap(new DoubleTapDetails(initialPosition));
return null;
});
}
_checkUp(tracker.initialButtons);
_reset();
}

if (_doubleTapTimer != null) {
_doubleTapTimer.cancel();
_doubleTapTimer = null;
}
}
void _checkUp(int buttons) {
D.assert(buttons == gesture_.kPrimaryButton);
if (onDoubleTap != null) {
invokeCallback("onDoubleTap",() => onDoubleTap);
}
}

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

if (onTapUp != null) {
invokeCallback<object>("onTapUp",
() => {
onTapUp(pointer, new TapUpDetails(globalPosition: position.global, localPosition: position.local));
onTapUp(pointer, new TapUpDetails(
localPosition: position.local,
globalPosition: position.global
));
return null;
});
}

() => {
onLongTapDown(pointer, new TapDownDetails(
globalPosition: lastPosition.global,
localPosition: lastPosition.local));
localPosition: lastPosition.local
));
return null;
});
}

public override string debugDescription {
get { return "multitap"; }
}
}
delegate bool _RouteEntryPredicate(_RouteEntry entry);
class _RouteEntry {
public _RouteEntry(
PointerRoute route,
Matrix4 transform
) {
this.route = route;
this.transform = transform;
}
public readonly PointerRoute route;
public readonly Matrix4 transform;
static _RouteEntryPredicate isRoutePredicate(PointerRoute route) {
return (_RouteEntry entry) => entry.route == route;
}
}
}

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


public delegate void PointerRoute(PointerEvent evt);
public class PointerRouter {
readonly Dictionary<int, Dictionary<PointerRoute, Matrix4>> _routeMap = new Dictionary<int, Dictionary<PointerRoute, Matrix4>>();
readonly Dictionary<int, Dictionary<PointerRoute, Matrix4>> _routeMap =
new Dictionary<int, Dictionary<PointerRoute, Matrix4>>();
pointer,
pointer,
public void removeRoute(int pointer, PointerRoute route) {
D.assert(_routeMap.ContainsKey(pointer));
var routes = _routeMap[pointer];

}
}
public void removeGlobalRoute(PointerRoute route) {
D.assert(_globalRoutes.ContainsKey(route));
_globalRoutes.Remove(route);

new Dictionary<PointerRoute, Matrix4>(routes)
);
}
public void _dispatchEventToRoutes(
PointerEvent evt,
Dictionary<PointerRoute, Matrix4> referenceRoutes,

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


public delegate void PointerSignalResolvedCallback(PointerSignalEvent evt);
public class PointerSignalResolver {
public bool _isSameEvent(PointerSignalEvent event1, PointerSignalEvent event2) {
return (event1.original ?? event1) == (event2.original ?? event2);
}
PointerSignalResolvedCallback _firstRegisteredCallback;
PointerSignalEvent _currentEvent;

D.assert(callback != null);
D.assert(_currentEvent == null || _currentEvent == evt);
D.assert(_currentEvent == null || _isSameEvent(_currentEvent, evt));
if (_firstRegisteredCallback != null) {
return;
}

return;
}
D.assert((_currentEvent.original ?? _currentEvent) == evt);
D.assert(_isSameEvent(_currentEvent, evt));
try {
_firstRegisteredCallback(_currentEvent);
}

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


protected virtual void resolvePointer(int pointer, GestureDisposition disposition) {
GestureArenaEntry entry = _entries[pointer];
if (entry != null) {
entry.resolve(disposition);
_entries.Remove(pointer);
entry.resolve(disposition);
_entries.Remove(pointer);
}
}

32
com.unity.uiwidgets/Runtime/gestures/scale.cs


}
public class ScaleStartDetails {
public ScaleStartDetails(Offset focalPoint = null) {
public ScaleStartDetails(
Offset focalPoint = null,
Offset localFocalPoint = null
) {
this.localFocalPoint = localFocalPoint ?? this.focalPoint;
public readonly Offset localFocalPoint;
return $"ScaleStartDetails(focalPoint: {focalPoint}";
return $"ScaleStartDetails(focalPoint: {focalPoint}, localFocalPoint: {localFocalPoint})";
}
}

Offset focalPoint = null,
Offset localFocalPoint = null,
float scale = 1.0f,
float horizontalScale = 1.0f,
float verticalScale = 1.0f,

localFocalPoint = localFocalPoint ?? this.focalPoint;
D.assert(scale >= 0.0f);
D.assert(horizontalScale >= 0.0f);

}
public readonly Offset focalPoint;
public readonly Offset localFocalPoint;
public readonly float scale;

public override string ToString() {
return
$"ScaleUpdateDetails(focalPoint: {focalPoint}, scale: {scale}, horizontalScale: {horizontalScale}, verticalScale: {verticalScale}, rotation: {rotation}";
$"ScaleUpdateDetails(focalPoint: {focalPoint}, localFocalPoint: {localFocalPoint}, scale: {scale}, horizontalScale: {horizontalScale}, verticalScale: {verticalScale}, rotation: {rotation}";
}
}

public class ScaleGestureRecognizer : OneSequenceGestureRecognizer {
public ScaleGestureRecognizer(object debugOwner, PointerDeviceKind? kind = null) : base(debugOwner: debugOwner,
kind: kind) { }
kind: kind) {
}
public GestureScaleStartCallback onStart;

_ScaleState _state = _ScaleState.ready;
Matrix4 _lastTransform;
Offset _initialFocalPoint;
Offset _currentFocalPoint;

}
public override void addAllowedPointer(PointerDownEvent evt) {
startTrackingPointer(evt.pointer);
startTrackingPointer(evt.pointer, evt.transform);
_velocityTrackers[evt.pointer] = new VelocityTracker();
if (_state == _ScaleState.ready) {
_state = _ScaleState.possible;

}
_pointerLocations[evt.pointer] = evt.position;
shouldStartIfAccepted = true;
shouldStartIfAccepted = true;
_lastTransform = evt.transform;
}
else if (evt is PointerDownEvent) {
_pointerLocations[evt.pointer] = evt.position;

_lastTransform = evt.transform;
_lastTransform = evt.transform;
}
_updateLines();

horizontalScale: _horizontalScaleFactor,
verticalScale: _verticalScaleFactor,
focalPoint: _currentFocalPoint,
localFocalPoint: PointerEvent.transformPosition(_lastTransform, _currentFocalPoint),
rotation: _computeRotationFactor()
));
return null;

D.assert(_state == _ScaleState.started);
if (onStart != null) {
invokeCallback<object>("onStart", () => {
onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint));
onStart(new ScaleStartDetails(
focalPoint: _currentFocalPoint,
localFocalPoint: PointerEvent.transformPosition(_lastTransform, _currentFocalPoint)
));
return null;
});
}

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


bool _sentTapDown = false;
bool _wonArenaForPrimaryPointer = false;
OffsetPair _finalPosition;
PointerDownEvent _down;
PointerUpEvent _up;

protected override void handlePrimaryPointer(PointerEvent evt) {
if (evt is PointerUpEvent) {
_up = (PointerUpEvent) evt;
_finalPosition = new OffsetPair(global: evt.position, local: evt.localPosition);
_checkUp();
} else if (evt is PointerCancelEvent) {
resolve(GestureDisposition.rejected);

2
com.unity.uiwidgets/Runtime/painting/text_painter.cs


}
public TextHeightBehavior textHeightBehavior {
get { return textHeightBehavior; }
get { return _textHeightBehavior; }
set {
if (_textHeightBehavior == value)
return;

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


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.rendering {

offset: childParentData.offset,
position: position,
hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
D.assert(transformed == position - childParentData.offset);
return child.hitTest(boxHitTestResult, position: transformed);
}
}
}
return false;
}

8
com.unity.uiwidgets/Runtime/rendering/box.mixin.njk


where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? result = child.getDistanceToActualBaseline(baseline);

public float? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
float? result = null;
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
float? candidate = child.getDistanceToActualBaseline(baseline);

}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
var child = firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);

public bool defaultHitTestChildren(BoxHitTestResult result, Offset position) {
ChildType child = this.lastChild;

if (isHit)
return true;
child = childParentData.previousSibling;
}
return false;
}

1
com.unity.uiwidgets/Runtime/rendering/editable.cs


_doubleTap = new DoubleTapGestureRecognizer(this);
_tap.onTapDown = _handleTapDown;
_tap.onTap = _handleTap;
_doubleTap.onDoubleTap = _handleDoubleTap;
_longPress = new LongPressGestureRecognizer(debugOwner: this);
_longPress.onLongPress = _handleLongPress;

90
com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs


namespace Unity.UIWidgets.rendering {
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public virtual bool debugValidateChild(RenderObject child) {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
D.assert(after != this,()=>
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
()=> "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after,()=> "A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);

185
com.unity.uiwidgets/Runtime/rendering/object.mixin.njk


D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

internal ChildType _child;
public ChildType child {
get { return this._child; }
get { return _child; }
if (this._child != null) {
this.dropChild(this._child);
if (_child != null) {
dropChild(_child);
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
_child = value;
if (_child != null) {
adoptChild(_child);
get { return this.child; }
set { this.child = (ChildType) value; }
get { return child; }
set { child = (ChildType) value; }
if (this._child != null) {
this._child.attach(owner);
if (_child != null) {
_child.attach(owner);
if (this._child != null) {
this._child.detach();
if (_child != null) {
_child.detach();
if (this._child != null) {
this.redepthChild(this._child);
if (_child != null) {
redepthChild(_child);
if (this._child != null) {
visitor(this._child);
if (_child != null) {
visitor(_child);
return this.child != null
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
return child != null
? new List<DiagnosticsNode>{child.toDiagnosticsNode(name: "child")}
: new List<DiagnosticsNode>();
}
}

public override void detach() {
base.detach();
D.assert(this.previousSibling == null);
D.assert(this.nextSibling == null);
D.assert(previousSibling == null);
D.assert(nextSibling == null);
// if (this.previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
// previousSiblingParentData.nextSibling = this.nextSibling;
// if (previousSibling != null) {
// var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) previousSibling.parentData;
// previousSiblingParentData.nextSibling = nextSibling;
// if (this.nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
// nextSiblingParentData.previousSibling = this.previousSibling;
// if (nextSibling != null) {
// var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) nextSibling.parentData;
// nextSiblingParentData.previousSibling = previousSibling;
// this.previousSibling = null;
// this.nextSibling = null;
// previousSibling = null;
// nextSibling = null;
}
}

int _childCount = 0;
public int childCount {
get { return this._childCount; }
get { return _childCount; }
}
public bool debugValidateChild(RenderObject child) {

"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"A " + GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +

"The " + this.GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + this.debugCreator + "\n" +
"The " + GetType() + " that expected a " + typeof(ChildType) + " child was created by:\n" +
" " + debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +

D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
this._childCount++;
D.assert(this._childCount > 0);
_childCount++;
D.assert(_childCount > 0);
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {
var firstChildParentData = (ParentDataType) this._firstChild.parentData;
childParentData.nextSibling = _firstChild;
if (_firstChild != null) {
var firstChildParentData = (ParentDataType) _firstChild.parentData;
this._firstChild = child;
this._lastChild = this._lastChild ?? child;
_firstChild = child;
_lastChild = _lastChild ?? child;
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(after, equals: this._lastChild));
D.assert(_firstChild != null);
D.assert(_lastChild != null);
D.assert(_debugUltimatePreviousSiblingOf(after, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(after, equals: _lastChild));
D.assert(after == this._lastChild);
D.assert(after == _lastChild);
this._lastChild = child;
_lastChild = child;
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;

}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, () => "A RenderObject cannot be inserted into itself.");
D.assert(child != this, ()=>"A RenderObject cannot be inserted into itself.");
() => "A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, () => "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
()=>"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, ()=>"A RenderObject cannot be inserted after itself.");
D.assert(child != _firstChild);
D.assert(child != _lastChild);
adoptChild(child);
_insertIntoChildList(child, after);
this.insert(child, this._lastChild);
insert(child, _lastChild);
children.ForEach(this.add);
children.ForEach(add);
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
D.assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
D.assert(_childCount >= 0);
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
D.assert(_firstChild == child);
_firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;

D.assert(this._lastChild == child);
this._lastChild = childParentData.previousSibling;
D.assert(_lastChild == child);
_lastChild = childParentData.previousSibling;
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;

childParentData.nextSibling = null;
this._childCount--;
_childCount--;
this._removeFromChildList(child);
this.dropChild(child);
_removeFromChildList(child);
dropChild(child);
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.dropChild(child);
dropChild(child);
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;
_firstChild = null;
_lastChild = null;
_childCount = 0;
}
public void move(ChildType child, ChildType after = null) {

return;
}
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();
_removeFromChildList(child);
_insertIntoChildList(child, after);
markNeedsLayout();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.attach(owner);
var childParentData = (ParentDataType) child.parentData;

public override void detach() {
base.detach();
ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
child.detach();
var childParentData = (ParentDataType) child.parentData;

public override void redepthChildren() {
ChildType child = this._firstChild;
ChildType child = _firstChild;
this.redepthChild(child);
redepthChild(child);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}

ChildType child = this._firstChild;
ChildType child = _firstChild;
while (child != null) {
visitor(child);
var childParentData = (ParentDataType) child.parentData;

public ChildType firstChild {
get { return this._firstChild; }
get { return _firstChild; }
get { return this._lastChild; }
get { return _lastChild; }
}
public ChildType childBefore(ChildType child) {

public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
if (firstChild != null) {
ChildType child = firstChild;
if (child == this.lastChild) {
if (child == lastChild) {
break;
}

}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
insert((ChildType) child, (ChildType) after);
this.remove((ChildType) child);
remove((ChildType) child);
this.move((ChildType) child, (ChildType) after);
move((ChildType) child, (ChildType) after);
get { return this.firstChild; }
get { return firstChild; }
get { return this.lastChild; }
get { return lastChild; }
return this.childBefore((ChildType) child);
return childBefore((ChildType) child);
return this.childAfter((ChildType) child);
return childAfter((ChildType) child);
}
}
{% endmacro %}

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


translucent,
}
public interface RenderAnimatedOpacityMixin<T> : RenderObjectWithChildMixin<T> where T : RenderObject {
int _alpha { get; }
public new bool alwaysNeedsCompositing {
get;
}
bool _currentlyNeedsCompositing { get; }
public Animation<float> opacity {
get;
set;
}
Animation<float> _opacity { get; }
public bool alwaysIncludeSemantics {
get;
set;
}
bool _alwaysIncludeSemantics { get; }
public void attach(PipelineOwner owner);
public void detach();
public void _updateOpacity();
public void paint(PaintingContext context, Offset offset);
public void visitChildrenForSemantics(RenderObjectVisitor visitor);
public void debugFillProperties(DiagnosticPropertiesBuilder properties);
}
public abstract class RenderProxyBoxWithHitTestBehavior : RenderProxyBox {
protected RenderProxyBoxWithHitTestBehavior(
HitTestBehavior behavior = HitTestBehavior.deferToChild,

29
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.njk


}
}
}
return 0.0f;

if (this.child != null) {
return this.child.getMinIntrinsicHeight(width);
}
}
if (this.child != null) {
return this.child.getDistanceToActualBaseline(baseline);
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}
return base.computeDistanceToActualBaseline(baseline);

if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
if (child != null) {
child.layout(constraints, parentUsesSize: true);
size = child.size;
this.performResize();
performResize();
if (this.child != null) {
return this.child.hitTest(result, position);
if (child != null) {
return child.hitTest(result, position);
}
return false;

}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
context.paintChild(this.child, offset);
if (child != null) {
context.paintChild(child, offset);
}
}
}

12
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


set { child = (RenderSliver) value; }
}
}
public class RenderSliverAnimatedOpacity :RenderAnimatedOpacityMixinRenderSliver<RenderSliver>{
public RenderSliverAnimatedOpacity(
Animation<float> opacity ,
RenderSliver sliver = null,
bool alwaysIncludeSemantics = false
) {
D.assert(opacity != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
child = sliver;
}
}
public class RenderSliverOpacity : RenderProxySliver {
public RenderSliverOpacity(
RenderSliver sliver = null,

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

hasErrors = true;
errorMessage.AppendLine($" {message}");
});
verify(scrollOffset >= 0.0f, "The \"scrollOffset\" is negative.");
verify(crossAxisExtent >= 0.0f, "The \"crossAxisExtent\" is negative.");
verify(
AxisUtils.axisDirectionToAxis(axisDirection) !=
AxisUtils.axisDirectionToAxis(crossAxisDirection),
"The \"axisDirection\" and the \"crossAxisDirection\" are along the same axis.");
verify(viewportMainAxisExtent >= 0.0f, "The \"viewportMainAxisExtent\" is negative.");
verify(remainingPaintExtent >= 0.0f, "The \"remainingPaintExtent\" is negative.");
verify(remainingCacheExtent >= 0.0f, "The \"remainingCacheExtent\" is negative.");
verify(cacheOrigin <= 0.0f, "The \"cacheOrigin\" is positive.");
verify(isNormalized, "The constraints are not normalized.");
void verifyFloat(float property, string name, bool mustBePositive = false, bool mustBeNegative = false) {
verify(property != null, $"The \"{name}\" is null.");
if (property.isNaN()) {
string additional = ".";
if (mustBePositive) {
additional = ", expected greater than or equal to zero.";
} else if (mustBeNegative) {
additional = ", expected less than or equal to zero.";
}
verify(false, $"The \"{name}\" is NaN" + $"{additional}");
} else if (mustBePositive) {
verify(property >= 0.0, $"The \"{name}\" is negative.");
} else if (mustBeNegative) {
verify(property <= 0.0, $"The \"{name}\" is positive.");
}
}
verify(axis != null, "The \"axis\" is null.");
verify(growthDirection != null, "The \"growthDirection\" is null.");
verifyFloat(scrollOffset, "scrollOffset");
verifyFloat(overlap, "overlap");
verifyFloat(crossAxisExtent, "crossAxisExtent");
verifyFloat(scrollOffset, "scrollOffset", mustBePositive: true);
verify(crossAxisDirection != null, "The \"crossAxisDirection\" is null.");
verify(AxisUtils.axisDirectionToAxis(axisDirection) != AxisUtils.axisDirectionToAxis(crossAxisDirection), "The \"axisDirection\" and the \"crossAxisDirection\" are along the same axis.");
verifyFloat(viewportMainAxisExtent, "viewportMainAxisExtent", mustBePositive: true);
verifyFloat(remainingPaintExtent, "remainingPaintExtent", mustBePositive: true);
verifyFloat(remainingCacheExtent, "remainingCacheExtent", mustBePositive: true);
verifyFloat(cacheOrigin, "cacheOrigin", mustBeNegative: true);
verifyFloat(precedingScrollExtent, "precedingScrollExtent", mustBePositive: true);
verify(isNormalized, "The constraints are not normalized."); // should be redundant with earlier checks
if (hasErrors) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {errorMessage}"));

}
public override string ToString() {
string result = "";
result += ($"{axisDirection}") +" , ";
result +=($"{growthDirection}")+" , ";
result +=($"{userScrollDirection}")+" , ";
result +=($"scrollOffset: {scrollOffset : F1}")+" , ";
result +=($"remainingPaintExtent: {remainingPaintExtent : F1}")+" , ";
if (overlap != 0.0)
result +=($"overlap: {overlap: F1}")+" , ";
result +=($"crossAxisExtent: {crossAxisExtent : F1}")+" , ";
result +=($"crossAxisDirection: crossAxisDirection")+" , ";
result +=($"viewportMainAxisExtent: {viewportMainAxisExtent : F1}")+" , ";
result +=($"remainingCacheExtent: {remainingCacheExtent : F1}")+" , ";
result +=($"cacheOrigin: {cacheOrigin : F1}");
return $"SliverConstraints({result})";
return
$"SliverConstraints({axisDirection}, {growthDirection}, {userScrollDirection}, scrollOffset: {scrollOffset:F1}, remainingPaintExtent: {remainingCacheExtent:F1}, " +
$"{(overlap != 0.0f ? "overlap: " + overlap.ToString("F1") + ", " : "")}crossAxisExtent: {crossAxisExtent:F1}, crossAxisDirection: {crossAxisDirection}, " +

public float? layoutOffset;
public override string ToString() {
if (layoutOffset == null)
return "layoutOffset = None";
else {
return layoutOffset.ToString(); // toStringAsFixed(3); // 1.000
}
return layoutOffset == null ? "layoutOffset = None" : $"layoutOffset = {layoutOffset:F1}";
}
}

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


public RenderStack(
StackFit? fit,
Overflow? overflow,
TextDirection textDirection,
this.textDirection = textDirection;
_alignment = alignment ?? Alignment.topLeft;
_fit = fit ?? StackFit.loose;
_overflow = overflow ?? Overflow.clip;

child.parentData = new StackParentData();
}
}
Alignment _resolvedAlignment;
void _markNeedResolution() {
_resolvedAlignment = null;
markNeedsLayout();
}
public TextDirection textDirection {
get {
return _textDirection;
}
set {
if (_textDirection == value)
return;
_textDirection = value;
_markNeedResolution();
}
}
TextDirection _textDirection;
Alignment _alignment;
public Alignment alignment {

public RenderIndexedStack(
List<RenderBox> children = null,
Alignment alignment = null,
TextDirection textDirection = default,
) : base(fit: null, overflow: null, children: children, alignment: alignment ?? Alignment.topLeft) {
) : base(fit: null, overflow: null, textDirection: textDirection, children: children, alignment: alignment ?? Alignment.topLeft) {
_index = index;
}

7
com.unity.uiwidgets/Runtime/services/asset_bundle.cs


throw new UIWidgetsError($"Unable to load asset: {key}");
if (data.Length < 10 * 1024) {
// 10KB takes about 3ms to parse on a Pixel 2 XL.
// See: https://github.com/dart-lang/sdk/issues/31954
return Encoding.UTF8.GetString(data);
}

yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError) {
completer.completeError(new Exception($"Failed to load from url \"{url}\": {www.error}"));
completer.completeError(new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary($"Unable to load asset: {key}"),
new StringProperty("HTTP status code", www.error)
}));
yield break;
}

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


_defaultBinaryMessenger = createBinaryMessenger();
window.onPlatformMessage = defaultBinaryMessenger.handlePlatformMessage;
//initLicenses();
//SystemChannels.system.setMessageHandler(handleSystemMessage);
}

services_.rootBundle.evict(asset);
}
}
class _DefaultBinaryMessenger : BinaryMessenger {
internal _DefaultBinaryMessenger() {

986
com.unity.uiwidgets/Runtime/services/keyboard_key.cs
文件差异内容过多而无法显示
查看文件

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


Alignment alignment = null,
StackFit fit = StackFit.loose,
Overflow overflow = Overflow.clip,
TextDirection textDirection = default,
this.textDirection = textDirection;
public readonly TextDirection textDirection;
textDirection: Directionality.of(context),
fit: fit,
overflow: overflow
);

var renderObject = (RenderStack) renderObjectRaw;
renderObject.alignment = alignment;
renderObject.textDirection = Directionality.of(context);
renderObject.fit = fit;
renderObject.overflow = overflow;
}

properties.add(new DiagnosticsProperty<Alignment>("alignment", alignment));
properties.add(new EnumProperty<TextDirection>("textDirection", textDirection, defaultValue: null));
properties.add(new EnumProperty<StackFit>("fit", fit));
properties.add(new EnumProperty<Overflow>("overflow", overflow));
}

) :
base(key: key, child: child) {
D.assert(behavior != null);
this.onPointerDown = onPointerDown;
this.onPointerMove = onPointerMove;
this.onPointerUp = onPointerUp;
this.onPointerCancel = onPointerCancel;
this.onPointerSignal = onPointerSignal;
this.behavior = behavior;
}
public readonly PointerDownEventListener onPointerDown;

2
com.unity.uiwidgets/Runtime/widgets/disposable_build_context.cs


return true;
}
void dispose() {
public void dispose() {
_state = null;
}
}

2
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


fontFamily: style.fontFamily,
fontSize: style.fontSize,
fontWeight: style.fontWeight,
textDirection: _textDirection,
textDirection: _textDirection.Value,
textAlign: widget.textAlign
);
_textInputConnection.setEditingState(localValue);

655
com.unity.uiwidgets/Runtime/widgets/fade_in_image.cs


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.rendering;
using Debug = System.Diagnostics.Debug;
using Object = System.Object;
public class FadeInImage : StatefulWidget {
public class FadeInImage : StatelessWidget {
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
TimeSpan? fadeOutDuration = null,
Curve fadeOutCurve = null,
TimeSpan? fadeInDuration = null,

D.assert(fadeInCurve != null);
D.assert(alignment != null);
this.placeholder = placeholder;
this.placeholderErrorBuilder = placeholderErrorBuilder;
this.imageErrorBuilder = imageErrorBuilder;
this.width = width;
this.height = height;
this.fit = fit;

public static FadeInImage memoryNetwork(
byte[] placeholder,
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
float placeholderScale = 1.0f,
float imageScale = 1.0f,
TimeSpan? fadeOutDuration = null,

BoxFit? fit = null,
Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Key key = null
Key key = null,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
) {
D.assert(placeholder != null);
D.assert(image != null);

D.assert(alignment != null);
var memoryImage = new MemoryImage(placeholder, placeholderScale);
var networkImage = new NetworkImage(image, imageScale);
/*placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
new MemoryImage(placeholder, scale: placeholderScale));
image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight,
new NetworkImage(image, scale: imageScale));*/
memoryImage,
networkImage,
fadeOutDuration,
fadeOutCurve,
fadeInDuration,
fadeInCurve,
width, height,
fit,
alignment,
repeat,
key
placeholder: memoryImage,
placeholderErrorBuilder: placeholderErrorBuilder,
image: networkImage,
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,
fadeInDuration: fadeInDuration,
fadeInCurve: fadeInCurve,
width: width, height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
key: key
ImageErrorWidgetBuilder placeholderErrorBuilder,
ImageErrorWidgetBuilder imageErrorBuilder,
AssetBundle bundle = null,
float? placeholderScale = null,
float imageScale = 1.0f,

BoxFit? fit = null,
Alignment alignment = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
Key key = null
Key key = null,
int placeholderCacheWidth = default,
int placeholderCacheHeight = default,
int imageCacheWidth = default,
int imageCacheHeight = default
) {
D.assert(placeholder != null);
D.assert(image != null);

var imageProvider = placeholderScale != null
? new ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale ?? 1.0f)
: (ImageProvider) new AssetImage(placeholder, bundle: bundle);
/*placeholder = placeholderScale != null
? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale))
: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, AssetImage(placeholder, bundle: bundle));*/
imageProvider,
networkImage,
fadeOutDuration,
fadeOutCurve,
fadeInDuration,
fadeInCurve,
width, height,
fit,
alignment,
repeat,
key
placeholder: imageProvider,
placeholderErrorBuilder: placeholderErrorBuilder,
image: networkImage,
imageErrorBuilder: imageErrorBuilder,
fadeOutDuration: fadeOutDuration,
fadeOutCurve: fadeOutCurve,
fadeInDuration: fadeInDuration,
fadeInCurve: fadeInCurve,
width: width, height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
key: key
public readonly ImageErrorWidgetBuilder placeholderErrorBuilder;
public readonly ImageErrorWidgetBuilder imageErrorBuilder;
public readonly TimeSpan fadeOutDuration;
public readonly Curve fadeOutCurve;
public readonly TimeSpan fadeInDuration;

public readonly Alignment alignment;
public readonly ImageRepeat repeat;
public override State createState() {
return new _FadeInImageState();
}
}
enum FadeInImagePhase {
start,
waiting,
fadeOut,
fadeIn,
completed
}
delegate void _ImageProviderResolverListener();
class _ImageProviderResolver {
public _ImageProviderResolver(
_FadeInImageState state,
_ImageProviderResolverListener listener
public Image _image(
ImageProvider image = null,
ImageErrorWidgetBuilder errorBuilder = null,
ImageFrameBuilder frameBuilder = null
this.state = state;
this.listener = listener;
D.assert(image != null);
return new Image(
image: image,
//errorBuilder: errorBuilder,
//frameBuilder: frameBuilder,
width: width,
height: height,
fit: fit,
alignment: alignment,
repeat: repeat,
//matchTextDirection: matchTextDirection,
gaplessPlayback: true
);
readonly _FadeInImageState state;
readonly _ImageProviderResolverListener listener;
public override Widget build(BuildContext context) {
Widget result = _image(
image: image,
errorBuilder: imageErrorBuilder,
frameBuilder: (BuildContext context, Widget child, int frame, bool wasSynchronouslyLoaded) => {
if (wasSynchronouslyLoaded)
return child;
return new _AnimatedFadeOutFadeIn(
key: key,
target: child,
placeholder: _image(
image: placeholder,
errorBuilder: placeholderErrorBuilder
),
isTargetLoaded: frame != null,
fadeInDuration: fadeInDuration,
fadeOutDuration: fadeOutDuration,
fadeInCurve: fadeInCurve,
fadeOutCurve: fadeOutCurve
);
}
);
return result;
}
}
FadeInImage widget {
get { return state.widget; }
public class _AnimatedFadeOutFadeIn : ImplicitlyAnimatedWidget {
public _AnimatedFadeOutFadeIn(
Key key,
Widget target,
Widget placeholder,
bool isTargetLoaded,
TimeSpan fadeOutDuration,
TimeSpan fadeInDuration,
Curve fadeOutCurve,
Curve fadeInCurve
) : base(key: key, duration: fadeInDuration + fadeOutDuration) {
D.assert(target != null);
D.assert(placeholder != null);
D.assert(isTargetLoaded != null);
D.assert(fadeOutDuration != null);
D.assert(fadeOutCurve != null);
D.assert(fadeInDuration != null);
D.assert(fadeInCurve != null);
this.target = target;
this.placeholder = placeholder;
this.isTargetLoaded = isTargetLoaded;
this.fadeInDuration = fadeInDuration;
this.fadeOutDuration = fadeOutDuration;
this.fadeInCurve = fadeInCurve;
this.fadeOutCurve = fadeOutCurve;
public ImageStream _imageStream;
public ImageInfo _imageInfo;
public readonly Widget target;
public readonly Widget placeholder;
public readonly bool isTargetLoaded;
public readonly TimeSpan? fadeInDuration;
public readonly TimeSpan? fadeOutDuration;
public readonly Curve fadeInCurve;
public readonly Curve fadeOutCurve;
public void resolve(ImageProvider provider) {
ImageStream oldImageStream = _imageStream;
Size size = null;
if (widget.width != null && widget.height != null) {
size = new Size((int) widget.width, (int) widget.height);
}
_imageStream = provider.resolve(ImageUtils.createLocalImageConfiguration(state.context, size));
D.assert(_imageStream != null);
public override State createState() => new _AnimatedFadeOutFadeInState();
if (_imageStream.key != oldImageStream?.key) {
oldImageStream?.removeListener(_handleImageChanged);
_imageStream.addListener(_handleImageChanged);
}
}
void _handleImageChanged(ImageInfo imageInfo, bool synchronousCall) {
_imageInfo = imageInfo;
listener();
}
public class _AnimatedFadeOutFadeInState : ImplicitlyAnimatedWidgetState<_AnimatedFadeOutFadeIn> {
FloatTween _targetOpacity;
FloatTween _placeholderOpacity;
Animation<float> _targetOpacityAnimation;
Animation<float> _placeholderOpacityAnimation;
public void stopListening() {
_imageStream?.removeListener(_handleImageChanged);
}
}
/*@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_targetOpacity = visitor(
_targetOpacity,
widget.isTargetLoaded ? 1.0 : 0.0,
(dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>;
_placeholderOpacity = visitor(
_placeholderOpacity,
widget.isTargetLoaded ? 0.0 : 1.0,
(dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>;
}*/
protected override void forEachTween(TweenVisitor visitor) {
_targetOpacity = (FloatTween) visitor.visit(
state: this,
tween: _targetOpacity,
targetValue: widget.isTargetLoaded ? 1.0f : 0.0f,
constructor: (float value) => new FloatTween(begin: value, 0));
class _FadeInImageState : TickerProviderStateMixin<FadeInImage> {
_ImageProviderResolver _imageResolver;
_ImageProviderResolver _placeholderResolver;
_placeholderOpacity = (FloatTween) visitor.visit(
state: this,
tween: _placeholderOpacity,
targetValue: widget.isTargetLoaded ? 0.0f : 1.0f,
constructor: (float value) => new FloatTween(begin: value, 0));
}
AnimationController _controller;
Animation<float> _animation;
protected override void didUpdateTweens() {
List<TweenSequenceItem<float>> list = new List<TweenSequenceItem<float>>();
FadeInImagePhase _phase = FadeInImagePhase.start;
Debug.Assert(widget.fadeOutDuration?.Milliseconds != null,
"widget.fadeOutDuration?.Milliseconds != null");
list.Add(new TweenSequenceItem<float>(
tween: _placeholderOpacity.chain(new CurveTween(curve: widget.fadeOutCurve)),
weight: (float) widget.fadeOutDuration?.Milliseconds
));
public override void initState() {
_imageResolver = new _ImageProviderResolver(state: this, _updatePhase);
_placeholderResolver = new _ImageProviderResolver(state: this, listener: () => {
setState(() => {
// Trigger rebuild to display the placeholder image
});
});
_controller = new AnimationController(
value: 1.0f,
vsync: this
);
_controller.addListener(() => {
setState(() => {
// Trigger rebuild to update opacity value.
});
});
_controller.addStatusListener(status => { _updatePhase(); });
base.initState();
}
Debug.Assert(widget.fadeInDuration?.Milliseconds != null,
"widget.fadeInDuration?.Milliseconds != null");
list.Add(new TweenSequenceItem<float>(
tween: new ConstantTween<float>(0),
weight: (float) widget.fadeInDuration?.Milliseconds
));
public override void didChangeDependencies() {
_resolveImage();
base.didChangeDependencies();
}
//[!!!] drive
/*_placeholderOpacityAnimation = animation.drive(list).addStatusListener((AnimationStatus status) =>{
if (_placeholderOpacityAnimation.isCompleted) {
// Need to rebuild to remove placeholder now that it is invisibile.
setState(() => {});
}
});*/
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
FadeInImage fadeInImage = oldWidget as FadeInImage;
if (widget.image != fadeInImage.image || widget.placeholder != fadeInImage.placeholder) {
_resolveImage();
List<TweenSequenceItem<float>> list2 = new List<TweenSequenceItem<float>>();
list2.Add(new TweenSequenceItem<float>(
tween: new ConstantTween<float>(0),
weight: (float) widget.fadeOutDuration?.Milliseconds
));
list2.Add(new TweenSequenceItem<float>(
tween: _targetOpacity.chain(new CurveTween(curve: widget.fadeInCurve)),
weight: (float) widget.fadeInDuration?.Milliseconds
));
//_targetOpacityAnimation = animation.drive(list2);[!!!] animation.cs drive
if (!widget.isTargetLoaded && _isValid(_placeholderOpacity) && _isValid(_targetOpacity)) {
//controller.value = controller.upperBound;[!!!] animation_controller.cs value set
}
}
void _resolveImage() {
_imageResolver.resolve(widget.image);
if (_isShowingPlaceholder) {
_placeholderResolver.resolve(widget.placeholder);
bool _isValid(Tween<float> tween) {
return tween.begin != null && tween.end != null;
if (_phase == FadeInImagePhase.start) {
_updatePhase();
}
}
void _updatePhase() {
setState(() => {
switch (_phase) {
case FadeInImagePhase.start:
if (_imageResolver._imageInfo != null) {
_phase = FadeInImagePhase.completed;
}
else {
_phase = FadeInImagePhase.waiting;
}
public override Widget build(BuildContext context) {
Widget target = new FadeTransition(
opacity: _targetOpacityAnimation,
child: widget.target
);
break;
case FadeInImagePhase.waiting:
if (_imageResolver._imageInfo != null) {
_controller.duration = widget.fadeOutDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeOutCurve
);
_phase = FadeInImagePhase.fadeOut;
_controller.reverse(1.0f);
}
if (_placeholderOpacityAnimation.isCompleted) {
return target;
}
break;
case FadeInImagePhase.fadeOut:
if (_controller.status == AnimationStatus.dismissed) {
// Done fading out placeholder. Begin target image fade-in.
_controller.duration = widget.fadeInDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeInCurve
);
_phase = FadeInImagePhase.fadeIn;
_placeholderResolver.stopListening();
_controller.forward(0.0f);
}
break;
case FadeInImagePhase.fadeIn:
if (_controller.status == AnimationStatus.completed) {
// Done finding in new image.
_phase = FadeInImagePhase.completed;
}
return new Stack(
fit: StackFit.passthrough,
alignment: AlignmentDirectional.center,
textDirection: TextDirection.ltr,
children: new List<Widget>() {
target,
new FadeTransition(
opacity: _placeholderOpacityAnimation,
child: widget.placeholder
)
}
);
}
break;
case FadeInImagePhase.completed:
// Nothing to do.
break;
}
});
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("targetOpacity", _targetOpacityAnimation));
properties.add(
new DiagnosticsProperty<Animation<float>>("placeholderOpacity", _placeholderOpacityAnimation));
}
public override void dispose() {
_imageResolver.stopListening();
_placeholderResolver.stopListening();
_controller.dispose();
base.dispose();
/*enum FadeInImagePhase {
start,
waiting,
fadeOut,
fadeIn,
completed
bool _isShowingPlaceholder {
get {
switch (_phase) {
case FadeInImagePhase.start:
case FadeInImagePhase.waiting:
case FadeInImagePhase.fadeOut:
return true;
case FadeInImagePhase.fadeIn:
case FadeInImagePhase.completed:
return false;
delegate void _ImageProviderResolverListener();
class _ImageProviderResolver {
public _ImageProviderResolver(
_FadeInImageState state,
_ImageProviderResolverListener listener
) {
this.state = state;
this.listener = listener;
}
readonly _FadeInImageState state;
readonly _ImageProviderResolverListener listener;
FadeInImage widget {
get { return state.widget; }
}
public ImageStream _imageStream;
public ImageInfo _imageInfo;
public void resolve(ImageProvider provider) {
ImageStream oldImageStream = _imageStream;
Size size = null;
if (widget.width != null && widget.height != null) {
size = new Size((int) widget.width, (int) widget.height);
return true;
_imageStream = provider.resolve(ImageUtils.createLocalImageConfiguration(state.context, size));
D.assert(_imageStream != null);
if (_imageStream.key != oldImageStream?.key) {
oldImageStream?.removeListener(_handleImageChanged);
_imageStream.addListener(_handleImageChanged);
}
}
void _handleImageChanged(ImageInfo imageInfo, bool synchronousCall) {
_imageInfo = imageInfo;
listener();
}
public void stopListening() {
_imageStream?.removeListener(_handleImageChanged);
ImageInfo _imageInfo {
get {
return _isShowingPlaceholder
? _placeholderResolver._imageInfo
: _imageResolver._imageInfo;
class _FadeInImageState : TickerProviderStateMixin<FadeInImage> {
_ImageProviderResolver _imageResolver;
_ImageProviderResolver _placeholderResolver;
AnimationController _controller;
Animation<float> _animation;
FadeInImagePhase _phase = FadeInImagePhase.start;
public override void initState() {
_imageResolver = new _ImageProviderResolver(state: this, _updatePhase);
_placeholderResolver = new _ImageProviderResolver(state: this, listener: () => {
setState(() => {
// Trigger rebuild to display the placeholder image
});
});
_controller = new AnimationController(
value: 1.0f,
vsync: this
);
_controller.addListener(() => {
setState(() => {
// Trigger rebuild to update opacity value.
});
});
_controller.addStatusListener(status => { _updatePhase(); });
base.initState();
}
public override void didChangeDependencies() {
_resolveImage();
base.didChangeDependencies();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
FadeInImage fadeInImage = oldWidget as FadeInImage;
if (widget.image != fadeInImage.image || widget.placeholder != fadeInImage.placeholder) {
_resolveImage();
}
}
void _resolveImage() {
_imageResolver.resolve(widget.image);
if (_isShowingPlaceholder) {
_placeholderResolver.resolve(widget.placeholder);
}
if (_phase == FadeInImagePhase.start) {
_updatePhase();
}
}
void _updatePhase() {
setState(() => {
switch (_phase) {
case FadeInImagePhase.start:
if (_imageResolver._imageInfo != null) {
_phase = FadeInImagePhase.completed;
}
else {
_phase = FadeInImagePhase.waiting;
}
break;
case FadeInImagePhase.waiting:
if (_imageResolver._imageInfo != null) {
_controller.duration = widget.fadeOutDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeOutCurve
);
_phase = FadeInImagePhase.fadeOut;
_controller.reverse(1.0f);
}
break;
case FadeInImagePhase.fadeOut:
if (_controller.status == AnimationStatus.dismissed) {
// Done fading out placeholder. Begin target image fade-in.
_controller.duration = widget.fadeInDuration;
_animation = new CurvedAnimation(
parent: _controller,
curve: widget.fadeInCurve
);
_phase = FadeInImagePhase.fadeIn;
_placeholderResolver.stopListening();
_controller.forward(0.0f);
}
break;
case FadeInImagePhase.fadeIn:
if (_controller.status == AnimationStatus.completed) {
// Done finding in new image.
_phase = FadeInImagePhase.completed;
}
break;
case FadeInImagePhase.completed:
// Nothing to do.
break;
}
});
}
public override void dispose() {
_imageResolver.stopListening();
_placeholderResolver.stopListening();
_controller.dispose();
base.dispose();
}
bool _isShowingPlaceholder {
get {
switch (_phase) {
case FadeInImagePhase.start:
case FadeInImagePhase.waiting:
case FadeInImagePhase.fadeOut:
return true;
case FadeInImagePhase.fadeIn:
case FadeInImagePhase.completed:
return false;
}
return true;
}
}
ImageInfo _imageInfo {
get {
return _isShowingPlaceholder
? _placeholderResolver._imageInfo
: _imageResolver._imageInfo;
}
}
public override Widget build(BuildContext context) {
D.assert(_phase != FadeInImagePhase.start);
ImageInfo imageInfo = _imageInfo;
return new RawImage(
image: imageInfo?.image,
width: widget.width,
height: widget.height,
scale: imageInfo?.scale ?? 1.0f,
color: Color.fromRGBO(255, 255, 255, _animation?.value ?? 1.0f),
colorBlendMode: BlendMode.modulate,
fit: widget.fit,
alignment: widget.alignment,
repeat: widget.repeat
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<FadeInImagePhase>("phase", _phase));
properties.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
properties.add(new DiagnosticsProperty<ImageStream>("image stream", _imageResolver._imageStream));
properties.add(new DiagnosticsProperty<ImageStream>("placeholder stream",
_placeholderResolver._imageStream));
}
public override Widget build(BuildContext context) {
D.assert(_phase != FadeInImagePhase.start);
ImageInfo imageInfo = _imageInfo;
return new RawImage(
image: imageInfo?.image,
width: widget.width,
height: widget.height,
scale: imageInfo?.scale ?? 1.0f,
color: Color.fromRGBO(255, 255, 255, _animation?.value ?? 1.0f),
colorBlendMode: BlendMode.modulate,
fit: widget.fit,
alignment: widget.alignment,
repeat: widget.repeat
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<FadeInImagePhase>("phase", _phase));
properties.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
properties.add(new DiagnosticsProperty<ImageStream>("image stream", _imageResolver._imageStream));
properties.add(new DiagnosticsProperty<ImageStream>("placeholder stream",
_placeholderResolver._imageStream));
}
}*/
}
}

642
com.unity.uiwidgets/Runtime/widgets/focus_manager.cs


}
/*string debugDescribeFocusTree() {
public static string debugDescribeFocusTree() {
}());
});
}*/
}
/*void debugDumpFocusTree() {
public static void debugDumpFocusTree() {
}*/
}
}
public class FocusAttachment {

}
}
public class FocusNode : ChangeNotifier {
//DiagnosticableTreeMixin,
public class FocusNode : DiagnosticableTreeMixinChangeNotifier{
public FocusNode(
string debugLabel = "",
FocusOnKeyCallback onKey = null,

D.assert(canRequestFocus != null);
_skipTraversal = skipTraversal;
_canRequestFocus = canRequestFocus;
/*_onKey = onKey {
this.debugLabel = debugLabel; ///????
}*/
_onKey = onKey;
this.debugLabel = debugLabel;
}
public bool skipTraversal {

BuildContext _context;
FocusOnKeyCallback onKey {
public FocusOnKeyCallback onKey {
get { return _onKey; }
}

List<FocusNode> _descendants;
bool _hasKeyboardToken = false;
FocusNode parent {
public FocusNode parent {
get { return _parent; }
}

}
/*bool nextFocus() {
public bool nextFocus() {
}*
}
bool previousFocus() {
public bool previousFocus() {
bool focusInDirection(TraversalDirection direction) {
public bool focusInDirection(TraversalDirection direction) {
}*/
}
/*public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
}*/
}
/*public override List<DiagnosticsNode> debugDescribeChildren() {
public override List<DiagnosticsNode> debugDescribeChildren() {
return _children.map<DiagnosticsNode>((FocusNode child) {
return _children.Select((FocusNode child)=> {
}).toList();
}*/
}).ToList();
}
/*public string toStringShort() {//override
public override string toStringShort() {//override
bool hasDebugLabel = debugLabel != null && debugLabel.isNotEmpty();
string nullStr = "";
string extraData = $"{(hasDebugLabel ? debugLabel : nullStr)} " +

return $"{describeIdentity(this)}" + $"{(extraData.isNotEmpty() ? extraData : nullStr)}";
return $"{foundation_.describeIdentity(this)}" + $"{(extraData.isNotEmpty() ? extraData : nullStr)}";
}*/
}
}
public class FocusScopeNode : FocusNode {

primaryFocus._doRequestFocus(findFirstFocus: findFirstFocus);
}
}
/*public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focusedChildren.isEmpty()) {
return;
}
List<string> childList = _focusedChildren.reversed.map<string>((FocusNode child) {
return child.toStringShort();
}).toList();
properties.add(new IEnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focusedChildren.isEmpty()) {
return;
}
List<string> childList = new List<string>();
_focusedChildren.Reverse();
childList = _focusedChildren.Select((FocusNode child)=> {
return child.toStringShort();
}).ToList();
// properties.add(new IEnumerableProperty<string>("focusedChildren", childList, defaultValue: new List<string>()));
}
public class FocusManager : ChangeNotifier {//DiagnosticableTreeMixin,
public class FocusManager : DiagnosticableTreeMixinChangeNotifier{
//RawKeyboard.instance.addListener(_handleRawKeyEvent);
RawKeyboard.instance.addListener(_handleRawKeyEvent);
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
}
public static FocusManager instance {

}
if (newMode != _highlightMode) {
_highlightMode = newMode;
//_notifyHighlightModeListeners();
_notifyHighlightModeListeners();
}
}

public void removeHighlightModeListener(ValueChanged<FocusHighlightMode> listener) => _listeners?.Remove(listener);
/*void _notifyHighlightModeListeners() {
void _notifyHighlightModeListeners() {
List<ValueChanged<FocusHighlightMode>> localListeners = List<ValueChanged<FocusHighlightMode>>.from(_listeners);
List<ValueChanged<FocusHighlightMode>> localListeners = new List<ValueChanged<FocusHighlightMode>>();
foreach (var listener in _listeners) {
localListeners.Add(listener);
}
try {
listener(_highlightMode);
listener(_highlightMode);
} catch (exception, stack) {
InformationCollector collector;
D.assert(() =>{
collector = () sync* {
yield DiagnosticsProperty<FocusManager>(
"The $runtimeType sending notification was",
this,
style: DiagnosticsTreeStyle.errorProperty,
);
};
return true;
}());
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: "widgets library",
context: ErrorDescription("while dispatching notifications for $runtimeType"),
informationCollector: collector,
));
}
}*/
}
public readonly FocusScopeNode rootScope = new FocusScopeNode(debugLabel: "Root Focus Scope");

}
}
/*void _handleRawKeyEvent(RawKeyEvent Event) {
void _handleRawKeyEvent(RawKeyEvent Event) {
if (_lastInteractionWasTouch) {
_lastInteractionWasTouch = false;

D.assert(FocusManagerUtils._focusDebug($"Received key event {Event.logicalKey}"));
//D.assert(FocusManagerUtils._focusDebug($"Received key event {Event.logicalKey}"));
if (_primaryFocus == null) {
D.assert(FocusManagerUtils._focusDebug($"No primary focus for key event, ignored: {Event}"));

bool handled = false;
foreach (FocusNode node in List < FocusNode >{
_primaryFocus, ..._primaryFocus.ancestors
}) {
List<FocusNode> nodes = new List<FocusNode>();
nodes.Add(_primaryFocus);
foreach (var node in _primaryFocus.ancestors) {
nodes.Add(node);
}
foreach (FocusNode node in nodes) {
if (node.onKey != null && node.onKey(node, Event)) {
D.assert(FocusManagerUtils._focusDebug($"Node {node} handled key event {Event}."));
handled = true;

if (!handled) {
D.assert(FocusManagerUtils._focusDebug($"Key event not handled by anyone: {Event}."));
}
}*/
}
public FocusNode primaryFocus {

public FocusNode _markedForFocus;
public void _markDetached(FocusNode node) {
D.assert(FocusManagerUtils._focusDebug($"Node was detached: {node}"));
if (_primaryFocus == node) {
_primaryFocus = null;
}
_dirtyNodes?.Remove(node);
D.assert(FocusManagerUtils._focusDebug($"Node was detached: {node}"));
if (_primaryFocus == node) {
_primaryFocus = null;
}
_dirtyNodes?.Remove(node);
}
public void _markPropertiesChanged(FocusNode node) {

}
}
public void _markNextFocus(FocusNode node) {
public void _markNextFocus(FocusNode node) {
_markedForFocus = null;
_markedForFocus = null;
} else {
_markedForFocus = node;
_markNeedsUpdate();

return;
}
_haveScheduledUpdate = true;
//scheduleMicrotask(_applyFocusChange);
async_.scheduleMicrotask(()=> {
_applyFocusChange();
return null;
});
/*public void reparentIfNeeded(FocusNode node) {
D.assert(node != null);
if (node._parent == null || node._parent == this) {
return;
}
node.unfocus();
D.assert(node._parent == null);
if (_focus == null) {
_setFocus(node);
}
}*/
/*void _applyFocusChange() {
void _applyFocusChange() {
_markedForFocus = rootScope;
_markedForFocus = rootScope;
HashSet<FocusNode> previousPath = previousFocus?.ancestors?.toSet() ?? new HashSet<FocusNode>();
HashSet<FocusNode> nextPath = _markedForFocus.ancestors.toSet();
// Notify nodes that are newly focused.
_dirtyNodes.addAll(nextPath.difference(previousPath));
// Notify nodes that are no longer focused
_dirtyNodes.addAll(previousPath.difference(nextPath));
HashSet<FocusNode> previousPath = new HashSet<FocusNode>(previousFocus?.ancestors) ?? new HashSet<FocusNode>();
HashSet<FocusNode> nextPath = new HashSet<FocusNode>(_markedForFocus.ancestors);
_primaryFocus = _markedForFocus;
_markedForFocus = null;
foreach(FocusNode node in FocusTravesalUtils.difference(nextPath,previousPath)) {
_dirtyNodes.Add(node);
}
foreach(FocusNode node in FocusTravesalUtils.difference(previousPath,nextPath)) {
_dirtyNodes.Add(node);
}
_primaryFocus = _markedForFocus;
_markedForFocus = null;
D.assert(FocusManagerUtils._focusDebug("Updating focus from $previousFocus to $_primaryFocus"));
if (previousFocus != null) {
_dirtyNodes.Add(previousFocus);
}
if (_primaryFocus != null) {
_dirtyNodes.Add(_primaryFocus);
}
D.assert(FocusManagerUtils._focusDebug($"Updating focus from {previousFocus} to {_primaryFocus}"));
if (previousFocus != null) {
_dirtyNodes.Add(previousFocus);
}
if (_primaryFocus != null) {
_dirtyNodes.Add(_primaryFocus);
}
D.assert(FocusManagerUtils._focusDebug("Notifying ${_dirtyNodes.length} dirty nodes:", _dirtyNodes.toList().map<String>((FocusNode node) => node.toString())));
D.assert(FocusManagerUtils._focusDebug($"Notifying {_dirtyNodes.Count} dirty nodes:",
_dirtyNodes.ToList().Select((FocusNode node) => {
return node.toString();
}).ToList()));
node._notify();
node._notify();
notifyListeners();
notifyListeners();
if (_kDebugFocus) {
debugDumpFocusTree();
}
return true;
if (FocusManagerUtils._kDebugFocus) {
FocusManagerUtils.debugDumpFocusTree();
}
return true;
}*/
}
/*public override List<DiagnosticsNode> debugDescribeChildren() {
public override List<DiagnosticsNode> debugDescribeChildren() {
}*/
}
/*public void debugFillProperties(DiagnosticPropertiesBuilder properties) {
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
properties.add(new FlagProperty("haveScheduledUpdate", value: _haveScheduledUpdate, ifTrue: "UPDATE SCHEDULED"));
properties.add(new DiagnosticsProperty<FocusNode>("primaryFocus", primaryFocus, defaultValue: null));
properties.add(new DiagnosticsProperty<FocusNode>("nextFocus", _markedForFocus, defaultValue: null));

}
}*/
}
}
/*
public class FocusNode : ChangeNotifier {
internal FocusScopeNode _parent;
internal FocusManager _manager;
internal bool _hasKeyboardToken = false;
public bool hasFocus {
get {
FocusNode node = null;
if (_manager != null) {
node = _manager._currentFocus;
}
return node == this;
}
}
public bool consumeKeyboardToken() {
if (!_hasKeyboardToken) {
return false;
}
_hasKeyboardToken = false;
return true;
}
public void unfocus() {
if (_parent != null) {
_parent._resignFocus(this);
}
D.assert(_parent == null);
D.assert(_manager == null);
}
public override void dispose() {
if (_manager != null) {
_manager._willDisposeFocusNode(this);
}
if (_parent != null) {
_parent._resignFocus(this);
}
D.assert(_parent == null);
D.assert(_manager == null);
base.dispose();
}
internal void _notify() {
notifyListeners();
}
public override string ToString() {
return $"{foundation_.describeIdentity(this)} hasFocus: {hasFocus}";
public class FocusScopeNode : DiagnosticableTree {
internal FocusManager _manager;
internal FocusScopeNode _parent;
internal FocusScopeNode _nextSibling;
internal FocusScopeNode _previousSibling;
internal FocusScopeNode _firstChild;
internal FocusScopeNode _lastChild;
internal FocusNode _focus;
internal List<FocusScopeNode> _focusPath;
public bool isFirstFocus {
get { return _parent == null || _parent._firstChild == this; }
}
internal List<FocusScopeNode> _getFocusPath() {
List<FocusScopeNode> nodes = new List<FocusScopeNode> {this};
FocusScopeNode node = _parent;
while (node != null && node != _manager?.rootScope) {
nodes.Add(node);
node = node._parent;
}
return nodes;
}
internal void _prepend(FocusScopeNode child) {
D.assert(child != this);
D.assert(child != _firstChild);
D.assert(child != _lastChild);
D.assert(child._parent == null);
D.assert(child._manager == null);
D.assert(child._nextSibling == null);
D.assert(child._previousSibling == null);
D.assert(() => {
var node = this;
while (node._parent != null) {
node = node._parent;
}
D.assert(node != child);
return true;
});
child._parent = this;
child._nextSibling = _firstChild;
if (_firstChild != null) {
_firstChild._previousSibling = child;
}
_firstChild = child;
_lastChild = _lastChild ?? child;
child._updateManager(_manager);
}
void _updateManager(FocusManager manager) {
Action<FocusScopeNode> update = null;
update = (child) => {
if (child._manager == manager) {
return;
}
child._manager = manager;
// We don"t proactively null out the manager for FocusNodes because the
// manager holds the currently active focus node until the end of the
// microtask, even if that node is detached from the focus tree.
if (manager != null && child._focus != null) {
child._focus._manager = manager;
}
child._visitChildren(update);
};
update(this);
}
void _visitChildren(Action<FocusScopeNode> vistor) {
FocusScopeNode child = _firstChild;
while (child != null) {
vistor.Invoke(child);
child = child._nextSibling;
}
}
bool _debugUltimatePreviousSiblingOf(FocusScopeNode child, FocusScopeNode equals) {
while (child._previousSibling != null) {
D.assert(child._previousSibling != child);
child = child._previousSibling;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(FocusScopeNode child, FocusScopeNode equals) {
while (child._nextSibling != null) {
D.assert(child._nextSibling != child);
child = child._nextSibling;
}
return child == equals;
}
internal void _remove(FocusScopeNode child) {
D.assert(child._parent == this);
D.assert(child._manager == _manager);
D.assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
D.assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
if (child._previousSibling == null) {
D.assert(_firstChild == child);
_firstChild = child._nextSibling;
}
else {
child._previousSibling._nextSibling = child._nextSibling;
}
if (child._nextSibling == null) {
D.assert(_lastChild == child);
_lastChild = child._previousSibling;
}
else {
child._nextSibling._previousSibling = child._previousSibling;
}
child._previousSibling = null;
child._nextSibling = null;
child._parent = null;
child._updateManager(null);
}
internal void _didChangeFocusChain() {
if (isFirstFocus && _manager != null) {
_manager._markNeedsUpdate();
}
}
// TODO: need update
public void requestFocus(FocusNode node = null) {
// D.assert(node != null);
var focusPath = _manager?._getCurrentFocusPath();
if (_focus == node &&
(_focusPath == focusPath || (focusPath != null && _focusPath != null &&
_focusPath.SequenceEqual(focusPath)))) {
return;
}
if (_focus != null) {
_focus.unfocus();
}
node._hasKeyboardToken = true;
_setFocus(node);
}
public void autofocus(FocusNode node) {
D.assert(node != null);
if (_focus == null) {
node._hasKeyboardToken = true;
_setFocus(node);
}
}
public void reparentIfNeeded(FocusNode node) {
D.assert(node != null);
if (node._parent == null || node._parent == this) {
return;
}
node.unfocus();
D.assert(node._parent == null);
if (_focus == null) {
_setFocus(node);
}
}
internal void _setFocus(FocusNode node) {
D.assert(node != null);
D.assert(node._parent == null);
D.assert(_focus == null);
_focus = node;
_focus._parent = this;
_focus._manager = _manager;
_focus._hasKeyboardToken = true;
_didChangeFocusChain();
_focusPath = _getFocusPath();
}
internal void _resignFocus(FocusNode node) {
D.assert(node != null);
if (_focus != node) {
return;
}
_focus._parent = null;
_focus._manager = null;
_focus = null;
_didChangeFocusChain();
}
public void setFirstFocus(FocusScopeNode child) {
D.assert(child != null);
D.assert(child._parent == null || child._parent == this);
if (_firstChild == child) {
return;
}
child.detach();
_prepend(child);
D.assert(child._parent == this);
_didChangeFocusChain();
}
public void reparentScopeIfNeeded(FocusScopeNode child) {
D.assert(child != null);
if (child._parent == null || child._parent == this) {
return;
}
if (child.isFirstFocus) {
setFirstFocus(child);
}
else {
child.detach();
}
}
public void detach() {
_didChangeFocusChain();
if (_parent != null) {
_parent._remove(this);
}
D.assert(_parent == null);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_focus != null) {
properties.add(new DiagnosticsProperty<FocusNode>("focus", _focus));
}
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (_firstChild != null) {
FocusScopeNode child = _firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: $"child {count}"));
if (child == _lastChild) {
break;
}
child = child._nextSibling;
count += 1;
}
}
return children;
}
}
public class FocusManager {
public FocusManager() {
rootScope._manager = this;
D.assert(rootScope._firstChild == null);
D.assert(rootScope._lastChild == null);
}
public readonly FocusScopeNode rootScope = new FocusScopeNode();
internal readonly FocusScopeNode _noneScope = new FocusScopeNode();
public FocusNode currentFocus {
get { return _currentFocus; }
}
internal FocusNode _currentFocus;
internal void _willDisposeFocusNode(FocusNode node) {
D.assert(node != null);
if (_currentFocus == node) {
_currentFocus = null;
}
}
bool _haveScheduledUpdate = false;
internal void _markNeedsUpdate() {
if (_haveScheduledUpdate) {
return;
}
_haveScheduledUpdate = true;
async_.scheduleMicrotask(() => {
_update();
return null;
});
}
internal FocusNode _findNextFocus() {
FocusScopeNode scope = rootScope;
while (scope._firstChild != null) {
scope = scope._firstChild;
}
return scope._focus;
}
internal void _update() {
_haveScheduledUpdate = false;
var nextFocus = _findNextFocus();
if (_currentFocus == nextFocus) {
return;
}
var previousFocus = _currentFocus;
_currentFocus = nextFocus;
if (previousFocus != null) {
previousFocus._notify();
}
if (_currentFocus != null) {
_currentFocus._notify();
}
}
internal List<FocusScopeNode> _getCurrentFocusPath() {
return _currentFocus?._parent?._getFocusPath();
}
public void focusNone(bool focus) {
if (focus) {
if (_noneScope._parent != null && _noneScope.isFirstFocus) {
return;
}
rootScope.setFirstFocus(_noneScope);
}
else {
if (_noneScope._parent == null) {
return;
}
_noneScope.detach();
}
}
public override string ToString() {
var status = _haveScheduledUpdate ? " UPDATE SCHEDULED" : "";
var indent = " ";
return string.Format("{1}{2}\n{0}currentFocus: {3}\n{4}", indent, foundation_.describeIdentity(this),
status, _currentFocus,
rootScope.toStringDeep(prefixLineOne: indent, prefixOtherLines: indent));
}
}*/

472
com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs


}
public class FocusTravesalUtils {
public static void _focusAndEnsureVisible(
FocusNode node,

}
return result;
}
static int _MERGE_SORT_LIMIT = 32;
/// as they started in.
public static void insertionSort<T>(List<T> list,
Comparator<T> compare = null, int start = 0, int end =0) {
//compare ??= defaultCompare<T>();
end = end == 0 ?list.Count : end;
for (int pos = start + 1; pos < end; pos++) {
int min = start;
int max = pos;
var element = list[pos];
while (min < max) {
int mid = min + ((max - min) >> 1);
int comparison = compare(element, list[mid]);
if (comparison < 0) {
max = mid;
} else {
min = mid + 1;
}
}
setRange(list,min + 1, pos + 1, list, min);
list[min] = element;
}
}
public delegate int Comparator<T>(T a, T b);
//public Comparator<T> defaultCompare<T>() => (value1, value2) => value1 ;
public static void mergeSort<T>(
List<T> list,
int? start = null , int? end = null, Comparator<T> compare = null) {
int _start = start ?? 0;
int _end = end ?? list.Count;
compare = compare ;//?? <T>();
int length = _end - _start;
if (length < 2) return;
if (length < _MERGE_SORT_LIMIT) {
insertionSort(list, compare: compare, start: _start, end: _end);
return;
}
int middle = _start + ((_end - _start) >> 1);
int firstLength = middle - _start;
int secondLength = _end - middle;
// secondLength is always the same as firstLength, or one greater.
var scratchSpace = new List<T>(secondLength);
_mergeSort(list, compare, middle, _end, scratchSpace, 0);
int firstTarget = _end - firstLength;
_mergeSort(list, compare, _start, middle, list, firstTarget);
_merge(compare, list, firstTarget, _end, scratchSpace, 0, secondLength, list,
_start);
}
public static void _mergeSort<T>(List<T> list, Comparator<T> compare, int start, int end,
List<T> target, int targetOffset) {
int length = end - start;
if (length < _MERGE_SORT_LIMIT) {
_movingInsertionSort(list, compare, start, end, target, targetOffset);
return;
}
int middle = start + (length >> 1);
int firstLength = middle - start;
int secondLength = end - middle;
int targetMiddle = targetOffset + firstLength;
_mergeSort(list, compare, middle, end, target, targetMiddle);
_mergeSort(list, compare, start, middle, list, middle);
_merge(compare, list, middle, middle + firstLength, target, targetMiddle,
targetMiddle + secondLength, target, targetOffset);
}
public static void _movingInsertionSort<T>(List<T> list, Comparator<T> compare, int start,
int end, List<T> target, int targetOffset) {
int length = end - start;
if (length == 0) return;
target[targetOffset] = list[start];
for (int i = 1; i < length; i++) {
var element = list[start + i];
int min = targetOffset;
int max = targetOffset + i;
while (min < max) {
int mid = min + ((max - min) >> 1);
if (compare(element, target[mid]) < 0) {
max = mid;
} else {
min = mid + 1;
}
}
setRange(target,min + 1, targetOffset + i + 1, target, min);
target[min] = element;
}
}
public static List<T>setRange<T>(List<T> alist, int start, int end, List<T> blist, int skipConut = 0 ) {
List<T> copyList = new List<T>();
List<T> resultList = new List<T>();
for (int i = skipConut; i < blist.Count; i++) {
copyList.Add(blist[i]);
}
for (int i = 0; i < start; i++) {
resultList.Add(alist[i]);
}
for (int i = 0; i < copyList.Count; i++) {
resultList.Add(blist[i]);
}
for (int i = start + copyList.Count - 1; i < alist.Count; i++) {
resultList.Add(alist[i]);
}
return resultList;
}
public static void _merge<T>(
Comparator<T> compare,
List<T> firstList,
int firstStart,
int firstEnd,
List<T> secondList,
int secondStart,
int secondEnd,
List<T> target,
int targetOffset) {
// No empty lists reaches here.
D.assert(firstStart < firstEnd);
D.assert(secondStart < secondEnd);
int cursor1 = firstStart;
int cursor2 = secondStart;
var firstElement = firstList[cursor1++];
var secondElement = secondList[cursor2++];
while (true) {
if (compare(firstElement, secondElement) <= 0) {
target[targetOffset++] = firstElement;
if (cursor1 == firstEnd) break; // Flushing second list after loop.
firstElement = firstList[cursor1++];
} else {
target[targetOffset++] = secondElement;
if (cursor2 != secondEnd) {
secondElement = secondList[cursor2++];
continue;
}
target[targetOffset++] = firstElement;
setRange(target,targetOffset, targetOffset + (firstEnd - cursor1),
firstList, cursor1);
return;
}
}
// First list empties first. Reached by break above.
target[targetOffset++] = secondElement;
setRange(target
,targetOffset, targetOffset + (secondEnd - cursor2), secondList, cursor2);
}
public class FocusTraversalGroup : StatefulWidget {
public FocusTraversalGroup(

) : base(key: key) {
policy = policy ;//?? new ReadingOrderTraversalPolicy();
policy = policy ?? new ReadingOrderTraversalPolicy();
this.child = child;
}

List<FocusNode> members = null
) {
groupNode = marker?.focusNode;
policy = marker?.policy ?? defaultPolicy ;//?? new ReadingOrderTraversalPolicy();
policy = marker?.policy ?? defaultPolicy ?? new ReadingOrderTraversalPolicy();
members = members ?? new List<FocusNode>();
}
public readonly FocusNode groupNode;

candidate = sorted.isNotEmpty() ? sorted.First() : null;
}
candidate ??= currentNode;
candidate = candidate ?? currentNode;
public abstract void invalidateScopeData(FocusScopeNode node);
public virtual void invalidateScopeData(FocusScopeNode node) {
}
public abstract void changedScope(FocusNode node = null, FocusScopeNode oldScope = null);
bool next(FocusNode currentNode) => _moveFocus(currentNode, forward: true);
public virtual void changedScope(FocusNode node = null, FocusScopeNode oldScope = null) {
}
public bool next(FocusNode currentNode) => _moveFocus(currentNode, forward: true);
bool previous(FocusNode currentNode) => _moveFocus(currentNode, forward: false);
public bool previous(FocusNode currentNode) => _moveFocus(currentNode, forward: false);
public abstract bool inDirection(FocusNode currentNode, TraversalDirection direction);

public List<FocusNode> _sortAllDescendants(FocusScopeNode scope) {
D.assert(scope != null);
_FocusTraversalGroupMarker scopeGroupMarker = _getMarker(scope.context);
FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ;//?? new ReadingOrderTraversalPolicy();
FocusTraversalPolicy defaultPolicy = scopeGroupMarker?.policy ?? new ReadingOrderTraversalPolicy();
Dictionary<FocusNode, _FocusTraversalGroupInfo> groups = new Dictionary<FocusNode, _FocusTraversalGroupInfo>();
foreach(FocusNode node in scope.descendants) {
_FocusTraversalGroupMarker groupMarker = _getMarker(node.context);

_FocusTraversalGroupMarker parentMarker = _getMarker(parentContext);
FocusNode parentNode = parentMarker?.focusNode;
groups[parentNode] ??= new _FocusTraversalGroupInfo(parentMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
FocusNode parentNode = parentMarker?.focusNode;
groups[groupNode] = groups.getOrDefault(parentNode) ?? new _FocusTraversalGroupInfo(parentMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
groups[groupNode] ??= new _FocusTraversalGroupInfo(groupMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
groups[groupNode] = groups.getOrDefault(groupNode) ?? new _FocusTraversalGroupInfo(groupMarker, members: new List<FocusNode>(), defaultPolicy: defaultPolicy);
D.assert(!groups[groupNode].members.Contains(node));
groups[groupNode].members.Add(node);
}

return false;
}
}
public class _DirectionalPolicyDataEntry {
public _DirectionalPolicyDataEntry(
TraversalDirection direction ,

public readonly TraversalDirection direction;
public readonly FocusNode node;
}
public class WidgetOrderTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy {
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
return descendants;
}
}
public class _DirectionalPolicyData {
public _DirectionalPolicyData(List<_DirectionalPolicyDataEntry> history) {
D.assert(history != null);
}
public readonly List<_DirectionalPolicyDataEntry> history;
}
public class _ReadingOrderSortData : Diagnosticable {
public _ReadingOrderSortData(FocusNode node) {
D.assert(node != null);

IEnumerable<HashSet<Directionality>> allAncestors = list.Select((_ReadingOrderSortData member) => new HashSet<Directionality>(member.directionalAncestors));
HashSet<Directionality> common = null;
foreach ( HashSet<Directionality> ancestorSet in allAncestors) {
common ??= ancestorSet;
common = common ?? ancestorSet;
common = FocusTravesalUtils.intersaction(common,ancestorSet);
}
if (common.isEmpty()) {

}
return common.First().textDirection;
}
/*public static void sortWithDirectionality(List<_ReadingOrderSortData> list, TextDirection directionality) {
mergeSort<_ReadingOrderSortData>(list, compare: (_ReadingOrderSortData a, _ReadingOrderSortData b)=> {
public static void sortWithDirectionality(List<_ReadingOrderSortData> list, TextDirection directionality) {
FocusTravesalUtils.mergeSort<_ReadingOrderSortData>(list,
compare: (_ReadingOrderSortData a, _ReadingOrderSortData b)=> {
switch (directionality) {
case TextDirection.ltr:
return a.rect.left.CompareTo(b.rect.left);

D.assert(false, ()=>"Unhandled directionality $directionality");
return 0;
});
}*/
}
public IEnumerable<Directionality> directionalAncestors {
get {

}
return result;
}
_directionalAncestors ??= getDirectionalityAncestors(node.context);
_directionalAncestors = _directionalAncestors ?? getDirectionalityAncestors(node.context);
return _directionalAncestors;
}
}

get {if (_rect == null) {
foreach(Rect rect in members.Select(
(_ReadingOrderSortData data) => data.rect)){
_rect ??= rect;
_rect = _rect ?? rect;
_rect = _rect.expandToInclude(rect);
}
}

}
List<Directionality> _memberAncestors;
/*public static void sortWithDirectionality(List<_ReadingOrderDirectionalGroupData> list, TextDirection directionality) {
mergeSort<_ReadingOrderDirectionalGroupData>(list, compare: (_ReadingOrderDirectionalGroupData a, _ReadingOrderDirectionalGroupData b) =>{
public static void sortWithDirectionality(List<_ReadingOrderDirectionalGroupData> list, TextDirection directionality) {
FocusTravesalUtils.mergeSort<_ReadingOrderDirectionalGroupData>(list, compare: (_ReadingOrderDirectionalGroupData a, _ReadingOrderDirectionalGroupData b) =>{
switch (directionality) {
case TextDirection.ltr:
return a.rect.left.CompareTo(b.rect.left);

D.assert(false, ()=>"Unhandled directionality $directionality");
return 0;
});
}*/
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<TextDirection>("directionality", directionality));

//})));
}
}
/*public class ReadingOrderTraversalPolicy : FocusTraversalPolicy , DirectionalFocusTraversalPolicyMixin
public interface DirectionalFocusTraversalPolicyMixin {
//Dictionary<FocusScopeNode, _DirectionalPolicyData> _policyData = new Dictionary<FocusScopeNode, _DirectionalPolicyData>();
void invalidateScopeData(FocusScopeNode node);
void changedScope(FocusNode node = null, FocusScopeNode oldScope = null);
FocusNode findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction);
FocusNode _sortAndFindInitial(FocusNode currentNode, bool vertical = false, bool first = false);
IEnumerable<FocusNode> _sortAndFilterHorizontally(
TraversalDirection direction,
Rect target,
FocusNode nearestScope);
IEnumerable<FocusNode> _sortAndFilterVertically(
TraversalDirection direction,
Rect target,
IEnumerable<FocusNode> nodes);
bool _popPolicyDataIfNeeded(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild);
void _pushPolicyData(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild);
bool inDirection(FocusNode currentNode, TraversalDirection direction);
}
public class ReadingOrderTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy
{
public List<_ReadingOrderDirectionalGroupData> _collectDirectionalityGroups(IEnumerable<_ReadingOrderSortData> candidates) {
TextDirection currentDirection = candidates.First().directionality;

if (bandGroup.members.Count == 1) {
continue;
}
// _ReadingOrderSortData.sortWithDirectionality(bandGroup.members, bandGroup.directionality);
_ReadingOrderSortData.sortWithDirectionality(bandGroup.members, bandGroup.directionality);
}*/
/*public _ReadingOrderSortData _pickNext(List<_ReadingOrderSortData> candidates) {
}
public _ReadingOrderSortData _pickNext(List<_ReadingOrderSortData> candidates) {
MERGESORT<_ReadingOrderSortData>(candidates, compare: (_ReadingOrderSortData a, _ReadingOrderSortData b) => a.rect.top.CompareTo(b.rect.top));
FocusTravesalUtils.mergeSort<_ReadingOrderSortData>(candidates, compare: (_ReadingOrderSortData a, _ReadingOrderSortData b) => a.rect.top.CompareTo(b.rect.top));
_ReadingOrderSortData topmost = candidates.First();
List<_ReadingOrderSortData> inBand(_ReadingOrderSortData current, IEnumerable<_ReadingOrderSortData> candidates) {

}
_ReadingOrderDirectionalGroupData.sortWithDirectionality(bandGroups, nearestCommonDirectionality);
return bandGroups.First().members.First();
}*/
}
/*public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
D.assert(descendants != null);
if (descendants.Count() <= 1) {
return descendants;

unplaced.Remove(current);
}
return sortedList;
}*/
// }
}
}
public interface Comparable<T> {
public int compareTo(T other);
int compare(Comparable<T> a, T b);
}
public abstract class FocusOrder : Diagnosticable , Comparable<FocusOrder> {
public FocusOrder() {
}
public int compareTo(FocusOrder other) {
D.assert(
GetType() == other.GetType(),()=>
"The sorting algorithm must not compare incomparable keys, since they don't "+
$"know how to order themselves relative to each other. Comparing {this} with {other}");
return doCompare(other);
}
public int compare(Comparable<FocusOrder> a, FocusOrder b) {
//throw new NotImplementedException();
return a.compareTo(b);
}
protected abstract int doCompare(FocusOrder other);
}
public class NumericFocusOrder : FocusOrder {
public NumericFocusOrder(float order) {
D.assert(order != null);
this.order = order;
}
public readonly float order;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("order", order));
}
protected override int doCompare(FocusOrder other) {
other = (NumericFocusOrder) other;
return order.CompareTo(((NumericFocusOrder) other).order);
}
}
class LexicalFocusOrder : FocusOrder {
public LexicalFocusOrder(string order) {
D.assert(order != null);
this.order = order;
}
public readonly string order;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new StringProperty("order", order));
}
protected override int doCompare(FocusOrder other) {
other = (LexicalFocusOrder) other;
return order.CompareTo(((LexicalFocusOrder) other).order);
}
}
class _OrderedFocusInfo {
public _OrderedFocusInfo(
FocusNode node = null,
FocusOrder order = null) {
D.assert(node != null);
D.assert(order != null);
this.order = order;
this.node = node;
}
public readonly FocusNode node;
public readonly FocusOrder order;
}
public class OrderedTraversalPolicy : DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy {
public OrderedTraversalPolicy(FocusTraversalPolicy secondary) {
}
public readonly FocusTraversalPolicy secondary;
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
FocusTraversalPolicy secondaryPolicy = secondary ?? new ReadingOrderTraversalPolicy();
IEnumerable<FocusNode> sortedDescendants = secondaryPolicy.sortDescendants(descendants);
List<FocusNode> unordered = new List<FocusNode>();
List<_OrderedFocusInfo> ordered = new List<_OrderedFocusInfo>();
foreach( FocusNode node in sortedDescendants) {
FocusOrder order = FocusTraversalOrder.of(node.context, nullOk: true);
if (order != null) {
ordered.Add(new _OrderedFocusInfo(node: node, order: order));
} else {
unordered.Add(node);
}
}
FocusTravesalUtils.mergeSort<_OrderedFocusInfo>(ordered, compare: (_OrderedFocusInfo a, _OrderedFocusInfo b)=> {
D.assert(
a.order.GetType() == b.order.GetType(),()=>
$"When sorting nodes for determining focus order, the order ({a.order}) of " +
$"node {a.node}, isn't the same type as the order ({b.order}) of {b.node}. " +
"Incompatible order types can't be compared. Use a FocusTraversalGroup to group " +
"similar orders together."
);
return a.order.compareTo(b.order);
});
return ordered.Select((_OrderedFocusInfo info) => info.node).Concat(unordered);
}
}
public class FocusTraversalOrder : InheritedWidget {
public FocusTraversalOrder(Key key = null, FocusOrder order = null, Widget child = null)
: base(key: key, child: child) {
}
public readonly FocusOrder order;
public static FocusOrder of(BuildContext context, bool nullOk = false) {
D.assert(context != null);
D.assert(nullOk != null);
FocusTraversalOrder marker = context.getElementForInheritedWidgetOfExactType<FocusTraversalOrder>()?.widget as FocusTraversalOrder;
FocusOrder order = marker?.order;
if (order == null && !nullOk) {
throw new UIWidgetsError("FocusTraversalOrder.of() was called with a context that "+
"does not contain a TraversalOrder widget. No TraversalOrder widget " +
"ancestor could be found starting from the context that was passed to " +
"FocusTraversalOrder.of().\n" +
"The context used was:\n" +
$" {context}");
}
return order;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) => false;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<FocusOrder>("order", order));
}
}
public class _RequestFocusActionBase : UiWidgetAction {
public _RequestFocusActionBase(LocalKey name) : base(name) {
}
FocusNode _previousFocus;
public override void invoke(FocusNode node, Intent intent) {
_previousFocus = FocusManagerUtils.primaryFocus;
node.requestFocus();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<FocusNode>("previous", _previousFocus));
}
}
public class NextFocusAction : _RequestFocusActionBase {
public NextFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(NextFocusAction));
public override void invoke(FocusNode node, Intent intent) {
node.nextFocus();
}
}
public class PreviousFocusAction : _RequestFocusActionBase {
public PreviousFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(PreviousFocusAction));
public override void invoke(FocusNode node, Intent intent) => node.previousFocus();
}
public class DirectionalFocusIntent : Intent {
public DirectionalFocusIntent(TraversalDirection direction = TraversalDirection.up, bool ignoreTextFields = true)
:base(DirectionalFocusAction.key) {
this.ignoreTextFields = ignoreTextFields;
this.direction = direction;
}
public readonly TraversalDirection direction;
public readonly bool ignoreTextFields;
}
public class DirectionalFocusAction : _RequestFocusActionBase {
public DirectionalFocusAction() : base(key) {
}
public readonly static LocalKey key = new ValueKey<Type>(typeof(DirectionalFocusAction));
public override void invoke(FocusNode node, Intent intent) {
intent = (DirectionalFocusIntent) intent;
if (!((DirectionalFocusIntent)intent).ignoreTextFields || !(node.context.widget is EditableText)) {
node.focusInDirection(((DirectionalFocusIntent) intent).direction);
}
}
}
}

332
com.unity.uiwidgets/Runtime/widgets/image.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

using Color = Unity.UIWidgets.ui.Color;
using Object = System.Object;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.widgets {

}
}
stream.addListener(listener, onError: errorListener);
stream.addListener(listener: listener, onError: errorListener);
public delegate Widget ImageFrameBuilder (
BuildContext context,
Widget child,
int frame,
bool wasSynchronouslyLoaded
);
// [!!!] class ImageChunkEvent is missing
public delegate Widget ImageLoadingBuilder(
BuildContext context,
Widget child//,
//ImageChunkEvent loadingProgress
);
public delegate Widget ImageErrorWidgetBuilder(
BuildContext context,
Object error,
StackTrace stackTrace
);
ImageFrameBuilder frameBuilder = null,
ImageLoadingBuilder loadingBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
) : base(key) {
) : base(key: key) {
this.frameBuilder = frameBuilder;
this.loadingBuilder = loadingBuilder;
this.errorBuilder = errorBuilder;
this.width = width;
this.height = height;
this.color = color;

string src,
Key key = null,
float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageLoadingBuilder loadingBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low,
IDictionary<string, string> headers = null
IDictionary<string, string> headers = null,
int cacheWidth = default,
int cacheHeight = default
var networkImage = new NetworkImage(src, scale, headers);
var networkImage = new NetworkImage(src, scale, headers);//image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, NetworkImage(src, scale: scale, headers: headers));
key,
networkImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: networkImage,
frameBuilder: frameBuilder,
loadingBuilder: loadingBuilder,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
var fileImage = new FileImage(file, scale);
var fileImage = new FileImage(file, scale);//ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, FileImage(file, scale: scale));
key,
fileImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: fileImage,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

AssetBundle bundle = null,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? scale = null,
float? width = null,
float? height = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
/*image = ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, scale != null
? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)
: AssetImage(name, bundle: bundle, package: package)
);*/
key,
image,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: image,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
);
}

float scale = 1.0f,
ImageFrameBuilder frameBuilder = null,
ImageErrorWidgetBuilder errorBuilder = null,
float? width = null,
float? height = null,
Color color = null,

ImageRepeat repeat = ImageRepeat.noRepeat,
Rect centerSlice = null,
bool gaplessPlayback = false,
FilterQuality filterQuality = FilterQuality.low
FilterQuality filterQuality = FilterQuality.low,
int cacheWidth = default,
int cacheHeight = default
// ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, MemoryImage(bytes, scale: scale));
key,
memoryImage,
width,
height,
color,
colorBlendMode,
fit,
alignment,
repeat,
centerSlice,
gaplessPlayback,
filterQuality
key: key,
image: memoryImage,
frameBuilder: frameBuilder,
loadingBuilder: null,
errorBuilder: errorBuilder,
width: width,
height: height,
color: color,
colorBlendMode: colorBlendMode,
fit: fit,
alignment: alignment,
repeat: repeat,
centerSlice: centerSlice,
gaplessPlayback: gaplessPlayback,
filterQuality: filterQuality
public readonly ImageFrameBuilder frameBuilder;
public readonly ImageLoadingBuilder loadingBuilder;
public readonly ImageErrorWidgetBuilder errorBuilder;
public readonly float? width;
public readonly float? height;
public readonly Color color;

base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ImageProvider>("image", image));
properties.add(new DiagnosticsProperty<ImageFrameBuilder>("frameBuilder", frameBuilder));
properties.add(new DiagnosticsProperty<ImageLoadingBuilder>("loadingBuilder", loadingBuilder));
properties.add(new DiagnosticsProperty<Color>("color", color,
properties.add(new ColorProperty("color", color,
defaultValue: foundation_.kNullDefaultValue));
properties.add(new EnumProperty<BlendMode>("colorBlendMode", colorBlendMode,
defaultValue: foundation_.kNullDefaultValue));

}
}
public class _ImageState : State<Image> {
public class _ImageState : State<Image> ,WidgetsBindingObserver{
//ImageChunkEvent _loadingProgress;
int _frameNumber;
bool _wasSynchronouslyLoaded;
DisposableBuildContext<State<Image>> _scrollAwareContext;
Object _lastException;
StackTrace _lastStack;
public override void initState() {
base.initState();
WidgetsBinding.instance.addObserver(this);
_scrollAwareContext = new DisposableBuildContext<State<Image>>(this);
}
public override void dispose() {
D.assert(_imageStream != null);
WidgetsBinding.instance.removeObserver(this);
_stopListeningToStream();
_scrollAwareContext.dispose();
base.dispose();
}
_invertColors = false;
_updateInvertColors();
_resolveImage();
if (TickerMode.of(context)) {

public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
Image image = (Image) oldWidget;
if (_isListeningToStream &&
(widget.loadingBuilder == null) != (image.loadingBuilder == null)) {
/*_imageStream.removeListener(_getListener(image.loadingBuilder));
_imageStream.addListener(_getListener());*/
}
/*public override void didChangeAccessibilityFeatures() {
base.didChangeAccessibilityFeatures();
setState(() => {
_updateInvertColors();
});
}*/
void _updateInvertColors() {
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors
?? false;
}
/*ScrollAwareImageProvider provider = new ScrollAwareImageProvider<dynamic>(
context: _scrollAwareContext,
imageProvider: widget.image
);
ImageStream newStream =
provider.resolve(ImageUtils.createLocalImageConfiguration(
context,
size: widget.width != null && widget.height != null
? new Size(widget.width.Value, widget.height.Value)
: null
));*/
ImageStream newStream =
widget.image.resolve(ImageUtils.createLocalImageConfiguration(
context,

D.assert(newStream != null);
_updateSourceStream(newStream);
}
/*ImageStreamListener _getListener(ImageLoadingBuilder loadingBuilder = null) {
loadingBuilder ??= widget.loadingBuilder;
_lastException = null;
_lastStack = null;
return new ImageStreamListener(
_handleImageFrame,
onChunk: loadingBuilder == null ? null : _handleImageChunk,
onError: widget.errorBuilder != null
? (dynamic error, StackTrace stackTrace) => {
setState(() => {
_lastException = error;
_lastStack = stackTrace;
});
}
: null
);
}*/
/*void _handleImageFrame(ImageInfo imageInfo, bool synchronousCall) {
setState(() =>{
_imageInfo = imageInfo;
_loadingProgress = null;
_frameNumber = _frameNumber == null ? 0 : _frameNumber + 1;
_wasSynchronouslyLoaded |= synchronousCall;
});
}
void _handleImageChunk(ImageChunkEvent _event) {
D.assert(widget.loadingBuilder != null);
setState(() => {
_loadingProgress = _event;
});
}*/
void _updateSourceStream(ImageStream newStream) {
if (_imageStream?.key == newStream?.key) {
return;

//_imageStream.removeListener(_getListener());
_imageStream.removeListener(_handleImageChanged);
}

/*setState(() => {
_loadingProgress = null;
_frameNumber = null;
_wasSynchronouslyLoaded = false;
});*/
//_imageStream.addListener(_getListener());
_imageStream.addListener(_handleImageChanged);
}
}

return;
}
//_imageStream.addListener(_getListener());
_imageStream.addListener(_handleImageChanged);
_isListeningToStream = true;
}

return;
}
//_imageStream.removeListener(_getListener());
public override void dispose() {
D.assert(_imageStream != null);
_stopListeningToStream();
base.dispose();
}
if (_lastException != null) {
D.assert(widget.errorBuilder != null);
return widget.errorBuilder(context, _lastException, _lastStack);
}
RawImage image = new RawImage(
image: _imageInfo?.image,
width: widget.width,

invertColors: _invertColors,
filterQuality: widget.filterQuality
);
/*if (widget.frameBuilder != null)
image = widget.frameBuilder(context, image, _frameNumber, _wasSynchronouslyLoaded);
if (widget.loadingBuilder != null)
image = widget.loadingBuilder(context, image, _loadingProgress);*/
return image;
}

description.add(new DiagnosticsProperty<ImageInfo>("pixels", _imageInfo));
//description.add(new DiagnosticsProperty<ImageChunkEvent>("loadingProgress", _loadingProgress));
description.add(new DiagnosticsProperty<int>("frameNumber", _frameNumber));
description.add(new DiagnosticsProperty<bool>("wasSynchronouslyLoaded", _wasSynchronouslyLoaded));
}
public void didChangeMetrics() {
setState();
}
public void didChangeTextScaleFactor() {
setState();
}
public void didChangePlatformBrightness() {
setState();
}
public void didChangeLocales(List<Locale> locale) {
setState();
}
public Future<bool> didPopRoute() {
return Future.value(false).to<bool>();
}
public Future<bool> didPushRoute(string route) {
return Future.value(false).to<bool>();
}
}
}

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


base.initState();
_controller = new AnimationController(
duration: widget.duration,
debugLabel: "{" + widget.toStringShort() + "}",
debugLabel: foundation_.kDebugMode ? widget.toStringShort() : null,
_controller.addStatusListener((AnimationStatus status) => {
switch (status) {
case AnimationStatus.completed:
if (widget.onEnd != null)
widget.onEnd();
break;
case AnimationStatus.dismissed:
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
});
_updateCurve();
_constructTweens();
didUpdateTweens();

Matrix4 transform = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(duration != null);
D.assert(margin == null || margin.isNonNegative);
D.assert(padding == null || padding.isNonNegative);

EdgeInsets padding = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(padding != null);
D.assert(padding.isNonNegative);
this.padding = padding;

public override Widget build(BuildContext context) {
return new Padding(
padding: _padding.evaluate(animation),
padding: _padding
.evaluate(animation)
.clamp(EdgeInsets.zero, EdgeInsets.infinity),
child: widget.child
);
}

Alignment alignment = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(alignment != null);
this.alignment = alignment;
this.child = child;

float? width = null,
float? height = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(left == null || right == null || width == null);
D.assert(top == null || bottom == null || height == null);
this.child = child;

Widget child = null,
Rect rect = null,
Curve curve = null,
TimeSpan? duration = null
TimeSpan? duration = null,
VoidCallback onEnd = null
) {
return new AnimatedPositioned(
child: child,

width: rect.width,
height: rect.height,
curve: curve ?? Curves.linear,
key: key
key: key,
onEnd: onEnd
);
}

float? width = null,
float? height = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(start == null || end == null || width == null);
D.assert(top == null || bottom == null || height == null);
this.child = child;

Widget child = null,
float? opacity = null,
Curve curve = null,
TimeSpan? duration = null
TimeSpan? duration = null,
VoidCallback onEnd = null
base(key: key, curve: curve ?? Curves.linear, duration: duration) {
base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
this.child = child;
this.opacity = opacity ?? 1.0f;

child: widget.child
);
}
}
public class SliverAnimatedOpacity : ImplicitlyAnimatedWidget {
protected SliverAnimatedOpacity(
Key key = null,
Widget sliver = null,
float opacity = default,
Curve curve = null,//Curve curve = Curve.linear
TimeSpan duration = default,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
}
public readonly Widget sliver;
public readonly float opacity;
public override State createState() {
return new _SliverAnimatedOpacityState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("opacity", opacity));
}
}
class _SliverAnimatedOpacityState : ImplicitlyAnimatedWidgetState<SliverAnimatedOpacity> {
FloatTween _opacity;
Animation<float> _opacityAnimation;
protected override void forEachTween(TweenVisitor visitor) {
_opacity = (FloatTween) visitor.visit(this,_opacity, widget.opacity, (float value) => new FloatTween(begin: value, 0));
}
protected override void didUpdateTweens() {
_opacityAnimation = animation.drive(_opacity);
}
public override Widget build(BuildContext context) {
return new SliverFadeTransition(
opacity: _opacityAnimation,
sliver: widget.sliver
);
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {

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


public readonly OrientationWidgetBuilder builder;
Widget _buildWithConstraints(BuildContext context, BoxConstraints constraints) {
Widget _buildWithConstraints(BuildContext context, Constraints constraints) {
constraints.maxWidth > constraints.maxHeight ? Orientation.landscape : Orientation.portrait;
((BoxConstraints)constraints).maxWidth > ((BoxConstraints)constraints).maxHeight ? Orientation.landscape : Orientation.portrait;
return builder(context, orientation);
}

2
com.unity.uiwidgets/Runtime/widgets/page_view.cs


slivers: new List<Widget> {
new SliverFillViewport(
viewportFraction: widget.controller.viewportFraction,
del: widget.childrenDelegate
_delegate: widget.childrenDelegate
)
}
);

6
com.unity.uiwidgets/Runtime/widgets/scroll_notification.mixin.njk


{% macro ViewportNotificationMixin(with) %}
public abstract class ViewportNotificationMixin{{with}} : {{with}} {
public int depth {
get { return this._depth; }
get { return _depth; }
}
int _depth = 0;

this._depth += 1;
_depth += 1;
}
return base.visitAncestor(element);

base.debugFillDescription(description);
description.Add(string.Format("depth: {0} ({1})",
this._depth, this._depth == 0 ? "local" : "remote"));
_depth, _depth == 0 ? "local" : "remote"));
}
}
{% endmacro %}

6
com.unity.uiwidgets/Runtime/widgets/selectable_text.cs


}
void _handleDragUpdate(DragUpdateDetails details) {
_lastDragUpdateDetails = details;
_dragUpdateThrottleTimer = _dragUpdateThrottleTimer ??
Timer.create(TextSelectionUtils._kDragSelectionUpdateThrottle,
_handleDragUpdateThrottled);
_lastDragUpdateDetails = details;
_dragUpdateThrottleTimer = _dragUpdateThrottleTimer ?? Timer.create(TextSelectionUtils._kDragSelectionUpdateThrottle, _handleDragUpdateThrottled);
}
object _handleDragUpdateThrottled() {

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


}
}
/*public class SliverFadeTransition : SingleChildRenderObjectWidget {
public class SliverFadeTransition : SingleChildRenderObjectWidget {
public SliverFadeTransition(
Animation<float> opacity ,
Key key = null,

alwaysIncludeSemantics: alwaysIncludeSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderSliverAnimatedOpacity renderObject) {
renderObject = (RenderSliverAnimatedOpacity) renderObject;
((RenderSliverAnimatedOpacity) renderObject).opacity = opacity;
((RenderSliverAnimatedOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverAnimatedOpacity)renderObject;
((RenderSliverAnimatedOpacity)renderObject).opacity = opacity;
((RenderSliverAnimatedOpacity)renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

}
}*/
}
public class RelativeRectTween : Tween<RelativeRect> {
public RelativeRectTween(
RelativeRect begin = null,

92
com.unity.uiwidgets/Runtime/services/text_editing.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.service {
// public class TextRange : IEquatable<TextRange> {
// public readonly int start;
// public readonly int end;
//
// public static TextRange collapsed(int offset) {
// D.assert(offset >= -1);
// return new TextRange(offset, offset);
// }
//
// public static readonly TextRange empty = new TextRange(-1, -1);
//
// public TextRange(int start, int end) {
// D.assert(start >= -1);
// D.assert(end >= -1);
// this.start = start;
// this.end = end;
// }
//
// public bool isValid {
// get { return start >= 0 && end >= 0; }
// }
//
// public bool isCollapsed {
// get { return start == end; }
// }
//
// public bool isNormalized {
// get { return start <= end; }
// }
//
// public string textBefore(string text) {
// D.assert(isNormalized);
// return text.Substring(0, start);
// }
//
// public string textAfter(string text) {
// D.assert(isNormalized);
// return text.Substring(end);
// }
//
// public string textInside(string text) {
// D.assert(isNormalized);
// return text.Substring(start, end - start);
// }
//
// public bool Equals(TextRange other) {
// if (ReferenceEquals(null, other)) {
// return false;
// }
//
// if (ReferenceEquals(this, other)) {
// return true;
// }
//
// return start == other.start && end == other.end;
// }
//
// public override bool Equals(object obj) {
// if (ReferenceEquals(null, obj)) {
// return false;
// }
//
// if (ReferenceEquals(this, obj)) {
// return true;
// }
//
// if (obj.GetType() != GetType()) {
// return false;
// }
//
// return Equals((TextRange) obj);
// }
//
// public override int GetHashCode() {
// unchecked {
// return (start * 397) ^ end;
// }
// }
//
// public static bool operator ==(TextRange left, TextRange right) {
// return Equals(left, right);
// }
//
// public static bool operator !=(TextRange left, TextRange right) {
// return !Equals(left, right);
// }
//
// public override string ToString() {
// return $"TextRange Start: {start}, End: {end}";
// }
// }
public class TextSelection : TextRange, IEquatable<TextSelection> {
public readonly int baseOffset;
public readonly int extentOffset;

28
com.unity.uiwidgets/Runtime/services/text_formatter.cs


public readonly int? maxLength;
internal static TextEditingValue truncate(TextEditingValue value, int maxLength) {
TextSelection newSelection = value.selection.copyWith(
baseOffset: Mathf.Min(value.selection.start, maxLength),
extentOffset: Mathf.Min(value.selection.end, maxLength));
string truncated = value.text.Substring(0, maxLength);
return new TextEditingValue(
text: truncated,
selection: newSelection,
composing: TextRange.empty
);
}
public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if (maxLength != null && maxLength > 0 && newValue.text.Length > maxLength) {
if (Input.compositionString.Length > 0) {

TextSelection newSelection = newValue.selection.copyWith(
baseOffset: Mathf.Min(newValue.selection.start, maxLength.Value),
extentOffset: Mathf.Min(newValue.selection.end, maxLength.Value)
);
string truncated = newValue.text.Substring(0, maxLength.Value);
return new TextEditingValue(
text: truncated,
selection: newSelection,
composing: TextRange.empty
);
if (oldValue.text.Length == maxLength.Value) {
return oldValue;
}
return truncate(newValue, maxLength.Value);
}
return newValue;

324
com.unity.uiwidgets/Runtime/services/text_input.cs


using UnityEngine;
namespace Unity.UIWidgets.service {
public enum FloatingCursorDragState {
Start,
Update,
End
public enum SmartDashesType {
disabled,
enabled
public class RawFloatingCursorPoint {
public RawFloatingCursorPoint(
Offset offset = null,
FloatingCursorDragState? state = null
) {
D.assert(state != null);
D.assert(state != FloatingCursorDragState.Update || offset != null);
//D.assert(state == FloatingCursorDragState.Update ? offset != null : true);
this.offset = offset;
this.state = state;
}
public readonly Offset offset;
public readonly FloatingCursorDragState? state;
public enum SmartQuotesType {
disabled,
enabled
public class TextInputType : IEquatable<TextInputType> {
public readonly int index;
public readonly bool? signed;

}
public static readonly TextInputType text = new TextInputType(0);
public static readonly TextInputType multiline = new TextInputType(1);
public static readonly TextInputType number = numberWithOptions();

public static readonly TextInputType url = new TextInputType(6);
public static readonly TextInputType visiblePassword = new TextInputType(7);
public static readonly List<TextInputType> values = new List<TextInputType> {
text, multiline, number, phone, datetime, emailAddress, url, visiblePassword
};
"text", "multiline", "number", "phone", "datetime", "emailAddress", "url"
"text", "multiline", "number", "phone", "datetime", "emailAddress", "url", "visiblePassword"
};
public JSONNode toJson() {

return $"{GetType().FullName}(name: {_name}, signed: {signed}, decimal: {decimalNum})";
}
}
public enum TextInputAction {
none,
unspecified,
done,
go,
search,
send,
next,
previous,
continueAction,
join,
route,
emergencyCall,
newline
}
public enum TextCapitalization {
words,
sentences,
characters,
none
}
public class TextInputConfiguration {
public TextInputConfiguration(
TextInputType inputType = null,
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType = null,
SmartQuotesType? smartQuotesType = null,
bool enableSuggestions = true,
string actionLabel = null,
TextInputAction inputAction = TextInputAction.done,
ui.Brightness keyboardAppearance = ui.Brightness.light,
TextCapitalization textCapitalization = TextCapitalization.none,
bool unityTouchKeyboard = false
) {
D.assert(inputType != null);
this.smartDashesType =
smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
this.smartQuotesType =
smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
this.inputType = inputType ?? TextInputType.text;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.actionLabel = actionLabel;
this.inputAction = inputAction;
this.textCapitalization = textCapitalization;
this.keyboardAppearance = keyboardAppearance;
this.unityTouchKeyboard = unityTouchKeyboard;
}
public readonly TextInputType inputType;
public readonly bool obscureText;
public readonly bool autocorrect;
public readonly SmartDashesType smartDashesType;
public readonly SmartQuotesType smartQuotesType;
public readonly bool enableSuggestions;
public readonly string actionLabel;
public readonly TextInputAction inputAction;
public readonly TextCapitalization textCapitalization;
public readonly ui.Brightness keyboardAppearance;
public readonly bool unityTouchKeyboard;
public JSONNode toJson() {
var json = new JSONObject();
json["inputType"] = inputType.toJson();
json["obscureText"] = obscureText;
json["autocorrect"] = autocorrect;
json["smartDashesType"] = smartDashesType.ToString();
json["smartQuotesType"] = smartQuotesType.ToString();
json["enableSuggestions"] = enableSuggestions;
json["actionLabel"] = actionLabel;
json["inputAction"] = inputAction.ToString();
json["unityTouchKeyboard"] = unityTouchKeyboard;
json["textCapitalization"] = textCapitalization.ToString();
json["keyboardAppearance"] = keyboardAppearance.ToString();
return json;
}
}
static partial class TextInputUtils {
internal static TextAffinity? _toTextAffinity(string affinity) {
switch (affinity) {

return FloatingCursorDragState.End;
}
throw new UIWidgetsError($"Unknown text cursor action: {state}");
throw new UIWidgetsError(new List<DiagnosticsNode>() {new ErrorSummary($"Unknown text cursor action: {state}")});
}
public static RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state,

}
}
public enum FloatingCursorDragState {
Start,
Update,
End
}
public class RawFloatingCursorPoint {
public RawFloatingCursorPoint(
Offset offset = null,
FloatingCursorDragState? state = null
) {
D.assert(state != null);
D.assert(state != FloatingCursorDragState.Update || offset != null);
this.offset = offset;
this.state = state;
}
public readonly Offset offset;
public readonly FloatingCursorDragState? state;
}
public readonly string text;
public readonly TextSelection selection;
public readonly TextRange composing;
static JSONNode defaultBoolNode = new JSONBool(false);
public TextEditingValue(
string text = "",

D.assert(text != null);
D.assert(selection != null);
D.assert(composing != null);
this.text = text;
this.composing = composing ?? TextRange.empty;

this.selection = selection.copyWith(start, end);
}
else {
this.selection = TextSelection.collapsed(-1);
this.selection = selection ?? TextSelection.collapsed(-1);
public static TextEditingValue fromJSON(JSONObject json) {
public static TextEditingValue fromJSON(JSONNode json) {
TextAffinity? affinity =
TextInputUtils._toTextAffinity(json["selectionAffinity"].Value);
return new TextEditingValue(

extentOffset: json.GetValueOrDefault("selectionExtent", defaultIndexNode).AsInt,
affinity: affinity != null ? affinity.Value : TextAffinity.downstream,
isDirectional: json["selectionIsDirectional"].AsBool
isDirectional: json.GetValueOrDefault("selectionIsDirectional", defaultBoolNode).AsBool
),
composing: new TextRange(
start: json.GetValueOrDefault("composingBase", defaultIndexNode).AsInt,

json["composingExtent"] = composing.end;
return json;
}
public readonly string text;
public readonly TextSelection selection;
public readonly TextRange composing;
public static readonly TextEditingValue empty = new TextEditingValue();
public TextEditingValue copyWith(
string text = null,

text ?? this.text,
selection ?? this.selection,
composing ?? this.composing
text: text ?? this.text,
selection: selection ?? this.selection,
composing: composing ?? this.composing
//unity-specific
public TextEditingValue insert(string text) {
string newText;
TextSelection newSelection;

);
}
//unity-specific
public TextEditingValue deleteSelection(bool backDelete = true) {
if (selection.isCollapsed) {
if (backDelete) {

}
}
//unity-specific
//unity-specific
//unity-specific
//unity-specific
//unity-specific
public TextEditingValue moveExtent(int move) {
int offset = selection.extentOffset + move;
offset = Mathf.Max(0, offset);

//unity-specific
public TextEditingValue moveSelection(int move) {
int offset = selection.baseOffset + move;
offset = Mathf.Max(0, offset);

//unity-specific
public TextEditingValue compose(string composeText) {
D.assert(!string.IsNullOrEmpty(composeText));
var composeStart = composing == TextRange.empty ? selection.start : composing.start;

);
}
//unity-specific
public TextEditingValue clearCompose() {
if (composing == TextRange.empty) {
return this;

);
}
public static readonly TextEditingValue empty = new TextEditingValue();
public bool Equals(TextEditingValue other) {
if (ReferenceEquals(null, other)) {
return false;

public override string ToString() {
return $"Text: {text}, Selection: {selection}, Composing: {composing}";
}
public static TextEditingValue fromJSON(JSONNode encoded) {
return new TextEditingValue(
text: encoded["text"] ,
selection: new TextSelection(
baseOffset: encoded.GetValueOrDefault("selectionBase", defaultIndexNode).AsInt,
extentOffset: encoded.GetValueOrDefault("selectionExtent", defaultIndexNode).AsInt,
affinity: TextInputUtils._toTextAffinity(encoded["selectionAffinity"] ) ?? TextAffinity.downstream,
isDirectional: encoded["selectionIsDirectional"] ?? false
),
composing: new TextRange(
start: encoded.GetValueOrDefault("composingBase", defaultIndexNode).AsInt,
end: encoded.GetValueOrDefault("composingExtent", defaultIndexNode).AsInt
)
);
}
}
public interface TextSelectionDelegate {

void performAction(TextInputAction action);
void updateFloatingCursor(RawFloatingCursorPoint point);
RawInputKeyResponse globalInputKeyHandler(RawKeyEvent evt);
}
public enum TextInputAction {
none,
unspecified,
done,
go,
search,
send,
next,
previous,
continueAction,
join,
route,
emergencyCall,
newline
}
public enum TextCapitalization {
words,
sentences,
characters,
none
}
public class TextInputConfiguration {
public TextInputConfiguration(
TextInputType inputType = null,
bool obscureText = false,
bool autocorrect = true,
//SmartDashesType smartDashesType,
//SmartQuotesType smartQuotesType,
bool enableSuggestions = true,
string actionLabel = null,
TextInputAction inputAction = TextInputAction.done,
ui.Brightness keyboardAppearance = ui.Brightness.light,
TextCapitalization textCapitalization = TextCapitalization.none,
bool unityTouchKeyboard = false
) {
D.assert(inputType != null);
D.assert(obscureText != null);
//smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
//smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
D.assert(autocorrect != null);
D.assert(enableSuggestions != null);
D.assert(keyboardAppearance != null);
D.assert(inputAction != null);
D.assert(textCapitalization != null);
this.inputType = inputType ?? TextInputType.text;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.actionLabel = actionLabel;
this.inputAction = inputAction;
this.textCapitalization = textCapitalization;
this.keyboardAppearance = keyboardAppearance;
this.unityTouchKeyboard = unityTouchKeyboard;
}
public readonly TextInputAction inputAction;
public readonly TextInputType inputType;
public readonly string actionLabel;
public readonly bool obscureText;
public readonly bool autocorrect;
//public readonly TextInputAction inputAction;
public readonly bool enableSuggestions;
public readonly TextCapitalization textCapitalization;
public readonly ui.Brightness keyboardAppearance;
public readonly bool unityTouchKeyboard;
public JSONNode toJson() {
var json = new JSONObject();
json["inputType"] = inputType.toJson();
json["obscureText"] = obscureText;
json["autocorrect"] = autocorrect;
//'smartDashesType': smartDashesType.index.toString(),
//'smartQuotesType': smartQuotesType.index.toString(),
json["enableSuggestions"] = enableSuggestions;
json["actionLabel"] = actionLabel;
json["inputAction"] = inputAction.ToString();
json["unityTouchKeyboard"] = unityTouchKeyboard;
json["textCapitalization"] = textCapitalization.ToString();
json["keyboardAppearance"] = keyboardAppearance.ToString();
return json;
}
//unity-specific
RawInputKeyResponse globalInputKeyHandler(RawKeyEvent evt);
}
public class TextInputConnection {

internal Size _cachedSize;
internal Matrix4 _cachedTransform;
D.assert(to != null);
//TextInput._instance._show();
Input.imeCompositionMode = IMECompositionMode.On;
TextInput.keyboardDelegate.show();

D.assert(attached);
TextInput.keyboardDelegate.setEditingState(value);
//TextInput._instance._setEditingState(value);
//var dictionary = new JSONObject();
//json["text"] = text;
Dictionary<string,object> dictionary = new Dictionary<string, object>();
dictionary["width"] = editableBoxSize.width;
dictionary["height"] = editableBoxSize.height;

);
}
}
string fontFamily = null,
float? fontSize = null,
FontWeight fontWeight = null,
TextDirection? textDirection = null,
TextAlign? textAlign = null
) { /// ????
string fontFamily,
float? fontSize,
FontWeight fontWeight,
TextDirection textDirection,
TextAlign textAlign
) {
dictionary["textAlignIndex"] = textAlign?.GetHashCode();
dictionary["textDirectionIndex"] = textDirection?.GetHashCode();
dictionary["textAlignIndex"] = (int)textAlign;
dictionary["textDirectionIndex"] = (int)textDirection;
//TextInput._instance._clearClient();
TextInput.keyboardDelegate.clearClient();
TextInput._currentConnection = null;
Input.imeCompositionMode = IMECompositionMode.Auto;

TextInput._currentConnection = null;
D.assert(!attached);
}
internal readonly Window _window;
TouchScreenKeyboard _keyboard;
}

public static TextInputConnection attach(TextInputClient client, TextInputConfiguration configuration) {
D.assert(client != null);
D.assert(configuration != null);
var connection = new TextInputConnection(client);
_currentConnection = connection;
if (keyboardDelegate != null) {

73
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine.UI;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
public class CountDemo : UIWidgetsPanel
{
protected void OnEnable()
{
base.OnEnable();
}
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new CounterApp()
);
}
}
}
internal class CounterApp : StatefulWidget
{
public override State createState()
{
return new CountDemoState();
}
}
internal class CountDemoState : State<CounterApp>
{
private int count = 0;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.white,
child: new Column(children: new List<Widget>()
{
new Text($"count: {count}"),
new CupertinoButton(
onPressed: () =>
{
setState(() =>
{
count++;
});
},
child: new Container(
color: Color.black,
width: 100,
height: 40
)
),
}
)
);
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.cs.meta


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

537
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.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 &314921619
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 314921623}
- component: {fileID: 314921622}
- component: {fileID: 314921621}
- component: {fileID: 314921620}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &314921620
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 314921619}
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 &314921621
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 314921619}
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 &314921622
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 314921619}
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 &314921623
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 314921619}
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: 1777874941}
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 &624009034
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 624009037}
- component: {fileID: 624009036}
- component: {fileID: 624009035}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &624009035
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 624009034}
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 &624009036
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 624009034}
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 &624009037
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 624009034}
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 &1344837310
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1344837313}
- component: {fileID: 1344837312}
- component: {fileID: 1344837311}
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 &1344837311
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1344837310}
m_Enabled: 1
--- !u!20 &1344837312
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1344837310}
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 &1344837313
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1344837310}
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}
--- !u!1 &1763163838
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1763163840}
- component: {fileID: 1763163839}
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 &1763163839
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1763163838}
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 &1763163840
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1763163838}
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 &1777874940
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1777874941}
- component: {fileID: 1777874942}
- component: {fileID: 1777874943}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1777874941
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777874940}
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: 314921623}
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: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1777874942
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777874940}
m_CullTransparentMesh: 0
--- !u!114 &1777874943
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777874940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb0c6b34bc87472499dccfb52a9bcbde, 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
fonts: []
devicePixelRatioOverride: 0
hardwareAntiAliasing: 0

7
Samples/UIWidgetsSamples_2019_4/Assets/CountDemo.unity.meta


fileFormatVersion: 2
guid: c157694a3a510e34aaf716cf9438dea5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

117
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.gen.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public abstract class RenderAnimatedOpacityMixinRenderSliver<ChildType> : RenderProxySliver, RenderAnimatedOpacityMixin<ChildType> where ChildType : RenderObject {
public int _alpha { get; set; }
public new bool alwaysNeedsCompositing {
get { return child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get; set; }
public Animation<float> opacity {
get { return _opacity; }
set {
D.assert(value != null);
if (_opacity == value)
return;
if (attached && _opacity != null)
_opacity.removeListener(_updateOpacity);
_opacity = value;
if (attached)
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
}
public Animation<float> _opacity { get; set; }
public bool alwaysIncludeSemantics {
get { return _alwaysIncludeSemantics; }
set {
if (value == _alwaysIncludeSemantics)
return;
_alwaysIncludeSemantics = value;
//markNeedsSemanticsUpdate();
}
}
public bool _alwaysIncludeSemantics { get; set; }
public override void attach(object owner) {
owner = (PipelineOwner) owner;
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public void attach(PipelineOwner owner) {
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public override void detach() {
_opacity.removeListener(_updateOpacity);
base.detach();
}
public void _updateOpacity() {
int oldAlpha = _alpha;
_alpha = ui.Color.getAlphaFromOpacity((float)_opacity.value);
if (oldAlpha != _alpha) {
bool didNeedCompositing = _currentlyNeedsCompositing;
_currentlyNeedsCompositing = _alpha > 0 && _alpha < 255;
if (child != null && didNeedCompositing != _currentlyNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
//if (oldAlpha == 0 || _alpha == 0)
// markNeedsSemanticsUpdate();
}
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null) {
if (_alpha == 0) {
layer = null;
return;
}
if (_alpha == 255) {
layer = null;
context.paintChild(child, offset);
return;
}
D.assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha, base.paint, oldLayer: layer as OpacityLayer);
}
}
public void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (child != null && (_alpha != 0 || alwaysIncludeSemantics))
visitor(child);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
public ChildType child { get; set; }
}
}

98
com.unity.uiwidgets/Runtime/rendering/RenderAnimatedOpacityMixin.mixin.njk


namespace Unity.UIWidgets.rendering {
{% macro RenderAnimatedOpacityMixin(with) %}
public abstract class RenderAnimatedOpacityMixin{{with}}<ChildType> : {{with}}, RenderAnimatedOpacityMixin<ChildType> where ChildType : RenderSliver {
public int _alpha { get; set;}
public new bool alwaysNeedsCompositing {
get { child != null && _currentlyNeedsCompositing;}
}
public bool _currentlyNeedsCompositing { get;set; }
public Animation<float> opacity {
get { return _opacity; }
set {
D.assert(value != null);
if (_opacity == value)
return;
if (attached && _opacity != null)
_opacity.removeListener(_updateOpacity);
_opacity = value;
if (attached)
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
}
public Animation<float> _opacity { get; set; }
public bool alwaysIncludeSemantics {
get { return _alwaysIncludeSemantics; }
set {
if (value == _alwaysIncludeSemantics)
return;
_alwaysIncludeSemantics = value;
//markNeedsSemanticsUpdate();
}
}
public bool _alwaysIncludeSemantics { get; set; }
public override void attach(PipelineOwner owner) {
base.attach(owner);
_opacity.addListener(_updateOpacity);
_updateOpacity();
}
public override void detach() {
_opacity.removeListener(_updateOpacity);
base.detach();
}
public void _updateOpacity() {
int oldAlpha = _alpha;
_alpha = ui.Color.getAlphaFromOpacity((float)_opacity.value);
if (oldAlpha != _alpha) {
bool didNeedCompositing = _currentlyNeedsCompositing;
_currentlyNeedsCompositing = _alpha > 0 && _alpha < 255;
if (child != null && didNeedCompositing != _currentlyNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
//if (oldAlpha == 0 || _alpha == 0)
// markNeedsSemanticsUpdate();
}
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null) {
if (_alpha == 0) {
layer = null;
return;
}
if (_alpha == 255) {
layer = null;
context.paintChild(child, offset);
return;
}
D.assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha, base.paint, oldLayer: layer as OpacityLayer);
}
}
public void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (child != null && (_alpha != 0 || alwaysIncludeSemantics))
visitor(child);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
{% endmacro %}
{{ RenderAnimatedOpacityMixin('RenderSliver') }}
}

72
com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.gen.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.foundation {
public class DiagnosticableTreeMixinChangeNotifier : ChangeNotifier, DiagnosticableTreeMixin {
protected DiagnosticableTreeMixinChangeNotifier() {
}
public virtual string toString( DiagnosticLevel minLevel = DiagnosticLevel.info ) {
return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
}
public virtual string toStringShallow(
string joiner = ", ",
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
if (foundation_.kReleaseMode) {
return toString();
}
string shallowString = "";
D.assert(() => {
var result = new StringBuilder();
result.Append(toString());
result.Append(joiner);
DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder();
debugFillProperties(builder);
result.Append(string.Join(joiner,
builder.properties.Where(n => !n.isFiltered(minLevel)).Select(n => n.ToString()).ToArray())
);
shallowString = result.ToString();
return true;
});
return shallowString;
}
public virtual string toStringDeep(
string prefixLineOne = "",
string prefixOtherLines = null,
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
}
public virtual string toStringShort() {
return foundation_.describeIdentity(this);
}
public virtual DiagnosticsNode toDiagnosticsNode(
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new DiagnosticableTreeNode(
name: name,
value: this,
style: style
);
}
public virtual List<DiagnosticsNode> debugDescribeChildren()
{
return new List<DiagnosticsNode>();
}
public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) { }
}
}

66
com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.njk


namespace Unity.UIWidgets.foundation {
{% macro DiagnosticableTreeMixin(with) %}
{% set className = 'DiagnosticableTreeMixin' + with %}
public class {{className}} : {{with}}, DiagnosticableTreeMixin {
protected {{className}}() {
}
public virtual string toString( DiagnosticLevel minLevel = DiagnosticLevel.info ) {
return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel);
}
public virtual string toStringShallow(
string joiner = ", ",
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
if (foundation_.kReleaseMode) {
return toString();
}
string shallowString = "";
D.assert(() => {
var result = new StringBuilder();
result.Append(toString());
result.Append(joiner);
DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder();
debugFillProperties(builder);
result.Append(string.Join(joiner,
builder.properties.Where(n => !n.isFiltered(minLevel)).Select(n => n.ToString()).ToArray())
);
shallowString = result.ToString();
return true;
});
return shallowString;
}
public virtual string toStringDeep(
string prefixLineOne = "",
string prefixOtherLines = null,
DiagnosticLevel minLevel = DiagnosticLevel.debug
) {
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
}
public virtual string toStringShort() {
return foundation_.describeIdentity(this);
}
public virtual DiagnosticsNode toDiagnosticsNode(
string name = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse) {
return new DiagnosticableTreeNode(
name: name,
value: this,
style: style
);
}
public virtual List<DiagnosticsNode> debugDescribeChildren()
{
return new List<DiagnosticsNode>();
}
public virtual void debugFillProperties(DiagnosticPropertiesBuilder properties) { }
}
{% endmacro %}
{{ DiagnosticableTreeMixin('ChangeNotifier') }}
}

313
com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.widgets {
public class DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy : FocusTraversalPolicy, DirectionalFocusTraversalPolicyMixin {
protected DirectionalFocusTraversalPolicyMixinFocusTraversalPolicy() {
}
public readonly Dictionary<FocusScopeNode, _DirectionalPolicyData> _policyData = new Dictionary<FocusScopeNode, _DirectionalPolicyData>();
public override void invalidateScopeData(FocusScopeNode node) {
base.invalidateScopeData(node);
_policyData.Remove(node);
}
public override void changedScope(FocusNode node = null, FocusScopeNode oldScope = null) {
base.changedScope(node: node, oldScope: oldScope);
if (oldScope != null) {
var delEntries = _policyData[oldScope]?.history?.Where((_DirectionalPolicyDataEntry entry)=> {
return entry.node == node;
});
foreach (var delEntry in delEntries) {
_policyData[oldScope]?.history?.Remove(delEntry);
}
}
}
public override FocusNode findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction) {
D.assert(direction != null);
D.assert(currentNode != null);
switch (direction) {
case TraversalDirection.up:
return _sortAndFindInitial(currentNode, vertical: true, first: false);
case TraversalDirection.down:
return _sortAndFindInitial(currentNode, vertical: true, first: true);
case TraversalDirection.left:
return _sortAndFindInitial(currentNode, vertical: false, first: false);
case TraversalDirection.right:
return _sortAndFindInitial(currentNode, vertical: false, first: true);
}
return null;
}
public FocusNode _sortAndFindInitial(FocusNode currentNode, bool vertical = false, bool first = false) {
IEnumerable<FocusNode> nodes = currentNode.nearestScope.traversalDescendants;
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
if (vertical) {
if (first) {
return a.rect.top.CompareTo(b.rect.top);
} else {
return b.rect.bottom.CompareTo(a.rect.bottom);
}
} else {
if (first) {
return a.rect.left.CompareTo(b.rect.left);
} else {
return b.rect.right.CompareTo(a.rect.right);
}
}
});
if (sorted.isNotEmpty()) {
return sorted.First();
}
return null;
}
public IEnumerable<FocusNode> _sortAndFilterHorizontally(
TraversalDirection direction,
Rect target,
FocusNode nearestScope)
{
D.assert(direction == TraversalDirection.left || direction == TraversalDirection.right);
IEnumerable<FocusNode> nodes = nearestScope.traversalDescendants;
D.assert(!nodes.Contains(nearestScope));
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dx.CompareTo(b.rect.center.dx));
IEnumerable<FocusNode> result = new List<FocusNode>();
switch (direction) {
case TraversalDirection.left:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx <= target.left);
break;
case TraversalDirection.right:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx >= target.right);
break;
case TraversalDirection.up:
case TraversalDirection.down:
break;
}
return result;
}
public IEnumerable<FocusNode> _sortAndFilterVertically(
TraversalDirection direction,
Rect target,
IEnumerable<FocusNode> nodes)
{
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dy.CompareTo(b.rect.center.dy));
switch (direction) {
case TraversalDirection.up:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy <= target.top);
case TraversalDirection.down:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy >= target.bottom);
case TraversalDirection.left:
case TraversalDirection.right:
break;
}
D.assert(direction == TraversalDirection.up || direction == TraversalDirection.down);
return null;
}
public bool _popPolicyDataIfNeeded(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && policyData.history.isNotEmpty() && policyData.history.First().direction != direction) {
if (policyData.history.Last().node.parent == null) {
invalidateScopeData(nearestScope);
return false;
}
bool popOrInvalidate(TraversalDirection direction) {
FocusNode lastNode = policyData.history.removeLast().node;
if (Scrollable.of(lastNode.context) != Scrollable.of(FocusManagerUtils.primaryFocus.context)) {
invalidateScopeData(nearestScope);
return false;
}
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtStart;
break;
case TraversalDirection.right:
case TraversalDirection.down:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtEnd;
break;
}
FocusTravesalUtils._focusAndEnsureVisible(
lastNode,
alignmentPolicy: alignmentPolicy
);
return true;
}
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
invalidateScopeData(nearestScope);
break;
case TraversalDirection.up:
case TraversalDirection.down:
if (popOrInvalidate(direction)) {
return true;
}
break;
}
break;
case TraversalDirection.left:
case TraversalDirection.right:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
if (popOrInvalidate(direction)) {
return true;
}
break;
case TraversalDirection.up:
case TraversalDirection.down:
invalidateScopeData(nearestScope);
break;
}
break;
}
}
if (policyData != null && policyData.history.isEmpty()) {
invalidateScopeData(nearestScope);
}
return false;
}
public void _pushPolicyData(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && !(policyData is _DirectionalPolicyData)) {
return;
}
_DirectionalPolicyDataEntry newEntry = new _DirectionalPolicyDataEntry(node: focusedChild, direction: direction);
if (policyData != null) {
policyData.history.Add(newEntry);
} else {
_policyData[nearestScope] = new _DirectionalPolicyData(history: new List<_DirectionalPolicyDataEntry>(){newEntry});
}
}
public override bool inDirection(FocusNode currentNode, TraversalDirection direction) {
FocusScopeNode nearestScope = currentNode.nearestScope;
FocusNode focusedChild = nearestScope.focusedChild;
if (focusedChild == null) {
FocusNode firstFocus = findFirstFocusInDirection(currentNode, direction) ?? currentNode;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.right:
case TraversalDirection.down:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
if (_popPolicyDataIfNeeded(direction, nearestScope, focusedChild)) {
return true;
}
FocusNode found = null;
ScrollableState focusedScrollable = Scrollable.of(focusedChild.context);
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
IEnumerable<FocusNode> eligibleNodes = _sortAndFilterVertically(
direction,
focusedChild.rect,
nearestScope.traversalDescendants
);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count() !=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
List<FocusNode> sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.up) {
//sorted = sorted.reversed.toList();
sorted.Reverse();
sorted = sorted.ToList();
}
Rect band = Rect.fromLTRB(focusedChild.rect.left, float.NegativeInfinity, focusedChild.rect.right, float.PositiveInfinity);
IEnumerable<FocusNode> inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count() !=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
return (a.rect.center.dx - focusedChild.rect.center.dx).abs().CompareTo((b.rect.center.dx - focusedChild.rect.center.dx).abs());
});
found = sorted.First();
break;
case TraversalDirection.right:
case TraversalDirection.left:
eligibleNodes = _sortAndFilterHorizontally(direction, focusedChild.rect, nearestScope);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count()!=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.left) {
sorted.Reverse();
sorted = sorted.ToList();
//sorted = sorted.reversed.toList();
}
band = Rect.fromLTRB(float.NegativeInfinity, focusedChild.rect.top, float.PositiveInfinity, focusedChild.rect.bottom);
inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count()!=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) =>{
return (a.rect.center.dy - focusedChild.rect.center.dy).abs().CompareTo((b.rect.center.dy - focusedChild.rect.center.dy).abs());
});
found = sorted.First();
break;
}
if (found != null) {
_pushPolicyData(direction, nearestScope, focusedChild);
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.down:
case TraversalDirection.right:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
return false;
}
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
return null;
}
}
}

310
com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.njk


namespace Unity.UIWidgets.widgets {
{% macro DirectionalFocusTraversalPolicyMixin(with) %}
{% set className = 'DirectionalFocusTraversalPolicyMixin' + with %}
public class {{className}} : {{with}}, DirectionalFocusTraversalPolicyMixin {
protected {{className}}() {
}
public readonly Dictionary<FocusScopeNode, _DirectionalPolicyData> _policyData = new Dictionary<FocusScopeNode, _DirectionalPolicyData>();
public override void invalidateScopeData(FocusScopeNode node) {
base.invalidateScopeData(node);
_policyData.Remove(node);
}
public override void changedScope(FocusNode node = null, FocusScopeNode oldScope = null) {
base.changedScope(node: node, oldScope: oldScope);
if (oldScope != null) {
var delEntries = _policyData[oldScope]?.history?.Where((_DirectionalPolicyDataEntry entry)=> {
return entry.node == node;
});
foreach (var delEntry in delEntries) {
_policyData[oldScope]?.history?.Remove(delEntry);
}
}
}
public override FocusNode findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction) {
D.assert(direction != null);
D.assert(currentNode != null);
switch (direction) {
case TraversalDirection.up:
return _sortAndFindInitial(currentNode, vertical: true, first: false);
case TraversalDirection.down:
return _sortAndFindInitial(currentNode, vertical: true, first: true);
case TraversalDirection.left:
return _sortAndFindInitial(currentNode, vertical: false, first: false);
case TraversalDirection.right:
return _sortAndFindInitial(currentNode, vertical: false, first: true);
}
return null;
}
public FocusNode _sortAndFindInitial(FocusNode currentNode, bool vertical = false, bool first = false) {
IEnumerable<FocusNode> nodes = currentNode.nearestScope.traversalDescendants;
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
if (vertical) {
if (first) {
return a.rect.top.CompareTo(b.rect.top);
} else {
return b.rect.bottom.CompareTo(a.rect.bottom);
}
} else {
if (first) {
return a.rect.left.CompareTo(b.rect.left);
} else {
return b.rect.right.CompareTo(a.rect.right);
}
}
});
if (sorted.isNotEmpty()) {
return sorted.First();
}
return null;
}
public IEnumerable<FocusNode> _sortAndFilterHorizontally(
TraversalDirection direction,
Rect target,
FocusNode nearestScope)
{
D.assert(direction == TraversalDirection.left || direction == TraversalDirection.right);
IEnumerable<FocusNode> nodes = nearestScope.traversalDescendants;
D.assert(!nodes.Contains(nearestScope));
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dx.CompareTo(b.rect.center.dx));
IEnumerable<FocusNode> result = new List<FocusNode>();
switch (direction) {
case TraversalDirection.left:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx <= target.left);
break;
case TraversalDirection.right:
result = sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dx >= target.right);
break;
case TraversalDirection.up:
case TraversalDirection.down:
break;
}
return result;
}
public IEnumerable<FocusNode> _sortAndFilterVertically(
TraversalDirection direction,
Rect target,
IEnumerable<FocusNode> nodes)
{
List<FocusNode> sorted = nodes.ToList();
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) => a.rect.center.dy.CompareTo(b.rect.center.dy));
switch (direction) {
case TraversalDirection.up:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy <= target.top);
case TraversalDirection.down:
return sorted.Where((FocusNode node) => node.rect != target && node.rect.center.dy >= target.bottom);
case TraversalDirection.left:
case TraversalDirection.right:
break;
}
D.assert(direction == TraversalDirection.up || direction == TraversalDirection.down);
return null;
}
public bool _popPolicyDataIfNeeded(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && policyData.history.isNotEmpty() && policyData.history.First().direction != direction) {
if (policyData.history.Last().node.parent == null) {
invalidateScopeData(nearestScope);
return false;
}
bool popOrInvalidate(TraversalDirection direction) {
FocusNode lastNode = policyData.history.removeLast().node;
if (Scrollable.of(lastNode.context) != Scrollable.of(FocusManagerUtils.primaryFocus.context)) {
invalidateScopeData(nearestScope);
return false;
}
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicitPolicy;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtStart;
break;
case TraversalDirection.right:
case TraversalDirection.down:
alignmentPolicy = ScrollPositionAlignmentPolicy.keepVisibleAtEnd;
break;
}
FocusTravesalUtils._focusAndEnsureVisible(
lastNode,
alignmentPolicy: alignmentPolicy
);
return true;
}
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
invalidateScopeData(nearestScope);
break;
case TraversalDirection.up:
case TraversalDirection.down:
if (popOrInvalidate(direction)) {
return true;
}
break;
}
break;
case TraversalDirection.left:
case TraversalDirection.right:
switch (policyData.history.First().direction) {
case TraversalDirection.left:
case TraversalDirection.right:
if (popOrInvalidate(direction)) {
return true;
}
break;
case TraversalDirection.up:
case TraversalDirection.down:
invalidateScopeData(nearestScope);
break;
}
break;
}
}
if (policyData != null && policyData.history.isEmpty()) {
invalidateScopeData(nearestScope);
}
return false;
}
public void _pushPolicyData(TraversalDirection direction, FocusScopeNode nearestScope, FocusNode focusedChild) {
_DirectionalPolicyData policyData = _policyData[nearestScope];
if (policyData != null && !(policyData is _DirectionalPolicyData)) {
return;
}
_DirectionalPolicyDataEntry newEntry = new _DirectionalPolicyDataEntry(node: focusedChild, direction: direction);
if (policyData != null) {
policyData.history.Add(newEntry);
} else {
_policyData[nearestScope] = new _DirectionalPolicyData(history: new List<_DirectionalPolicyDataEntry>(){newEntry});
}
}
public override bool inDirection(FocusNode currentNode, TraversalDirection direction) {
FocusScopeNode nearestScope = currentNode.nearestScope;
FocusNode focusedChild = nearestScope.focusedChild;
if (focusedChild == null) {
FocusNode firstFocus = findFirstFocusInDirection(currentNode, direction) ?? currentNode;
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.right:
case TraversalDirection.down:
FocusTravesalUtils._focusAndEnsureVisible(
firstFocus,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
if (_popPolicyDataIfNeeded(direction, nearestScope, focusedChild)) {
return true;
}
FocusNode found = null;
ScrollableState focusedScrollable = Scrollable.of(focusedChild.context);
switch (direction) {
case TraversalDirection.down:
case TraversalDirection.up:
IEnumerable<FocusNode> eligibleNodes = _sortAndFilterVertically(
direction,
focusedChild.rect,
nearestScope.traversalDescendants
);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count() !=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
List<FocusNode> sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.up) {
//sorted = sorted.reversed.toList();
sorted.Reverse();
sorted = sorted.ToList();
}
Rect band = Rect.fromLTRB(focusedChild.rect.left, float.NegativeInfinity, focusedChild.rect.right, float.PositiveInfinity);
IEnumerable<FocusNode> inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count() !=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b)=> {
return (a.rect.center.dx - focusedChild.rect.center.dx).abs().CompareTo((b.rect.center.dx - focusedChild.rect.center.dx).abs());
});
found = sorted.First();
break;
case TraversalDirection.right:
case TraversalDirection.left:
eligibleNodes = _sortAndFilterHorizontally(direction, focusedChild.rect, nearestScope);
if (focusedScrollable != null && !focusedScrollable.position.atEdge()) {
IEnumerable<FocusNode> filteredEligibleNodes = eligibleNodes.Where((FocusNode node) => Scrollable.of(node.context) == focusedScrollable);
if (filteredEligibleNodes.Count()!=0) {
eligibleNodes = filteredEligibleNodes;
}
}
if (eligibleNodes.Count() == 0) {
break;
}
sorted = eligibleNodes.ToList();
if (direction == TraversalDirection.left) {
sorted.Reverse();
sorted = sorted.ToList();
//sorted = sorted.reversed.toList();
}
band = Rect.fromLTRB(float.NegativeInfinity, focusedChild.rect.top, float.PositiveInfinity, focusedChild.rect.bottom);
inBand = sorted.Where((FocusNode node) => !node.rect.intersect(band).isEmpty);
if (inBand.Count()!=0) {
found = inBand.First();
break;
}
FocusTravesalUtils.mergeSort<FocusNode>(sorted, compare: (FocusNode a, FocusNode b) =>{
return (a.rect.center.dy - focusedChild.rect.center.dy).abs().CompareTo((b.rect.center.dy - focusedChild.rect.center.dy).abs());
});
found = sorted.First();
break;
}
if (found != null) {
_pushPolicyData(direction, nearestScope, focusedChild);
switch (direction) {
case TraversalDirection.up:
case TraversalDirection.left:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtStart
);
break;
case TraversalDirection.down:
case TraversalDirection.right:
FocusTravesalUtils._focusAndEnsureVisible(
found,
alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd
);
break;
}
return true;
}
return false;
}
public override IEnumerable<FocusNode> sortDescendants(IEnumerable<FocusNode> descendants) {
return null;
}
}
{% endmacro %}
{{ DirectionalFocusTraversalPolicyMixin('FocusTraversalPolicy') }}
}

8
com.unity.uiwidgets/Runtime/material.meta


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

8
com.unity.uiwidgets/Runtime/ui33.meta


fileFormatVersion: 2
guid: 628dbae83defc65479f1ad3d8c9acbfb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/com.unity.uiwidgets/Runtime/service/text_editing.cs → /com.unity.uiwidgets/Runtime/services/text_editing.cs

/com.unity.uiwidgets/Runtime/service/clipboard.cs → /com.unity.uiwidgets/Runtime/services/clipboard.cs

/com.unity.uiwidgets/Runtime/service/system_chrome.cs → /com.unity.uiwidgets/Runtime/services/system_chrome.cs

/com.unity.uiwidgets/Runtime/service/keyboard.cs → /com.unity.uiwidgets/Runtime/services/keyboard.cs

/com.unity.uiwidgets/Runtime/service/raw_keyboard.cs → /com.unity.uiwidgets/Runtime/services/raw_keyboard.cs

/com.unity.uiwidgets/Runtime/service/text_formatter.cs → /com.unity.uiwidgets/Runtime/services/text_formatter.cs

/com.unity.uiwidgets/Runtime/service/platform_channel.cs → /com.unity.uiwidgets/Runtime/services/platform_channel.cs

/com.unity.uiwidgets/Runtime/service/system_channels.cs → /com.unity.uiwidgets/Runtime/services/system_channels.cs

/com.unity.uiwidgets/Runtime/service/text_input.cs → /com.unity.uiwidgets/Runtime/services/text_input.cs

正在加载...
取消
保存