scroll/drag/right

This commit is contained in:
open-trade 2020-11-25 17:02:27 +08:00
parent 114f03f00c
commit 87c339d884
2 changed files with 26 additions and 10 deletions

View File

@ -408,9 +408,16 @@ class FFI {
return getByName('remote_id'); return getByName('remote_id');
} }
static void tap() { static void tap(bool right) {
sendMouse('down', 'left'); sendMouse('down', right ? 'right' : 'left');
sendMouse('up', 'left'); sendMouse('up', right ? 'right' : 'left');
}
static void scroll(double y) {
var y2 = y.round();
if (y2 == 0) return;
setByName('send_mouse',
json.encode(modify({'type': 'wheel', 'y': y2.toString()})));
} }
static void resetModifiers() { static void resetModifiers() {

View File

@ -94,9 +94,6 @@ class _RemotePageState extends State<RemotePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final size = MediaQueryData.fromWindow(ui.window).size;
print('$size');
print('${MediaQuery.of(context).size}');
EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
@ -178,12 +175,16 @@ class _RemotePageState extends State<RemotePage> {
: null, : null,
body: GestureDetector( body: GestureDetector(
onTap: () { onTap: () {
FFI.tap(); if (_drag || _scroll) return;
FFI.tap(_right);
}, },
onScaleStart: (details) { onScaleStart: (details) {
_scale = 1; _scale = 1;
_xOffset = details.focalPoint.dx; _xOffset = details.focalPoint.dx;
_yOffset = details.focalPoint.dy; _yOffset = details.focalPoint.dy;
if (_drag) {
FFI.sendMouse('down', 'left');
}
}, },
onScaleUpdate: (details) { onScaleUpdate: (details) {
var scale = details.scale; var scale = details.scale;
@ -192,15 +193,23 @@ class _RemotePageState extends State<RemotePage> {
var y = details.focalPoint.dy; var y = details.focalPoint.dy;
var dx = x - _xOffset; var dx = x - _xOffset;
var dy = y - _yOffset; var dy = y - _yOffset;
FFI.cursorModel.updatePan(dx, dy); if (_scroll) {
FFI.scroll(-dy);
} else {
FFI.cursorModel.updatePan(dx, dy);
}
_xOffset = x; _xOffset = x;
_yOffset = y; _yOffset = y;
} else { } else if (!_drag && !_scroll) {
FFI.canvasModel.updateScale(scale / _scale); FFI.canvasModel.updateScale(scale / _scale);
_scale = scale; _scale = scale;
} }
}, },
onScaleEnd: (_) {}, onScaleEnd: (_) {
if (_drag) {
FFI.sendMouse('up', 'left');
}
},
child: FlutterEasyLoading( child: FlutterEasyLoading(
child: Container( child: Container(
color: MyTheme.canvasColor, color: MyTheme.canvasColor,