adjust cursor position for keyboard
This commit is contained in:
parent
ed3fd81ef7
commit
e3b0ee9caf
@ -252,6 +252,13 @@ class CursorModel with ChangeNotifier {
|
|||||||
return Rect.fromLTWH(x0, y0, size.width / scale, size.height / scale);
|
return Rect.fromLTWH(x0, y0, size.width / scale, size.height / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double adjustForKeyboard() {
|
||||||
|
var keyboardHeight = MediaQueryData.fromWindow(ui.window).viewInsets.bottom;
|
||||||
|
if (keyboardHeight < 100) return 0;
|
||||||
|
var h = _y - getVisibleRect().top;
|
||||||
|
return h > 200 ? h - 200 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void updatePan(double dx, double dy) {
|
void updatePan(double dx, double dy) {
|
||||||
final scale = FFI.canvasModel.scale;
|
final scale = FFI.canvasModel.scale;
|
||||||
dx /= scale;
|
dx /= scale;
|
||||||
|
@ -221,10 +221,11 @@ class ImagePaint extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<ImageModel>(context);
|
final m = Provider.of<ImageModel>(context);
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = Provider.of<CanvasModel>(context);
|
||||||
|
final adjust = FFI.cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter:
|
painter: new ImagePainter(
|
||||||
new ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
image: m.image, x: c.x / s, y: (c.y - adjust) / s, scale: s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,12 +235,13 @@ class CursorPaint extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
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 = FFI.cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
image: m.image,
|
image: m.image,
|
||||||
x: m.x * s - m.hotx + c.x,
|
x: m.x * s - m.hotx + c.x,
|
||||||
y: m.y * s - m.hoty + c.y,
|
y: m.y * s - m.hoty + c.y - adjust,
|
||||||
scale: 1),
|
scale: 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user