fix cursor (hotx,hoty) && add default remote cursor image

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-11-13 23:41:07 +08:00
parent 5a25d0c9f7
commit a3afb03109
3 changed files with 83 additions and 58 deletions

View File

@@ -340,10 +340,8 @@ class ImagePaint extends StatelessWidget {
return FlutterCustomMemoryImageCursor(
pixbuf: cache.data,
key: key,
// hotx: cache.hotx,
// hoty: cache.hoty,
hotx: 0,
hoty: 0,
hotx: cache.hotx,
hoty: cache.hoty,
imageWidth: (cache.width * cache.scale).toInt(),
imageHeight: (cache.height * cache.scale).toInt(),
);
@@ -488,11 +486,19 @@ class CursorPaint extends StatelessWidget {
final m = Provider.of<CursorModel>(context);
final c = Provider.of<CanvasModel>(context);
// final adjust = m.adjustForKeyboard();
double hotx = m.hotx;
double hoty = m.hoty;
if (m.image == null) {
if (m.defaultCache != null) {
hotx = m.defaultCache!.hotx;
hoty = m.defaultCache!.hoty;
}
}
return CustomPaint(
painter: ImagePainter(
image: m.image,
x: m.x - m.hotx + c.x / c.scale,
y: m.y - m.hoty + c.y / c.scale,
image: m.image ?? m.defaultImage,
x: m.x - hotx + c.x / c.scale,
y: m.y - hoty + c.y / c.scale,
scale: c.scale),
);
}