浏览代码

some updates.

/main
kg 6 年前
当前提交
0daf0fb5
共有 16 个文件被更改,包括 769 次插入181 次删除
  1. 2
      Assets/UIWidgets/painting/borders.cs
  2. 2
      Assets/UIWidgets/painting/box_border.cs
  3. 2
      Assets/UIWidgets/painting/box_decoration.cs
  4. 2
      Assets/UIWidgets/painting/decoration.cs
  5. 224
      Assets/UIWidgets/painting/edge_insets.cs
  6. 125
      Assets/UIWidgets/rendering/box.cs
  7. 4
      Assets/UIWidgets/rendering/object.cs
  8. 195
      Assets/UIWidgets/rendering/object.mixin.gen.cs
  9. 107
      Assets/UIWidgets/rendering/object.mixin.njk
  10. 145
      Assets/UIWidgets/rendering/proxy_box.cs
  11. 4
      Assets/UIWidgets/rendering/proxy_box.mixin.gen.cs
  12. 4
      Assets/UIWidgets/rendering/proxy_box.mixin.njk
  13. 4
      Assets/UIWidgets/rendering/view.cs
  14. 15
      Assets/UIWidgets/rendering/viewpoint.cs
  15. 112
      Assets/UIWidgets/painting/alignment.cs
  16. 3
      Assets/UIWidgets/painting/alignment.cs.meta

2
Assets/UIWidgets/painting/borders.cs


namespace UIWidgets.painting {
public abstract class ShapeBorder {
public abstract EdgeInsetsGeometry dimensions { get; }
public abstract EdgeInsets dimensions { get; }
}
}

2
Assets/UIWidgets/painting/box_border.cs


public readonly BorderSide left;
public override EdgeInsetsGeometry dimensions {
public override EdgeInsets dimensions {
get { return null; }
}

2
Assets/UIWidgets/painting/box_decoration.cs


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

2
Assets/UIWidgets/painting/decoration.cs


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

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);
}
}
}

125
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 loosen() {
return new BoxConstraints(
minWidth: 0.0,
maxWidth: this.maxWidth,
minHeight: 0.0,
maxHeight: this.maxHeight
);
}
public BoxConstraints enforce(BoxConstraints constraints) {
return new BoxConstraints(
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 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);

4
Assets/UIWidgets/rendering/object.cs


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;

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


namespace UIWidgets.rendering {
public abstract class ContainerRenderBox<ChildType, ParentDataType> : RenderBox
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);
}
}
}
public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox
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
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);
}
}
}
}

107
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('RenderBox') }}
{{ RenderObjectWithChildMixin('RenderObject') }}
public abstract class Container{{with}}<ChildType, ParentDataType> : {{with}}
public abstract class ContainerRenderObjectMixin{{with}}<ChildType, ParentDataType> : {{with}}
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') }}
}

145
Assets/UIWidgets/rendering/proxy_box.cs


foreground,
}
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) {

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() {

15
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>,
RenderAbstractViewport
where ParentDataClass : ContainerParentDataMixin<RenderSliver> {
protected RenderViewportBase(

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) {
}
}
}

112
Assets/UIWidgets/painting/alignment.cs


using System;
using UIWidgets.ui;
namespace UIWidgets.painting {
public class Alignment : IEquatable<Alignment> {
public Alignment(double x, double y) {
this.x = x;
this.y = y;
}
private readonly double x;
private 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);
public Alignment add(Alignment other) {
return this + other;
}
public static Alignment operator -(Alignment a, Alignment b) {
return new Alignment(a.x - b.x, a.y - b.y);
}
public static Alignment operator +(Alignment a, Alignment b) {
return new Alignment(a.x + b.x, a.y + b.y);
}
public static Alignment operator -(Alignment a) {
return new Alignment(-a.x, -a.y);
}
public static Alignment operator *(Alignment a, double b) {
return new Alignment(a.x * b, a.y * b);
}
public static Alignment operator /(Alignment a, double b) {
return new Alignment(a.x / b, a.y / b);
}
public static Alignment operator %(Alignment a, double b) {
return new Alignment(a.x % b, a.y % b);
}
public Offset alongOffset(Offset other) {
double centerX = other.dx / 2.0;
double centerY = other.dy / 2.0;
return new Offset(centerX + this.x * centerX, centerY + this.y * centerY);
}
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 Offset withinRect(Rect rect) {
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
);
}
Rect inscribe(Size size, Rect rect) {
double halfWidthDelta = (rect.width - size.width) / 2.0;
double halfHeightDelta = (rect.height - size.height) / 2.0;
return Rect.fromLTWH(
rect.left + halfWidthDelta + this.x * halfWidthDelta,
rect.top + halfHeightDelta + this.y * halfHeightDelta,
size.width,
size.height
);
}
public bool Equals(Alignment 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);
}
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((Alignment) obj);
}
public override int GetHashCode() {
unchecked {
return (this.x.GetHashCode() * 397) ^ this.y.GetHashCode();
}
}
public static bool operator ==(Alignment a, Alignment b) {
return object.Equals(a, b);
}
public static bool operator !=(Alignment a, Alignment b) {
return !(a == b);
}
}
}

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


fileFormatVersion: 2
guid: d34b191577d24c30b0fd2a99022b8a88
timeCreated: 1535002958
正在加载...
取消
保存