xingwei.zhu
5 年前
当前提交
ecc57ee8
共有 64 个文件被更改,包括 2958 次插入 和 556 次删除
-
5README-ZH.md
-
5README.md
-
4Runtime/Unity.UIWidgets.asmdef
-
11Runtime/animation/tween.cs
-
9Runtime/engine/UIWidgetsPanel.cs
-
27Runtime/foundation/basic_types.cs
-
8Runtime/foundation/key.cs
-
2Runtime/gestures/constants.cs
-
4Runtime/gestures/converter.cs
-
1Runtime/material/mergeable_material.cs
-
232Runtime/material/slider.cs
-
213Runtime/material/slider_theme.cs
-
2Runtime/material/text_field.cs
-
2Runtime/material/user_accounts_drawer_header.cs
-
17Runtime/painting/basic_types.cs
-
5Runtime/rendering/editable.cs
-
4Runtime/rendering/paragraph.cs
-
5Runtime/service/text_formatter.cs
-
61Runtime/ui/matrix.cs
-
72Runtime/ui/painting/canvas_clip.cs
-
13Runtime/ui/painting/canvas_impl.cs
-
155Runtime/ui/painting/path.cs
-
2Runtime/ui/painting/shadow_utils.cs
-
14Runtime/ui/painting/tessellation_generator.cs
-
187Runtime/ui/painting/txt/font_manager.cs
-
12Runtime/ui/painting/txt/mesh_generator.cs
-
2Runtime/ui/text.cs
-
58Runtime/ui/txt/layout.cs
-
15Runtime/ui/txt/linebreaker.cs
-
4Runtime/ui/txt/paint_record.cs
-
7Runtime/ui/txt/paragraph.cs
-
4Runtime/ui/txt/text_buff.cs
-
2Runtime/ui/txt/wordbreaker.cs
-
34Runtime/widgets/basic.cs
-
11Runtime/widgets/drag_target.cs
-
34Runtime/widgets/form.cs
-
80Runtime/widgets/gesture_detector.cs
-
10Runtime/widgets/implicit_animations.cs
-
1Runtime/widgets/single_child_scroll_view.cs
-
12Samples/UIWidgetSample/MaterialSample.cs
-
8Samples/UIWidgetSample/txt/TextFieldSample.cs
-
8Runtime/InternalBridge.meta
-
110Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib.meta
-
1001Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib
-
110Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib.meta
-
412Runtime/gestures/scale.cs
-
11Runtime/gestures/scale.cs.meta
-
156Runtime/material/text_form_field.cs
-
3Runtime/material/text_form_field.cs.meta
-
127Runtime/rendering/rotated_box.cs
-
3Runtime/rendering/rotated_box.cs.meta
-
23Runtime/ui/painting/ArrayRef.cs
-
11Runtime/ui/painting/ArrayRef.cs.meta
-
64Samples/UIWidgetSample/ScaleGestureSample.cs
-
11Samples/UIWidgetSample/ScaleGestureSample.cs.meta
-
12Runtime/InternalBridge/InternalBridge.asmdef
-
7Runtime/InternalBridge/InternalBridge.asmdef.meta
-
35Runtime/InternalBridge/NoAllocHelpersBridge.cs
-
11Runtime/InternalBridge/NoAllocHelpersBridge.cs.meta
-
37Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio.jslib.meta
-
8Runtime/utils.meta
-
0/Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2018.3.jslib
|
|||
fileFormatVersion: 2 |
|||
guid: 6692331a428d6455c97baf446a850594 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: eed39ef42fc8d4856874e03a2ae9c63a |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
'': Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Android: 1 |
|||
Exclude Editor: 1 |
|||
Exclude Linux: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude LinuxUniversal: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
Exclude iOS: 1 |
|||
- first: |
|||
Android: Android |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: ARMv7 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
DefaultValueInitialized: true |
|||
OS: AnyOS |
|||
- first: |
|||
Facebook: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Facebook: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Facebook: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Linux |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86 |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
WebGL: WebGL |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
AddToEmbeddedBinaries: false |
|||
CompileFlags: |
|||
FrameworkDependencies: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Runtime/Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_2019.1.jslib
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: fa7d598e002d745e487155c443ed56e4 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
'': Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Android: 1 |
|||
Exclude Editor: 1 |
|||
Exclude Linux: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude LinuxUniversal: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude WebGL: 0 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
Exclude iOS: 1 |
|||
- first: |
|||
Android: Android |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: ARMv7 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
DefaultValueInitialized: true |
|||
OS: AnyOS |
|||
- first: |
|||
Facebook: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Facebook: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Facebook: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Linux |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86 |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: AnyCPU |
|||
- first: |
|||
WebGL: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
AddToEmbeddedBinaries: false |
|||
CompileFlags: |
|||
FrameworkDependencies: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.gestures { |
|||
enum _ScaleState { |
|||
ready, |
|||
possible, |
|||
accepted, |
|||
started |
|||
} |
|||
|
|||
public class ScaleStartDetails { |
|||
public ScaleStartDetails(Offset focalPoint = null) { |
|||
this.focalPoint = focalPoint ?? Offset.zero; |
|||
} |
|||
|
|||
public readonly Offset focalPoint; |
|||
|
|||
public override string ToString() { |
|||
return $"ScaleStartDetails(focalPoint: {this.focalPoint}"; |
|||
} |
|||
} |
|||
|
|||
|
|||
public class ScaleUpdateDetails { |
|||
public ScaleUpdateDetails( |
|||
Offset focalPoint = null, |
|||
float scale = 1.0f, |
|||
float horizontalScale = 1.0f, |
|||
float verticalScale = 1.0f, |
|||
float rotation = 0.0f |
|||
) { |
|||
focalPoint = focalPoint ?? Offset.zero; |
|||
|
|||
D.assert(scale >= 0.0f); |
|||
D.assert(horizontalScale >= 0.0f); |
|||
D.assert(verticalScale >= 0.0f); |
|||
|
|||
this.focalPoint = focalPoint; |
|||
this.scale = scale; |
|||
this.horizontalScale = horizontalScale; |
|||
this.verticalScale = verticalScale; |
|||
this.rotation = rotation; |
|||
} |
|||
|
|||
public readonly Offset focalPoint; |
|||
|
|||
public readonly float scale; |
|||
|
|||
public readonly float horizontalScale; |
|||
|
|||
public readonly float verticalScale; |
|||
|
|||
public readonly float rotation; |
|||
|
|||
public override string ToString() { |
|||
return |
|||
$"ScaleUpdateDetails(focalPoint: {this.focalPoint}, scale: {this.scale}, horizontalScale: {this.horizontalScale}, verticalScale: {this.verticalScale}, rotation: {this.rotation}"; |
|||
} |
|||
} |
|||
|
|||
public class ScaleEndDetails { |
|||
public ScaleEndDetails(Velocity velocity = null) { |
|||
this.velocity = velocity ?? Velocity.zero; |
|||
} |
|||
|
|||
public readonly Velocity velocity; |
|||
|
|||
public override string ToString() { |
|||
return $"ScaleEndDetails(velocity: {this.velocity}"; |
|||
} |
|||
} |
|||
|
|||
public delegate void GestureScaleStartCallback(ScaleStartDetails details); |
|||
|
|||
public delegate void GestureScaleUpdateCallback(ScaleUpdateDetails details); |
|||
|
|||
public delegate void GestureScaleEndCallback(ScaleEndDetails details); |
|||
|
|||
static class _ScaleGestureUtils { |
|||
public static bool _isFlingGesture(Velocity velocity) { |
|||
D.assert(velocity != null); |
|||
float speedSquared = velocity.pixelsPerSecond.distanceSquared; |
|||
return speedSquared > Constants.kMinFlingVelocity * Constants.kMinFlingVelocity; |
|||
} |
|||
} |
|||
|
|||
class _LineBetweenPointers { |
|||
public _LineBetweenPointers( |
|||
Offset pointerStartLocation = null, |
|||
int pointerStartId = 0, |
|||
Offset pointerEndLocation = null, |
|||
int pointerEndId = 1) { |
|||
pointerStartLocation = pointerStartLocation ?? Offset.zero; |
|||
pointerEndLocation = pointerEndLocation ?? Offset.zero; |
|||
|
|||
D.assert(pointerStartId != pointerEndId); |
|||
|
|||
this.pointerStartLocation = pointerStartLocation; |
|||
this.pointerStartId = pointerStartId; |
|||
this.pointerEndLocation = pointerEndLocation; |
|||
this.pointerEndId = pointerEndId; |
|||
} |
|||
|
|||
public readonly Offset pointerStartLocation; |
|||
|
|||
public readonly int pointerStartId; |
|||
|
|||
public readonly Offset pointerEndLocation; |
|||
|
|||
public readonly int pointerEndId; |
|||
} |
|||
|
|||
|
|||
public class ScaleGestureRecognizer : OneSequenceGestureRecognizer { |
|||
public ScaleGestureRecognizer(object debugOwner) : base(debugOwner: debugOwner) { |
|||
} |
|||
|
|||
public GestureScaleStartCallback onStart; |
|||
|
|||
public GestureScaleUpdateCallback onUpdate; |
|||
|
|||
public GestureScaleEndCallback onEnd; |
|||
|
|||
_ScaleState _state = _ScaleState.ready; |
|||
|
|||
Offset _initialFocalPoint; |
|||
Offset _currentFocalPoint; |
|||
float _initialSpan; |
|||
float _currentSpan; |
|||
float _initialHorizontalSpan; |
|||
float _currentHorizontalSpan; |
|||
float _initialVerticalSpan; |
|||
float _currentVerticalSpan; |
|||
_LineBetweenPointers _initialLine; |
|||
_LineBetweenPointers _currentLine; |
|||
Dictionary<int, Offset> _pointerLocations; |
|||
List<int> _pointerQueue; |
|||
readonly Dictionary<int, VelocityTracker> _velocityTrackers = new Dictionary<int, VelocityTracker>(); |
|||
|
|||
float _scaleFactor { |
|||
get { return this._initialSpan > 0.0f ? this._currentSpan / this._initialSpan : 1.0f; } |
|||
} |
|||
|
|||
float _horizontalScaleFactor { |
|||
get { |
|||
return this._initialHorizontalSpan > 0.0f |
|||
? this._currentHorizontalSpan / this._initialHorizontalSpan |
|||
: 1.0f; |
|||
} |
|||
} |
|||
|
|||
float _verticalScaleFactor { |
|||
get { |
|||
return this._initialVerticalSpan > 0.0f ? this._currentVerticalSpan / this._initialVerticalSpan : 1.0f; |
|||
} |
|||
} |
|||
|
|||
float _computeRotationFactor() { |
|||
if (this._initialLine == null || this._currentLine == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
float fx = this._initialLine.pointerStartLocation.dx; |
|||
float fy = this._initialLine.pointerStartLocation.dy; |
|||
float sx = this._initialLine.pointerEndLocation.dx; |
|||
float sy = this._initialLine.pointerEndLocation.dy; |
|||
|
|||
float nfx = this._currentLine.pointerStartLocation.dx; |
|||
float nfy = this._currentLine.pointerStartLocation.dy; |
|||
float nsx = this._currentLine.pointerEndLocation.dx; |
|||
float nsy = this._currentLine.pointerEndLocation.dy; |
|||
|
|||
float angle1 = Mathf.Atan2(fy - sy, fx - sx); |
|||
float angle2 = Mathf.Atan2(nfy - nsy, nfx - nsx); |
|||
|
|||
return angle2 - angle1; |
|||
} |
|||
|
|||
public override void addAllowedPointer(PointerDownEvent evt) { |
|||
this.startTrackingPointer(evt.pointer); |
|||
this._velocityTrackers[evt.pointer] = new VelocityTracker(); |
|||
if (this._state == _ScaleState.ready) { |
|||
this._state = _ScaleState.possible; |
|||
this._initialSpan = 0.0f; |
|||
this._currentSpan = 0.0f; |
|||
this._initialHorizontalSpan = 0.0f; |
|||
this._currentHorizontalSpan = 0.0f; |
|||
this._initialVerticalSpan = 0.0f; |
|||
this._currentVerticalSpan = 0.0f; |
|||
this._pointerLocations = new Dictionary<int, Offset>(); |
|||
this._pointerQueue = new List<int>(); |
|||
} |
|||
} |
|||
|
|||
protected override void handleEvent(PointerEvent evt) { |
|||
D.assert(this._state != _ScaleState.ready); |
|||
bool didChangeConfiguration = false; |
|||
bool shouldStartIfAccepted = false; |
|||
|
|||
if (evt is PointerMoveEvent) { |
|||
VelocityTracker tracker = this._velocityTrackers[evt.pointer]; |
|||
D.assert(tracker != null); |
|||
if (!evt.synthesized) { |
|||
tracker.addPosition(evt.timeStamp, evt.position); |
|||
} |
|||
|
|||
this._pointerLocations[evt.pointer] = evt.position; |
|||
shouldStartIfAccepted = true; |
|||
} |
|||
else if (evt is PointerDownEvent) { |
|||
this._pointerLocations[evt.pointer] = evt.position; |
|||
this._pointerQueue.Add(evt.pointer); |
|||
didChangeConfiguration = true; |
|||
shouldStartIfAccepted = true; |
|||
} |
|||
else if (evt is PointerUpEvent || evt is PointerCancelEvent) { |
|||
this._pointerLocations.Remove(evt.pointer); |
|||
this._pointerQueue.Remove(evt.pointer); |
|||
didChangeConfiguration = true; |
|||
} |
|||
|
|||
this._updateLines(); |
|||
this._update(); |
|||
|
|||
if (!didChangeConfiguration || this._reconfigure(evt.pointer)) { |
|||
this._advanceStateMachine(shouldStartIfAccepted); |
|||
} |
|||
|
|||
this.stopTrackingIfPointerNoLongerDown(evt); |
|||
} |
|||
|
|||
void _update() { |
|||
int count = this._pointerLocations.Keys.Count; |
|||
|
|||
Offset focalPoint = Offset.zero; |
|||
foreach (int pointer in this._pointerLocations.Keys) { |
|||
focalPoint += this._pointerLocations[pointer]; |
|||
} |
|||
|
|||
this._currentFocalPoint = count > 0 ? focalPoint / count : Offset.zero; |
|||
|
|||
float totalDeviation = 0.0f; |
|||
float totalHorizontalDeviation = 0.0f; |
|||
float totalVerticalDeviation = 0.0f; |
|||
|
|||
foreach (int pointer in this._pointerLocations.Keys) { |
|||
totalDeviation += (this._currentFocalPoint - this._pointerLocations[pointer]).distance; |
|||
totalHorizontalDeviation += (this._currentFocalPoint.dx - this._pointerLocations[pointer].dx).abs(); |
|||
totalVerticalDeviation += (this._currentFocalPoint.dy - this._pointerLocations[pointer].dy).abs(); |
|||
} |
|||
|
|||
this._currentSpan = count > 0 ? totalDeviation / count : 0.0f; |
|||
this._currentHorizontalSpan = count > 0 ? totalHorizontalDeviation / count : 0.0f; |
|||
this._currentVerticalSpan = count > 0 ? totalVerticalDeviation / count : 0.0f; |
|||
} |
|||
|
|||
void _updateLines() { |
|||
int count = this._pointerLocations.Keys.Count; |
|||
D.assert(this._pointerQueue.Count >= count); |
|||
|
|||
if (count < 2) { |
|||
this._initialLine = this._currentLine; |
|||
} |
|||
else if (this._initialLine != null && |
|||
this._initialLine.pointerStartId == this._pointerQueue[0] && |
|||
this._initialLine.pointerEndId == this._pointerQueue[1]) { |
|||
this._currentLine = new _LineBetweenPointers( |
|||
pointerStartId: this._pointerQueue[0], |
|||
pointerStartLocation: this._pointerLocations[this._pointerQueue[0]], |
|||
pointerEndId: this._pointerQueue[1], |
|||
pointerEndLocation: this._pointerLocations[this._pointerQueue[1]] |
|||
); |
|||
} |
|||
else { |
|||
this._initialLine = new _LineBetweenPointers( |
|||
pointerStartId: this._pointerQueue[0], |
|||
pointerStartLocation: this._pointerLocations[this._pointerQueue[0]], |
|||
pointerEndId: this._pointerQueue[1], |
|||
pointerEndLocation: this._pointerLocations[this._pointerQueue[1]] |
|||
); |
|||
this._currentLine = null; |
|||
} |
|||
} |
|||
|
|||
bool _reconfigure(int pointer) { |
|||
this._initialFocalPoint = this._currentFocalPoint; |
|||
this._initialSpan = this._currentSpan; |
|||
this._initialLine = this._currentLine; |
|||
this._initialHorizontalSpan = this._currentHorizontalSpan; |
|||
this._initialVerticalSpan = this._currentVerticalSpan; |
|||
if (this._state == _ScaleState.started) { |
|||
if (this.onEnd != null) { |
|||
VelocityTracker tracker = this._velocityTrackers[pointer]; |
|||
D.assert(tracker != null); |
|||
|
|||
Velocity velocity = tracker.getVelocity(); |
|||
if (_ScaleGestureUtils._isFlingGesture(velocity)) { |
|||
Offset pixelsPerSecond = velocity.pixelsPerSecond; |
|||
if (pixelsPerSecond.distanceSquared > |
|||
Constants.kMaxFlingVelocity * Constants.kMaxFlingVelocity) { |
|||
velocity = new Velocity( |
|||
pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * |
|||
Constants.kMaxFlingVelocity); |
|||
} |
|||
|
|||
this.invokeCallback<object>("onEnd", () => { |
|||
this.onEnd(new ScaleEndDetails(velocity: velocity)); |
|||
return null; |
|||
}); |
|||
} |
|||
else { |
|||
this.invokeCallback<object>("onEnd", () => { |
|||
this.onEnd(new ScaleEndDetails(velocity: Velocity.zero)); |
|||
return null; |
|||
}); |
|||
} |
|||
} |
|||
|
|||
this._state = _ScaleState.accepted; |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
void _advanceStateMachine(bool shouldStartIfAccepted) { |
|||
if (this._state == _ScaleState.ready) { |
|||
this._state = _ScaleState.possible; |
|||
} |
|||
|
|||
if (this._state == _ScaleState.possible) { |
|||
float spanDelta = (this._currentSpan - this._initialSpan).abs(); |
|||
float focalPointDelta = (this._currentFocalPoint - this._initialFocalPoint).distance; |
|||
if (spanDelta > Constants.kScaleSlop || focalPointDelta > Constants.kPanSlop) { |
|||
this.resolve(GestureDisposition.accepted); |
|||
} |
|||
} |
|||
else if (this._state >= _ScaleState.accepted) { |
|||
this.resolve(GestureDisposition.accepted); |
|||
} |
|||
|
|||
if (this._state == _ScaleState.accepted && shouldStartIfAccepted) { |
|||
this._state = _ScaleState.started; |
|||
this._dispatchOnStartCallbackIfNeeded(); |
|||
} |
|||
|
|||
if (this._state == _ScaleState.started && this.onUpdate != null) { |
|||
this.invokeCallback<object>("onUpdate", () => { |
|||
this.onUpdate(new ScaleUpdateDetails( |
|||
scale: this._scaleFactor, |
|||
horizontalScale: this._horizontalScaleFactor, |
|||
verticalScale: this._verticalScaleFactor, |
|||
focalPoint: this._currentFocalPoint, |
|||
rotation: this._computeRotationFactor() |
|||
)); |
|||
return null; |
|||
}); |
|||
} |
|||
} |
|||
|
|||
void _dispatchOnStartCallbackIfNeeded() { |
|||
D.assert(this._state == _ScaleState.started); |
|||
if (this.onStart != null) { |
|||
this.invokeCallback<object>("onStart", () => { |
|||
this.onStart(new ScaleStartDetails(focalPoint: this._currentFocalPoint)); |
|||
return null; |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public override void acceptGesture(int pointer) { |
|||
if (this._state == _ScaleState.possible) { |
|||
this._state = _ScaleState.started; |
|||
this._dispatchOnStartCallbackIfNeeded(); |
|||
} |
|||
} |
|||
|
|||
public override void rejectGesture(int pointer) { |
|||
this.stopTrackingPointer(pointer); |
|||
} |
|||
|
|||
protected override void didStopTrackingLastPointer(int pointer) { |
|||
switch (this._state) { |
|||
case _ScaleState.possible: |
|||
this.resolve(GestureDisposition.rejected); |
|||
break; |
|||
case _ScaleState.ready: |
|||
D.assert(false); |
|||
break; |
|||
case _ScaleState.accepted: |
|||
break; |
|||
case _ScaleState.started: |
|||
D.assert(false); |
|||
break; |
|||
} |
|||
|
|||
this._state = _ScaleState.ready; |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._velocityTrackers.Clear(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
public override string debugDescription { |
|||
get { return "scale"; } |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6408adf8aeb2a4ac38ee9f49dc748c2a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgets.Runtime.material { |
|||
public class TextFormField : FormField<string> { |
|||
public TextFormField( |
|||
Key key = null, |
|||
TextEditingController controller = null, |
|||
string initialValue = null, |
|||
FocusNode focusNode = null, |
|||
InputDecoration decoration = null, |
|||
TextInputType keyboardType = null, |
|||
TextCapitalization textCapitalization = TextCapitalization.none, |
|||
TextInputAction? textInputAction = null, |
|||
TextStyle style = null, |
|||
TextDirection? textDirection = null, |
|||
TextAlign textAlign = TextAlign.left, |
|||
bool autofocus = false, |
|||
bool obscureText = false, |
|||
bool autocorrect = true, |
|||
bool autovalidate = false, |
|||
bool maxLengthEnforced = true, |
|||
int maxLines = 1, |
|||
int? maxLength = null, |
|||
VoidCallback onEditingComplete = null, |
|||
ValueChanged<string> onFieldSubmitted = null, |
|||
FormFieldSetter<string> onSaved = null, |
|||
FormFieldValidator<string> validator = null, |
|||
List<TextInputFormatter> inputFormatters = null, |
|||
bool enabled = true, |
|||
float cursorWidth = 2.0f, |
|||
Radius cursorRadius = null, |
|||
Color cursorColor = null, |
|||
Brightness? keyboardAppearance = null, |
|||
EdgeInsets scrollPadding = null, |
|||
bool enableInteractiveSelection = true, |
|||
InputCounterWidgetBuilder buildCounter = null |
|||
) : base( |
|||
key: key, |
|||
initialValue: controller != null ? controller.text : (initialValue ?? ""), |
|||
onSaved: onSaved, |
|||
validator: validator, |
|||
autovalidate: autovalidate, |
|||
enabled: enabled, |
|||
builder: (FormFieldState<string> field) => { |
|||
_TextFormFieldState state = (_TextFormFieldState) field; |
|||
InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) |
|||
.applyDefaults(Theme.of(field.context).inputDecorationTheme); |
|||
return new TextField( |
|||
controller: state._effectiveController, |
|||
focusNode: focusNode, |
|||
decoration: effectiveDecoration.copyWith(errorText: field.errorText), |
|||
keyboardType: keyboardType, |
|||
textInputAction: textInputAction, |
|||
style: style, |
|||
textAlign: textAlign, |
|||
textDirection: textDirection ?? TextDirection.ltr, |
|||
textCapitalization: textCapitalization, |
|||
autofocus: autofocus, |
|||
obscureText: obscureText, |
|||
autocorrect: autocorrect, |
|||
maxLengthEnforced: maxLengthEnforced, |
|||
maxLines: maxLines, |
|||
maxLength: maxLength, |
|||
onChanged: field.didChange, |
|||
onEditingComplete: onEditingComplete, |
|||
onSubmitted: onFieldSubmitted, |
|||
inputFormatters: inputFormatters, |
|||
enabled: enabled, |
|||
cursorWidth: cursorWidth, |
|||
cursorRadius: cursorRadius, |
|||
cursorColor: cursorColor, |
|||
scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), |
|||
keyboardAppearance: keyboardAppearance, |
|||
enableInteractiveSelection: enableInteractiveSelection, |
|||
buildCounter: buildCounter |
|||
); |
|||
} |
|||
) { |
|||
D.assert(initialValue == null || controller == null); |
|||
D.assert(maxLines > 0); |
|||
D.assert(maxLength == null || maxLength > 0); |
|||
this.controller = controller; |
|||
} |
|||
|
|||
public readonly TextEditingController controller; |
|||
|
|||
public override State createState() { |
|||
return new _TextFormFieldState(); |
|||
} |
|||
} |
|||
|
|||
class _TextFormFieldState : FormFieldState<string> { |
|||
TextEditingController _controller; |
|||
|
|||
public TextEditingController _effectiveController { |
|||
get { return this.widget.controller ?? this._controller; } |
|||
} |
|||
|
|||
public new TextFormField widget { |
|||
get { return (TextFormField) base.widget; } |
|||
} |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
if (this.widget.controller == null) { |
|||
this._controller = new TextEditingController(text: this.widget.initialValue); |
|||
} |
|||
else { |
|||
this.widget.controller.addListener(this._handleControllerChanged); |
|||
} |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget _oldWidget) { |
|||
TextFormField oldWidget = _oldWidget as TextFormField; |
|||
base.didUpdateWidget(oldWidget); |
|||
if (this.widget.controller != oldWidget.controller) { |
|||
oldWidget.controller?.removeListener(this._handleControllerChanged); |
|||
this.widget.controller?.addListener(this._handleControllerChanged); |
|||
|
|||
if (oldWidget.controller != null && this.widget.controller == null) { |
|||
this._controller = TextEditingController.fromValue(oldWidget.controller.value); |
|||
} |
|||
|
|||
if (this.widget.controller != null) { |
|||
this.setValue(this.widget.controller.text); |
|||
if (oldWidget.controller == null) { |
|||
this._controller = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this.widget.controller?.removeListener(this._handleControllerChanged); |
|||
base.dispose(); |
|||
} |
|||
|
|||
public override void reset() { |
|||
base.reset(); |
|||
this.setState(() => { this._effectiveController.text = (string) this.widget.initialValue; }); |
|||
} |
|||
|
|||
void _handleControllerChanged() { |
|||
if (this._effectiveController.text != this.value) { |
|||
this.didChange(this._effectiveController.text); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0a9f1467be1c4653b3dbf8a1c7209f70 |
|||
timeCreated: 1557304128 |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgets.Runtime.rendering { |
|||
class RotatedBoxUtils { |
|||
public const float _kQuarterTurnsInRadians = Mathf.PI / 2.0f; |
|||
} |
|||
|
|||
public class RenderRotatedBox : RenderObjectWithChildMixinRenderBox<RenderBox> { |
|||
public RenderRotatedBox( |
|||
int quarterTurns, |
|||
RenderBox child = null |
|||
) { |
|||
this.child = child; |
|||
this._quarterTurns = quarterTurns; |
|||
} |
|||
|
|||
public int quarterTurns { |
|||
get { return this._quarterTurns; } |
|||
set { |
|||
if (this._quarterTurns == value) { |
|||
return; |
|||
} |
|||
|
|||
this._quarterTurns = value; |
|||
this.markNeedsLayout(); |
|||
} |
|||
} |
|||
|
|||
int _quarterTurns; |
|||
|
|||
bool _isVertical { |
|||
get { return this.quarterTurns % 2 == 1; } |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicWidth(float height) { |
|||
if (this.child == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return this._isVertical |
|||
? this.child.getMinIntrinsicHeight(height) |
|||
: this.child.getMinIntrinsicWidth(height); |
|||
} |
|||
|
|||
protected override float computeMaxIntrinsicWidth(float height) { |
|||
if (this.child == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return this._isVertical |
|||
? this.child.getMaxIntrinsicHeight(height) |
|||
: this.child.getMaxIntrinsicWidth(height); |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicHeight(float width) { |
|||
if (this.child == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return this._isVertical ? this.child.getMinIntrinsicWidth(width) : this.child.getMinIntrinsicHeight(width); |
|||
} |
|||
|
|||
protected override float computeMaxIntrinsicHeight(float width) { |
|||
if (this.child == null) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
return this._isVertical ? this.child.getMaxIntrinsicWidth(width) : this.child.getMaxIntrinsicHeight(width); |
|||
} |
|||
|
|||
Matrix3 _paintTransform; |
|||
|
|||
protected override void performLayout() { |
|||
this._paintTransform = null; |
|||
if (this.child != null) { |
|||
this.child.layout(this._isVertical ? this.constraints.flipped : this.constraints, parentUsesSize: true); |
|||
this.size = this._isVertical |
|||
? new Size(this.child.size.height, this.child.size.width) |
|||
: this.child.size; |
|||
this._paintTransform = Matrix3.I(); |
|||
this._paintTransform.preTranslate(this.size.width / 2.0f, this.size.height / 2.0f); |
|||
this._paintTransform.preRotate(RotatedBoxUtils._kQuarterTurnsInRadians * (this.quarterTurns % 4)); |
|||
this._paintTransform.preTranslate(-this.child.size.width / 2.0f, -this.child.size.height / 2.0f); |
|||
} |
|||
else { |
|||
this.performResize(); |
|||
} |
|||
} |
|||
|
|||
protected override bool hitTestChildren( |
|||
HitTestResult result, |
|||
Offset position = null |
|||
) { |
|||
D.assert(this._paintTransform != null || this.debugNeedsLayout || this.child == null); |
|||
if (this.child == null || this._paintTransform == null) { |
|||
return false; |
|||
} |
|||
|
|||
|
|||
Matrix3 inverse = Matrix3.I(); |
|||
this._paintTransform.invert(inverse); |
|||
return this.child.hitTest(result, position: inverse.mapPoint(position)); |
|||
} |
|||
|
|||
void _paintChild(PaintingContext context, Offset offset) { |
|||
context.paintChild(this.child, offset); |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
if (this.child != null) { |
|||
context.pushTransform(this.needsCompositing, offset, this._paintTransform, this._paintChild); |
|||
} |
|||
} |
|||
|
|||
public override void applyPaintTransform(RenderObject child, Matrix3 transform) { |
|||
if (this._paintTransform != null) { |
|||
transform.preConcat(this._paintTransform); |
|||
} |
|||
|
|||
base.applyPaintTransform(child, transform); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 057a0f3b94794fce9f9f3aa7bb624256 |
|||
timeCreated: 1557210363 |
|
|||
using System; |
|||
|
|||
namespace Unity.UIWidgets.ui { |
|||
public class ArrayRef<T> { |
|||
public T[] array; |
|||
|
|||
public int length; |
|||
|
|||
public ArrayRef() { |
|||
this.array = Array.Empty<T>(); |
|||
this.length = 0; |
|||
} |
|||
|
|||
public void add(T item) { |
|||
if (this.length == this.array.Length) { |
|||
int newCapacity = this.array.Length == 0 ? 4 : this.array.Length * 2; |
|||
Array.Resize(ref this.array, newCapacity); |
|||
} |
|||
|
|||
this.array[this.length++] = item; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 58955e5dc127a42a2ab203e6d1839fd8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class ScaleGestureSample : UIWidgetsSamplePanel { |
|||
protected override Widget createWidget() { |
|||
return new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new ScaleGesturePanel() |
|||
); |
|||
} |
|||
|
|||
protected override void OnEnable() { |
|||
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons"); |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
class ScaleGesturePanel : StatefulWidget { |
|||
public override State createState() { |
|||
return new ScaleGesturePanelState(); |
|||
} |
|||
} |
|||
|
|||
class ScaleGesturePanelState : State<ScaleGesturePanel> { |
|||
float scaleValue = 1.0f; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
appBar: new AppBar( |
|||
title: new Center( |
|||
child: new Text("Test Scale Gesture Widget") |
|||
) |
|||
), |
|||
body: new GestureDetector( |
|||
onScaleStart: scaleDetails => { Debug.Log("Scale Start !"); }, |
|||
onScaleUpdate: scaleDetails => { |
|||
Debug.Log("Scale value = " + scaleDetails.scale); |
|||
this.setState(() => { this.scaleValue = scaleDetails.scale; }); |
|||
}, |
|||
onScaleEnd: scaleDetails => { Debug.Log("Scale End"); }, |
|||
child: new Card( |
|||
color: Colors.white, |
|||
child: new Center( |
|||
child: new Column( |
|||
mainAxisSize: MainAxisSize.min, |
|||
crossAxisAlignment: CrossAxisAlignment.center, |
|||
children: new List<Widget> { |
|||
new Icon(Unity.UIWidgets.material.Icons.ac_unit, size: 128.0f, color: Colors.black), |
|||
new RaisedButton( |
|||
child: new Text("Scale: " + this.scaleValue), |
|||
onPressed: () => { Debug.Log("Button Pressed"); }) |
|||
} |
|||
) |
|||
)) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 38800d11bb7a9447582e892145b3bd82 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"name": "Unity.InternalAPIEngineBridge.024", |
|||
"references": [], |
|||
"optionalUnityReferences": [], |
|||
"includePlatforms": [], |
|||
"excludePlatforms": [], |
|||
"allowUnsafeCode": false, |
|||
"overrideReferences": false, |
|||
"precompiledReferences": [], |
|||
"autoReferenced": true, |
|||
"defineConstraints": [] |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4c951e9ffe25e41eabcc32758a061e70 |
|||
AssemblyDefinitionImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.UIWidgets.InternalBridge { |
|||
public static class NoAllocHelpersBridge<T> { |
|||
public static T[] ExtractArrayFromListT(List<T> list) { |
|||
return UnityEngine.NoAllocHelpers.ExtractArrayFromListT(list); |
|||
} |
|||
|
|||
public static void ResizeList(List<T> list, int size) { |
|||
if (size < list.Count) { |
|||
list.RemoveRange(size, list.Count - size); |
|||
return; |
|||
} |
|||
|
|||
if (size == list.Count) { |
|||
return; |
|||
} |
|||
|
|||
if (list.Capacity < size) { |
|||
list.Capacity = size; |
|||
} |
|||
|
|||
UnityEngine.NoAllocHelpers.ResizeList(list, size); |
|||
} |
|||
|
|||
public static void EnsureListElemCount(List<T> list, int size) { |
|||
list.Clear(); |
|||
if (list.Capacity < size) { |
|||
list.Capacity = size; |
|||
} |
|||
|
|||
ResizeList(list, size); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ae100515a41a04d9f8426e6d7c4b2d04 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9e688991bb495461b8404d9fb47c6684 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Facebook: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
WebGL: WebGL |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 963d1b7d830374b3a915967d4721dc4a |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue