flutter_desktop: change cursor on scroll auto
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
d8f16a523e
commit
adafa38cfa
@ -537,8 +537,17 @@ class ImagePaint extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<ImageModel>(context);
|
final m = Provider.of<ImageModel>(context);
|
||||||
var c = Provider.of<CanvasModel>(context);
|
var c = Provider.of<CanvasModel>(context);
|
||||||
|
|
||||||
final s = c.scale;
|
final s = c.scale;
|
||||||
|
|
||||||
|
mouseRegion({child}) => Obx(() => MouseRegion(
|
||||||
|
cursor: (cursorOverImage.isTrue && keyboardEnabled.isTrue)
|
||||||
|
? (remoteCursorMoved.isTrue
|
||||||
|
? SystemMouseCursors.none
|
||||||
|
: _buildCustomCursorLinux(context, s))
|
||||||
|
: MouseCursor.defer,
|
||||||
|
onHover: (evt) {},
|
||||||
|
child: child));
|
||||||
|
|
||||||
if (c.scrollStyle == ScrollStyle.scrollbar) {
|
if (c.scrollStyle == ScrollStyle.scrollbar) {
|
||||||
final imageWidget = SizedBox(
|
final imageWidget = SizedBox(
|
||||||
width: c.getDisplayWidth() * s,
|
width: c.getDisplayWidth() * s,
|
||||||
@ -547,7 +556,6 @@ class ImagePaint extends StatelessWidget {
|
|||||||
painter: ImagePainter(image: m.image, x: 0, y: 0, scale: s),
|
painter: ImagePainter(image: m.image, x: 0, y: 0, scale: s),
|
||||||
));
|
));
|
||||||
|
|
||||||
Rx<Offset> pos = Rx<Offset>(const Offset(0.0, 0.0));
|
|
||||||
return Center(
|
return Center(
|
||||||
child: NotificationListener<ScrollNotification>(
|
child: NotificationListener<ScrollNotification>(
|
||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
@ -562,16 +570,8 @@ class ImagePaint extends StatelessWidget {
|
|||||||
c.setScrollPercent(percentX, percentY);
|
c.setScrollPercent(percentX, percentY);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: Obx(() => MouseRegion(
|
child: mouseRegion(
|
||||||
cursor: (cursorOverImage.isTrue && keyboardEnabled.isTrue)
|
child: _buildCrossScrollbar(_buildListener(imageWidget))),
|
||||||
? (remoteCursorMoved.isTrue
|
|
||||||
? SystemMouseCursors.none
|
|
||||||
: _buildCustomCursorLinux(context, s))
|
|
||||||
: MouseCursor.defer,
|
|
||||||
onHover: (evt) {
|
|
||||||
pos.value = evt.position;
|
|
||||||
},
|
|
||||||
child: _buildCrossScrollbar(_buildListener(imageWidget)))),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -582,7 +582,7 @@ class ImagePaint extends StatelessWidget {
|
|||||||
painter:
|
painter:
|
||||||
ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
||||||
));
|
));
|
||||||
return _buildListener(imageWidget);
|
return mouseRegion(child: _buildListener(imageWidget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,6 +594,8 @@ class ImagePaint extends StatelessWidget {
|
|||||||
} else {
|
} else {
|
||||||
final key = cacheLinux.key(scale);
|
final key = cacheLinux.key(scale);
|
||||||
cursor.addKeyLinux(key);
|
cursor.addKeyLinux(key);
|
||||||
|
// debugPrint(
|
||||||
|
// 'REMOVE ME ================================= linux curor key: $key');
|
||||||
return FlutterCustomMemoryImageCursor(
|
return FlutterCustomMemoryImageCursor(
|
||||||
pixbuf: cacheLinux.data,
|
pixbuf: cacheLinux.data,
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -8,7 +8,7 @@ import './material_mod_popup_menu.dart' as mod_menu;
|
|||||||
|
|
||||||
// https://stackoverflow.com/questions/68318314/flutter-popup-menu-inside-popup-menu
|
// https://stackoverflow.com/questions/68318314/flutter-popup-menu-inside-popup-menu
|
||||||
class PopupMenuChildrenItem<T> extends mod_menu.PopupMenuEntry<T> {
|
class PopupMenuChildrenItem<T> extends mod_menu.PopupMenuEntry<T> {
|
||||||
PopupMenuChildrenItem({
|
const PopupMenuChildrenItem({
|
||||||
key,
|
key,
|
||||||
this.height = kMinInteractiveDimension,
|
this.height = kMinInteractiveDimension,
|
||||||
this.padding,
|
this.padding,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user