refact: mobile reset canvas (#9766)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-10-29 09:49:04 +08:00 committed by GitHub
parent 3a75947553
commit f0450db203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1659,11 +1659,25 @@ class CanvasModel with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
clear([bool notify = false]) { // For reset canvas to the last view style
reset() {
_scale = _lastViewStyle.scale;
_devicePixelRatio = ui.window.devicePixelRatio;
if (kIgnoreDpi && _lastViewStyle.style == kRemoteViewStyleOriginal) {
_scale = 1.0 / _devicePixelRatio;
}
final displayWidth = getDisplayWidth();
final displayHeight = getDisplayHeight();
_x = (size.width - displayWidth * _scale) / 2;
_y = (size.height - displayHeight * _scale) / 2;
bind.sessionSetViewStyle(sessionId: sessionId, value: _lastViewStyle.style);
notifyListeners();
}
clear() {
_x = 0; _x = 0;
_y = 0; _y = 0;
_scale = 1.0; _scale = 1.0;
if (notify) notifyListeners();
} }
updateScrollPercent() { updateScrollPercent() {
@ -1988,7 +2002,7 @@ class CursorModel with ChangeNotifier {
_x = _displayOriginX; _x = _displayOriginX;
_y = _displayOriginY; _y = _displayOriginY;
parent.target?.inputModel.moveMouse(_x, _y); parent.target?.inputModel.moveMouse(_x, _y);
parent.target?.canvasModel.clear(true); parent.target?.canvasModel.reset();
notifyListeners(); notifyListeners();
} }