gewentao
6 年前
当前提交
562e0b71
共有 9 个文件被更改,包括 471 次插入 和 10 次删除
-
2Assets/UIWidgets/rendering/error.cs
-
2Assets/UIWidgets/rendering/object.cs
-
129Assets/UIWidgets/rendering/proxy_box.cs
-
197Assets/UIWidgets/widgets/basic.cs
-
3Assets/UIWidgets/widgets/binding.cs
-
3Assets/UIWidgets/widgets/framework.cs
-
6Assets/UIWidgets/widgets/image.cs
-
136Assets/UIWidgets/widgets/container.cs
-
3Assets/UIWidgets/widgets/container.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.painting; |
|||
using UnityEngine; |
|||
using Color = UIWidgets.ui.Color; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public class DecoratedBox : SingleChildRenderObjectWidget { |
|||
public DecoratedBox( |
|||
Decoration decoration, |
|||
Widget child, |
|||
string key = null, |
|||
DecorationPosition position = DecorationPosition.background |
|||
) : base(key, child) { |
|||
this.position = position; |
|||
this.decoration = decoration; |
|||
} |
|||
|
|||
public Decoration decoration; |
|||
|
|||
public DecorationPosition position; |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderDecoratedBox( |
|||
decoration: decoration, |
|||
position: position, |
|||
configuration: ImageUtil.createLocalImageConfiguration(context) |
|||
); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
((RenderDecoratedBox) renderObject).decoration = decoration; |
|||
((RenderDecoratedBox) renderObject).configuration = ImageUtil.createLocalImageConfiguration(context); |
|||
((RenderDecoratedBox) renderObject).position = position; |
|||
} |
|||
} |
|||
|
|||
public class Container : StatelessWidget { |
|||
public Container( |
|||
string key, |
|||
Alignment alignment, |
|||
EdgeInsets padding, |
|||
Color color, |
|||
Decoration decoration, |
|||
Decoration forgroundDecoration, |
|||
double width, |
|||
double height, |
|||
BoxConstraints constraints, |
|||
EdgeInsets margin, |
|||
Matrix4x4 transfrom, |
|||
Widget child |
|||
) : base(key) { |
|||
this.alignment = alignment; |
|||
this.foregroundDecoration = forgroundDecoration; |
|||
this.transform = transfrom; |
|||
this.margin = margin; |
|||
this.child = child; |
|||
this.padding = padding; |
|||
|
|||
this.decoration = decoration ?? (color != null ? new BoxDecoration(color) : null); |
|||
this.constraints = (width != 0.0 || height != 0.0) |
|||
? ((constraints == null ? null : constraints.tighten(width, height)) |
|||
?? BoxConstraints.tightFor(width, height)) |
|||
: constraints; |
|||
} |
|||
|
|||
public Widget child; |
|||
public Alignment alignment; |
|||
public EdgeInsets padding; |
|||
public Decoration decoration; |
|||
public Decoration foregroundDecoration; |
|||
public BoxConstraints constraints; |
|||
public EdgeInsets margin; |
|||
public Matrix4x4 transform; |
|||
|
|||
EdgeInsets _paddingIncludingDecoration { |
|||
get { |
|||
if (decoration == null || decoration.padding == null) |
|||
return padding; |
|||
EdgeInsets decorationPadding = decoration.padding; |
|||
if (padding == null) |
|||
return decorationPadding; |
|||
return padding.add(decorationPadding); |
|||
} |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget current = child; |
|||
|
|||
if (child == null && (constraints == null || !constraints.isTight)) { |
|||
current = new LimitedBox( |
|||
maxWidth: 0.0, |
|||
maxHeight: 0.0, |
|||
child: new ConstrainedBox(constraints: BoxConstraints.expand()) |
|||
); |
|||
} |
|||
|
|||
if (alignment != null) { |
|||
current = new Align(alignment: alignment, child: current); |
|||
} |
|||
|
|||
EdgeInsets effetivePadding = _paddingIncludingDecoration; |
|||
if (effetivePadding != null) { |
|||
current = new Padding(padding: effetivePadding, child: current); |
|||
} |
|||
|
|||
if (decoration != null) { |
|||
current = new DecoratedBox(decoration: decoration, child: current); |
|||
} |
|||
|
|||
if (foregroundDecoration != null) { |
|||
current = new DecoratedBox( |
|||
decoration: decoration, |
|||
position: DecorationPosition.foreground, |
|||
child: current |
|||
); |
|||
} |
|||
|
|||
if (constraints != null) { |
|||
current = new ConstrainedBox(constraints: constraints, child: current); |
|||
} |
|||
|
|||
if (margin != null) { |
|||
current = new Padding(padding: margin, child: current); |
|||
} |
|||
|
|||
if (transform != null) { |
|||
current = new Transform(transform: transform, child: current); |
|||
} |
|||
|
|||
return current; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c96e4ace3a14122bc2107afe55771da |
|||
timeCreated: 1536831109 |
撰写
预览
正在加载...
取消
保存
Reference in new issue