浏览代码

update rendering to object.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
4628b8ac
共有 5 个文件被更改,包括 476 次插入120 次删除
  1. 5
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  2. 30
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  3. 256
      com.unity.uiwidgets/Runtime/rendering/object.cs
  4. 6
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  5. 299
      com.unity.uiwidgets/Runtime/rendering/mouse_tracking.cs

5
com.unity.uiwidgets/Runtime/rendering/layer.cs


get { return _lastChild; }
}
internal Layer _lastChild;
internal bool hasChildren {
get { return _firstChild != null; }
}
public ui.Scene buildScene(ui.SceneBuilder builder) {
List<PictureLayer> temporaryLayers = new List<PictureLayer>();
D.assert(()=> {

30
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


D.assert(perspective > 0);
D.assert(perspective <= 0.01f, () => perspectiveTooHighMessage);
D.assert(magnification > 0);
D.assert(overAndUnderCenterOpacity != null);
D.assert(squeeze != null);
D.assert(squeeze > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,

return _overAndUnderCenterOpacity;
}
set {
D.assert(value != null);
D.assert(value >= 0 && value <= 1);
if (value == _overAndUnderCenterOpacity)
return;

return _squeeze;
}
set {
D.assert(value != null);
D.assert(value > 0);
if (value == _squeeze)
return;

PaintingContext context,
Offset offset,
RenderBox child,
// Matrix4x4 cylindricalTransform,
Matrix4 cylindricalTransform,
Offset offsetToCenter
) {

_offset + offsetToCenter
);
};
/*PaintingContextCallback opacityPainter = (PaintingContext context2, Offset offset2) =>{
context2.pushOpacity(offset2, (overAndUnderCenterOpacity * 255).round(), painter);
};
context.pushTransform(
needsCompositing,
offset,
_centerOriginTransform(cylindricalTransform),
// Pre-transform painting function.
overAndUnderCenterOpacity == 1 ? painter : opacityPainter
);
Matrix4 _centerOriginTransform(Matrix4 originalMatrix) {
Matrix4 result = Matrix4.identity();
Offset centerOriginTranslation = Alignment.center.alongSize(size);
result.translate(centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1),
centerOriginTranslation.dy);
result.multiply(originalMatrix);
result.translate(-centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1),
-centerOriginTranslation.dy);
return result;*/ //[!!!]need?
}
public override Rect describeApproximatePaintClip(RenderObject child) {
if (child != null && _shouldClipAtCurrentOffset()) {
return Offset.zero & size;

}
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null
) {
protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
return false;
}

256
com.unity.uiwidgets/Runtime/rendering/object.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {

D.assert(debugAlsoPaintedParent || child._layer.attached);
child._layer.removeAllChildren();
}
D.assert(child._layer is OffsetLayer);
D.assert(() => {
child._layer.debugCreator = child.debugCreator ?? child.GetType().ToString();
return true;

public void pushLayer(ContainerLayer childLayer, PaintingContextCallback painter, Offset offset,
Rect childPaintBounds = null) {
D.assert(!childLayer.attached);
D.assert(childLayer.parent == null);
if (childLayer.hasChildren) {
childLayer.removeAllChildren();
}
stopRecordingIfNeeded();
appendLayer(childLayer);

return new PaintingContext(childLayer, bounds);
}
public void pushClipRect(bool needsCompositing, Offset offset, Rect clipRect, PaintingContextCallback painter,
Clip clipBehavior = Clip.hardEdge) {
public ClipRectLayer pushClipRect(
bool needsCompositing,
Offset offset,
Rect clipRect,
PaintingContextCallback painter,
Clip clipBehavior = Clip.hardEdge,
ClipRectLayer oldLayer = null) {
pushLayer(new ClipRectLayer(offsetClipRect, clipBehavior: clipBehavior),
painter, offset, childPaintBounds: offsetClipRect);
ClipRectLayer layer = oldLayer ?? new ClipRectLayer();
layer.clipRect = offsetClipRect;
layer.clipBehavior = clipBehavior;
pushLayer(layer, painter, offset, childPaintBounds: offsetClipRect);
return layer;
return null;
public void pushClipRRect(bool needsCompositing, Offset offset, Rect bounds, RRect clipRRect,
PaintingContextCallback painter, Clip clipBehavior = Clip.antiAlias) {
public ClipRRectLayer pushClipRRect(
bool needsCompositing,
Offset offset,
Rect bounds,
RRect clipRRect,
PaintingContextCallback painter,
Clip clipBehavior = Clip.antiAlias,
ClipRRectLayer oldLayer = null) {
pushLayer(new ClipRRectLayer(offsetClipRRect, clipBehavior: clipBehavior),
painter, offset, childPaintBounds: offsetBounds);
ClipRRectLayer layer = oldLayer ?? new ClipRRectLayer();
layer.clipRRect = offsetClipRRect;
layer.clipBehavior = clipBehavior;
pushLayer(layer, painter, offset, childPaintBounds: offsetBounds);
return layer;
return null;
public void pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath,
PaintingContextCallback painter, Clip clipBehavior = Clip.antiAlias) {
public ClipPathLayer pushClipPath(
bool needsCompositing,
Offset offset,
Rect bounds,
Path clipPath,
PaintingContextCallback painter,
Clip clipBehavior = Clip.antiAlias,
ClipPathLayer oldLayer = null) {
pushLayer(new ClipPathLayer(clipPath: offsetClipPath, clipBehavior: clipBehavior), painter, offset,
childPaintBounds: offsetBounds);
ClipPathLayer layer = oldLayer ?? new ClipPathLayer();
layer.clipPath = offsetClipPath;
layer.clipBehavior = clipBehavior;
pushLayer(layer, painter, offset, childPaintBounds: offsetBounds);
return layer;
return null;
public ColorFilterLayer pushColorFilter(Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, ColorFilterLayer oldLayer = null) {
D.assert(colorFilter != null);
ColorFilterLayer layer = oldLayer ?? new ColorFilterLayer();
layer.colorFilter = colorFilter;
pushLayer(layer, painter, offset);
return layer;
}
public void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform,
PaintingContextCallback painter) {
public TransformLayer pushTransform(
bool needsCompositing,
Offset offset,
Matrix4 transform,
PaintingContextCallback painter,
TransformLayer oldLayer = null) {
Matrix4 effectiveTransform;
if (offset == null || offset == Offset.zero) {
effectiveTransform = transform;

}
if (needsCompositing) {
// it could just be "scale == 0", ignore the assertion.
// D.assert(invertible);
TransformLayer layer = oldLayer ?? new TransformLayer();
layer.transform = effectiveTransform;
new TransformLayer(effectiveTransform),
layer,
return layer;
}
else {
canvas.save();

return null;
public void pushOpacity(Offset offset, int alpha, PaintingContextCallback painter) {
pushLayer(new OpacityLayer(alpha: alpha), painter, offset);
}
public OpacityLayer pushOpacity(Offset offset, int alpha, PaintingContextCallback painter, OpacityLayer oldLayer = null) {
OpacityLayer layer = oldLayer ?? new OpacityLayer();
layer.alpha = alpha;

$"{GetType()}#{GetHashCode()}(layer: {_containerLayer}, canvas bounds: {estimatedBounds}";
}
public ColorFilterLayer pushColorFilter(Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, ColorFilterLayer oldLayer = null) {
D.assert(colorFilter != null);
ColorFilterLayer layer = oldLayer ?? new ColorFilterLayer();
layer.colorFilter = colorFilter;
pushLayer(layer, painter, offset);
return layer;
}
protected Constraints(){}
public abstract bool isTight { get; }
public abstract bool isNormalized { get; }

_needsCompositing = isRepaintBoundary || alwaysNeedsCompositing;
}
void reassemble() {
markNeedsLayout();
markNeedsCompositingBitsUpdate();
markNeedsPaint();
visitChildren((RenderObject child) =>{
child.reassemble();
});
}
public ParentData parentData;
public virtual void setupParentData(RenderObject child) {

D.assert(node._relayoutBoundary == node);
return true;
}
// TODO
/*void markNeedsSemanticsUpdate() {
D.assert(!attached || !owner._debugDoingSemantics);
if (!attached || owner._semanticsOwner == null) {
_cachedSemanticsConfiguration = null;
return;
}
bool wasSemanticsBoundary = _semantics != null && _cachedSemanticsConfiguration?.isSemanticBoundary == true;
_cachedSemanticsConfiguration = null;
bool isEffectiveSemanticsBoundary = _semanticsConfiguration.isSemanticBoundary && wasSemanticsBoundary;
RenderObject node = this;
while (!isEffectiveSemanticsBoundary && node.parent is RenderObject) {
if (node != this && node._needsSemanticsUpdate)
break;
node._needsSemanticsUpdate = true;
node = node.parent as RenderObject;
isEffectiveSemanticsBoundary = node._semanticsConfiguration.isSemanticBoundary;
if (isEffectiveSemanticsBoundary && node._semantics == null) {
return;
}
}
if (node != this && _semantics != null && _needsSemanticsUpdate) {
owner._nodesNeedingSemantics.remove(this);
}
if (!node._needsSemanticsUpdate) {
node._needsSemanticsUpdate = true;
if (owner != null) {
D.assert(node._semanticsConfiguration.isSemanticBoundary || node.parent is! RenderObject);
owner._nodesNeedingSemantics.add(node);
owner.requestVisualUpdate();
}
}
}*/
public virtual void markNeedsLayout() {
D.assert(_debugCanPerformMutations);
if (_needsLayout) {

if (_relayoutBoundary != this) {
_relayoutBoundary = null;
_needsLayout = true;
visitChildren(child => { child._cleanRelayoutBoundary(); });
visitChildren(_cleanChildRelayoutBoundary);
}
static void _cleanChildRelayoutBoundary(RenderObject child) {
child._cleanRelayoutBoundary();
}
public void scheduleInitialLayout() {

D.assert(!_debugDoingThisLayout);
RenderObject relayoutBoundary;
if (!parentUsesSize || sizedByParent || constraints.isTight || !(this.parent is RenderObject)) {
if (!parentUsesSize || sizedByParent || constraints.isTight || !(parent is RenderObject)) {
RenderObject parent = (RenderObject) this.parent;
relayoutBoundary = parent._relayoutBoundary;
relayoutBoundary = (parent as RenderObject)._relayoutBoundary;
}
D.assert(() => {

}
_constraints = constraints;
if (_relayoutBoundary != null && relayoutBoundary != _relayoutBoundary) {
visitChildren(_cleanChildRelayoutBoundary);
}
_relayoutBoundary = relayoutBoundary;
D.assert(!_debugMutationsLocked);

}
}
/// Rotate this render object (not yet implemented).
void rotate(
int oldAngle, // 0..3
int newAngle, // 0..3
TimeSpan time
) { }
public bool debugDoingThisPaint {
get { return _debugDoingThisPaint; }
}

return _layer;
}
set {
D.assert(!isRepaintBoundary);
D.assert(
!isRepaintBoundary,
() => "Attempted to set a layer to a repaint boundary render object.\n" +
"The framework creates and assigns an OffsetLayer to a repaint " +
"boundary automatically."
);
public void setLayer(ContainerLayer newLayer) {
D.assert(
!isRepaintBoundary,()=>
"Attempted to set a layer to a repaint boundary render object.\n" +
"The framework creates and assigns an OffsetLayer to a repaint "+
"boundary automatically.");
_layer = newLayer;
}
public ContainerLayer debugLayer {
get {
ContainerLayer result = null;

return true;
});
D.assert(_layer != null);
D.assert(_layer is OffsetLayer);
if (owner != null) {
owner._nodesNeedingPaint.Add(this);

else if (this.parent is RenderObject) {
D.assert(_layer == null);
var parent = (RenderObject) this.parent;
RenderObject parent = this.parent as RenderObject;
D.assert(parent == this.parent);
}
else {
D.assert(() => {

internal void _paintWithContext(PaintingContext context, Offset offset) {
D.assert(() => {
if (_debugDoingThisPaint) {
throw new UIWidgetsError(
"Tried to paint a RenderObject reentrantly.\n" +
"The following RenderObject was already being painted when it was " +
"painted again:\n" +
" " + toStringShallow(joiner: "\n ") + "\n" +
"Since this typically indicates an infinite recursion, it is " +
"disallowed."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary("Tried to paint a RenderObject reentrantly."),
describeForError(
"The following RenderObject was already being painted when it was " +
"painted again"
),
new ErrorDescription(
"Since this typically indicates an infinite recursion, it is " +
"disallowed."
)
});
}
return true;

D.assert(() => {
if (_needsCompositingBitsUpdate) {
throw new UIWidgetsError(
"Tried to paint a RenderObject before its compositing bits were " +
"updated.\n" +
"The following RenderObject was marked as having dirty compositing " +
"bits at the time that it was painted:\n" +
" " + toStringShallow(joiner: "\n ") + "\n" +
"A RenderObject that still has dirty compositing bits cannot be " +
"painted because this indicates that the tree has not yet been " +
"properly configured for creating the layer tree.\n" +
"This usually indicates an error in the Flutter framework itself."
);
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary(
"Tried to paint a RenderObject before its compositing bits were " +
"updated."
),
describeForError(
"The following RenderObject was marked as having dirty compositing " +
"bits at the time that it was painted"
),
new ErrorDescription(
"A RenderObject that still has dirty compositing bits cannot be " +
"painted because this indicates that the tree has not yet been " +
"properly configured for creating the layer tree."
),
new ErrorHint(
"This usually indicates an error in the Flutter framework itself."
)
});
}
return true;

}
public Matrix4 getTransformTo(RenderObject ancestor) {
bool ancestorSpecified = ancestor != null;
D.assert(attached);
if (ancestor == null) {

D.assert(renderer != null);
renderers.Add(renderer);
}
if (ancestorSpecified)
renderers.Add(ancestor);
var transform = Matrix4.identity();
for (int index = renderers.Count - 1; index > 0; index -= 1) {
renderers[index].applyPaintTransform(renderers[index - 1], transform);

header += " NEEDS-PAINT";
}
if (_needsCompositingBitsUpdate)
header += " NEEDS-COMPOSITING-BITS-UPDATE";
if (!attached) {
header += " DETACHED";
}

public override string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
public override string toString(DiagnosticLevel minLevel = DiagnosticLevel.info) {
return toStringShort();
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("needsCompositing", value: _needsCompositing, ifTrue: "needs compositing"));
properties.add(new DiagnosticsProperty<object>(
"creator", debugCreator, defaultValue: foundation_.kNullDefaultValue,
level: DiagnosticLevel.debug));

defaultValue: foundation_.kNullDefaultValue));
}
public override List<DiagnosticsNode> debugDescribeChildren() => new List<DiagnosticsNode>();
public virtual void showOnScreen(
RenderObject descendant = null,
Rect rect = null,

);
}
}
public DiagnosticsNode describeForError(String name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
public DiagnosticsNode describeForError(string name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
return toDiagnosticsNode(name: name, style: style);
}
}

public class UIWidgetsErrorDetailsForRendering : UIWidgetsErrorDetails {
public UIWidgetsErrorDetailsForRendering(
Exception exception = null,
StackTrace stack = null,
string library = null,
DiagnosticsNode context = null,
RenderObject renderObject = null,

6
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


public override void paint(PaintingContext context, Offset offset) {
if (child != null && child.geometry.visible) {
if (_alpha == 0) {
setLayer(null);
layer = null;
setLayer(null);
layer = null;
context.paintChild(child, offset);
return;
}

base.paint,
oldLayer: layer as OpacityLayer
);
setLayer(opacity);
layer = opacity;
}
}
/*public override void visitChildrenForSemantics(RenderObject visitor) {

299
com.unity.uiwidgets/Runtime/rendering/mouse_tracking.cs


/*using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public delegate void PointerEnterEventListener(PointerEnterEvent _event);
public delegate void PointerExitEventListener(PointerExitEvent _event);
public delegate void PointerHoverEventListener(PointerHoverEvent _event);
public class MouseTrackerAnnotation : Diagnosticable {
public MouseTrackerAnnotation(
PointerEnterEventListener onEnter,
PointerHoverEventListener onHover,
PointerExitEventListener onExit) {
this.onEnter = onEnter;
this.onHover = onHover;
this.onExit = onExit;
}
public readonly PointerEnterEventListener onEnter;
public readonly PointerHoverEventListener onHover;
public readonly PointerExitEventListener onExit;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagsSummary<Delegate>(
"callbacks",
new Dictionary<string, Delegate> {
{"enter", onEnter},
{"hover", onHover},
{"exit", onExit},
},
ifEmpty: "<none>"
));
}
}
public delegate IEnumerable<MouseTrackerAnnotation> MouseDetectorAnnotationFinder(Offset offset);
public delegate void _UpdatedDeviceHandler(_MouseState mouseState, HashSet<MouseTrackerAnnotation> previousAnnotations);
public class _MouseState {
public _MouseState(PointerEvent initialEvent) {
D.assert(initialEvent != null);
_latestEvent = initialEvent;
}
public HashSet<MouseTrackerAnnotation> annotations {
get { return _annotations; }
}
HashSet<MouseTrackerAnnotation> _annotations = new HashSet<MouseTrackerAnnotation>();
public HashSet<MouseTrackerAnnotation> replaceAnnotations(HashSet<MouseTrackerAnnotation> value) {
HashSet<MouseTrackerAnnotation> previous = _annotations;
_annotations = value;
return previous;
}
public PointerEvent latestEvent {
get {
return _latestEvent;
}
set {
D.assert(value != null);
_latestEvent = value;
}
}
PointerEvent _latestEvent;
public int device {
get {
return latestEvent.device;
}
}
public override string ToString() {
string describeEvent(PointerEvent _event) {
return _event == null ? "null" : foundation_.describeIdentity(_event);
}
string describeLatestEvent = $"latestEvent: {describeEvent(latestEvent)}";
string describeAnnotations = $"annotations: [list of {annotations.Count}]";
return $"{foundation_.describeIdentity(this)}({describeLatestEvent}, {describeAnnotations})";
}
}
public class MouseTracker : ChangeNotifier {
public MouseTracker(PointerRouter _router, MouseDetectorAnnotationFinder annotationFinder) {
D.assert(_router != null);
D.assert(annotationFinder != null);
_router.addGlobalRoute(_handleEvent);
}
public override void dispose() {
base.dispose();
_router.removeGlobalRoute(_handleEvent);
}
public readonly MouseDetectorAnnotationFinder annotationFinder;
public readonly PointerRouter _router;
public readonly Dictionary<int, _MouseState> _mouseStates = new Dictionary<int, _MouseState>();
static bool _shouldMarkStateDirty(_MouseState state, PointerEvent value) {
if (state == null)
return true;
D.assert(value != null);
PointerEvent lastEvent = state.latestEvent;
D.assert(value.device == lastEvent.device);
D.assert((value is PointerAddedEvent) == (lastEvent is PointerRemovedEvent));
if (value is PointerSignalEvent)
return false;
return lastEvent is PointerAddedEvent
|| value is PointerRemovedEvent
|| lastEvent.position != value.position;
}
void _handleEvent(PointerEvent _event) {
if (_event.kind != PointerDeviceKind.mouse)
return;
if (_event is PointerSignalEvent)
return;
int device = _event.device;
_MouseState existingState = _mouseStates.getOrDefault(device);
if (!_shouldMarkStateDirty(existingState, _event))
return;
PointerEvent previousEvent = existingState?.latestEvent;
_updateDevices(
targetEvent: _event,
handleUpdatedDevice: (_MouseState mouseState, HashSet<MouseTrackerAnnotation> previousAnnotations) =>{
D.assert(mouseState.device == _event.device);
_dispatchDeviceCallbacks(
lastAnnotations: previousAnnotations,
nextAnnotations: mouseState.annotations,
previousEvent: previousEvent,
unhandledEvent: _event
);
});
}
HashSet<MouseTrackerAnnotation> _findAnnotations(_MouseState state) {
Offset globalPosition = state.latestEvent.position;
int device = state.device;
HashSet<MouseTrackerAnnotation> temp = new HashSet<MouseTrackerAnnotation>();
foreach (var set in annotationFinder(globalPosition)) {
temp.Add(set);
}
return (_mouseStates.ContainsKey(device)) ? temp : new HashSet<MouseTrackerAnnotation>();
}
static bool _duringBuildPhase {
get {
return SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks;
}
}
void _updateAllDevices() {
_updateDevices(
handleUpdatedDevice: (_MouseState mouseState, HashSet<MouseTrackerAnnotation> previousAnnotations) => {
_dispatchDeviceCallbacks(
lastAnnotations: previousAnnotations,
nextAnnotations: mouseState.annotations,
previousEvent: mouseState.latestEvent,
unhandledEvent: null
);
});
}
bool _duringDeviceUpdate = false;
void _updateDevices(
PointerEvent targetEvent = null,
_UpdatedDeviceHandler handleUpdatedDevice = null
) {
D.assert(handleUpdatedDevice != null);
D.assert(!_duringBuildPhase);
D.assert(!_duringDeviceUpdate);
bool mouseWasConnected = mouseIsConnected;
_MouseState targetState = null;
if (targetEvent != null) {
targetState = _mouseStates.getOrDefault(targetEvent.device);
if (targetState == null) {
targetState = new _MouseState(initialEvent: targetEvent);
_mouseStates[targetState.device] = targetState;
} else {
D.assert(!(targetEvent is PointerAddedEvent));
targetState.latestEvent = targetEvent;
if (targetEvent is PointerRemovedEvent)
_mouseStates.Remove(targetEvent.device);
}
}
D.assert(() => {
_duringDeviceUpdate = true;
return true;
});
IEnumerable<_MouseState> dirtyStates = targetEvent == null ? _mouseStates.Values : new List<_MouseState>{targetState};
foreach (_MouseState dirtyState in dirtyStates) {
HashSet<MouseTrackerAnnotation> nextAnnotations = _findAnnotations(dirtyState);
HashSet<MouseTrackerAnnotation> lastAnnotations = dirtyState.replaceAnnotations(nextAnnotations);
handleUpdatedDevice(dirtyState, lastAnnotations);
}
D.assert(() => {
_duringDeviceUpdate = false;
return true;
});
if (mouseWasConnected != mouseIsConnected)
notifyListeners();
}
static void _dispatchDeviceCallbacks(
HashSet<MouseTrackerAnnotation> lastAnnotations = null,
HashSet<MouseTrackerAnnotation> nextAnnotations = null,
PointerEvent previousEvent = null,
PointerEvent unhandledEvent = null
) {
D.assert(lastAnnotations != null);
D.assert(nextAnnotations != null);
PointerEvent latestEvent = unhandledEvent ?? previousEvent;
D.assert(latestEvent != null);
List<MouseTrackerAnnotation> exitingAnnotations = new List<MouseTrackerAnnotation>();
foreach (var annotation in lastAnnotations) {
if (!nextAnnotations.Contains(annotation)) {
exitingAnnotations.Add(annotation);
}
}
foreach (MouseTrackerAnnotation annotation in exitingAnnotations) {
annotation.onExit?.Invoke(PointerExitEvent.fromMouseEvent(latestEvent));
}
List<MouseTrackerAnnotation> enteringAnnotations = new List<MouseTrackerAnnotation>();
foreach (var annotation in nextAnnotations) {
if (!lastAnnotations.Contains(annotation)) {
enteringAnnotations.Add(annotation);
}
}
enteringAnnotations.Reverse();
foreach (MouseTrackerAnnotation annotation in enteringAnnotations) {
annotation.onEnter?.Invoke(PointerEnterEvent.fromMouseEvent(latestEvent));
}
if (unhandledEvent is PointerHoverEvent) {
Offset lastHoverPosition = previousEvent is PointerHoverEvent ? previousEvent.position : null;
bool pointerHasMoved = lastHoverPosition == null || lastHoverPosition != unhandledEvent.position;
List<MouseTrackerAnnotation> nextAnnotationsList = new List<MouseTrackerAnnotation>();
foreach (var annotation in nextAnnotations) {
nextAnnotationsList.Add(annotation);
}
nextAnnotationsList.Reverse();
IEnumerable<MouseTrackerAnnotation> hoveringAnnotations = pointerHasMoved ? nextAnnotationsList : enteringAnnotations;
foreach (MouseTrackerAnnotation annotation in hoveringAnnotations) {
annotation.onHover?.Invoke((PointerHoverEvent)unhandledEvent);
}
}
}
bool _hasScheduledPostFrameCheck = false;
public void schedulePostFrameCheck() {
D.assert(_duringBuildPhase);
D.assert(!_duringDeviceUpdate);
if (!mouseIsConnected)
return;
if (!_hasScheduledPostFrameCheck) {
_hasScheduledPostFrameCheck = true;
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timeSpan) => {
D.assert(_hasScheduledPostFrameCheck);
_hasScheduledPostFrameCheck = false;
_updateAllDevices();
});
}
}
public bool mouseIsConnected {
get {
return _mouseStates.isNotEmpty();
}
}
}
}*/
正在加载...
取消
保存