浏览代码

merge

/main
gewentao 6 年前
当前提交
47d43193
共有 35 个文件被更改,包括 2797 次插入432 次删除
  1. 73
      Assets/UIWidgets/Tests/RenderBoxes.cs
  2. 12
      Assets/UIWidgets/editor/editor_window.cs
  3. 252
      Assets/UIWidgets/painting/alignment.cs
  4. 6
      Assets/UIWidgets/painting/alignment.cs.meta
  5. 18
      Assets/UIWidgets/painting/basic_types.cs
  6. 68
      Assets/UIWidgets/painting/borders.cs
  7. 123
      Assets/UIWidgets/painting/box_border.cs
  8. 77
      Assets/UIWidgets/painting/box_decoration.cs
  9. 7
      Assets/UIWidgets/painting/box_shadow.cs
  10. 4
      Assets/UIWidgets/painting/decoration.cs
  11. 224
      Assets/UIWidgets/painting/edge_insets.cs
  12. 205
      Assets/UIWidgets/rendering/box.cs
  13. 30
      Assets/UIWidgets/rendering/image.cs
  14. 30
      Assets/UIWidgets/rendering/object.cs
  15. 251
      Assets/UIWidgets/rendering/object.mixin.gen.cs
  16. 140
      Assets/UIWidgets/rendering/object.mixin.njk
  17. 147
      Assets/UIWidgets/rendering/proxy_box.cs
  18. 4
      Assets/UIWidgets/rendering/proxy_box.mixin.gen.cs
  19. 4
      Assets/UIWidgets/rendering/proxy_box.mixin.njk
  20. 2
      Assets/UIWidgets/rendering/sliver.cs
  21. 4
      Assets/UIWidgets/rendering/view.cs
  22. 17
      Assets/UIWidgets/rendering/viewpoint.cs
  23. 4
      Assets/UIWidgets/ui/geometry.cs
  24. 5
      Assets/UIWidgets/ui/painting/canvas_impl.cs
  25. 5
      Assets/UIWidgets/ui/text.cs
  26. 73
      Assets/UIWidgets/rendering/box.mixin.gen.cs
  27. 11
      Assets/UIWidgets/rendering/box.mixin.gen.cs.meta
  28. 74
      Assets/UIWidgets/rendering/box.mixin.njk
  29. 3
      Assets/UIWidgets/rendering/box.mixin.njk.meta
  30. 594
      Assets/UIWidgets/rendering/flex.cs
  31. 3
      Assets/UIWidgets/rendering/flex.cs.meta
  32. 629
      Assets/UIWidgets/rendering/shifted_box.cs
  33. 3
      Assets/UIWidgets/rendering/shifted_box.cs.meta
  34. 124
      Assets/UIWidgets/rendering/stack.cs
  35. 3
      Assets/UIWidgets/rendering/stack.cs.meta

73
Assets/UIWidgets/Tests/RenderBoxes.cs


using System;
using System.Collections.Generic;
using UIWidgets.painting;
using UIWidgets.ui;
using Color = UIWidgets.ui.Color;
namespace UIWidgets.Tests {
public class RenderBoxes : EditorWindow {

RenderBoxes() {
this._options = new Func<RenderBox>[] {
this.test1,
this.none,
this.decoratedBox,
this.flex,
};
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray();
this._selected = 0;

[NonSerialized] private bool hasInvoked = false;
void OnGUI() {
if (this.windowAdapter != null) {
this.windowAdapter.OnGUI();
}
var selected = EditorGUILayout.Popup("test case", this._selected, this._optionStrings);
if (selected != this._selected || !this.hasInvoked) {
this._selected = selected;

this.rendererBindings.setRoot(renderBox);
}
if (this.windowAdapter != null) {
this.windowAdapter.OnGUI();
}
}

this.rendererBindings = null;
}
RenderBox test1() {
RenderBox none() {
}
RenderBox decoratedBox() {
return new RenderConstrainedOverflowBox(
minWidth: 100,
maxWidth: 100,
minHeight: 100,
maxHeight: 100,
child: new RenderDecoratedBox(
decoration: new BoxDecoration(
color: new Color(0xFFFFFFFF),
borderRadius: BorderRadius.all(3),
boxShadow: new List<BoxShadow> {
new BoxShadow(
color: new Color(0xFFFF00FF),
offset: new Offset(0, 0),
blurRadius: 3.0,
spreadRadius: 10
)
}
)
)
);
}
RenderBox flex() {
var flexbox = new RenderFlex(
direction: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.center);
flexbox.add(new RenderConstrainedBox(
additionalConstraints: new BoxConstraints(minWidth: 300, minHeight: 200),
child: new RenderDecoratedBox(
decoration: new BoxDecoration(
color: new Color(0xFF00FF00)
)
)));
flexbox.add(new RenderConstrainedBox(
additionalConstraints: new BoxConstraints(minWidth: 100, minHeight: 300),
child: new RenderDecoratedBox(
decoration: new BoxDecoration(
color: new Color(0xFF00FFFF)
)
)));
flexbox.add(new RenderConstrainedBox(
additionalConstraints: new BoxConstraints(minWidth: 50, minHeight: 100),
child: new RenderDecoratedBox(
decoration: new BoxDecoration(
color: new Color(0xFF0000FF)
)
)));
return flexbox;
}
}
}

12
Assets/UIWidgets/editor/editor_window.cs


using System;
using UIWidgets.flow;
using UIWidgets.rendering;
using UIWidgets.widgets;
using UnityEditor;
using UnityEngine;
using Rect = UnityEngine.Rect;

public void Update() {
bool dirty = false;
if (this._devicePixelRatio != EditorGUIUtility.pixelsPerPoint) {
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint;
this._lastPosition = this.editorWindow.position;
this._physicalSize = new Size(this._lastPosition.width, this._lastPosition.height);
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint;
this._lastPosition = this.editorWindow.position;
this._physicalSize = new Size(
this._lastPosition.width * EditorGUIUtility.pixelsPerPoint,
this._lastPosition.height * EditorGUIUtility.pixelsPerPoint);
if (this._onMetricsChanged != null) {
this._onMetricsChanged();
}

252
Assets/UIWidgets/painting/alignment.cs


using System;
// todo should be in text.cs
public enum TextDirection
{
/// The text flows from right to left (e.g. Arabic, Hebrew).
rtl,
/// The text flows from left to right (e.g., English, French).
ltr,
}
public abstract class AlignmentGeometry
public class Alignment : IEquatable<Alignment>
public AlignmentGeometry()
public Alignment(double x, double y)
this.x = x;
this.y = y;
public abstract double x { get; }
public abstract double start { get; }
public abstract double y { get; }
public readonly double x;
public readonly double y;
public static readonly Alignment topLeft = new Alignment(-1.0, -1.0);
public static readonly Alignment topCenter = new Alignment(0, -1.0);
public static readonly Alignment topRight = new Alignment(1.0, -1.0);
public static readonly Alignment centerLeft = new Alignment(-1.0, 0.0);
public static readonly Alignment center = new Alignment(0.0, 0.0);
public static readonly Alignment centerRight = new Alignment(1.0, 0.0);
public static readonly Alignment bottomLeft = new Alignment(-1.0, 1.0);
public static readonly Alignment bottomCenter = new Alignment(0.0, 1.0);
public static readonly Alignment bottomRight = new Alignment(1.0, 1.0);
// todo more operators
AlignmentGeometry add(AlignmentGeometry other)
public Alignment resolve(TextDirection direction)
return new _MixedAlignment(
x + other.x,
start + other.start,
y + other.y
);
return this;
public virtual Alignment resolve(TextDirection direction)
public Alignment add(Alignment other)
return null;
return this + other;
}
public class Alignment : AlignmentGeometry
{
public Alignment(double x, double y)
public static Alignment operator -(Alignment a, Alignment b)
this._x = x;
this._y = y;
return new Alignment(a.x - b.x, a.y - b.y);
private readonly double _x;
public override double x
public static Alignment operator +(Alignment a, Alignment b)
get { return _x; }
return new Alignment(a.x + b.x, a.y + b.y);
private readonly double _y;
public static Alignment operator -(Alignment a)
{
return new Alignment(-a.x, -a.y);
}
public override double y
public static Alignment operator *(Alignment a, double b)
get { return _y; }
return new Alignment(a.x * b, a.y * b);
public override double start
public static Alignment operator /(Alignment a, double b)
get { return 0.0; }
return new Alignment(a.x / b, a.y / b);
public static readonly Alignment topLeft = new Alignment(-1.0, -1.0);
public static readonly Alignment topCenter = new Alignment(0.0, -1.0);
public static readonly Alignment topRight = new Alignment(1.0, -1.0);
public static readonly Alignment centerLeft = new Alignment(-1.0, 0.0);
public static readonly Alignment center = new Alignment(0.0, 0.0);
public static readonly Alignment centerRight = new Alignment(1.0, 0.0);
public static readonly Alignment bottomLeft = new Alignment(-1.0, 1.0);
public static readonly Alignment bottomCenter = new Alignment(0.0, 1.0);
public static readonly Alignment bottomRight = new Alignment(1.0, 1.0);
public static Alignment operator %(Alignment a, double b)
{
return new Alignment(a.x % b, a.y % b);
}
public static Alignment operator -(Alignment a, Alignment b)
public Offset alongOffset(Offset other)
return new Alignment(a._x - b._x, a._y - b._y);
double centerX = other.dx / 2.0;
double centerY = other.dy / 2.0;
return new Offset(centerX + this.x * centerX, centerY + this.y * centerY);
// todo more operators
public Offset alongSize(Size other)
{
double centerX = other.width / 2.0;
double centerY = other.height / 2.0;
return new Offset(centerX + this.x * centerX, centerY + this.y * centerY);
}
public override Alignment resolve(TextDirection direction)
public Offset withinRect(Rect rect)
return this;
double halfWidth = rect.width / 2.0;
double halfHeight = rect.height / 2.0;
return new Offset(
rect.left + halfWidth + this.x * halfWidth,
rect.top + halfHeight + this.y * halfHeight
);
}
public Rect inscribe(Size size, Rect rect)

return Rect.fromLTWH(
rect.left + halfWidthDelta + _x * halfWidthDelta,
rect.top + halfHeightDelta + _y * halfHeightDelta,
rect.left + halfWidthDelta + this.x * halfWidthDelta,
rect.top + halfHeightDelta + this.y * halfHeightDelta,
}
public class _MixedAlignment : AlignmentGeometry
{
public _MixedAlignment(double x, double start, double y)
public bool Equals(Alignment other)
this._x = x;
this._start = start;
this._y = y;
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return this.x.Equals(other.x) && this.y.Equals(other.y);
private readonly double _x;
public override double x
public override bool Equals(object obj)
get { return _x; }
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((Alignment) obj);
private readonly double _start;
public override double start
public override int GetHashCode()
get { return _start; }
unchecked
{
return (this.x.GetHashCode() * 397) ^ this.y.GetHashCode();
}
private readonly double _y;
public override double y
public static bool operator ==(Alignment a, Alignment b)
get { return _y; }
return object.Equals(a, b);
public static _MixedAlignment operator -(_MixedAlignment a)
public static bool operator !=(Alignment a, Alignment b)
return new _MixedAlignment(
-a._x,
-a._start,
-a._y
);
return !(a == b);
public static _MixedAlignment operator *(_MixedAlignment a, double other)
public class _MixedAlignment : IEquatable<_MixedAlignment>
return new _MixedAlignment(
a._x * other,
a._start * other,
a._y * other
);
}
public _MixedAlignment(double x, double start, double y)
{
this.x = x;
this.start = start;
this.y = y;
}
public static _MixedAlignment operator /(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a._x / other,
a._start / other,
a._y / other
);
}
private readonly double x;
public static _MixedAlignment operator %(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a._x % other,
a._start % other,
a._y % other
);
}
private readonly double start;
public override Alignment resolve(TextDirection direction)
{
switch (direction)
private readonly double y;
public static _MixedAlignment operator -(_MixedAlignment a)
{
return new _MixedAlignment(
-a.x,
-a.start,
-a.y
);
}
public static _MixedAlignment operator *(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x * other,
a.start * other,
a.y * other
);
}
public static _MixedAlignment operator /(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x / other,
a.start / other,
a.y / other
);
}
public static _MixedAlignment operator %(_MixedAlignment a, double other)
{
return new _MixedAlignment(
a.x % other,
a.start % other,
a.y % other
);
}
public Alignment resolve(TextDirection direction)
case TextDirection.rtl:
return new Alignment(_x - _start, _y);
case TextDirection.ltr:
return new Alignment(_x + _start, _y);
switch (direction)
{
case TextDirection.rtl:
return new Alignment(x - start, y);
case TextDirection.ltr:
return new Alignment(x + start, y);
}
return null;
return null;
public bool Equals(_MixedAlignment other)
{
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return this.x.Equals(other.x) && this.y.Equals(other.y) && this.start.Equals(other.start);
}
}
}
}

6
Assets/UIWidgets/painting/alignment.cs.meta


fileFormatVersion: 2
guid: 52b90656e86c4a39af38d0518a67f68b
timeCreated: 1534820611
fileFormatVersion: 2
guid: 52b90656e86c4a39af38d0518a67f68b
timeCreated: 1534820611

18
Assets/UIWidgets/painting/basic_types.cs


vertical,
}
public enum VerticalDirection {
up,
down,
}
public static Axis flipAxis(Axis direction) {
switch (direction) {
case Axis.horizontal:
return Axis.vertical;
case Axis.vertical:
return Axis.horizontal;
}
throw new Exception("unknown axis");
}
public static Axis axisDirectionToAxis(AxisDirection axisDirection) {
switch (axisDirection) {
case AxisDirection.up:

throw new Exception("unknown axisDirection");
}
}
}

68
Assets/UIWidgets/painting/borders.cs


namespace UIWidgets.painting {
public abstract class ShapeBorder {
public abstract EdgeInsetsGeometry dimensions { get; }
using System;
using UIWidgets.ui;
namespace UIWidgets.painting {
public class BorderSide : IEquatable<BorderSide> {
public BorderSide(
Color color = null,
double width = 1.0
) {
this.color = color ?? new Color(0xFF000000);
this.width = width;
}
public static BorderSide merge(BorderSide a, BorderSide b) {
return new BorderSide(
color: a.color,
width: a.width + b.width
);
}
public readonly Color color;
public readonly double width;
public static readonly BorderSide none = new BorderSide(width: 0.0);
public BorderSide copyWith(
Color color = null,
double? width = null
) {
return new BorderSide(
color: color ?? this.color,
width: width ?? this.width
);
}
public static bool canMerge(BorderSide a, BorderSide b) {
return a.color == b.color;
}
public bool Equals(BorderSide other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.color, other.color) && this.width.Equals(other.width);
}
public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((BorderSide) obj);
}
public override int GetHashCode() {
unchecked {
return ((this.color != null ? this.color.GetHashCode() : 0) * 397) ^ this.width.GetHashCode();
}
}
public static bool operator ==(BorderSide lhs, BorderSide rhs) {
return object.Equals(lhs, rhs);
}
public static bool operator !=(BorderSide lhs, BorderSide rhs) {
return !(lhs == rhs);
}
}
}

123
Assets/UIWidgets/painting/box_border.cs


using UnityEditor;
namespace UIWidgets.painting {
public class BorderSide : IEquatable<BorderSide> {
public BorderSide(
Color color = null,
double width = 1.0
) {
this.color = color ?? Color.fromARGB(255, 0, 0, 0);
this.width = width;
}
public readonly Color color;
public readonly double width;
public static readonly BorderSide none = new BorderSide(width: 0.0);
public bool Equals(BorderSide other) {
return this.color.Equals(other.color) && this.width.Equals(other.width);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) return false;
return obj is BorderSide && Equals((BorderSide) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.color.GetHashCode();
hashCode = (hashCode * 397) ^ this.width.GetHashCode();
return hashCode;
}
}
public static bool operator ==(BorderSide lhs, BorderSide rhs) {
return lhs.Equals(rhs);
}
public static bool operator !=(BorderSide lhs, BorderSide rhs) {
return !(lhs == rhs);
}
}
public class Border : ShapeBorder {
public class Border : IEquatable<Border> {
public Border(
BorderSide top = null,
BorderSide right = null,

public readonly BorderSide bottom;
public readonly BorderSide left;
public static Border all(
Color color = null,
double width = 1.0
) {
BorderSide side = new BorderSide(color: color, width: width);
return new Border(top: side, right: side, bottom: side, left: side);
}
public override EdgeInsetsGeometry dimensions {
get { return null; }
public static Border merge(Border a, Border b) {
return new Border(
top: BorderSide.merge(a.top, b.top),
right: BorderSide.merge(a.right, b.right),
bottom: BorderSide.merge(a.bottom, b.bottom),
left: BorderSide.merge(a.left, b.left)
);
}
public EdgeInsets dimensions {
get {
return EdgeInsets.fromLTRB(
this.left.width,
this.top.width,
this.right.width,
this.bottom.width);
}
return this.right.color == topColor && this.bottom.color == topColor && this.left.color == topColor;
return this.right.color == topColor
&& this.bottom.color == topColor
&& this.left.color == topColor;
}
}
public Border add(Border other) {
if (BorderSide.canMerge(this.top, other.top) &&
BorderSide.canMerge(this.right, other.right) &&
BorderSide.canMerge(this.bottom, other.bottom) &&
BorderSide.canMerge(this.left, other.left)) {
return Border.merge(this, other);
return null;
}
public void paint(Canvas canvas, Rect rect, BorderRadius borderRadius = null) {

canvas.drawRect(rect,
BorderWidth.only(this.top.width, this.right.width, this.bottom.width, this.left.width),
borderRadius ?? BorderRadius.zero, paint);
borderRadius, paint);
}
if (borderRadius != null) {
canvas.save();
canvas.clipRRect(RRect.fromRectAndCorners(rect,
borderRadius.topLeft, borderRadius.topRight,
borderRadius.bottomRight, borderRadius.bottomLeft));
}
if (this.top.width > 0) {

new Offset(rect.left + this.left.width, rect.bottom - this.bottom.width),
};
canvas.drawPloygon4(points, paint);
}
if (borderRadius != null) {
canvas.restore();
}
}
public bool Equals(Border other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.top, other.top)
&& object.Equals(this.right, other.right)
&& object.Equals(this.bottom, other.bottom)
&& object.Equals(this.left, other.left);
}
public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((Border) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (this.top != null ? this.top.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.right != null ? this.right.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.bottom != null ? this.bottom.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.left != null ? this.left.GetHashCode() : 0);
return hashCode;
}
}
}

77
Assets/UIWidgets/painting/box_decoration.cs


using System.Collections.Generic;
using UIWidgets.foundation;
using UIWidgets.ui;
using UnityEditor;
public class BoxDecoration : Decoration {
public class BoxDecoration : Decoration, IEquatable<BoxDecoration> {
public BoxDecoration(
Color color = null,
DecorationImage image = null,

public readonly Gradient gradient;
public override EdgeInsetsGeometry padding {
public override EdgeInsets padding {
get {
if (this.border != null) {
return this.border.dimensions;

public override BoxPainter createBoxPainter(VoidCallback onChanged = null) {
return new _BoxDecorationPainter(this, onChanged);
}
public bool Equals(BoxDecoration other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return object.Equals(this.color, other.color)
&& object.Equals(this.image, other.image)
&& object.Equals(this.border, other.border)
&& object.Equals(this.borderRadius, other.borderRadius)
&& object.Equals(this.boxShadow, other.boxShadow)
&& object.Equals(this.gradient, other.gradient);
}
public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((BoxDecoration) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (this.color != null ? this.color.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.image != null ? this.image.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.border != null ? this.border.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.borderRadius != null ? this.borderRadius.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.boxShadow != null ? this.boxShadow.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.gradient != null ? this.gradient.GetHashCode() : 0);
return hashCode;
}
}
public static bool operator ==(BoxDecoration a, BoxDecoration b) {
return object.Equals(a, b);
}
public static bool operator !=(BoxDecoration a, BoxDecoration b) {
return !(a == b);
}
public _BoxDecorationPainter(BoxDecoration _decoration, VoidCallback onChanged) : base(onChanged) {
this._decoration = _decoration;
public _BoxDecorationPainter(BoxDecoration decoration, VoidCallback onChanged)
: base(onChanged) {
this._decoration = decoration;
public Rect _rectForCachedBackgroundPaint;
public Paint _getBackgroundPaint(Rect rect) {

}
foreach (BoxShadow boxShadow in this._decoration.boxShadow) {
Paint paint = boxShadow.toPaint();
Paint paint = new Paint {
color = boxShadow.color,
blurSigma = boxShadow.blurRadius
};
canvas.drawRectShadow(bounds, paint);
}
}

this._paintBox(canvas, rect, this._getBackgroundPaint(rect));
var paint = this._getBackgroundPaint(rect);
canvas.drawRect(rect, null, this._decoration.borderRadius, paint);
}
}

}
// _imagePainter ??= _decoration.image.createPainter(onChanged);
// Path clipPath;
// switch (_decoration.shape) {
// case BoxShape.circle:
// clipPath = new Path()..addOval(rect);
// break;
// case BoxShape.rectangle:
// if (_decoration.borderRadius != null)
// clipPath = new Path()..addRRect(_decoration.borderRadius.resolve(configuration.textDirection).toRRect(rect));
// break;
// }
// _imagePainter.paint(canvas, rect, clipPath, configuration);
public void dispose() {
public override void dispose() {
base.dispose();
}

this._paintShadows(canvas, rect);
this._paintBackgroundColor(canvas, rect);
this._paintBackgroundImage(canvas, rect, configuration);
borderRadius: (BorderRadius) this._decoration.borderRadius
borderRadius: this._decoration.borderRadius
);
}
}

7
Assets/UIWidgets/painting/box_shadow.cs


get { return BoxShadow.convertRadiusToSigma(this.blurRadius); }
}
public Paint toPaint() {
return new Paint {
color = this.color,
blurSigma = this.blurSigma
};
}
public bool Equals(BoxShadow other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;

4
Assets/UIWidgets/painting/decoration.cs


protected Decoration() {
}
public virtual EdgeInsetsGeometry padding {
public virtual EdgeInsets padding {
get { return EdgeInsets.zero; }
}

public abstract void paint(Canvas canvas, Offset offset, ImageConfiguration configuration);
public void dispose() {
public virtual void dispose() {
}
}
}

224
Assets/UIWidgets/painting/edge_insets.cs


using System;
using UIWidgets.ui;
public abstract class EdgeInsetsGeometry {
protected EdgeInsetsGeometry() {
public class EdgeInsets : IEquatable<EdgeInsets> {
private EdgeInsets(double left, double top, double right, double bottom) {
this.left = left;
this.right = right;
this.top = top;
this.bottom = bottom;
}
public readonly double left;
public readonly double right;
public readonly double top;
public readonly double bottom;
public class EdgeInsets : EdgeInsetsGeometry {
private EdgeInsets() {
public bool isNonNegative {
get {
return this.left >= 0.0
&& this.right >= 0.0
&& this.top >= 0.0
&& this.bottom >= 0.0;
}
public static EdgeInsets only() {
return new EdgeInsets();
public double horizontal {
get { return this.left + this.right; }
}
public double vertical {
get { return this.top + this.bottom; }
}
public double along(Axis axis) {
switch (axis) {
case Axis.horizontal:
return this.horizontal;
case Axis.vertical:
return this.vertical;
}
throw new InvalidOperationException();
}
public Size collapsedSize {
get { return new Size(this.horizontal, this.vertical); }
}
public EdgeInsets flipped {
get { return EdgeInsets.fromLTRB(this.right, this.bottom, this.left, this.top); }
}
public Size inflateSize(Size size) {
return new Size(size.width + this.horizontal, size.height + this.vertical);
}
public Size deflateSize(Size size) {
return new Size(size.width - this.horizontal, size.height - this.vertical);
}
public static EdgeInsets fromLTRB(double left, double top, double right, double bottom) {
return new EdgeInsets(left, top, right, bottom);
}
public static EdgeInsets all(double value) {
return new EdgeInsets(value, value, value, value);
}
public static EdgeInsets only(double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0) {
return new EdgeInsets(left, top, right, bottom);
}
public static EdgeInsets symmetric(double vertical = 0.0, double horizontal = 0.0) {
return new EdgeInsets(horizontal, vertical, horizontal, vertical);
public Offset topLeft {
get { return new Offset(this.left, this.top); }
}
public Offset topRight {
get { return new Offset(-this.right, this.top); }
}
public Offset bottomLeft {
get { return new Offset(this.left, -this.bottom); }
}
public Offset bottomRight {
get { return new Offset(-this.right, -this.bottom); }
}
public Rect inflateRect(Rect rect) {
return Rect.fromLTRB(
rect.left - this.left, rect.top - this.top,
rect.right + this.right, rect.bottom + this.bottom);
}
public Rect deflateRect(Rect rect) {
return Rect.fromLTRB(
rect.left + this.left, rect.top + this.top,
rect.right - this.right, rect.bottom - this.bottom);
}
public EdgeInsets subtract(EdgeInsets other) {
return EdgeInsets.fromLTRB(
this.left - other.left,
this.top - other.top,
this.right - other.right,
this.bottom - other.bottom
);
}
public EdgeInsets add(EdgeInsets other) {
return EdgeInsets.fromLTRB(
this.left + other.left,
this.top + other.top,
this.right + other.right,
this.bottom + other.bottom
);
}
public static EdgeInsets operator -(EdgeInsets a, EdgeInsets b) {
return EdgeInsets.fromLTRB(
a.left - b.left,
a.top - b.top,
a.right - b.right,
a.bottom - b.bottom
);
}
public static EdgeInsets operator +(EdgeInsets a, EdgeInsets b) {
return EdgeInsets.fromLTRB(
a.left + b.left,
a.top + b.top,
a.right + b.right,
a.bottom + b.bottom
);
}
public static EdgeInsets operator -(EdgeInsets a) {
return EdgeInsets.fromLTRB(
-a.left,
-a.top,
-a.right,
-a.bottom
);
}
public static EdgeInsets operator *(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
a.left * b,
a.top * b,
a.right * b,
a.bottom * b
);
}
public static EdgeInsets operator /(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
a.left / b,
a.top / b,
a.right / b,
a.bottom / b
);
}
public static EdgeInsets operator %(EdgeInsets a, double b) {
return EdgeInsets.fromLTRB(
a.left % b,
a.top % b,
a.right % b,
a.bottom % b
);
}
public EdgeInsets copyWith(
double? left = null,
double? top = null,
double? right = null,
double? bottom = null
) {
return EdgeInsets.only(
left: left ?? this.left,
top: top ?? this.top,
right: right ?? this.right,
bottom: bottom ?? this.bottom
);
}
public bool Equals(EdgeInsets other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return this.left.Equals(other.left)
&& this.right.Equals(other.right)
&& this.top.Equals(other.top)
&& this.bottom.Equals(other.bottom);
}
public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((EdgeInsets) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.left.GetHashCode();
hashCode = (hashCode * 397) ^ this.right.GetHashCode();
hashCode = (hashCode * 397) ^ this.top.GetHashCode();
hashCode = (hashCode * 397) ^ this.bottom.GetHashCode();
return hashCode;
}
}
public static bool operator ==(EdgeInsets a, EdgeInsets b) {
return object.Equals(a, b);
}
public static bool operator !=(EdgeInsets a, EdgeInsets b) {
return !(a == b);
}
}
}

205
Assets/UIWidgets/rendering/box.cs


);
}
public static BoxConstraints tightFor(
double? width = null,
double? height = null
) {
return new BoxConstraints(
width ?? 0.0,
width ?? double.PositiveInfinity,
height ?? 0.0,
height ?? double.PositiveInfinity
);
}
public static BoxConstraints tightForFinite(
double width = double.PositiveInfinity,
double height = double.PositiveInfinity
) {
return new BoxConstraints(
!double.IsPositiveInfinity(width) ? width : 0.0,
!double.IsPositiveInfinity(width) ? width : double.PositiveInfinity,
!double.IsPositiveInfinity(height) ? height : 0.0,
!double.IsPositiveInfinity(height) ? height : double.PositiveInfinity
);
}
public static BoxConstraints expand(
double? width = null,
double? height = null
) {
return new BoxConstraints(
width ?? double.PositiveInfinity,
width ?? double.PositiveInfinity,
height ?? double.PositiveInfinity,
height ?? double.PositiveInfinity
);
}
public BoxConstraints copyWith(
double? minWidth = null,
double? maxWidth = null,
double? minHeight = null,
double? maxHeight = null
) {
return new BoxConstraints(
minWidth ?? this.minWidth,
maxWidth ?? this.maxWidth,
minHeight ?? this.minHeight,
maxHeight ?? this.maxHeight
);
}
public BoxConstraints deflate(EdgeInsets edges) {
double horizontal = edges.horizontal;
double vertical = edges.vertical;
double deflatedMinWidth = Math.Max(0.0, this.minWidth - horizontal);
double deflatedMinHeight = Math.Max(0.0, this.minHeight - vertical);
return new BoxConstraints(
minWidth: deflatedMinWidth,
maxWidth: Math.Max(deflatedMinWidth, this.maxWidth - horizontal),
minHeight: deflatedMinHeight,
maxHeight: Math.Max(deflatedMinHeight, this.maxHeight - vertical)
);
}
public BoxConstraints loosen() {
return new BoxConstraints(
minWidth: 0.0,
maxWidth: this.maxWidth,
minHeight: 0.0,
maxHeight: this.maxHeight
);
}
// may lose precision here
Mathf.Clamp((float)this.minWidth, (float)constraints.minWidth, (float)constraints.maxWidth),
Mathf.Clamp((float)this.minWidth, (float)constraints.minWidth, (float)constraints.maxWidth),
Mathf.Clamp((float)this.minHeight, (float)constraints.minWidth, (float)constraints.maxWidth),
Mathf.Clamp((float)this.maxHeight, (float)constraints.minHeight, (float)constraints.maxHeight)
minWidth: Mathf.Clamp(
(float) this.minWidth,
(float) constraints.minWidth,
(float) constraints.maxWidth),
maxWidth: Mathf.Clamp(
(float) this.maxWidth,
(float) constraints.minWidth,
(float) constraints.maxWidth),
minHeight: Mathf.Clamp(
(float) this.minHeight,
(float) constraints.minHeight,
(float) constraints.maxHeight),
maxHeight: Mathf.Clamp(
(float) this.maxHeight,
(float) constraints.minHeight,
(float) constraints.maxHeight)
);
}
public BoxConstraints tighten(
double? width = null,
double? height = null
) {
return new BoxConstraints(
minWidth: width == null
? this.minWidth
: Mathf.Clamp((float) width.Value, (float) this.minWidth, (float) this.maxWidth),
maxWidth: width == null
? this.maxWidth
: Mathf.Clamp((float) width.Value, (float) this.minWidth, (float) this.maxWidth),
minHeight: height == null
? this.minHeight
: Mathf.Clamp((float) height.Value, (float) this.minHeight, (float) this.maxHeight),
maxHeight: height == null
? this.maxHeight
: Mathf.Clamp((float) height.Value, (float) this.minHeight, (float) this.maxHeight)
public BoxConstraints widthConstraints()
{
public BoxConstraints flipped {
get {
return new BoxConstraints(
minWidth: this.minHeight,
maxWidth: this.maxHeight,
minHeight: this.minWidth,
maxHeight: this.maxWidth
);
}
}
public BoxConstraints widthConstraints() {
return new BoxConstraints(minWidth: this.minWidth, maxWidth: this.maxWidth);
}

}
public bool hasBoundedWidth {
get { return this.minWidth < double.PositiveInfinity; }
get { return this.maxWidth < double.PositiveInfinity; }
get { return this.minHeight < double.PositiveInfinity; }
get { return this.maxHeight < double.PositiveInfinity; }
}
public bool hasInfiniteWidth {

public override void performLayout() {
}
public override void applyPaintTransform(RenderObject child, Matrix4x4 transform) {
public override void applyPaintTransform(RenderObject child, ref Matrix4x4 transform) {
transform.SetTRS(new Vector2((float) offset.dx, (float) offset.dy), Quaternion.identity, Vector3.one);
transform = Matrix4x4.Translate(offset.toVector()) * transform;
var det = transform.determinant;
if (det == 0f) {
return Offset.zero;
}
public Offset localToGlobal(Offset point, RenderObject ancestor = null) {
return MatrixUtils.transformPoint(this.getTransformTo(ancestor), point);

get { return Offset.zero & this.size; }
}
}
public abstract class
RenderBoxContainerDefaultsMixin<ChildType, ParentDataType>
: ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>
where ChildType : RenderBox
where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public double? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? result = child.getDistanceToActualBaseline(baseline);
if (result != null) {
return result.Value + childParentData.offset.dy;
}
child = childParentData.nextSibling;
}
return null;
}
public double? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
double? result = null;
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? candidate = child.getDistanceToActualBaseline(baseline);
if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
} else {
result = candidate;
}
}
child = childParentData.nextSibling;
}
return result;
}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);
child = childParentData.nextSibling;
}
}
public List<ChildType> getChildrenAsList() {
var result = new List<ChildType>();
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
result.Add(child);
child = childParentData.nextSibling;
}
return result;
}
}
}

30
Assets/UIWidgets/rendering/image.cs


Rect centerSlice,
// TextDirection textDirection,
bool matchTextDirection = false,
AlignmentGeometry alignment = null,
// AlignmentGeometry alignment = null,
double scale = 1.0
)
{

this._centerSlice = centerSlice;
// this._matchTextDirection = matchTextDirection;
// this._textDir
this._alignment = alignment ?? Alignment.center;
// this._alignment = alignment ?? Alignment.center;
this._textDirection = textDirection;
_updateColorFilter();
}

{
if (_resolvedAlignment != null)
return;
_resolvedAlignment = alignment.resolve(textDirection);
// _resolvedAlignment = alignment.resolve(textDirection);
_flipHorizontally = matchTextDirection && textDirection == TextDirection.rtl;
}

}
}
private AlignmentGeometry _alignment;
// private AlignmentGeometry _alignment;
public AlignmentGeometry alignment
{
get { return _alignment; }
set
{
if (value == _alignment)
return;
_alignment = value;
_markNeedsResolution();
}
}
// public AlignmentGeometry alignment
// {
// get { return _alignment; }
// set
// {
// if (value == _alignment)
// return;
// _alignment = value;
// _markNeedsResolution();
// }
// }
private ImageRepeat _repeat;

30
Assets/UIWidgets/rendering/object.cs


}
}
public abstract class ContainerParentDataMixin<ChildType> : ParentData where ChildType : RenderObject {
public ChildType previousSibling;
public ChildType nextSibling;
public override void detach() {
base.detach();
if (this.previousSibling != null) {
var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
previousSiblingParentData.nextSibling = this.nextSibling;
}
if (this.nextSibling != null) {
var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
nextSiblingParentData.previousSibling = this.previousSibling;
}
public interface ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
ChildType previousSibling { get; set; }
this.previousSibling = null;
this.nextSibling = null;
}
ChildType nextSibling { get; set; }
}
public abstract class RenderObject : AbstractNode {

this.markNeedsPaint();
}
public bool sizedByParent {
public virtual bool sizedByParent {
get { return false; }
}

return;
}
this._needsPaint = true;
if (this.isRepaintBoundary) {
if (this.owner != null) {
this.owner._nodesNeedingPaint.Add(this);

public virtual void paint(PaintingContext context, Offset offset) {
}
public virtual void applyPaintTransform(RenderObject child, Matrix4x4 transform) {
public virtual void applyPaintTransform(RenderObject child, ref Matrix4x4 transform) {
}
public Matrix4x4 getTransformTo(RenderObject ancestor) {

var transform = Matrix4x4.identity;
for (int index = renderers.Count - 1; index > 0; index -= 1) {
renderers[index].applyPaintTransform(renderers[index - 1], transform);
renderers[index].applyPaintTransform(renderers[index - 1], ref transform);
}
return transform;

251
Assets/UIWidgets/rendering/object.mixin.gen.cs


namespace UIWidgets.rendering {
public abstract class ContainerRenderBox<ChildType, ParentDataType> : RenderBox
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
public abstract class ContainerParentDataMixinParentData<ChildType> : ParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }
public override void detach() {
base.detach();
if (this.previousSibling != null) {
var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
previousSiblingParentData.nextSibling = this.nextSibling;
}
if (this.nextSibling != null) {
var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
nextSiblingParentData.previousSibling = this.previousSibling;
}
this.previousSibling = null;
this.nextSibling = null;
}
}
public abstract class ContainerParentDataMixinBoxParentData<ChildType> : BoxParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }
public override void detach() {
base.detach();
if (this.previousSibling != null) {
var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
previousSiblingParentData.nextSibling = this.nextSibling;
}
if (this.nextSibling != null) {
var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
nextSiblingParentData.previousSibling = this.previousSibling;
}
this.previousSibling = null;
this.nextSibling = null;
}
}
public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox
where ParentDataType : ContainerParentDataMixin<ChildType> {
where ParentDataType : ParentData, ContainerParentDataMixin<ChildType> {
public int _childCount = 0;
public int countCount {

public ChildType _firstChild;
public ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {

this._removeFromChildList(child);
this._insertIntoChildList(child, after);
// this.markNeedsLayout();
this.markNeedsLayout();
}
public override void attach(object owner) {

}
public abstract class ContainerRenderSliver<ChildType, ParentDataType> : RenderSliver
public abstract class ContainerRenderObjectMixinRenderSliver<ChildType, ParentDataType> : RenderSliver
where ParentDataType : ContainerParentDataMixin<ChildType> {
where ParentDataType : ParentData, ContainerParentDataMixin<ChildType> {
public int _childCount = 0;
public int countCount {

public ChildType _firstChild;
public ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {

this._removeFromChildList(child);
this._insertIntoChildList(child, after);
// this.markNeedsLayout();
this.markNeedsLayout();
}
public override void attach(object owner) {

}
}
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
}

140
Assets/UIWidgets/rendering/object.mixin.njk


using UnityEngine;
namespace UIWidgets.rendering {
{% macro RenderObjectWithChildMixin(with) %}
public abstract class RenderObjectWithChildMixin{{with}}<ChildType> : {{with}} where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
{% endmacro %}
{{ RenderObjectWithChildMixin('RenderObject') }}
{{ RenderObjectWithChildMixin('RenderBox') }}
{% macro ContainerParentDataMixin(with) %}
public abstract class ContainerParentDataMixin{{with}}<ChildType> : {{with}}, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }
public override void detach() {
base.detach();
if (this.previousSibling != null) {
var previousSiblingParentData = (ContainerParentDataMixin<ChildType>) this.previousSibling.parentData;
previousSiblingParentData.nextSibling = this.nextSibling;
}
if (this.nextSibling != null) {
var nextSiblingParentData = (ContainerParentDataMixin<ChildType>) this.nextSibling.parentData;
nextSiblingParentData.previousSibling = this.previousSibling;
}
this.previousSibling = null;
this.nextSibling = null;
}
}
{% endmacro %}
{{ ContainerParentDataMixin('ParentData') }}
{{ ContainerParentDataMixin('BoxParentData') }}
public abstract class Container{{with}}<ChildType, ParentDataType> : {{with}}
public abstract class ContainerRenderObjectMixin{{with}}<ChildType, ParentDataType> : {{with}}
where ParentDataType : ContainerParentDataMixin<ChildType> {
where ParentDataType : ParentData, ContainerParentDataMixin<ChildType> {
public int _childCount = 0;
public int countCount {

public ChildType _firstChild;
public ChildType _lastChild;
public void _insertIntoChildList(ChildType child, ChildType after = null) {

this._removeFromChildList(child);
this._insertIntoChildList(child, after);
// this.markNeedsLayout();
this.markNeedsLayout();
}
public override void attach(object owner) {

{{ ContainerRenderObjectMixin('RenderSliver') }}
{% macro RenderObjectWithChildMixin(with) %}
public abstract class RenderObjectWithChildMixin{{with}}<ChildType> : {{with}} where ChildType : RenderObject {
public ChildType _child;
public ChildType child {
get { return this._child; }
set {
if (this._child != null) {
this.dropChild(this._child);
}
this._child = value;
if (this._child != null) {
this.adoptChild(this._child);
}
}
}
public override void attach(object owner) {
base.attach(owner);
if (this._child != null) {
this._child.attach(owner);
}
}
public override void detach() {
base.detach();
if (this._child != null) {
this._child.detach();
}
}
public override void redepthChildren() {
if (this._child != null) {
this.redepthChild(this._child);
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
if (this._child != null) {
visitor(this._child);
}
}
}
{% endmacro %}
{{ RenderObjectWithChildMixin('RenderBox') }}
{{ RenderObjectWithChildMixin('RenderObject') }}
}

147
Assets/UIWidgets/rendering/proxy_box.cs


}
}
public class RenderConstrainedBox : RenderProxyBox {
public RenderConstrainedBox(
RenderBox child = null,
BoxConstraints additionalConstraints = null) : base(child) {
this._additionalConstraints = additionalConstraints;
}
public BoxConstraints additionalConstraints {
get { return this._additionalConstraints; }
set {
if (this._additionalConstraints == value) {
return;
}
this._additionalConstraints = value;
this.markNeedsLayout();
}
}
public BoxConstraints _additionalConstraints;
public override double computeMinIntrinsicWidth(double height) {
if (this._additionalConstraints.hasBoundedWidth && this._additionalConstraints.hasTightWidth) {
return this._additionalConstraints.minWidth;
}
double width = base.computeMinIntrinsicWidth(height);
if (!this._additionalConstraints.hasInfiniteWidth) {
return this._additionalConstraints.constrainWidth(width);
}
return width;
}
public override double computeMaxIntrinsicWidth(double height) {
if (this._additionalConstraints.hasBoundedWidth && this._additionalConstraints.hasTightWidth) {
return this._additionalConstraints.maxWidth;
}
double width = base.computeMaxIntrinsicWidth(height);
if (!this._additionalConstraints.hasInfiniteWidth) {
return this._additionalConstraints.constrainWidth(width);
}
return width;
}
public override double computeMinIntrinsicHeight(double width) {
if (this._additionalConstraints.hasBoundedHeight && this._additionalConstraints.hasTightHeight) {
return this._additionalConstraints.minHeight;
}
double height = base.computeMinIntrinsicHeight(width);
if (!this._additionalConstraints.hasInfiniteHeight) {
return this._additionalConstraints.constrainHeight(height);
}
return height;
}
public override double computeMaxIntrinsicHeight(double width) {
if (this._additionalConstraints.hasBoundedHeight && this._additionalConstraints.hasTightHeight) {
return this._additionalConstraints.minHeight;
}
double height = base.computeMaxIntrinsicHeight(width);
if (!this._additionalConstraints.hasInfiniteHeight) {
return this._additionalConstraints.constrainHeight(height);
}
return height;
}
public override void performLayout() {
if (this.child != null) {
this.child.layout(this._additionalConstraints.enforce(this.constraints), parentUsesSize: true);
this.size = this.child.size;
} else {
this.size = this._additionalConstraints.enforce(this.constraints).constrain(Size.zero);
}
}
}
public class RenderLimitedBox : RenderProxyBox {
public RenderLimitedBox(
RenderBox child = null,
double maxWidth = double.PositiveInfinity,
double maxHeight = double.PositiveInfinity
) : base(child) {
this._maxWidth = maxWidth;
this._maxHeight = maxHeight;
}
public double maxWidth {
get { return this._maxWidth; }
set {
if (this._maxWidth == value) {
return;
}
this._maxWidth = value;
this.markNeedsLayout();
}
}
public double _maxWidth;
public double maxHeight {
get { return this._maxHeight; }
set {
if (this._maxHeight == value) {
return;
}
this._maxHeight = value;
this.markNeedsLayout();
}
}
public double _maxHeight;
public BoxConstraints _limitConstraints(BoxConstraints constraints) {
return new BoxConstraints(
minWidth: constraints.minWidth,
maxWidth: constraints.hasBoundedWidth
? constraints.maxWidth
: constraints.constrainWidth(this.maxWidth),
minHeight: constraints.minHeight,
maxHeight: constraints.hasBoundedHeight
? constraints.maxHeight
: constraints.constrainHeight(this.maxHeight)
);
}
public override void performLayout() {
if (this.child != null) {
this.child.layout(this._limitConstraints(this.constraints), parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
} else {
this.size = this._limitConstraints(this.constraints).constrain(Size.zero);
}
}
}
public class RenderDecoratedBox : RenderProxyBox {
public RenderDecoratedBox(
Decoration decoration,

4
Assets/UIWidgets/rendering/proxy_box.mixin.gen.cs


public override void performLayout() {
if (this.child != null) {
this.child.layout(this.constraints, true);
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
} else {
this.performResize();

public override void applyPaintTransform(RenderObject child, Matrix4x4 transform) {
public override void applyPaintTransform(RenderObject child, ref Matrix4x4 transform) {
}
public override void paint(PaintingContext context, Offset offset) {

4
Assets/UIWidgets/rendering/proxy_box.mixin.njk


public override void performLayout() {
if (this.child != null) {
this.child.layout(this.constraints, true);
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
} else {
this.performResize();

public override void applyPaintTransform(RenderObject child, Matrix4x4 transform) {
public override void applyPaintTransform(RenderObject child, ref Matrix4x4 transform) {
}
public override void paint(PaintingContext context, Offset offset) {

2
Assets/UIWidgets/rendering/sliver.cs


namespace UIWidgets.rendering {
public class SliverPhysicalParentData : ContainerParentDataMixin<RenderSliver> {
public class SliverPhysicalParentData : ContainerParentDataMixinParentData<RenderSliver> {
}
public class SliverPhysicalContainerParentData : SliverPhysicalParentData {

4
Assets/UIWidgets/rendering/view.cs


}
}
public override void applyPaintTransform(RenderObject child, Matrix4x4 transform) {
public override void applyPaintTransform(RenderObject child, ref Matrix4x4 transform) {
base.applyPaintTransform(child, transform);
base.applyPaintTransform(child, ref transform);
}
public void compositeFrame() {

17
Assets/UIWidgets/rendering/viewpoint.cs


public readonly Rect rect;
}
public abstract class RenderViewportBase<ParentDataClass> : ContainerRenderBox<RenderSliver, ParentDataClass>,
public abstract class RenderViewportBase<ParentDataClass> :
ContainerRenderObjectMixinRenderBox<RenderSliver, ParentDataClass>,
where ParentDataClass : ContainerParentDataMixin<RenderSliver> {
where ParentDataClass : ParentData, ContainerParentDataMixin<RenderSliver> {
protected RenderViewportBase(
AxisDirection crossAxisDirection,
ViewportOffset offset,

if (value == this._crossAxisDirection) {
return;
}
this._crossAxisDirection = value;
this.markNeedsLayout();
}

if (this.attached) {
this._offset.addListener(this.markNeedsLayout);
}
public ViewportOffset _offset;
public double cacheExtent {

this.markNeedsLayout();
}
}
public double _cacheExtent;
public override void attach(object owner) {

public class RenderViewport : RenderViewportBase<SliverPhysicalContainerParentData> {
public RenderViewport(AxisDirection crossAxisDirection, ViewportOffset offset, double cacheExtent = RenderAbstractViewportUtils.defaultCacheExtent, AxisDirection axisDirection = AxisDirection.down) : base(crossAxisDirection, offset, cacheExtent, axisDirection) {
public RenderViewport(AxisDirection crossAxisDirection, ViewportOffset offset,
double cacheExtent = RenderAbstractViewportUtils.defaultCacheExtent,
AxisDirection axisDirection = AxisDirection.down) : base(crossAxisDirection, offset, cacheExtent,
axisDirection) {
}
}
}

4
Assets/UIWidgets/ui/geometry.cs


return new Size(a.width + b.dx, a.height + b.dy);
}
public static Offset operator -(Size a, Size b) {
return new Offset(a.width - b.width, a.height - b.width);
}
public static Size operator *(Size a, double operand) {
return new Size(a.width * operand, a.height * operand);
}

5
Assets/UIWidgets/ui/painting/canvas_impl.cs


}
public CanvasImpl() {
this._transform = Matrix4x4.identity;
this._transform = Matrix4x4.Scale(new Vector3(
1.0f / EditorGUIUtility.pixelsPerPoint,
1.0f / EditorGUIUtility.pixelsPerPoint,
1.0f));
}
public void drawPloygon4(Offset[] points, Paint paint) {

5
Assets/UIWidgets/ui/text.cs


alphabetic,
ideographic,
}
public enum TextDirection {
rtl,
ltr,
}
}

73
Assets/UIWidgets/rendering/box.mixin.gen.cs


using System;
using System.Collections.Generic;
using UIWidgets.ui;
namespace UIWidgets.rendering {
public abstract class
RenderBoxContainerDefaultsMixinContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>
: ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType>
where ChildType : RenderBox
where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public double? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? result = child.getDistanceToActualBaseline(baseline);
if (result != null) {
return result.Value + childParentData.offset.dy;
}
child = childParentData.nextSibling;
}
return null;
}
public double? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
double? result = null;
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? candidate = child.getDistanceToActualBaseline(baseline);
if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
} else {
result = candidate;
}
}
child = childParentData.nextSibling;
}
return result;
}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);
child = childParentData.nextSibling;
}
}
public List<ChildType> getChildrenAsList() {
var result = new List<ChildType>();
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
result.Add(child);
child = childParentData.nextSibling;
}
return result;
}
}
}

11
Assets/UIWidgets/rendering/box.mixin.gen.cs.meta


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

74
Assets/UIWidgets/rendering/box.mixin.njk


using System;
using System.Collections.Generic;
using UIWidgets.ui;
namespace UIWidgets.rendering {
{% macro RenderBoxContainerDefaultsMixin(with) %}
public abstract class
RenderBoxContainerDefaultsMixin{{with}}<ChildType, ParentDataType>
: {{with}}<ChildType, ParentDataType>
where ChildType : RenderBox
where ParentDataType : ContainerParentDataMixinBoxParentData<ChildType> {
public double? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? result = child.getDistanceToActualBaseline(baseline);
if (result != null) {
return result.Value + childParentData.offset.dy;
}
child = childParentData.nextSibling;
}
return null;
}
public double? defaultComputeDistanceToHighestActualBaseline(TextBaseline baseline) {
double? result = null;
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
double? candidate = child.getDistanceToActualBaseline(baseline);
if (candidate != null) {
candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
} else {
result = candidate;
}
}
child = childParentData.nextSibling;
}
return result;
}
public void defaultPaint(PaintingContext context, Offset offset) {
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
context.paintChild(child, childParentData.offset + offset);
child = childParentData.nextSibling;
}
}
public List<ChildType> getChildrenAsList() {
var result = new List<ChildType>();
var child = this.firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
result.Add(child);
child = childParentData.nextSibling;
}
return result;
}
}
{% endmacro %}
{{ RenderBoxContainerDefaultsMixin('ContainerRenderObjectMixinRenderBox') }}
}

3
Assets/UIWidgets/rendering/box.mixin.njk.meta


fileFormatVersion: 2
guid: 936a3392b16d40d7b11ada65583df02d
timeCreated: 1535077168

594
Assets/UIWidgets/rendering/flex.cs


using System;
using System.Collections.Generic;
using UIWidgets.painting;
using UIWidgets.ui;
namespace UIWidgets.rendering {
public enum FlexFit {
tight,
loose,
}
public class FlexParentData : ContainerParentDataMixinBoxParentData<RenderBox> {
public int flex;
public FlexFit fit;
}
public enum MainAxisSize {
min,
max,
}
public enum MainAxisAlignment {
start,
end,
center,
spaceBetween,
spaceAround,
spaceEvenly,
}
public enum CrossAxisAlignment {
start,
end,
center,
stretch,
baseline,
}
public delegate double _ChildSizingFunction(RenderBox child, double extent);
public class RenderFlex : RenderBoxContainerDefaultsMixinContainerRenderObjectMixinRenderBox<RenderBox,
FlexParentData> {
public RenderFlex(
List<RenderBox> children = null,
Axis direction = Axis.horizontal,
MainAxisSize mainAxisSize = MainAxisSize.max,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection textDirection = TextDirection.ltr,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline textBaseline = TextBaseline.alphabetic
) {
this._direction = direction;
this._mainAxisAlignment = mainAxisAlignment;
this._mainAxisSize = mainAxisSize;
this._crossAxisAlignment = crossAxisAlignment;
this._textDirection = textDirection;
this._verticalDirection = verticalDirection;
this._textBaseline = textBaseline;
this.addAll(children);
}
public Axis direction {
get { return this._direction; }
set {
if (this._direction == value) {
return;
}
this._direction = value;
this.markNeedsLayout();
}
}
public Axis _direction;
public MainAxisSize mainAxisSize {
get { return this._mainAxisSize; }
set {
if (this._mainAxisSize == value) {
return;
}
this._mainAxisSize = value;
this.markNeedsLayout();
}
}
public MainAxisSize _mainAxisSize;
public MainAxisAlignment mainAxisAlignment {
get { return this._mainAxisAlignment; }
set {
if (this._mainAxisAlignment == value) {
return;
}
this._mainAxisAlignment = value;
this.markNeedsLayout();
}
}
public MainAxisAlignment _mainAxisAlignment;
public CrossAxisAlignment crossAxisAlignment {
get { return this._crossAxisAlignment; }
set {
if (this._crossAxisAlignment == value) {
return;
}
this._crossAxisAlignment = value;
this.markNeedsLayout();
}
}
public CrossAxisAlignment _crossAxisAlignment;
public TextDirection textDirection {
get { return this._textDirection; }
set {
if (this._textDirection == value) {
return;
}
this._textDirection = value;
this.markNeedsLayout();
}
}
public TextDirection _textDirection;
public VerticalDirection verticalDirection {
get { return this._verticalDirection; }
set {
if (this._verticalDirection == value) {
return;
}
this._verticalDirection = value;
this.markNeedsLayout();
}
}
public VerticalDirection _verticalDirection;
public TextBaseline textBaseline {
get { return this._textBaseline; }
set {
if (this._textBaseline == value) {
return;
}
this._textBaseline = value;
this.markNeedsLayout();
}
}
public TextBaseline _textBaseline;
public double _overflow;
public override void setupParentData(RenderObject child) {
if (!(child.parentData is FlexParentData)) {
child.parentData = new FlexParentData();
}
}
public double _getIntrinsicSize(
Axis sizingDirection,
double extent,
_ChildSizingFunction childSize
) {
if (this._direction == sizingDirection) {
double totalFlex = 0.0;
double inflexibleSpace = 0.0;
double maxFlexFractionSoFar = 0.0;
RenderBox child = this.firstChild;
while (child != null) {
int flex = this._getFlex(child);
totalFlex += flex;
if (flex > 0) {
double flexFraction = childSize(child, extent) / this._getFlex(child);
maxFlexFractionSoFar = Math.Max(maxFlexFractionSoFar, flexFraction);
} else {
inflexibleSpace += childSize(child, extent);
}
var childParentData = (FlexParentData) child.parentData;
child = childParentData.nextSibling;
}
return maxFlexFractionSoFar * totalFlex + inflexibleSpace;
} else {
double availableMainSpace = extent;
int totalFlex = 0;
double inflexibleSpace = 0.0;
double maxCrossSize = 0.0;
RenderBox child = this.firstChild;
while (child != null) {
int flex = this._getFlex(child);
totalFlex += flex;
if (flex == 0) {
double mainSize = 0.0;
double crossSize = 0.0;
switch (this._direction) {
case Axis.horizontal:
mainSize = child.getMaxIntrinsicWidth(double.PositiveInfinity);
crossSize = childSize(child, mainSize);
break;
case Axis.vertical:
mainSize = child.getMaxIntrinsicHeight(double.PositiveInfinity);
crossSize = childSize(child, mainSize);
break;
}
inflexibleSpace += mainSize;
maxCrossSize = Math.Max(maxCrossSize, crossSize);
}
var childParentData = (FlexParentData) child.parentData;
child = childParentData.nextSibling;
}
double spacePerFlex = Math.Max(0.0, (availableMainSpace - inflexibleSpace) / totalFlex);
child = this.firstChild;
while (child != null) {
int flex = this._getFlex(child);
if (flex > 0) {
maxCrossSize = Math.Max(maxCrossSize, childSize(child, spacePerFlex * flex));
}
var childParentData = (FlexParentData) child.parentData;
child = childParentData.nextSibling;
}
return maxCrossSize;
}
}
public override double computeMinIntrinsicWidth(double height) {
return this._getIntrinsicSize(
sizingDirection: Axis.horizontal,
extent: height,
childSize: (RenderBox child, double extent) => child.getMinIntrinsicWidth(extent)
);
}
public override double computeMaxIntrinsicWidth(double height) {
return this._getIntrinsicSize(
sizingDirection: Axis.horizontal,
extent: height,
childSize: (RenderBox child, double extent) => child.getMaxIntrinsicWidth(extent)
);
}
public override double computeMinIntrinsicHeight(double width) {
return this._getIntrinsicSize(
sizingDirection: Axis.vertical,
extent: width,
childSize: (RenderBox child, double extent) => child.getMinIntrinsicHeight(extent)
);
}
public override double computeMaxIntrinsicHeight(double width) {
return this._getIntrinsicSize(
sizingDirection: Axis.vertical,
extent: width,
childSize: (RenderBox child, double extent) => child.getMaxIntrinsicHeight(extent)
);
}
public override double? computeDistanceToActualBaseline(TextBaseline baseline) {
if (this._direction == Axis.horizontal) {
return this.defaultComputeDistanceToHighestActualBaseline(baseline);
}
return this.defaultComputeDistanceToFirstActualBaseline(baseline);
}
public int _getFlex(RenderBox child) {
var childParentData = (FlexParentData) child.parentData;
return childParentData.flex;
}
public FlexFit _getFit(RenderBox child) {
var childParentData = (FlexParentData) child.parentData;
return childParentData.fit;
}
public double _getCrossSize(RenderBox child) {
switch (this._direction) {
case Axis.horizontal:
return child.size.height;
case Axis.vertical:
return child.size.width;
}
return 0;
}
public double _getMainSize(RenderBox child) {
switch (this._direction) {
case Axis.horizontal:
return child.size.width;
case Axis.vertical:
return child.size.height;
}
return 0;
}
public override void performLayout() {
int totalFlex = 0;
int totalChildren = 0;
double maxMainSize = this._direction == Axis.horizontal
? this.constraints.maxWidth
: this.constraints.maxHeight;
bool canFlex = maxMainSize < double.PositiveInfinity;
double crossSize = 0.0;
double allocatedSize = 0.0;
RenderBox child = this.firstChild;
RenderBox lastFlexChild = null;
while (child != null) {
var childParentData = (FlexParentData) child.parentData;
totalChildren++;
int flex = this._getFlex(child);
if (flex > 0) {
totalFlex += childParentData.flex;
lastFlexChild = child;
} else {
BoxConstraints innerConstraints = null;
if (this.crossAxisAlignment == CrossAxisAlignment.stretch) {
switch (this._direction) {
case Axis.horizontal:
innerConstraints = new BoxConstraints(
minHeight: this.constraints.maxHeight,
maxHeight: this.constraints.maxHeight);
break;
case Axis.vertical:
innerConstraints = new BoxConstraints(
minWidth: this.constraints.maxWidth,
maxWidth: this.constraints.maxWidth);
break;
}
} else {
switch (this._direction) {
case Axis.horizontal:
innerConstraints = new BoxConstraints(
maxHeight: this.constraints.maxHeight);
break;
case Axis.vertical:
innerConstraints = new BoxConstraints(
maxWidth: this.constraints.maxWidth);
break;
}
}
child.layout(innerConstraints, parentUsesSize: true);
allocatedSize += this._getMainSize(child);
crossSize = Math.Max(crossSize, this._getCrossSize(child));
}
child = childParentData.nextSibling;
}
double freeSpace = Math.Max(0.0, (canFlex ? maxMainSize : 0.0) - allocatedSize);
double allocatedFlexSpace = 0.0;
double maxBaselineDistance = 0.0;
if (totalFlex > 0 || this.crossAxisAlignment == CrossAxisAlignment.baseline) {
double spacePerFlex = canFlex && totalFlex > 0 ? (freeSpace / totalFlex) : double.NaN;
child = this.firstChild;
while (child != null) {
int flex = this._getFlex(child);
if (flex > 0) {
double maxChildExtent = canFlex
? (child == lastFlexChild ? (freeSpace - allocatedFlexSpace) : spacePerFlex * flex)
: double.PositiveInfinity;
double minChildExtent = 0.0;
switch (this._getFit(child)) {
case FlexFit.tight:
minChildExtent = maxChildExtent;
break;
case FlexFit.loose:
minChildExtent = 0.0;
break;
}
BoxConstraints innerConstraints = null;
if (this.crossAxisAlignment == CrossAxisAlignment.stretch) {
switch (this._direction) {
case Axis.horizontal:
innerConstraints = new BoxConstraints(
minWidth: minChildExtent,
maxWidth: maxChildExtent,
minHeight: this.constraints.maxHeight,
maxHeight: this.constraints.maxHeight);
break;
case Axis.vertical:
innerConstraints = new BoxConstraints(
minWidth: this.constraints.maxWidth,
maxWidth: this.constraints.maxWidth,
minHeight: minChildExtent,
maxHeight: maxChildExtent);
break;
}
} else {
switch (this._direction) {
case Axis.horizontal:
innerConstraints = new BoxConstraints(
minWidth: minChildExtent,
maxWidth: maxChildExtent,
maxHeight: this.constraints.maxHeight);
break;
case Axis.vertical:
innerConstraints = new BoxConstraints(
maxWidth: this.constraints.maxWidth,
minHeight: minChildExtent,
maxHeight: maxChildExtent);
break;
}
}
child.layout(innerConstraints, parentUsesSize: true);
double childSize = this._getMainSize(child);
allocatedSize += childSize;
allocatedFlexSpace += maxChildExtent;
crossSize = Math.Max(crossSize, this._getCrossSize(child));
}
if (this.crossAxisAlignment == CrossAxisAlignment.baseline) {
double? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
if (distance != null) {
maxBaselineDistance = Math.Max(maxBaselineDistance, distance.Value);
}
}
var childParentData = (FlexParentData) child.parentData;
child = childParentData.nextSibling;
}
}
double idealSize = canFlex && this.mainAxisSize == MainAxisSize.max ? maxMainSize : allocatedSize;
double actualSize = 0.0;
double actualSizeDelta = 0.0;
switch (this._direction) {
case Axis.horizontal:
this.size = this.constraints.constrain(new Size(idealSize, crossSize));
actualSize = this.size.width;
crossSize = this.size.height;
break;
case Axis.vertical:
this.size = this.constraints.constrain(new Size(crossSize, idealSize));
actualSize = this.size.height;
crossSize = this.size.width;
break;
}
actualSizeDelta = actualSize - allocatedSize;
this._overflow = Math.Max(0.0, -actualSizeDelta);
double remainingSpace = Math.Max(0.0, actualSizeDelta);
double leadingSpace = 0.0;
double betweenSpace = 0.0;
bool flipMainAxis = !RenderFlex._startIsTopLeft(this.direction, this.textDirection, this.verticalDirection);
switch (this._mainAxisAlignment) {
case MainAxisAlignment.start:
leadingSpace = 0.0;
betweenSpace = 0.0;
break;
case MainAxisAlignment.end:
leadingSpace = remainingSpace;
betweenSpace = 0.0;
break;
case MainAxisAlignment.center:
leadingSpace = remainingSpace / 2.0;
betweenSpace = 0.0;
break;
case MainAxisAlignment.spaceBetween:
leadingSpace = 0.0;
betweenSpace = totalChildren > 1 ? remainingSpace / (totalChildren - 1) : 0.0;
break;
case MainAxisAlignment.spaceAround:
betweenSpace = totalChildren > 0 ? remainingSpace / totalChildren : 0.0;
leadingSpace = betweenSpace / 2.0;
break;
case MainAxisAlignment.spaceEvenly:
betweenSpace = totalChildren > 0 ? remainingSpace / (totalChildren + 1) : 0.0;
leadingSpace = betweenSpace;
break;
}
// Position elements
double childMainPosition = flipMainAxis ? actualSize - leadingSpace : leadingSpace;
child = this.firstChild;
while (child != null) {
var childParentData = (FlexParentData) child.parentData;
double childCrossPosition = 0.0;
switch (this._crossAxisAlignment) {
case CrossAxisAlignment.start:
case CrossAxisAlignment.end:
childCrossPosition =
RenderFlex._startIsTopLeft(
AxisUtils.flipAxis(this.direction), this.textDirection, this.verticalDirection)
== (this._crossAxisAlignment == CrossAxisAlignment.start)
? 0.0
: crossSize - this._getCrossSize(child);
break;
case CrossAxisAlignment.center:
childCrossPosition = crossSize / 2.0 - this._getCrossSize(child) / 2.0;
break;
case CrossAxisAlignment.stretch:
childCrossPosition = 0.0;
break;
case CrossAxisAlignment.baseline:
childCrossPosition = 0.0;
if (this._direction == Axis.horizontal) {
double? distance = child.getDistanceToBaseline(this.textBaseline, onlyReal: true);
if (distance != null) {
childCrossPosition = maxBaselineDistance - distance.Value;
}
}
break;
}
if (flipMainAxis) {
childMainPosition -= this._getMainSize(child);
}
switch (this._direction) {
case Axis.horizontal:
childParentData.offset = new Offset(childMainPosition, childCrossPosition);
break;
case Axis.vertical:
childParentData.offset = new Offset(childCrossPosition, childMainPosition);
break;
}
if (flipMainAxis) {
childMainPosition -= betweenSpace;
} else {
childMainPosition += this._getMainSize(child) + betweenSpace;
}
child = childParentData.nextSibling;
}
}
private static bool _startIsTopLeft(Axis direction, TextDirection textDirection,
VerticalDirection verticalDirection) {
switch (direction) {
case Axis.horizontal:
switch (textDirection) {
case TextDirection.ltr:
return true;
case TextDirection.rtl:
return false;
}
break;
case Axis.vertical:
switch (verticalDirection) {
case VerticalDirection.down:
return true;
case VerticalDirection.up:
return false;
}
break;
}
return true;
}
public override void paint(PaintingContext context, Offset offset) {
if (this._overflow <= 0.0) {
this.defaultPaint(context, offset);
return;
}
if (this.size.isEmpty)
return;
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, this.defaultPaint);
}
}
}

3
Assets/UIWidgets/rendering/flex.cs.meta


fileFormatVersion: 2
guid: a376f91ffd8d45e8a5af74f6f2f044b7
timeCreated: 1535074163

629
Assets/UIWidgets/rendering/shifted_box.cs


using System;
using UIWidgets.painting;
using UIWidgets.ui;
namespace UIWidgets.rendering {
public abstract class RenderShiftedBox : RenderObjectWithChildMixinRenderBox<RenderBox> {
protected RenderShiftedBox(RenderBox child) {
this.child = child;
}
public override double computeMinIntrinsicWidth(double height) {
if (this.child != null) {
return this.child.getMinIntrinsicWidth(height);
}
return 0.0;
}
public override double computeMaxIntrinsicWidth(double height) {
if (this.child != null) {
return this.child.getMaxIntrinsicWidth(height);
}
return 0.0;
}
public override double computeMinIntrinsicHeight(double width) {
if (this.child != null) {
return this.child.getMinIntrinsicHeight(width);
}
return 0.0;
}
public override double computeMaxIntrinsicHeight(double width) {
if (this.child != null) {
return this.child.getMaxIntrinsicHeight(width);
}
return 0.0;
}
public override double? computeDistanceToActualBaseline(TextBaseline baseline) {
double? result;
if (this.child != null) {
result = this.child.getDistanceToActualBaseline(baseline);
if (result != null) {
var childParentData = (BoxParentData) this.child.parentData;
result += childParentData.offset.dy;
}
} else {
result = base.computeDistanceToActualBaseline(baseline);
}
return result;
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
var childParentData = (BoxParentData) this.child.parentData;
context.paintChild(this.child, childParentData.offset + offset);
}
}
}
public class RenderPadding : RenderShiftedBox {
RenderPadding(
EdgeInsets padding = null,
RenderBox child = null
) : base(child) {
this._padding = padding;
}
public EdgeInsets padding {
get { return this._padding; }
set {
if (this._padding == value) {
return;
}
this._padding = value;
this.markNeedsLayout();
}
}
public EdgeInsets _padding;
public override double computeMinIntrinsicWidth(double height) {
if (this.child != null) {
return this.child.getMinIntrinsicWidth(Math.Max(0.0, height - this._padding.vertical)) +
this._padding.horizontal;
}
return this._padding.horizontal;
}
public override double computeMaxIntrinsicWidth(double height) {
if (this.child != null) {
return this.child.getMaxIntrinsicWidth(Math.Max(0.0, height - this._padding.vertical)) +
this._padding.horizontal;
}
return this._padding.horizontal;
}
public override double computeMinIntrinsicHeight(double width) {
if (this.child != null) {
return this.child.getMinIntrinsicHeight(Math.Max(0.0, width - this._padding.horizontal)) +
this._padding.vertical;
}
return this._padding.vertical;
}
public override double computeMaxIntrinsicHeight(double width) {
if (this.child != null) {
return this.child.getMaxIntrinsicHeight(Math.Max(0.0, width - this._padding.horizontal)) +
this._padding.vertical;
}
return this._padding.vertical;
}
public override void performLayout() {
if (this.child == null) {
this.size = this.constraints.constrain(this._padding.inflateSize(Size.zero));
return;
}
var innerConstraints = this.constraints.deflate(this._padding);
this.child.layout(innerConstraints, parentUsesSize: true);
var childParentData = (BoxParentData) this.child.parentData;
childParentData.offset = this._padding.topLeft;
this.size = this.constraints.constrain(this._padding.inflateSize(this.child.size));
}
}
public abstract class RenderAligningShiftedBox : RenderShiftedBox {
protected RenderAligningShiftedBox(
Alignment alignment = null,
RenderBox child = null
) : base(child) {
this._alignment = alignment ?? Alignment.center;
}
public Alignment alignment {
get { return this._alignment; }
set {
if (this._alignment == value) {
return;
}
this._alignment = value;
this.markNeedsLayout();
}
}
public Alignment _alignment;
protected void alignChild() {
var childParentData = (BoxParentData) this.child.parentData;
childParentData.offset = this._alignment.alongOffset(this.size - this.child.size);
}
}
public class RenderPositionedBox : RenderAligningShiftedBox {
public RenderPositionedBox(
RenderBox child = null,
double? widthFactor = null,
double? heightFactor = null,
Alignment alignment = null
) : base(alignment, child) {
this._widthFactor = widthFactor;
this._heightFactor = heightFactor;
}
public double? widthFactor {
get { return this._widthFactor; }
set {
if (this._widthFactor == value) {
return;
}
this._widthFactor = value;
this.markNeedsLayout();
}
}
public double? _widthFactor;
public double? heightFactor {
get { return this._heightFactor; }
set {
if (this._heightFactor == value) {
return;
}
this._heightFactor = value;
this.markNeedsLayout();
}
}
public double? _heightFactor;
public override void performLayout() {
bool shrinkWrapWidth = this._widthFactor != null || double.IsPositiveInfinity(this.constraints.maxWidth);
bool shrinkWrapHeight = this._heightFactor != null || double.IsPositiveInfinity(this.constraints.maxHeight);
if (this.child != null) {
this.child.layout(this.constraints.loosen(), parentUsesSize: true);
this.size = this.constraints.constrain(new Size(
shrinkWrapWidth ? this.child.size.width * (this._widthFactor ?? 1.0) : double.PositiveInfinity,
shrinkWrapHeight ? this.child.size.height * (this._heightFactor ?? 1.0) : double.PositiveInfinity));
this.alignChild();
} else {
this.size = this.constraints.constrain(new Size(
shrinkWrapWidth ? 0.0 : double.PositiveInfinity,
shrinkWrapHeight ? 0.0 : double.PositiveInfinity));
}
}
}
public class RenderConstrainedOverflowBox : RenderAligningShiftedBox {
public RenderConstrainedOverflowBox(
RenderBox child = null,
double? minWidth = null,
double? maxWidth = null,
double? minHeight = null,
double? maxHeight = null,
Alignment alignment = null
) : base(alignment, child) {
this._minWidth = minWidth;
this._maxWidth = maxWidth;
this._minHeight = minHeight;
this._maxHeight = maxHeight;
}
public double? minWidth {
get { return this._minWidth; }
set {
if (this._minWidth == value) {
return;
}
this._minWidth = value;
this.markNeedsLayout();
}
}
public double? _minWidth;
public double? maxWidth {
get { return this._maxWidth; }
set {
if (this._maxWidth == value) {
return;
}
this._maxWidth = value;
this.markNeedsLayout();
}
}
public double? _maxWidth;
public double? minHeight {
get { return this._minHeight; }
set {
if (this._minHeight == value) {
return;
}
this._minHeight = value;
this.markNeedsLayout();
}
}
public double? _minHeight;
public double? maxHeight {
get { return this._maxHeight; }
set {
if (this._maxHeight == value) {
return;
}
this._maxHeight = value;
this.markNeedsLayout();
}
}
public double? _maxHeight;
public BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
return new BoxConstraints(
minWidth: this._minWidth ?? constraints.minWidth,
maxWidth: this._maxWidth ?? constraints.maxWidth,
minHeight: this._minHeight ?? constraints.minHeight,
maxHeight: this._maxHeight ?? constraints.maxHeight
);
}
public override bool sizedByParent {
get { return true; }
}
public override void performResize() {
this.size = this.constraints.biggest;
}
public override void performLayout() {
if (this.child != null) {
this.child.layout(this._getInnerConstraints(this.constraints), parentUsesSize: true);
this.alignChild();
}
}
}
public class RenderUnconstrainedBox : RenderAligningShiftedBox {
public RenderUnconstrainedBox(
Alignment alignment = null,
Axis? constrainedAxis = null,
RenderBox child = null
) : base(alignment, child) {
this._constrainedAxis = constrainedAxis;
}
public Axis? constrainedAxis {
get { return this._constrainedAxis; }
set {
if (this._constrainedAxis == value) {
return;
}
this._constrainedAxis = value;
this.markNeedsLayout();
}
}
public Axis? _constrainedAxis;
public Rect _overflowContainerRect = Rect.zero;
public Rect _overflowChildRect = Rect.zero;
public bool _isOverflowing = false;
public override void performLayout() {
if (this.child != null) {
BoxConstraints childConstraints = null;
if (this.constrainedAxis != null) {
switch (this.constrainedAxis) {
case Axis.horizontal:
childConstraints = new BoxConstraints(
maxWidth: this.constraints.maxWidth,
minWidth: this.constraints.minWidth);
break;
case Axis.vertical:
childConstraints = new BoxConstraints(
maxHeight: this.constraints.maxHeight,
minHeight: this.constraints.minHeight);
break;
}
} else {
childConstraints = new BoxConstraints();
}
this.child.layout(childConstraints, parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
this.alignChild();
var childParentData = (BoxParentData) child.parentData;
this._overflowContainerRect = Offset.zero & this.size;
this._overflowChildRect = childParentData.offset & this.child.size;
} else {
this.size = this.constraints.smallest;
this._overflowContainerRect = Rect.zero;
this._overflowChildRect = Rect.zero;
}
this._isOverflowing = RelativeRect.fromRect(
this._overflowContainerRect, this._overflowChildRect).hasInsets;
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child == null || this.size.isEmpty) {
return;
}
if (!this._isOverflowing) {
base.paint(context, offset);
return;
}
context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, base.paint);
}
}
public class RenderSizedOverflowBox : RenderAligningShiftedBox {
public RenderSizedOverflowBox(
RenderBox child = null,
Size requestedSize = null,
Alignment alignment = null
) : base(alignment, child) {
this._requestedSize = requestedSize;
}
public Size requestedSize {
get { return this._requestedSize; }
set {
if (this._requestedSize == value) {
return;
}
this._requestedSize = value;
this.markNeedsLayout();
}
}
public Size _requestedSize;
public override double computeMinIntrinsicWidth(double height) {
return this._requestedSize.width;
}
public override double computeMaxIntrinsicWidth(double height) {
return this._requestedSize.width;
}
public override double computeMinIntrinsicHeight(double width) {
return this._requestedSize.height;
}
public override double computeMaxIntrinsicHeight(double width) {
return this._requestedSize.height;
}
public override double? computeDistanceToActualBaseline(TextBaseline baseline) {
if (this.child != null) {
return this.child.getDistanceToActualBaseline(baseline);
}
return base.computeDistanceToActualBaseline(baseline);
}
public override void performLayout() {
this.size = this.constraints.constrain(this._requestedSize);
if (this.child != null) {
this.child.layout(this.constraints);
this.alignChild();
}
}
}
public class RenderFractionallySizedOverflowBox : RenderAligningShiftedBox {
public RenderFractionallySizedOverflowBox(
RenderBox child = null,
double? widthFactor = null,
double? heightFactor = null,
Alignment alignment = null
) : base(alignment, child) {
this._widthFactor = widthFactor;
this._heightFactor = heightFactor;
}
public double? widthFactor {
get { return this._widthFactor; }
set {
if (this._widthFactor != value) {
return;
}
this._widthFactor = value;
this.markNeedsLayout();
}
}
public double? _widthFactor;
public double? heightFactor {
get { return this._heightFactor; }
set {
if (this._heightFactor != value) {
return;
}
this._heightFactor = value;
this.markNeedsLayout();
}
}
public double? _heightFactor;
public BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
double minWidth = constraints.minWidth;
double maxWidth = constraints.maxWidth;
if (this._widthFactor != null) {
double width = maxWidth * this._widthFactor.Value;
minWidth = width;
maxWidth = width;
}
double minHeight = constraints.minHeight;
double maxHeight = constraints.maxHeight;
if (this._heightFactor != null) {
double height = maxHeight * this._heightFactor.Value;
minHeight = height;
maxHeight = height;
}
return new BoxConstraints(
minWidth: minWidth,
maxWidth: maxWidth,
minHeight: minHeight,
maxHeight: maxHeight
);
}
public override double computeMinIntrinsicWidth(double height) {
double result;
if (this.child == null) {
result = base.computeMinIntrinsicWidth(height);
} else {
result = this.child.getMinIntrinsicWidth(height * (this._heightFactor ?? 1.0));
}
return result / (this._widthFactor ?? 1.0);
}
public override double computeMaxIntrinsicWidth(double height) {
double result;
if (this.child == null) {
result = base.computeMaxIntrinsicWidth(height);
} else {
result = this.child.getMaxIntrinsicWidth(height * (this._heightFactor ?? 1.0));
}
return result / (this._widthFactor ?? 1.0);
}
public override double computeMinIntrinsicHeight(double width) {
double result;
if (this.child == null) {
result = base.computeMinIntrinsicHeight(width);
} else {
result = this.child.getMinIntrinsicHeight(width * (this._widthFactor ?? 1.0));
}
return result / (this._heightFactor ?? 1.0);
}
public override double computeMaxIntrinsicHeight(double width) {
double result;
if (this.child == null) {
result = base.computeMaxIntrinsicHeight(width);
} else {
result = this.child.getMaxIntrinsicHeight(width * (this._widthFactor ?? 1.0));
}
return result / (this._heightFactor ?? 1.0);
}
public override void performLayout() {
if (this.child != null) {
this.child.layout(this._getInnerConstraints(this.constraints), parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
this.alignChild();
} else {
this.size = this.constraints.constrain(
this._getInnerConstraints(this.constraints).constrain(Size.zero));
}
}
}
public class RenderBaseline : RenderShiftedBox {
public RenderBaseline(
RenderBox child = null,
double baseline = 0.0,
TextBaseline baselineType = TextBaseline.alphabetic
) : base(child) {
this._baseline = baseline;
this._baselineType = baselineType;
}
public double baseline {
get { return this._baseline; }
set {
if (this._baseline != value) {
return;
}
this._baseline = value;
this.markNeedsLayout();
}
}
public double _baseline;
public TextBaseline baselineType {
get { return this._baselineType; }
set {
if (this._baselineType != value) {
return;
}
this._baselineType = value;
this.markNeedsLayout();
}
}
public TextBaseline _baselineType;
public override void performLayout() {
if (this.child != null) {
this.child.layout(this.constraints.loosen(), parentUsesSize: true);
double? childBaseline = this.child.getDistanceToBaseline(this.baselineType);
double actualBaseline = this.baseline;
double top = actualBaseline - childBaseline.Value;
var childParentData = (BoxParentData) child.parentData;
childParentData.offset = new Offset(0.0, top);
Size childSize = this.child.size;
this.size = this.constraints.constrain(new Size(childSize.width, top + childSize.height));
} else {
this.performResize();
}
}
}
}

3
Assets/UIWidgets/rendering/shifted_box.cs.meta


fileFormatVersion: 2
guid: 44ca0b36c9844abfbed7a60e76c5391e
timeCreated: 1535007022

124
Assets/UIWidgets/rendering/stack.cs


using System;
using UIWidgets.ui;
namespace UIWidgets.rendering {
public class RelativeRect : IEquatable<RelativeRect> {
private RelativeRect(double left, double top, double right, double bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public readonly double left;
public readonly double top;
public readonly double right;
public readonly double bottom;
public static RelativeRect fromLTRB(double left, double top, double right, double bottom) {
return new RelativeRect(left, top, right, bottom);
}
public static RelativeRect fromSize(Rect rect, Size container) {
return new RelativeRect(
rect.left,
rect.top,
container.width - rect.right,
container.height - rect.bottom);
}
public static RelativeRect fromRect(Rect rect, Rect container) {
return RelativeRect.fromLTRB(
rect.left - container.left,
rect.top - container.top,
container.right - rect.right,
container.bottom - rect.bottom
);
}
public static readonly RelativeRect fill = RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0);
public bool hasInsets {
get { return this.left > 0.0 || this.top > 0.0 || this.right > 0.0 || this.bottom > 0.0; }
}
public RelativeRect shift(Offset offset) {
return RelativeRect.fromLTRB(
this.left + offset.dx,
this.top + offset.dy,
this.right - offset.dx,
this.bottom - offset.dy);
}
public RelativeRect inflate(double delta) {
return RelativeRect.fromLTRB(
this.left - delta,
this.top - delta,
this.right - delta,
this.bottom - delta);
}
public RelativeRect deflate(double delta) {
return this.inflate(-delta);
}
public RelativeRect intersect(RelativeRect other) {
return RelativeRect.fromLTRB(
Math.Max(this.left, other.left),
Math.Max(this.top, other.top),
Math.Max(this.right, other.right),
Math.Max(this.bottom, other.bottom)
);
}
public Rect toRect(Rect container) {
return Rect.fromLTRB(
this.left + container.left,
this.top + container.top,
container.right - this.right,
container.bottom - this.bottom);
}
public Rect toSize(Size container) {
return Rect.fromLTRB(
this.left,
this.top,
container.width - this.right,
container.height - this.bottom);
}
public bool Equals(RelativeRect other) {
if (object.ReferenceEquals(null, other)) return false;
if (object.ReferenceEquals(this, other)) return true;
return this.left.Equals(other.left)
&& this.top.Equals(other.top)
&& this.right.Equals(other.right)
&& this.bottom.Equals(other.bottom);
}
public override bool Equals(object obj) {
if (object.ReferenceEquals(null, obj)) return false;
if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((RelativeRect) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.left.GetHashCode();
hashCode = (hashCode * 397) ^ this.top.GetHashCode();
hashCode = (hashCode * 397) ^ this.right.GetHashCode();
hashCode = (hashCode * 397) ^ this.bottom.GetHashCode();
return hashCode;
}
}
public static bool operator ==(RelativeRect a, RelativeRect b) {
return object.Equals(a, b);
}
public static bool operator !=(RelativeRect a, RelativeRect b) {
return !(a == b);
}
}
}

3
Assets/UIWidgets/rendering/stack.cs.meta


fileFormatVersion: 2
guid: cb21eea13f0f4663bdcf7d8679d90133
timeCreated: 1535009723
正在加载...
取消
保存