浏览代码

Merge remote-tracking branch 'upstream/master'

/main
fzhangtj 6 年前
当前提交
88ac27cb
共有 8 个文件被更改,包括 181 次插入42 次删除
  1. 12
      Runtime/editor/scroll_input.cs
  2. 57
      Runtime/engine/WidgetCanvas.cs
  3. 26
      Runtime/rendering/layer.cs
  4. 67
      Runtime/rendering/proxy_box.cs
  5. 4
      Runtime/ui/geometry.cs
  6. 39
      Runtime/widgets/basic.cs
  7. 11
      Editor/editor/WidgetCanvasEditor.cs.meta
  8. 7
      UIWidgetCleanupPlugin.DotSettings.meta

12
Runtime/editor/scroll_input.cs


using System;
readonly int _bufferSize = 10;
readonly int _bufferSize = 20;
readonly float _scrollScale = 10;
float _scrollDeltaX;

float _pointerY;
int _buttonId;
public ScrollInput(int bufferSize = 10, float scrollScale = 10) {
this._bufferIndex = bufferSize;
this._bufferSize = bufferSize;
public ScrollInput(int? bufferSize = null, float? scrollScale = null) {
this._bufferSize = bufferSize ?? this._bufferSize;
this._scrollScale = scrollScale ?? this._scrollScale;
this._bufferIndex = this._bufferSize;
this._scrollScale = scrollScale;
}
public void onScroll(float deltaX, float deltaY, float pointerX, float pointerY, int buttonId) {

57
Runtime/engine/WidgetCanvas.cs


}
protected override Vector2 queryWindowSize() {
var rect = RectTransformUtility.PixelAdjustRect(this._widgetCanvas.rectTransform,
var rect = RectTransformUtility.PixelAdjustRect(this._widgetCanvas.rectTransform,
this._widgetCanvas.canvas);
var size = new Vector2(rect.width, rect.height) / this._widgetCanvas.devicePixelRatio;
size.x = Mathf.Round(size.x);

readonly ScrollInput _scrollInput = new ScrollInput();
DisplayMetrics _displayMetrics;
protected override void OnEnable() {
base.OnEnable();
this._displayMetrics = DisplayMetricsProvider.provider();

this.texture = texture;
this.material = mat;
}
void Update() {
this._displayMetrics.Update();
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {

}
if (this._mouseEntered) {
if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = this.canvas.scaleFactor;
var pos = this.getPointPosition(Input.mousePosition);
this._scrollInput.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.x,
pos.y,
this.getScrollButton());
}
var deltaScroll = this._scrollInput.getScrollDelta();
if (deltaScroll != Vector2.zero) {
this._windowAdapter.postPointerEvent(new ScrollData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.scroll,
kind: PointerDeviceKind.mouse,
device: this._scrollInput.getDeviceId(),
physicalX: this._scrollInput.getPointerPosX(),
physicalY: this._scrollInput.getPointerPosY(),
scrollX: deltaScroll.x,
scrollY: deltaScroll.y
));
}
this.handleMouseScroll();
}

physicalY: pos.y
));
}
void handleMouseScroll() {
if (Input.mouseScrollDelta.y != 0 || Input.mouseScrollDelta.x != 0) {
var scaleFactor = this.canvas.scaleFactor;
var pos = this.getPointPosition(Input.mousePosition);
this._scrollInput.onScroll(Input.mouseScrollDelta.x * scaleFactor,
Input.mouseScrollDelta.y * scaleFactor,
pos.x,
pos.y,
this.getScrollButton());
}
var deltaScroll = this._scrollInput.getScrollDelta();
if (deltaScroll != Vector2.zero) {
this._windowAdapter.postPointerEvent(new ScrollData(
timeStamp: Timer.timespanSinceStartup,
change: PointerChange.scroll,
kind: PointerDeviceKind.mouse,
device: this._scrollInput.getDeviceId(),
physicalX: this._scrollInput.getPointerPosX(),
physicalY: this._scrollInput.getPointerPosY(),
scrollX: deltaScroll.x,
scrollY: deltaScroll.y
));
}
}
int getScrollButton() {
return mouseScrollId;

26
Runtime/rendering/layer.cs


if (child._previousSibling == null) {
D.assert(this.firstChild == child);
this._firstChild = child.nextSibling;
} else {
}
else {
child._previousSibling._nextSibling = child.nextSibling;
}

} else {
}
else {
child._nextSibling._previousSibling = child.previousSibling;
}

while (child != null) {
if (childOffset == null || childOffset == Offset.zero) {
child._addToSceneWithRetainedRendering(builder);
} else {
}
else {
child = child.nextSibling;
}
}

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
bool enabled = true;
D.assert(() => {
enabled = !D.debugDisableClipLayers;

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
this._lastEffectiveTransform = this._transform;
var totalOffset = this.offset + layerOffset;

this.addChildrenToScene(builder);
builder.pop();
this._lastOffset = this.unlinkedOffset + layerOffset;
} else {
}
else {
this._lastOffset = null;
var matrix = Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy);
builder.pushTransform(matrix);

D.assert(transform != null);
if (this._lastTransform != null) {
transform.preConcat(this._lastTransform);
} else {
}
else {
transform.preConcat(Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy));
}
}

defaultValue: Diagnostics.kNullDefaultValue));
}
}
}
}

67
Runtime/rendering/proxy_box.cs


}
public class RenderClipRRect : _RenderCustomClip<RRect> {
public RenderClipRRect(
RenderBox child = null,
BorderRadius borderRadius = null,
CustomClipper<RRect> clipper = null,
Clip clipBehavior = Clip.antiAlias
) : base(child: child, clipper: clipper, clipBehavior: clipBehavior) {
D.assert(clipBehavior != Clip.none);
this._borderRadius = borderRadius ?? BorderRadius.zero;
D.assert(this._borderRadius != null || clipper != null);
}
public BorderRadius borderRadius {
get { return this._borderRadius; }
set {
D.assert(value != null);
if (this._borderRadius == value) {
return;
}
this._borderRadius = value;
this._markNeedsClip();
}
}
BorderRadius _borderRadius;
protected override RRect _defaultClip {
get { return this._borderRadius.toRRect(Offset.zero & this.size); }
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position)) {
return false;
}
}
return base.hitTest(result, position: position);
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
context.pushClipRRect(this.needsCompositing, offset, this._clip.outerRect, this._clip,
base.paint, clipBehavior: this.clipBehavior);
}
}
protected override void debugPaintSize(PaintingContext context, Offset offset) {
D.assert(() => {
if (this.child != null) {
base.debugPaintSize(context, offset);
context.canvas.drawRRect(this._clip.shift(offset), this._debugPaint);
this._debugText.paint(context.canvas,
offset + new Offset(this._clip.tlRadiusX,
-(this._debugText.text.style.fontSize ?? 0.0f) * 1.1f));
}
return true;
});
}
}
public class RenderClipPath : _RenderCustomClip<Path> {
public RenderClipPath(
RenderBox child = null,

4
Runtime/ui/geometry.cs


}
public static int sign(this float value) {
return (int) Mathf.Sign(value);
return value == 0.0f ? 0 : value > 0.0f ? 1 : -1;
}
public static bool isInfinite(this float it) {

if (other == null || other.isEmpty) {
return this;
}
return fromLTRB(
Mathf.Min(this.left, other.left),
Mathf.Min(this.top, other.top),

39
Runtime/widgets/basic.cs


}
}
public class ClipRRect : SingleChildRenderObjectWidget {
public ClipRRect(
Key key = null,
BorderRadius borderRadius = null,
CustomClipper<RRect> clipper = null,
Clip clipBehavior = Clip.antiAlias,
Widget child = null
) : base(key: key, child: child) {
D.assert(borderRadius != null || clipper != null);
this.borderRadius = borderRadius;
this.clipper = clipper;
this.clipBehavior = clipBehavior;
}
public readonly BorderRadius borderRadius;
public readonly CustomClipper<RRect> clipper;
public readonly Clip clipBehavior;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderClipRRect(borderRadius: this.borderRadius, clipper: this.clipper,
clipBehavior: this.clipBehavior);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderClipRRect _renderObject = (RenderClipRRect) renderObject;
_renderObject.borderRadius = this.borderRadius;
_renderObject.clipper = this.clipper;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius, showName: false,
defaultValue: null));
properties.add(new DiagnosticsProperty<CustomClipper<RRect>>("clipper", this.clipper, defaultValue: null));
}
}
public class ClipPath : SingleChildRenderObjectWidget {
public ClipPath(
Key key = null,

11
Editor/editor/WidgetCanvasEditor.cs.meta


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

7
UIWidgetCleanupPlugin.DotSettings.meta


fileFormatVersion: 2
guid: 2b375812364de43858a5045e73ed3bd3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存