Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit 83c9cdb

Browse files
authored
Merge pull request #187 from Unity-Technologies/handle_touches_on_mobile
Handle touches on mobile
2 parents 10f9911 + e23cbe0 commit 83c9cdb

File tree

14 files changed

+258
-338
lines changed

14 files changed

+258
-338
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using uiwidgets;
4+
using Unity.UIWidgets.engine;
5+
using Unity.UIWidgets.foundation;
6+
using Unity.UIWidgets.material;
7+
using Unity.UIWidgets.rendering;
8+
using Unity.UIWidgets.ui;
9+
using Unity.UIWidgets.widgets;
10+
using UnityEngine;
11+
using UnityEngine.Networking;
12+
using Image = Unity.UIWidgets.widgets.Image;
13+
using ui_ = Unity.UIWidgets.widgets.ui_;
14+
15+
namespace UIWidgetsSample
16+
{
17+
public class MobileTouchSample : UIWidgetsPanel
18+
{
19+
protected override void main()
20+
{
21+
ui_.runApp(new MaterialApp(
22+
title: "Http Request Sample",
23+
home: new Scaffold(
24+
body: new MobileTouchWidget()
25+
)
26+
));
27+
}
28+
}
29+
30+
public class MobileTouchWidget : StatefulWidget
31+
{
32+
public MobileTouchWidget(Key key = null) : base(key)
33+
{
34+
}
35+
36+
public override State createState()
37+
{
38+
return new MobileTouchWidgetState();
39+
}
40+
}
41+
42+
class MobileTouchWidgetState : State<MobileTouchWidget>
43+
{
44+
private float scale = 1;
45+
private int frameNo = 0;
46+
private float rotation = 0;
47+
48+
public override Widget build(BuildContext context)
49+
{
50+
return new Column(
51+
crossAxisAlignment: CrossAxisAlignment.center,
52+
children: new List<Widget>()
53+
{
54+
new Text("Frame: " + frameNo),
55+
new Text("Scale: " + scale),
56+
new Text("Rotation: " + rotation),
57+
new GestureDetector(
58+
child: new Container(height: 300, color: Colors.blue),
59+
onScaleStart: details => { },
60+
onScaleUpdate: details =>
61+
{
62+
scale = details.scale;
63+
rotation = details.rotation;
64+
frameNo += 1;
65+
setState(() => { });
66+
},
67+
onScaleEnd: details => { }
68+
)
69+
});
70+
}
71+
}
72+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:1da51fd7da36b323f17882f7ddaabbb5a08c09ce5e649821a1f242927da4974f
3-
size 76055048
2+
oid sha256:39792c1a15937910cf2938e3e9937422e3520dab4a14b09f3e8fbf91a233db52
3+
size 76747900
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:ee599723799bd2fd383fd8e36407ab66072cf01d6df48a349efe8ee9e6300b25
3-
size 247466888
2+
oid sha256:845d1eb0cab9827127f8758e5393fbc12191fae907edffab8a2d29db5425c945
3+
size 247828112
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:16d2be3e47cfadfd0bbb33aabe4edc5a18e04dd122172b5f9fa855d04e8158ee
3-
size 21817320
2+
oid sha256:45bc8d2b586ede8e9dae7ce5f660b4cbadf0994d0d7b4d28e7c2fd6211d116fa
3+
size 21819832
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:8db63b6dfb62799c6decd05c92136208ae0dcce6eb3d545bbda1e19594e9ba75
3-
size 11256320
2+
oid sha256:49701553366d65e4ed4f03b9d8534c47f4bc9bd5b847dffbe3c11e19033d9264
3+
size 11258880

com.unity.uiwidgets/Runtime/Plugins/x86_64/libUIWidgets.dll.meta

Lines changed: 33 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.uiwidgets/Runtime/engine/UIWidgetsPanelWrapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ public void OnMouseMove(Vector2? pos) {
289289
if (pos == null) {
290290
return;
291291
}
292-
293-
UIWidgetsPanel_onMouseMove(ptr: _ptr, x: pos.Value.x, y: pos.Value.y);
292+
293+
UIWidgetsPanel_onMouseMove(ptr: _ptr, x: pos.Value.x, y: pos.Value.y, -1);
294294
}
295295

296296
public void OnMouseScroll(Vector2 delta, Vector2? pos) {
@@ -330,7 +330,7 @@ public void OnDrag(Vector2? pos, int pointerId) {
330330

331331
// mouse event
332332
if (pointerId < 0) {
333-
UIWidgetsPanel_onMouseMove(ptr: _ptr, x: pos.Value.x, y: pos.Value.y);
333+
UIWidgetsPanel_onMouseMove(ptr: _ptr, x: pos.Value.x, y: pos.Value.y, pointerId);
334334
}
335335
}
336336

@@ -360,7 +360,7 @@ public void OnKeyDown(Event e) {
360360
static extern void UIWidgetsPanel_onMouseUp(IntPtr ptr, float x, float y, int button);
361361

362362
[DllImport(dllName: NativeBindings.dllName)]
363-
static extern void UIWidgetsPanel_onMouseMove(IntPtr ptr, float x, float y);
363+
static extern void UIWidgetsPanel_onMouseMove(IntPtr ptr, float x, float y, int button);
364364

365365
[DllImport(dllName: NativeBindings.dllName)]
366366
static extern void UIWidgetsPanel_onMouseLeave(IntPtr ptr);

engine/Scripts/lib_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def set_env_verb():
127127
global flutter_root_path
128128
flutter_root_path = os.getenv('FLUTTER_ROOT_PATH', 'null')
129129
if flutter_root_path == 'null':
130-
os.environ["FLUTTER_ROOT_PATH"] = engine_path + "/engine/src"
130+
os.environ["FLUTTER_ROOT_PATH"] = os.path.join(engine_path, "engine","src")
131131
flutter_root_path = os.getenv('FLUTTER_ROOT_PATH')
132132
else:
133133
print("This environment variable has been set, skip")

0 commit comments

Comments
 (0)