fix: android cursor scale (#8478)
* fix: android cursor scale Signed-off-by: fufesou <linlong1266@gmail.com> * Min scale restriction for mobile cursor Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
49f848a453
commit
dbbd9179b7
@ -927,7 +927,7 @@ class CursorPaint extends StatelessWidget {
|
|||||||
final m = Provider.of<CursorModel>(context);
|
final m = Provider.of<CursorModel>(context);
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = Provider.of<CanvasModel>(context);
|
||||||
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
final s = c.scale;
|
||||||
double hotx = m.hotx;
|
double hotx = m.hotx;
|
||||||
double hoty = m.hoty;
|
double hoty = m.hoty;
|
||||||
if (m.image == null) {
|
if (m.image == null) {
|
||||||
@ -936,12 +936,22 @@ class CursorPaint extends StatelessWidget {
|
|||||||
hoty = preDefaultCursor.image!.height / 2;
|
hoty = preDefaultCursor.image!.height / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final image = m.image ?? preDefaultCursor.image;
|
||||||
|
final minSize = 24.0;
|
||||||
|
double mins =
|
||||||
|
minSize / (image!.width > image.height ? image.width : image.height);
|
||||||
|
double factor = 1.0;
|
||||||
|
if (s < mins) {
|
||||||
|
factor = s / mins;
|
||||||
|
}
|
||||||
|
final s2 = s < mins ? mins : s;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: ImagePainter(
|
painter: ImagePainter(
|
||||||
image: m.image ?? preDefaultCursor.image,
|
image: image,
|
||||||
x: m.x * s - hotx + c.x,
|
x: (m.x - hotx) * factor + c.x / s2,
|
||||||
y: m.y * s - hoty + c.y - adjust,
|
y: (m.y - hoty) * factor + (c.y - adjust) / s2,
|
||||||
scale: 1),
|
scale: s2),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user