show disabled cursor on the control end

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-10-16 12:29:51 +08:00
parent 268dddc303
commit 52a21234d4
2 changed files with 38 additions and 5 deletions

View File

@@ -280,10 +280,12 @@ class ImagePaint extends StatelessWidget {
final s = c.scale;
mouseRegion({child}) => Obx(() => MouseRegion(
cursor: (cursorOverImage.isTrue && keyboardEnabled.isTrue)
? (remoteCursorMoved.isTrue
? SystemMouseCursors.none
: _buildCustomCursorLinux(context, s))
cursor: cursorOverImage.isTrue
? keyboardEnabled.isTrue
? (remoteCursorMoved.isTrue
? SystemMouseCursors.none
: _buildCustomCursorLinux(context, s))
: _buildDisabledCursor(context, s)
: MouseCursor.defer,
onHover: (evt) {},
child: child));
@@ -350,6 +352,28 @@ class ImagePaint extends StatelessWidget {
}
}
MouseCursor _buildDisabledCursor(BuildContext context, double scale) {
final cursor = Provider.of<CursorModel>(context);
final cacheLinux = cursor.cacheLinux;
if (cacheLinux == null) {
return MouseCursor.defer;
} else {
if (cursor.cachedForbidmemoryCursorData == null) {
cursor.updateForbiddenCursorBuffer();
}
final key = 'disabled_cursor_key';
cursor.addKeyLinux(key);
return FlutterCustomMemoryImageCursor(
pixbuf: cursor.cachedForbidmemoryCursorData,
key: key,
hotx: cacheLinux.hotx,
hoty: cacheLinux.hoty,
imageWidth: 32,
imageHeight: 32,
);
}
}
Widget _buildCrossScrollbarFromLayout(
BuildContext context, Widget child, Size layoutSize, Size size) {
final scrollConfig = CustomMouseWheelScrollConfig(