GitHub
6 年前
当前提交
7a2e9138
共有 12 个文件被更改,包括 700 次插入 和 29 次删除
-
2Assets/UIWidgets/rendering/object.cs
-
129Assets/UIWidgets/rendering/proxy_box.cs
-
7Assets/UIWidgets/ui/window.cs
-
197Assets/UIWidgets/widgets/basic.cs
-
162Assets/UIWidgets/widgets/binding.cs
-
14Assets/UIWidgets/widgets/image.cs
-
43Assets/UIWidgets/rendering/error.cs
-
3Assets/UIWidgets/rendering/error.cs.meta
-
136Assets/UIWidgets/widgets/container.cs
-
3Assets/UIWidgets/widgets/container.cs.meta
-
30Assets/UIWidgets/widgets/ticker_provider.cs
-
3Assets/UIWidgets/widgets/ticker_provider.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.gestures; |
|||
using UIWidgets.painting; |
|||
using UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Rect = UIWidgets.ui.Rect; |
|||
|
|||
namespace UIWidgets.rendering { |
|||
public class RenderErrorBox : RenderBox { |
|||
const string _kLine = "\n\n────────────────────\n\n"; |
|||
|
|||
public RenderErrorBox(string message = "") { |
|||
this.message = message; |
|||
if (message == "") return; |
|||
ui.ParagraphBuilder builder = new ui.ParagraphBuilder(paragraphStyle); |
|||
builder.pushStyle(textStyle); |
|||
builder.addText( |
|||
string.Format( |
|||
"{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}{17}{18}{19}{20}{21}{22}{23}", |
|||
message, _kLine, message, _kLine, message, _kLine, message, _kLine, message, _kLine, message, |
|||
_kLine, message, _kLine, message, _kLine, message, _kLine, message, _kLine, message, _kLine, |
|||
message, _kLine) |
|||
); |
|||
_paragraph = builder.build(); |
|||
} |
|||
|
|||
private string message; |
|||
ui.Paragraph _paragraph; |
|||
|
|||
static ui.TextStyle textStyle = new ui.TextStyle( |
|||
color: new ui.Color(0xFFFFFF66), |
|||
fontFamily: "monospace", |
|||
fontSize: 14.0, |
|||
fontWeight: FontWeight.w700 |
|||
); |
|||
|
|||
static ui.ParagraphStyle paragraphStyle = new ui.ParagraphStyle( |
|||
lineHeight: 1.0 |
|||
); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 64dfb38ea47d49c7b9f3d0debeee4409 |
|||
timeCreated: 1536819405 |
|
|||
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, |
|||
Key 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( |
|||
Key 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 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UIWidgets.foundation; |
|||
using UIWidgets.rendering; |
|||
using UIWidgets.ui; |
|||
using UnityEngine.Assertions; |
|||
|
|||
namespace UIWidgets.widgets { |
|||
public class TickerMode : InheritedWidget { |
|||
public TickerMode(Key key, bool enabled, Widget child) : base(key, child) { |
|||
this.enabled = enabled; |
|||
} |
|||
|
|||
public readonly bool enabled; |
|||
|
|||
public static bool of(BuildContext context) { |
|||
var widget = context.inheritFromWidgetOfExactType(typeof(TickerMode)); |
|||
return widget is TickerMode ? (widget as TickerMode).enabled : true; |
|||
} |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget oldWidget) { |
|||
return this.enabled != ((TickerMode)oldWidget).enabled; |
|||
} |
|||
|
|||
public override Element createElement() { |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: aa6922a60d7945ffb3b92dede5941836 |
|||
timeCreated: 1536807803 |
撰写
预览
正在加载...
取消
保存
Reference in new issue