浏览代码

fix container.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
52f29042
共有 2 个文件被更改,包括 109 次插入5 次删除
  1. 57
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  2. 57
      com.unity.uiwidgets/Runtime/widgets/container.cs

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


return builder(context);
}
}
public class ColoredBox : SingleChildRenderObjectWidget {
/// Creates a widget that paints its area with the specified [Color].
///
/// The [color] parameter must not be null.
public ColoredBox(Color color = null, Widget child = null, Key key = null) : base(key: key, child: child) {
D.assert(color != null);
}
/// The color to paint the background area with.
public readonly Color color;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderColoredBox(color: color);
}
public void updateRenderObject(BuildContext context, _RenderColoredBox renderObject) {
renderObject.color = color;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Color>("color", color));
}
}
public class _RenderColoredBox : RenderProxyBoxWithHitTestBehavior {
public _RenderColoredBox(Color color = null)
: base(behavior: HitTestBehavior.opaque) {
_color = color;
}
public Color color {
get { return _color; }
set {
D.assert(value != null);
if (value == _color) {
return;
}
_color = value;
markNeedsPaint();
}
}
Color _color;
public override void paint(PaintingContext context, Offset offset) {
if (size > Size.zero) {
Paint paint = new Paint();
paint.color = color;
context.canvas.drawRect(offset & size, paint);
}
if (child != null) {
context.paintChild(child, offset);
}
}
}
}

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


BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix4 transfrom = null,
Widget child = null
) : base(key) {
Widget child = null,
Clip clipBehavior = Clip.none
) : base(key: key) {
D.assert(margin == null || margin.isNonNegative);
D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());

"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."
);
D.assert(clipBehavior != null);
this.alignment = alignment;
this.padding = padding;
foregroundDecoration = forgroundDecoration;

this.color = color;
this.clipBehavior = clipBehavior;
}
public readonly Widget child;

public readonly BoxConstraints constraints;
public readonly EdgeInsets margin;
public readonly Matrix4 transform;
public readonly Color color;
public readonly Clip clipBehavior;
EdgeInsets _paddingIncludingDecoration {
get {

current = new Padding(padding: effetivePadding, child: current);
}
if (color != null)
current = new ColoredBox(color: color, child: current);
if (decoration != null) {
current = new DecoratedBox(decoration: decoration, child: current);
}

current = new Transform(transform: new Matrix4(transform), child: current);
}
if (clipBehavior != Clip.none) {
current = new ClipPath(
clipper: new _DecorationClipper(
textDirection: Directionality.of(context),
decoration: decoration
),
clipBehavior: clipBehavior,
child: current
);
}
return current;
}

alignment, showName: false, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding",
padding, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Decoration>("bg",
properties.add(new DiagnosticsProperty<Clip>("clipBehavior", clipBehavior, defaultValue: Clip.none));
if (color != null)
properties.add(new DiagnosticsProperty<Color>("bg", color));
else
properties.add(new DiagnosticsProperty<Decoration>("bg",
decoration, defaultValue: foundation_.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Decoration>("fg",
foregroundDecoration, defaultValue: foundation_.kNullDefaultValue));

margin, defaultValue: foundation_.kNullDefaultValue));
properties.add(ObjectFlagProperty<Matrix4>.has("transform",
transform));
}
}
/// A clipper that uses [Decoration.getClipPath] to clip.
public class _DecorationClipper : CustomClipper<Path> {
public _DecorationClipper(
TextDirection textDirection = TextDirection.rtl,
Decoration decoration = null
) {
D.assert(decoration != null);
textDirection = TextDirection.ltr;
}
public readonly TextDirection textDirection;
public readonly Decoration decoration;
public override Path getClip(Size size) {
return decoration.getClipPath(Offset.zero & size, textDirection);
}
public override bool shouldReclip(CustomClipper<Path> oldClipper) {
return ((_DecorationClipper)oldClipper).decoration != decoration
|| ((_DecorationClipper)oldClipper).textDirection != textDirection;
}
}
}
正在加载...
取消
保存