|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Unity.UIWidgets.animation; |
|
|
|
using Unity.UIWidgets.async; |
|
|
|
using Unity.UIWidgets.editor; |
|
|
|
|
|
|
Texture _texture; |
|
|
|
Vector2 _lastMouseMove; |
|
|
|
bool _mouseEntered; |
|
|
|
|
|
|
|
Vector2 _lastScrollMove; |
|
|
|
TimeSpan _lastScrollEndTime = TimeSpan.Zero; |
|
|
|
static readonly TimeSpan _ScrollEndInterval = new TimeSpan(0, 0, 0, 0, 200); |
|
|
|
|
|
|
|
protected override void OnEnable() { |
|
|
|
base.OnEnable(); |
|
|
|
|
|
|
|
|
|
|
this._windowAdapter.attachRootWidget(root); |
|
|
|
this._lastMouseMove = Input.mousePosition; |
|
|
|
this._lastScrollMove = Input.mouseScrollDelta; |
|
|
|
Debug.Log(this._lastScrollMove); |
|
|
|
} |
|
|
|
|
|
|
|
public double pixelRatio { |
|
|
|
|
|
|
this.handleMouseMove(); |
|
|
|
} |
|
|
|
|
|
|
|
if (this._mouseEntered) { |
|
|
|
// 0 -> !0 => scroll start, use the current position to perform hit test and set the
|
|
|
|
// current scroll target (if can, otherwise set it null), this target should be saved
|
|
|
|
// !0 -> !0 => use the delta to do the scroll thing.
|
|
|
|
// !0 -> 0 => scroll end. current scroll target = null
|
|
|
|
if (this._lastScrollMove.y == 0 && Input.mouseScrollDelta.y == 0) { |
|
|
|
if (this._lastScrollEndTime != TimeSpan.Zero && |
|
|
|
(Timer.timespanSinceStartup - this._lastScrollEndTime > _ScrollEndInterval)) { |
|
|
|
this._lastScrollEndTime = TimeSpan.Zero; |
|
|
|
this._windowAdapter.postPointerEvent(new PointerData( |
|
|
|
timeStamp: Timer.timespanSinceStartup, |
|
|
|
change: PointerChange.scroll_end, |
|
|
|
kind: PointerDeviceKind.mouse, |
|
|
|
device: this.getScrollButton(), |
|
|
|
physicalX: 0, |
|
|
|
physicalY: 0 |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (this._lastScrollMove.y != 0 && Input.mouseScrollDelta.y == 0) { |
|
|
|
//Debug.Log("scroll end");
|
|
|
|
this._lastScrollEndTime = Timer.timespanSinceStartup; |
|
|
|
|
|
|
|
this._windowAdapter.postPointerEvent(new PointerData( |
|
|
|
timeStamp: Timer.timespanSinceStartup, |
|
|
|
change: PointerChange.scrolling, |
|
|
|
kind: PointerDeviceKind.mouse, |
|
|
|
device: this.getScrollButton(), |
|
|
|
physicalX: 0, |
|
|
|
physicalY: this._lastScrollMove.y |
|
|
|
)); |
|
|
|
} else if (this._lastScrollMove.y == 0 && Input.mouseScrollDelta.y != 0) { |
|
|
|
//Debug.Log("scroll start");
|
|
|
|
var pos = this.getPointPosition(Input.mousePosition); |
|
|
|
this._windowAdapter.postPointerEvent(new PointerData( |
|
|
|
timeStamp: Timer.timespanSinceStartup, |
|
|
|
change: PointerChange.scroll_start, |
|
|
|
kind: PointerDeviceKind.mouse, |
|
|
|
device: this.getScrollButton(), |
|
|
|
physicalX: pos.x, |
|
|
|
physicalY: pos.y |
|
|
|
)); |
|
|
|
} else if (this._lastScrollMove.y != 0 && Input.mouseScrollDelta.y != 0) { |
|
|
|
//Debug.Log("scroll continue");
|
|
|
|
this._windowAdapter.postPointerEvent(new PointerData( |
|
|
|
timeStamp: Timer.timespanSinceStartup, |
|
|
|
change: PointerChange.scrolling, |
|
|
|
kind: PointerDeviceKind.mouse, |
|
|
|
device: this.getScrollButton(), |
|
|
|
physicalX: 0, |
|
|
|
physicalY: this._lastScrollMove.y |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
this._lastScrollMove = Input.mouseScrollDelta; |
|
|
|
|
|
|
|
this._lastMouseMove = Input.mousePosition; |
|
|
|
|
|
|
|
D.assert(this._windowAdapter != null); |
|
|
|
|
|
|
physicalX: pos.x, |
|
|
|
physicalY: pos.y |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
int getScrollButton() { |
|
|
|
return 5; |
|
|
|
} |
|
|
|
|
|
|
|
int getMouseButtonDown() { |
|
|
|