浏览代码

updates

/main
kg 6 年前
当前提交
79c3c83d
共有 40 个文件被更改,包括 871 次插入57 次删除
  1. 1
      Assets/UIWidgets/foundation/callback.cs
  2. 1
      Assets/UIWidgets/foundation/change_notifier.cs
  3. 2
      Assets/UIWidgets/painting/box_border.cs
  4. 14
      Assets/UIWidgets/painting/box_decoration.cs
  5. 8
      Assets/UIWidgets/rendering/layer.cs
  6. 13
      Assets/UIWidgets/rendering/object.cs
  7. 6
      Assets/UIWidgets/rendering/object.mixin.njk
  8. 5
      Assets/UIWidgets/rendering/proxy_box.cs
  9. 11
      Assets/UIWidgets/rendering/viewpoint.cs
  10. 35
      Assets/UIWidgets/ui/compositing.cs
  11. 31
      Assets/UIWidgets/ui/geometry.cs
  12. 72
      Assets/UIWidgets/ui/painting.cs
  13. 1
      Assets/UIWidgets/widgets/framework.cs
  14. 3
      Assets/UIWidgets/editor.meta
  15. 3
      Assets/UIWidgets/flow.meta
  16. 2
      Assets/UIWidgets/foundation/binding.cs
  17. 3
      Assets/UIWidgets/foundation/binding.cs.meta
  18. 68
      Assets/UIWidgets/rendering/binding.cs
  19. 3
      Assets/UIWidgets/rendering/binding.cs.meta
  20. 11
      Assets/UIWidgets/rendering/binding.gen.cs.meta
  21. 3
      Assets/UIWidgets/rendering/binding.njk
  22. 3
      Assets/UIWidgets/rendering/binding.njk.meta
  23. 113
      Assets/UIWidgets/rendering/view.cs
  24. 3
      Assets/UIWidgets/rendering/view.cs.meta
  25. 3
      Assets/UIWidgets/scheduler.meta
  26. 50
      Assets/UIWidgets/ui/window.cs
  27. 3
      Assets/UIWidgets/ui/window.cs.meta
  28. 100
      Assets/UIWidgets/editor/editor_window.cs
  29. 3
      Assets/UIWidgets/editor/editor_window.cs.meta
  30. 39
      Assets/UIWidgets/flow/container_layer.cs
  31. 3
      Assets/UIWidgets/flow/container_layer.cs.meta
  32. 35
      Assets/UIWidgets/flow/layer.cs
  33. 3
      Assets/UIWidgets/flow/layer.cs.meta
  34. 60
      Assets/UIWidgets/flow/layer_builder.cs
  35. 3
      Assets/UIWidgets/flow/layer_builder.cs.meta
  36. 208
      Assets/UIWidgets/scheduler/binding.cs
  37. 3
      Assets/UIWidgets/scheduler/binding.cs.meta

1
Assets/UIWidgets/foundation/callback.cs


namespace UIWidgets.foundation {
public delegate void VoidCallback();
}

1
Assets/UIWidgets/foundation/change_notifier.cs


using System;
using System.Collections.Generic;
using UIWidgets.ui;
using UnityEngine;
namespace UIWidgets.foundation {

2
Assets/UIWidgets/painting/box_border.cs


this.size = size;
}
public static readonly ImageConfiguration empty = new ImageConfiguration();
public ImageConfiguration copyWith(
Size size = null) {
return new ImageConfiguration(

14
Assets/UIWidgets/painting/box_decoration.cs


using System;
using System.Collections.Generic;
using UIWidgets.foundation;
using UIWidgets.ui;

public Paint _getBackgroundPaint(Rect rect) {
if (this._cachedBackgroundPaint == null) {
this._cachedBackgroundPaint = new Paint();
var paint = new Paint();
if (this._decoration.color != null) {
paint.color = this._decoration.color;
}
this._cachedBackgroundPaint = paint;
}
return this._cachedBackgroundPaint;

if (this._decoration.borderRadius == null) {
//canvas.drawRect(rect, paint);
} else {
//canvas.drawRRect(_decoration.borderRadius.resolve().toRRect(rect), paint);
}
canvas.drawRect(paint, rect, borderRadius: this._decoration.borderRadius);
}
public void _paintShadows(Canvas canvas, Rect rect) {

8
Assets/UIWidgets/rendering/layer.cs


using UIWidgets.foundation;
using UIWidgets.rendering;
using UnityEngine;
using Rect = UIWidgets.ui.Rect;
namespace UIWidgets.rendering {
public abstract class Layer : AbstractNode {

}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix4x4 transform, Offset offset = null) : base(offset) {
this._transform = transform;
}
public Matrix4x4 _transform;
}
public class OpacityLayer : ContainerLayer {

13
Assets/UIWidgets/rendering/object.cs


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using TMPro;
using UIWidgets.foundation;
using UIWidgets.ui;
using UnityEditor.Rendering;

}
public class PipelineOwner {
public PipelineOwner(VoidCallback onNeedVisualUpdate = null) {
public PipelineOwner(
RendererBinding binding = null,
VoidCallback onNeedVisualUpdate = null) {
this.binding = binding;
public readonly RendererBinding binding;
public readonly VoidCallback onNeedVisualUpdate;
public void requestVisualUpdate() {

var owner = (PipelineOwner) ownerObject;
base.attach(owner);
if (this._needsLayout && this._relayoutBoundary == null) {
if (this._needsLayout && this._relayoutBoundary != null) {
this._needsLayout = false;
this.markNeedsLayout();
}

}
}
public bool isRepaintBoundary {
public virtual bool isRepaintBoundary {
public bool alwaysNeedsCompositing {
public virtual bool alwaysNeedsCompositing {
get { return false; }
}

6
Assets/UIWidgets/rendering/object.mixin.njk


namespace UIWidgets.rendering {
{% macro ContainerRenderObjectMixin(with) %}
public class Container{{with}}<ChildType, ParentDataType> : {{with}}
public abstract class Container{{with}}<ChildType, ParentDataType> : {{with}}
where ChildType : RenderObject
where ParentDataType : ContainerParentDataMixin<ChildType> {
public int _childCount = 0;

}
}
public override void vivitChildren(RenderObjectVisitor visitor) {
public override void visitChildren(RenderObjectVisitor visitor) {
ChildType child = this._firstChild;
while (child != null) {
visitor(child);

{% endmacro %}
{{ RenderObjectWithChildMixin('RenderBox') }}
{{ RenderObjectWithChildMixin('RenderObject') }}
}

5
Assets/UIWidgets/rendering/proxy_box.cs


DecorationPosition position = DecorationPosition.background,
ImageConfiguration configuration = null,
RenderBox child = null
) {
) : base(child) {
this._decoration = decoration;
this._position = position;
this._configuration = configuration ?? ImageConfiguration.empty;
}
public BoxPainter _painter;

11
Assets/UIWidgets/rendering/viewpoint.cs


public override void detach() {
this._offset.removeListener(this.markNeedsLayout);
base.detach();
}
}
public RevealedOffset getOffsetToReveal(RenderObject target, double alignment, Rect rect = null) {
throw new System.NotImplementedException();
}
public RenderViewport(AxisDirection crossAxisDirection, ViewportOffset offset, double cacheExtent = RenderAbstractViewportUtils.defaultCacheExtent, AxisDirection axisDirection = AxisDirection.down) : base(crossAxisDirection, offset, cacheExtent, axisDirection) {
}
}
}

35
Assets/UIWidgets/ui/compositing.cs


namespace UIWidgets.ui {
using System;
using UIWidgets.flow;
using UnityEngine;
namespace UIWidgets.ui {
private readonly LayerBuilder _layerBuilder = new LayerBuilder();
public void pushTransform(Matrix4x4 matrix) {
this._layerBuilder.pushTransform(matrix);
}
this._layerBuilder.pushClipRect(rect);
this._layerBuilder.pushOpacity(alpha);
this._layerBuilder.pop();
this._layerBuilder.pushPicture(offset, picture);
}
public Scene build() {
return new Scene(this._layerBuilder.takeLayer());
}
}
public class Scene : IDisposable {
public Scene(Layer rootLayer) {
this._rootLayer = rootLayer;
}
private readonly Layer _rootLayer;
public Layer takeLayer() {
return this._rootLayer;
}
public void Dispose() {
}
}
}

31
Assets/UIWidgets/ui/geometry.cs


get { return this.width <= 0.0 || this.height <= 0.0; }
}
public static Size operator *(Size a, double operand) {
return new Size(a.width * operand, a.height * operand);
}
public static Size operator /(Size a, double operand) {
return new Size(a.width / operand, a.height / operand);
}
public double shortestSide {
get { return Math.Min(Math.Abs(this.width), Math.Abs(this.height)); }
}

public const double _giantScalar = 1.0E+9;
public static readonly Rect largest = Rect.fromLTRB(-_giantScalar, -_giantScalar, _giantScalar, _giantScalar);
public static readonly Rect largest =
Rect.fromLTRB(-Rect._giantScalar, -Rect._giantScalar, Rect._giantScalar, Rect._giantScalar);
public bool isInfinite {
get {

return Rect.fromLTRB(this.left - delta, this.top - delta, this.right + delta, this.bottom + delta);
}
public Rect intersect(Rect other) {
return Rect.fromLTRB(
Math.Max(this.left, other.left),
Math.Max(this.top, other.top),
Math.Min(this.right, other.right),
Math.Min(this.bottom, other.bottom)
);
}
public Rect expandToInclude(Rect other) {
return Rect.fromLTRB(
Math.Min(this.left, other.left),
Math.Min(this.top, other.top),
Math.Max(this.right, other.right),
Math.Max(this.bottom, other.bottom)
);
}
}
}
public bool Equals(Rect other) {
if (object.ReferenceEquals(null, other)) return false;

72
Assets/UIWidgets/ui/painting.cs


});
}
public void drawRect(Paint paint, Rect rect, BorderWidth borderWidth, BorderRadius borderRadius) {
public void drawRect(Paint paint, Rect rect, BorderWidth borderWidth = null, BorderRadius borderRadius = null) {
this.recorder.addDrawCmd(new drawRect {
color = paint.color,
rect = rect,

}
}
public class GUICanvas : Canvas {
static GUICanvas() {
GUICanvas.shadowMat = Resources.Load<Material>("UIWidgets_ShadowMat");
if (GUICanvas.shadowMat == null) {
throw new Exception("UIWidgets_ShadowShader not found");
}
}
public static readonly Material shadowMat;
public override void drawPloygon4(Paint paint, params Offset[] points) {
Vector3[] vectors = new Vector3 [points.Length];
for (int i = 0; i < points.Length; i++) {
vectors[i] = points[i].toVector();
}
Handles.DrawSolidRectangleWithOutline(vectors, paint.color.toColor(),
new UnityEngine.Color(0f, 0f, 0f, 0f));
}
public override void drawRect(Paint paint, Rect rect, BorderWidth borderWidth, BorderRadius borderRadius) {
GUI.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill, true, 0,
paint.color.toColor(), borderWidth.toVector(), borderRadius.toVector());
}
public override void drawRectShadow(Paint paint, Rect rect) {
GUICanvas.shadowMat.SetFloatArray("_Rect", new float[] {
(float) rect.left, (float) rect.top, (float) rect.width, (float) rect.height,
});
GUICanvas.shadowMat.SetFloat("_sigma", (float) paint.blurSigma);
Graphics.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture,
new UnityEngine.Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0, paint.color.toColor(), GUICanvas.shadowMat);
}
}
// public class GUICanvas : Canvas {
// static GUICanvas() {
// GUICanvas.shadowMat = Resources.Load<Material>("UIWidgets_ShadowMat");
// if (GUICanvas.shadowMat == null) {
// throw new Exception("UIWidgets_ShadowShader not found");
// }
// }
//
// public static readonly Material shadowMat;
//
// public override void drawPloygon4(Paint paint, params Offset[] points) {
// Vector3[] vectors = new Vector3 [points.Length];
// for (int i = 0; i < points.Length; i++) {
// vectors[i] = points[i].toVector();
// }
//
// Handles.DrawSolidRectangleWithOutline(vectors, paint.color.toColor(),
// new UnityEngine.Color(0f, 0f, 0f, 0f));
// }
//
// public override void drawRect(Paint paint, Rect rect, BorderWidth borderWidth, BorderRadius borderRadius) {
// GUI.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill, true, 0,
// paint.color.toColor(), borderWidth.toVector(), borderRadius.toVector());
// }
//
// public override void drawRectShadow(Paint paint, Rect rect) {
// GUICanvas.shadowMat.SetFloatArray("_Rect", new float[] {
// (float) rect.left, (float) rect.top, (float) rect.width, (float) rect.height,
// });
// GUICanvas.shadowMat.SetFloat("_sigma", (float) paint.blurSigma);
//
// Graphics.DrawTexture(rect.toRect(), EditorGUIUtility.whiteTexture,
// new UnityEngine.Rect(0.0f, 0.0f, 1f, 1f), 0, 0, 0, 0, paint.color.toColor(), GUICanvas.shadowMat);
// }
// }
}

1
Assets/UIWidgets/widgets/framework.cs


using System.Linq;
using UIWidgets.foundation;
using UIWidgets.rendering;
using UIWidgets.ui;
using UnityEngine.Assertions;
namespace UIWidgets.widgets {

3
Assets/UIWidgets/editor.meta


fileFormatVersion: 2
guid: 531a69a207e64172959ffbed66131560
timeCreated: 1534308241

3
Assets/UIWidgets/flow.meta


fileFormatVersion: 2
guid: e1056a6e2b8247cbaf7db24691b913ec
timeCreated: 1534389920

2
Assets/UIWidgets/foundation/binding.cs


namespace UIWidgets.foundation {
}

3
Assets/UIWidgets/foundation/binding.cs.meta


fileFormatVersion: 2
guid: 5d042465a280442e8c71335670cabc3a
timeCreated: 1534222421

68
Assets/UIWidgets/rendering/binding.cs


using System;
using UIWidgets.scheduler;
using UIWidgets.ui;
namespace UIWidgets.rendering {
public abstract class RendererBinding : SchedulerBinding {
public RendererBinding(Window window) : base(window) {
this._pipelineOwner = new PipelineOwner(
binding: this,
onNeedVisualUpdate: this.ensureVisualUpdate
);
window._onMetricsChanged = this.handleMetricsChanged;
this.initRenderView();
this.addPersistentFrameCallback(this._handlePersistentFrameCallback);
}
public void initRenderView() {
this.renderView = new RenderView(configuration: this.createViewConfiguration());
this.renderView.scheduleInitialFrame();
}
public PipelineOwner pipelineOwner {
get { return this._pipelineOwner; }
}
public PipelineOwner _pipelineOwner;
public RenderView renderView {
get { return (RenderView) this._pipelineOwner.rootNode; }
set { this._pipelineOwner.rootNode = value; }
}
public void handleMetricsChanged() {
this.renderView.configuration = this.createViewConfiguration();
this.scheduleForcedFrame();
}
public ViewConfiguration createViewConfiguration() {
var devicePixelRatio = this._window.devicePixelRatio;
return new ViewConfiguration(
size: this._window.physicalSize / devicePixelRatio,
devicePixelRatio: devicePixelRatio
);
}
public void _handlePersistentFrameCallback(TimeSpan timeStamp) {
this.drawFrame();
}
public void drawFrame() {
this.pipelineOwner.flushLayout();
this.pipelineOwner.flushCompositingBits();
this.pipelineOwner.flushPaint();
this.renderView.compositeFrame();
}
public void render(Scene scene) {
this._window.render(scene);
}
}
public class RendererBindingImpl : RendererBinding {
public RendererBindingImpl(Window window, RenderBox root) : base(window) {
this.renderView.child = root;
}
}
}

3
Assets/UIWidgets/rendering/binding.cs.meta


fileFormatVersion: 2
guid: 7c20610b6dd54a58a6735fadc317cb90
timeCreated: 1534222643

11
Assets/UIWidgets/rendering/binding.gen.cs.meta


fileFormatVersion: 2
guid: b8e36c63511f04dbf8d5ed86f144274d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/UIWidgets/rendering/binding.njk


namespace UIWidgets.rendering {
}

3
Assets/UIWidgets/rendering/binding.njk.meta


fileFormatVersion: 2
guid: 3c1a210c4c4b4354bba182d6903742cd
timeCreated: 1534222730

113
Assets/UIWidgets/rendering/view.cs


using System;
using UIWidgets.ui;
using UnityEngine;
using Rect = UIWidgets.ui.Rect;
namespace UIWidgets.rendering {
public class ViewConfiguration {
public ViewConfiguration(
Size size = null,
double devicePixelRatio = 1.0
) {
this.size = size ?? Size.zero;
this.devicePixelRatio = devicePixelRatio;
}
public readonly Size size;
public readonly double devicePixelRatio;
public Matrix4x4 toMatrix() {
return Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(
(float) this.devicePixelRatio, (float) this.devicePixelRatio, 1));
}
public override string ToString() {
return string.Format("${0} at ${1}x", this.size, this.devicePixelRatio);
}
}
public class RenderView : RenderObjectWithChildMixinRenderObject<RenderBox> {
public RenderView(
RenderBox child = null,
ViewConfiguration configuration = null) {
this.child = child;
this._configuration = configuration;
}
public Size size {
get { return this._size; }
}
public Size _size = Size.zero;
public ViewConfiguration configuration {
get { return this._configuration; }
set {
if (value == this._configuration) {
return;
}
this._configuration = value;
this.replaceRootLayer((OffsetLayer) this._updateMatricesAndCreateNewRootLayer());
this.markNeedsLayout();
}
}
public ViewConfiguration _configuration;
public void scheduleInitialFrame() {
this.scheduleInitialLayout();
this.scheduleInitialPaint((OffsetLayer) this._updateMatricesAndCreateNewRootLayer());
this.owner.requestVisualUpdate();
}
public Matrix4x4 _rootTransform;
public Layer _updateMatricesAndCreateNewRootLayer() {
this._rootTransform = this.configuration.toMatrix();
ContainerLayer rootLayer = new TransformLayer(transform: this._rootTransform);
rootLayer.attach(this);
return rootLayer;
}
public override void performResize() {
throw new NotImplementedException();
}
public override void performLayout() {
this._size = this.configuration.size;
if (this.child != null) {
this.child.layout(BoxConstraints.tight(this._size));
}
}
public override bool isRepaintBoundary {
get { return true; }
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
context.paintChild(this.child, offset);
}
}
public void applyPaintTransform(RenderBox child, Matrix4x4 transform) {
transform *= this._rootTransform;
base.applyPaintTransform(child, transform);
}
public void compositeFrame() {
var builder = new SceneBuilder();
this.layer.addToScene(builder, Offset.zero);
using (var scene = builder.build()) {
this.owner.binding.render(scene);
}
}
public override Rect paintBounds {
get { return Offset.zero & (this.size * this.configuration.devicePixelRatio); }
}
}
}

3
Assets/UIWidgets/rendering/view.cs.meta


fileFormatVersion: 2
guid: 92d5facf02ac421dbe319205bf049557
timeCreated: 1534220758

3
Assets/UIWidgets/scheduler.meta


fileFormatVersion: 2
guid: d1ea4ed01afa43fb82a5f5f549595271
timeCreated: 1534227201

50
Assets/UIWidgets/ui/window.cs


using System;
using UIWidgets.rendering;
using UIWidgets.widgets;
namespace UIWidgets.ui {
public delegate void VoidCallback();
public delegate void FrameCallback(TimeSpan duration);
public abstract class Window {
public double devicePixelRatio {
get { return this._devicePixelRatio; }
}
public double _devicePixelRatio = 1.0;
public Size physicalSize {
get { return this._physicalSize; }
}
public Size _physicalSize = Size.zero;
public VoidCallback onMetricsChanged {
get { return this._onMetricsChanged; }
set { this._onMetricsChanged = value; }
}
public VoidCallback _onMetricsChanged;
public FrameCallback onBeginFrame {
get { return this._onBeginFrame; }
set { this._onBeginFrame = value; }
}
public FrameCallback _onBeginFrame;
public VoidCallback onDrawFrame {
get { return this._onDrawFrame; }
set { this._onDrawFrame = value; }
}
public VoidCallback _onDrawFrame;
public abstract void scheduleFrame();
public abstract void render(Scene scene);
}
}

3
Assets/UIWidgets/ui/window.cs.meta


fileFormatVersion: 2
guid: 81bd1754231e433bb8db2424e0a0debd
timeCreated: 1534300726

100
Assets/UIWidgets/editor/editor_window.cs


using System;
using UIWidgets.flow;
using UIWidgets.rendering;
using UIWidgets.ui;
using UIWidgets.widgets;
using UnityEditor;
using UnityEngine;
using Rect = UnityEngine.Rect;
namespace UIWidgets.editor {
public class WindowAdapter : Window {
public WindowAdapter(EditorWindow editorWindow) {
this.editorWindow = editorWindow;
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint;
this._lastPosition = editorWindow.position;
this._physicalSize = new Size(this._lastPosition.width, this._lastPosition.height);
}
public EditorWindow editorWindow;
public Rect _lastPosition;
public readonly DateTime _epoch = DateTime.Now;
public void OnGUI() {
if (this.onBeginFrame != null) {
this.onBeginFrame(DateTime.Now - this._epoch);
}
if (this.onDrawFrame != null) {
this.onDrawFrame();
}
}
public void Update() {
bool dirty = false;
if (this._devicePixelRatio != EditorGUIUtility.pixelsPerPoint) {
this._devicePixelRatio = EditorGUIUtility.pixelsPerPoint;
dirty = true;
}
if (this._lastPosition != this.editorWindow.position) {
this._lastPosition = this.editorWindow.position;
this._physicalSize = new Size(this._lastPosition.width, this._lastPosition.height);
dirty = true;
}
if (dirty) {
if (this._onMetricsChanged != null) {
this._onMetricsChanged();
}
}
}
public override void scheduleFrame() {
if (this.editorWindow != null) {
this.editorWindow.Repaint();
}
}
public override void render(Scene scene) {
var layer = scene.takeLayer();
var prerollContext = new PrerollContext();
layer.preroll(prerollContext, Matrix4x4.identity);
var paintContext = new PaintContext();
layer.paint(paintContext);
}
}
public class EditorWindow : UnityEditor.EditorWindow {
protected virtual void OnGUI() {
if (this.windowAdapter != null) {
this.windowAdapter.OnGUI();
}
}
protected virtual void Update() {
if (this.windowAdapter != null) {
this.windowAdapter.Update();
}
}
protected virtual void Awake() {
this.windowAdapter = new WindowAdapter(this);
}
protected void OnDestroy() {
this.windowAdapter = null;
}
public WindowAdapter windowAdapter;
public void runWidget(Widget root) {
}
public void runRenderBox(RenderBox root) {
new RendererBindingImpl(this.windowAdapter, root);
}
}
}

3
Assets/UIWidgets/editor/editor_window.cs.meta


fileFormatVersion: 2
guid: e8cf046da18d4f6d97d5de766aea64e0
timeCreated: 1534308250

39
Assets/UIWidgets/flow/container_layer.cs


using System.Collections.Generic;
using UIWidgets.ui;
using Matrix4x4 = UnityEngine.Matrix4x4;
namespace UIWidgets.flow {
public abstract class ContainerLayer : Layer {
private readonly List<Layer> _layers = new List<Layer>();
public List<Layer> layers {
get { return this._layers; }
}
public void add(Layer layer) {
layer.parent = this;
this._layers.Add(layer);
}
public override void preroll(PrerollContext context, Matrix4x4 matrix) {
Rect childPaintBounds = Rect.zero;
this.prerollChildren(context, matrix, childPaintBounds);
this.paintBounds = childPaintBounds;
}
protected void prerollChildren(PrerollContext context, Matrix4x4 childMatrix, Rect childPaintBounds) {
foreach (var layer in this._layers) {
layer.preroll(context, childMatrix);
childPaintBounds.expandToInclude(layer.paintBounds);
}
}
protected void paintChildren(PaintContext context) {
foreach (var layer in this._layers) {
if (layer.needsPainting) {
layer.paint(context);
}
}
}
}
}

3
Assets/UIWidgets/flow/container_layer.cs.meta


fileFormatVersion: 2
guid: 54b9aa9fb9694d2a80843b7c14f4de09
timeCreated: 1534390038

35
Assets/UIWidgets/flow/layer.cs


using UnityEngine;
using Rect = UIWidgets.ui.Rect;
namespace UIWidgets.flow {
public class PrerollContext {
}
public class PaintContext {
}
public abstract class Layer {
private ContainerLayer _parent;
public ContainerLayer parent {
get { return this._parent; }
set { this._parent = value; }
}
private Rect _paintBounds;
public Rect paintBounds {
get { return this._paintBounds; }
set { this._paintBounds = value; }
}
public bool needsPainting {
get { return !this._paintBounds.isEmpty; }
}
public virtual void preroll(PrerollContext context, Matrix4x4 matrix) {
}
public abstract void paint(PaintContext context);
}
}

3
Assets/UIWidgets/flow/layer.cs.meta


fileFormatVersion: 2
guid: 523b29e94d694060871b6531d0a4f482
timeCreated: 1534389944

60
Assets/UIWidgets/flow/layer_builder.cs


using System.Collections.Generic;
using UIWidgets.ui;
using Matrix4x4 = UnityEngine.Matrix4x4;
namespace UIWidgets.flow {
public class LayerBuilder {
private ContainerLayer _rootLayer;
private ContainerLayer _currentLayer;
private readonly Stack<Rect> _cullRects = new Stack<Rect>();
public LayerBuilder() {
this._cullRects.Push(Rect.largest);
}
private void pushLayer(ContainerLayer layer, Rect cullRect) {
this._cullRects.Push(cullRect);
if (this._rootLayer == null) {
this._rootLayer = layer;
this._currentLayer = layer;
return;
}
if (this._currentLayer == null) {
return;
}
this._currentLayer.add(layer);
this._currentLayer = layer;
}
public Layer takeLayer() {
return this._rootLayer;
}
public void pop() {
if (this._currentLayer == null) {
return;
}
this._cullRects.Pop();
this._currentLayer = this._currentLayer.parent;
}
public void pushTransform(Matrix4x4 matrix) {
}
public void pushClipRect(Rect clipRect) {
}
public void pushOpacity(int alpha) {
}
public void pushPicture(Offset offset, Picture picture) {
}
}
}

3
Assets/UIWidgets/flow/layer_builder.cs.meta


fileFormatVersion: 2
guid: f7ca7d815141405a85b3a2de247eb1dc
timeCreated: 1534391496

208
Assets/UIWidgets/scheduler/binding.cs


using System;
using System.Collections.Generic;
using UIWidgets.ui;
using UnityEngine;
namespace UIWidgets.scheduler {
public enum SchedulerPhase {
idle,
transientCallbacks,
midFrameMicrotasks,
persistentCallbacks,
postFrameCallbacks,
}
public class _FrameCallbackEntry {
public _FrameCallbackEntry(FrameCallback callback, bool rescheduling = false) {
this.callback = callback;
}
public readonly FrameCallback callback;
}
public abstract class SchedulerBinding {
public SchedulerBinding(Window window) {
this._window = window;
window.onBeginFrame = this._handleBeginFrame;
window.onDrawFrame = this._handleDrawFrame;
}
public readonly Window _window;
public double timeDilation {
get { return this._timeDilation; }
set {
if (this._timeDilation == value) {
return;
}
this.resetEpoch();
this._timeDilation = value;
}
}
public double _timeDilation = 1.0;
public int _nextFrameCallbackId = 0;
public Dictionary<int, _FrameCallbackEntry> _transientCallbacks = new Dictionary<int, _FrameCallbackEntry>();
public HashSet<int> _removedIds = new HashSet<int>();
public int transientCallbackCount {
get { return this._transientCallbacks.Count; }
}
public int scheduleFrameCallback(FrameCallback callback, bool rescheduling = false) {
this.scheduleFrame();
this._nextFrameCallbackId += 1;
this._transientCallbacks[this._nextFrameCallbackId] =
new _FrameCallbackEntry(callback, rescheduling: rescheduling);
return this._nextFrameCallbackId;
}
public void cancelFrameCallbackWithId(int id) {
this._transientCallbacks.Remove(id);
this._removedIds.Add(id);
}
public readonly List<FrameCallback> _persistentCallbacks = new List<FrameCallback>();
public void addPersistentFrameCallback(FrameCallback callback) {
this._persistentCallbacks.Add(callback);
}
public readonly List<FrameCallback> _postFrameCallbacks = new List<FrameCallback>();
public void addPostFrameCallback(FrameCallback callback) {
this._postFrameCallbacks.Add(callback);
}
public bool hasScheduledFrame {
get { return this._hasScheduledFrame; }
}
public bool _hasScheduledFrame = false;
public SchedulerPhase schedulerPhase {
get { return this._schedulerPhase; }
}
public SchedulerPhase _schedulerPhase = SchedulerPhase.idle;
public void ensureVisualUpdate() {
switch (this.schedulerPhase) {
case SchedulerPhase.idle:
case SchedulerPhase.postFrameCallbacks:
this.scheduleFrame();
return;
case SchedulerPhase.transientCallbacks:
case SchedulerPhase.midFrameMicrotasks:
case SchedulerPhase.persistentCallbacks:
return;
}
}
public void scheduleFrame() {
if (this._hasScheduledFrame) {
return;
}
this._window.scheduleFrame();
this._hasScheduledFrame = true;
}
public void scheduleForcedFrame() {
this.scheduleFrame();
}
public TimeSpan? _firstRawTimeStampInEpoch;
public TimeSpan _epochStart = TimeSpan.Zero;
public TimeSpan _lastRawTimeStamp = TimeSpan.Zero;
public void resetEpoch() {
this._epochStart = this._adjustForEpoch(this._lastRawTimeStamp);
this._firstRawTimeStampInEpoch = null;
}
public TimeSpan _adjustForEpoch(TimeSpan rawTimeStamp) {
var rawDurationSinceEpoch = this._firstRawTimeStampInEpoch == null
? TimeSpan.Zero
: rawTimeStamp - this._firstRawTimeStampInEpoch.Value;
return new TimeSpan((long) (rawDurationSinceEpoch.Ticks / this.timeDilation) + this._epochStart.Ticks);
}
public TimeSpan currentFrameTimeStamp {
get { return this._currentFrameTimeStamp.Value; }
}
public TimeSpan? _currentFrameTimeStamp;
public void _handleBeginFrame(TimeSpan rawTimeStamp) {
this.handleBeginFrame(rawTimeStamp);
}
public void _handleDrawFrame() {
this.handleDrawFrame();
}
public void handleBeginFrame(TimeSpan? rawTimeStamp) {
if (this._firstRawTimeStampInEpoch == null) {
this._firstRawTimeStampInEpoch = rawTimeStamp;
}
this._currentFrameTimeStamp = this._adjustForEpoch(rawTimeStamp ?? this._lastRawTimeStamp);
if (rawTimeStamp != null) {
this._lastRawTimeStamp = rawTimeStamp.Value;
}
this._hasScheduledFrame = false;
try {
this._schedulerPhase = SchedulerPhase.transientCallbacks;
var callbacks = this._transientCallbacks;
this._transientCallbacks = new Dictionary<int, _FrameCallbackEntry>();
foreach (var entry in callbacks) {
if (!this._removedIds.Contains(entry.Key)) {
this._invokeFrameCallback(entry.Value.callback, this._currentFrameTimeStamp.Value);
}
}
this._removedIds.Clear();
}
finally {
this._schedulerPhase = SchedulerPhase.midFrameMicrotasks;
}
}
public void _invokeFrameCallback(FrameCallback callback, TimeSpan timeStamp) {
try {
callback(timeStamp);
}
catch (Exception ex) {
Debug.LogError("error in frame callback: " + ex);
}
}
public void handleDrawFrame() {
try {
this._schedulerPhase = SchedulerPhase.persistentCallbacks;
foreach (FrameCallback callback in this._persistentCallbacks) {
this._invokeFrameCallback(callback, this._currentFrameTimeStamp.Value);
}
this._schedulerPhase = SchedulerPhase.postFrameCallbacks;
var localPostFrameCallbacks = new List<FrameCallback>(this._postFrameCallbacks);
this._postFrameCallbacks.Clear();
foreach (FrameCallback callback in localPostFrameCallbacks) {
this._invokeFrameCallback(callback, this._currentFrameTimeStamp.Value);
}
}
finally {
this._schedulerPhase = SchedulerPhase.idle;
this._currentFrameTimeStamp = null;
}
}
}
}

3
Assets/UIWidgets/scheduler/binding.cs.meta


fileFormatVersion: 2
guid: 6b74179dadff469cb8ee1f7b2ff51ae7
timeCreated: 1534227207
正在加载...
取消
保存