浏览代码

Merge branch 'master' into layout

/main
Yuncong Zhang 5 年前
当前提交
447d118a
共有 6 个文件被更改,包括 45 次插入23 次删除
  1. 4
      Runtime/editor/editor_utils.cs
  2. 6
      Runtime/engine/DisplayMetrics.cs
  3. 2
      Runtime/engine/UIWidgetsPanel.cs
  4. 22
      Runtime/gestures/long_press.cs
  5. 11
      Runtime/widgets/gesture_detector.cs
  6. 23
      Samples/UIWidgetSample/LongPressSample.cs

4
Runtime/editor/editor_utils.cs


public void OnEnable() {
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio();
}
public void onViewMetricsChanged() {
}
public float devicePixelRatio {
get { return this._lastDevicePixelRatio; }

6
Runtime/engine/DisplayMetrics.cs


void OnEnable();
void OnGUI();
void Update();
void onViewMetricsChanged();
float devicePixelRatio { get; }

}
public void Update() {
}
public void onViewMetricsChanged() {
public float devicePixelRatio {
get {

2
Runtime/engine/UIWidgetsPanel.cs


void _handleViewMetricsChanged(string method, List<JSONNode> args) {
this._windowAdapter.onViewMetricsChanged();
this._displayMetrics.Update();
this._displayMetrics.onViewMetricsChanged();
}
protected override void OnEnable() {

22
Runtime/gestures/long_press.cs


base(deadline: Constants.kLongPressTimeout, debugOwner: debugOwner, kind: kind) {
}
bool _longPressAccepted = false;
public GestureLongPressUpCallback onLongPressUp;
this._longPressAccepted = true;
if (this.onLongPress != null) {
this.invokeCallback<object>("onLongPress", () => {
this.onLongPress();

protected override void handlePrimaryPointer(PointerEvent evt) {
if (evt is PointerUpEvent) {
this.resolve(GestureDisposition.rejected);
if (this._longPressAccepted && this.onLongPressUp != null) {
this._longPressAccepted = false;
this.invokeCallback<object>("onLongPressUp", () => {
this.onLongPressUp();
return null;
});
}
else {
this.resolve(GestureDisposition.rejected);
}
}
else if (evt is PointerDownEvent || evt is PointerCancelEvent) {
this._longPressAccepted = false;
}
}

Offset _longPressOrigin;
TimeSpan? _longPressStartTimestamp;
public GestureLongPressDragStartCallback onLongPressStart;
public GestureLongPressDragUpdateCallback onLongPressDragUpdate;

11
Runtime/widgets/gesture_detector.cs


throw new UIWidgetsError(
"Incorrect GestureDetector arguments.\n" +
"Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer."
);
);
string recognizer = havePan ? "pan" : "scale";
if (haveVerticalDrag && haveHorizontalDrag) {
throw new UIWidgetsError(

);
}
}
if (haveLongPress && haveLongPressDrag) {
throw new UIWidgetsError(
"Incorrect GestureDetector arguments.\n" +

gestures[typeof(LongPressGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
() => new LongPressGestureRecognizer(debugOwner: this),
instance => { instance.onLongPress = this.onLongPress; }
instance => {
instance.onLongPress = this.onLongPress;
instance.onLongPressUp = this.onLongPressUp;
}
);
}

23
Samples/UIWidgetSample/LongPressSample.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
public class LongPressSample: UIWidgetsSamplePanel {
protected override Widget createWidget() {
public class LongPressSample : UIWidgetsSamplePanel {
protected override Widget createWidget() {
return new WidgetsApp(
home: new LongPressSampleWidget(),
pageRouteBuilder: this.pageRouteBuilder);

public class LongPressSampleWidget: StatefulWidget {
public class LongPressSampleWidget : StatefulWidget {
public override State createState() {
return new _LongPressSampleWidgetState();
}

public override Widget build(BuildContext context) {
return new GestureDetector(
onLongPressDragStart: (value) => {
Debug.Log($"Long Press Drag Start: {value}");
},
onLongPressDragUpdate: (value) => {
Debug.Log($"Long Press Drag Update: {value}");
},
onLongPressDragUp: (value) => {
Debug.Log($"Long Press Drag Up: {value}");
},
onLongPressDragStart: (value) => { Debug.Log($"Long Press Drag Start: {value}"); },
onLongPressDragUpdate: (value) => { Debug.Log($"Long Press Drag Update: {value}"); },
onLongPressDragUp: (value) => { Debug.Log($"Long Press Drag Up: {value}"); },
onLongPressUp: () => { Debug.Log($"Long Press Up"); },
onLongPress: () => { Debug.Log($"Long Press"); },
child: new Center(
child: new Container(
width: 200,

正在加载...
取消
保存