mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 23:19:02 +08:00
fix: android, two finger pan, scale (#8429)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
0b32e741f7
commit
42394fcbdd
@ -305,7 +305,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// mobile
|
// mobile
|
||||||
ffi.canvasModel.updateScale(d.scale / _scale);
|
ffi.canvasModel.updateScale(d.scale / _scale, d.focalPoint);
|
||||||
_scale = d.scale;
|
_scale = d.scale;
|
||||||
ffi.canvasModel.panX(d.focalPointDelta.dx);
|
ffi.canvasModel.panX(d.focalPointDelta.dx);
|
||||||
ffi.canvasModel.panY(d.focalPointDelta.dy);
|
ffi.canvasModel.panY(d.focalPointDelta.dy);
|
||||||
|
@ -1576,22 +1576,21 @@ class CanvasModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScale(double v) {
|
updateScale(double v, Offset focalPoint) {
|
||||||
if (parent.target?.imageModel.image == null) return;
|
if (parent.target?.imageModel.image == null) return;
|
||||||
final offset = parent.target?.cursorModel.offset ?? const Offset(0, 0);
|
final s = _scale;
|
||||||
var r = parent.target?.cursorModel.getVisibleRect() ?? Rect.zero;
|
|
||||||
final px0 = (offset.dx - r.left) * _scale;
|
|
||||||
final py0 = (offset.dy - r.top) * _scale;
|
|
||||||
_scale *= v;
|
_scale *= v;
|
||||||
final maxs = parent.target?.imageModel.maxScale ?? 1;
|
final maxs = parent.target?.imageModel.maxScale ?? 1;
|
||||||
final mins = parent.target?.imageModel.minScale ?? 1;
|
final mins = parent.target?.imageModel.minScale ?? 1;
|
||||||
if (_scale > maxs) _scale = maxs;
|
if (_scale > maxs) _scale = maxs;
|
||||||
if (_scale < mins) _scale = mins;
|
if (_scale < mins) _scale = mins;
|
||||||
r = parent.target?.cursorModel.getVisibleRect() ?? Rect.zero;
|
// (focalPoint.dx - _x_1) / s1 + displayOriginX = (focalPoint.dx - _x_2) / s2 + displayOriginX
|
||||||
final px1 = (offset.dx - r.left) * _scale;
|
// _x_2 = focalPoint.dx - (focalPoint.dx - _x_1) / s1 * s2
|
||||||
final py1 = (offset.dy - r.top) * _scale;
|
_x = focalPoint.dx - (focalPoint.dx - _x) / s * _scale;
|
||||||
_x -= px1 - px0;
|
final adjustForKeyboard = parent.target?.cursorModel.adjustForKeyboard() ?? 0.0;
|
||||||
_y -= py1 - py0;
|
// (focalPoint.dy - _y_1 + adjust) / s1 + displayOriginY = (focalPoint.dy - _y_2 + adjust) / s2 + displayOriginY
|
||||||
|
// _y_2 = focalPoint.dy + adjust - (focalPoint.dy - _y_1 + adjust) / s1 * s2
|
||||||
|
_y = focalPoint.dy + adjustForKeyboard - (focalPoint.dy - _y + adjustForKeyboard) / s * _scale;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user