浏览代码

Merge branch 'kgdev' into 'master'

fix dismiss.

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!112
/main
Fan Zhang 6 年前
当前提交
b9d246b2
共有 12 个文件被更改,包括 225 次插入3 次删除
  1. 1
      Runtime/engine/UIWidgetsPanel.cs
  2. 35
      Runtime/rendering/layer.cs
  3. 19
      Runtime/ui/compositing.cs
  4. 4
      Runtime/ui/window.cs
  5. 2
      Runtime/widgets/app.cs
  6. 4
      Runtime/widgets/dismissible.cs
  7. 51
      Runtime/flow/texture_layer.cs
  8. 11
      Runtime/flow/texture_layer.cs.meta
  9. 58
      Runtime/rendering/texture.cs
  10. 11
      Runtime/rendering/texture.cs.meta
  11. 21
      Runtime/widgets/texture.cs
  12. 11
      Runtime/widgets/texture.cs.meta

1
Runtime/engine/UIWidgetsPanel.cs


using UnityEngine.UI;
using RawImage = UnityEngine.UI.RawImage;
using Rect = UnityEngine.Rect;
using Texture = UnityEngine.Texture;
namespace Unity.UIWidgets.engine {
public class UIWidgetWindowAdapter : WindowAdapter {

35
Runtime/rendering/layer.cs


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

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Rect>("paint bounds", this.canvasBounds));
}
}
public class TextureLayer : Layer {
public TextureLayer(
Rect rect,
Texture texture,
bool freeze = false
) {
D.assert(rect != null);
D.assert(texture != null);
this.rect = rect;
this.texture = texture;
this.freeze = freeze;
}
public readonly Rect rect;
public readonly Texture texture;
public readonly bool freeze;
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
Rect shiftedRect = this.rect.shift(layerOffset);
builder.addTexture(
this.texture,
offset: shiftedRect.topLeft,
width: shiftedRect.width,
height: shiftedRect.height,
freeze: this.freeze
);
return null;
}
}

19
Runtime/ui/compositing.cs


using System;
using Unity.UIWidgets.flow;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public class SceneBuilder {

this._currentLayer.add(layer);
}
public void addTexture(
Texture texture,
Offset offset,
float width,
float height,
bool freeze) {
if (this._currentLayer == null) {
return;
}
var layer = new TextureLayer();
layer.offset = offset;
layer.size = new Size(width, height);
layer.texture = texture;
layer.freeze = freeze;
this._currentLayer.add(layer);
}
public void addPerformanceOverlay(int enabledOptions, Rect bounds) {
if (this._currentLayer == null) {
return;

4
Runtime/ui/window.cs


public abstract void scheduleFrame(bool regenerateLayerTree = true);
public void textureFrameAvailable() {
this.scheduleFrame(false);
}
public abstract void render(Scene scene);
public abstract void scheduleMicrotask(Action callback);

2
Runtime/widgets/app.cs


var name = settings.name;
var pageContentBuilder = name == Navigator.defaultRouteName && this.widget.home != null
? context => this.widget.home
: this.widget.routes[name];
: this.widget.routes.getOrDefault(name);
if (pageContentBuilder != null) {
D.assert(this.widget.pageRouteBuilder != null,

4
Runtime/widgets/dismissible.cs


case _FlingGestureKind.forward:
D.assert(this._dragExtent != 0.0f);
D.assert(!this._moveController.isDismissed);
if ((this.widget.dismissThresholds[this._dismissDirection] ?? _kDismissThreshold) >= 1.0) {
if ((this.widget.dismissThresholds.getOrDefault(this._dismissDirection) ?? _kDismissThreshold) >= 1.0) {
this._moveController.reverse();
break;
}

if (!this._moveController.isDismissed) {
// we already know it's not completed, we check that above
if (this._moveController.value >
(this.widget.dismissThresholds[this._dismissDirection] ?? _kDismissThreshold)) {
(this.widget.dismissThresholds.getOrDefault(this._dismissDirection) ?? _kDismissThreshold)) {
this._moveController.forward();
}
else {

51
Runtime/flow/texture_layer.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.flow {
public class TextureLayer : Layer {
Offset _offset = Offset.zero;
public Offset offset {
set { this._offset = value ?? Offset.zero; }
}
Size _size;
public Size size {
set { this._size = value; }
}
Texture _texture;
public Texture texture {
set { this._texture = value; }
}
bool _freeze = false;
public bool freeze {
set { this._freeze = value; }
}
public override void preroll(PrerollContext context, Matrix3 matrix) {
this.paintBounds = Rect.fromLTWH(
this._offset.dx, this._offset.dy, this._size.width, this._size.height);
}
public override void paint(PaintContext context) {
D.assert(this.needsPainting);
if (this._texture == null) {
return;
}
var image = new Image(this._texture, noDispose: true);
var canvas = context.canvas;
canvas.drawImageRect(image, this.paintBounds, new Paint());
}
}
}

11
Runtime/flow/texture_layer.cs.meta


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

58
Runtime/rendering/texture.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class TextureBox : RenderBox {
public TextureBox(Texture texture) {
D.assert(texture != null);
this._texture = texture;
}
public Texture texture {
get { return this._texture; }
set {
D.assert(value != null);
if (value != this._texture) {
this._texture = value;
this.markNeedsPaint();
}
}
}
Texture _texture;
protected override bool sizedByParent {
get { return true; }
}
protected override bool alwaysNeedsCompositing {
get { return true; }
}
public override bool isRepaintBoundary {
get { return true; }
}
protected override void performResize() {
this.size = this.constraints.biggest;
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void paint(PaintingContext context, Offset offset) {
if (this._texture == null) {
return;
}
context.addLayer(new TextureLayer(
rect: Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this.size.height),
texture: this._texture
));
}
}
}

11
Runtime/rendering/texture.cs.meta


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

21
Runtime/widgets/texture.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
namespace Unity.UIWidgets.widgets {
public class Texture : LeafRenderObjectWidget {
public Texture(Key key, UnityEngine.Texture texture) : base(key: key) {
D.assert(texture != null);
this.texture = texture;
}
public readonly UnityEngine.Texture texture;
public override RenderObject createRenderObject(BuildContext context) {
return new TextureBox(texture: this.texture);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
((TextureBox) renderObject).texture = this.texture;
}
}
}

11
Runtime/widgets/texture.cs.meta


fileFormatVersion: 2
guid: 5de15949323be4d0eb8faec4015cd792
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存