gewentao
6 年前
当前提交
47d43193
共有 35 个文件被更改,包括 2797 次插入 和 432 次删除
-
73Assets/UIWidgets/Tests/RenderBoxes.cs
-
12Assets/UIWidgets/editor/editor_window.cs
-
252Assets/UIWidgets/painting/alignment.cs
-
6Assets/UIWidgets/painting/alignment.cs.meta
-
18Assets/UIWidgets/painting/basic_types.cs
-
68Assets/UIWidgets/painting/borders.cs
-
123Assets/UIWidgets/painting/box_border.cs
-
77Assets/UIWidgets/painting/box_decoration.cs
-
7Assets/UIWidgets/painting/box_shadow.cs
-
4Assets/UIWidgets/painting/decoration.cs
-
224Assets/UIWidgets/painting/edge_insets.cs
-
205Assets/UIWidgets/rendering/box.cs
-
30Assets/UIWidgets/rendering/image.cs
-
30Assets/UIWidgets/rendering/object.cs
-
251Assets/UIWidgets/rendering/object.mixin.gen.cs
-
140Assets/UIWidgets/rendering/object.mixin.njk
-
147Assets/UIWidgets/rendering/proxy_box.cs
-
4Assets/UIWidgets/rendering/proxy_box.mixin.gen.cs
-
4Assets/UIWidgets/rendering/proxy_box.mixin.njk
-
2Assets/UIWidgets/rendering/sliver.cs
-
4Assets/UIWidgets/rendering/view.cs
-
17Assets/UIWidgets/rendering/viewpoint.cs
-
4Assets/UIWidgets/ui/geometry.cs
-
5Assets/UIWidgets/ui/painting/canvas_impl.cs
-
5Assets/UIWidgets/ui/text.cs
-
73Assets/UIWidgets/rendering/box.mixin.gen.cs
-
11Assets/UIWidgets/rendering/box.mixin.gen.cs.meta
-
74Assets/UIWidgets/rendering/box.mixin.njk
-
3Assets/UIWidgets/rendering/box.mixin.njk.meta
-
594Assets/UIWidgets/rendering/flex.cs
-
3Assets/UIWidgets/rendering/flex.cs.meta
-
629Assets/UIWidgets/rendering/shifted_box.cs
-
3Assets/UIWidgets/rendering/shifted_box.cs.meta
-
124Assets/UIWidgets/rendering/stack.cs
-
3Assets/UIWidgets/rendering/stack.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 52b90656e86c4a39af38d0518a67f68b |
|||
timeCreated: 1534820611 |
|||
fileFormatVersion: 2 |
|||
guid: 52b90656e86c4a39af38d0518a67f68b |
|||
timeCreated: 1534820611 |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
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; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e3cc56d5c46c4172a60c42d39eab183 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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') }} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 936a3392b16d40d7b11ada65583df02d |
|||
timeCreated: 1535077168 |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a376f91ffd8d45e8a5af74f6f2f044b7 |
|||
timeCreated: 1535074163 |
|
|||
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(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 44ca0b36c9844abfbed7a60e76c5391e |
|||
timeCreated: 1535007022 |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cb21eea13f0f4663bdcf7d8679d90133 |
|||
timeCreated: 1535009723 |
撰写
预览
正在加载...
取消
保存
Reference in new issue