Add peer option: zoom cursor & show menubar on conn

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-11-16 18:07:58 +08:00
parent 46423614c8
commit 9a70725090
28 changed files with 121 additions and 23 deletions

View File

@@ -51,6 +51,7 @@ class _RemotePageState extends State<RemotePage>
String keyboardMode = "legacy";
final _cursorOverImage = false.obs;
late RxBool _showRemoteCursor;
late RxBool _zoomCursor;
late RxBool _remoteCursorMoved;
late RxBool _keyboardEnabled;
@@ -68,6 +69,10 @@ class _RemotePageState extends State<RemotePage>
KeyboardEnabledState.init(id);
ShowRemoteCursorState.init(id);
RemoteCursorMovedState.init(id);
final optZoomCursor = 'zoom-cursor';
PeerBoolOption.init(id, optZoomCursor,
() => bind.sessionGetToggleOptionSync(id: id, arg: optZoomCursor));
_zoomCursor = PeerBoolOption.find(id, optZoomCursor);
_showRemoteCursor = ShowRemoteCursorState.find(id);
_keyboardEnabled = KeyboardEnabledState.find(id);
_remoteCursorMoved = RemoteCursorMovedState.find(id);
@@ -216,6 +221,7 @@ class _RemotePageState extends State<RemotePage>
});
return ImagePaint(
id: widget.id,
zoomCursor: _zoomCursor,
cursorOverImage: _cursorOverImage,
keyboardEnabled: _keyboardEnabled,
remoteCursorMoved: _remoteCursorMoved,
@@ -233,6 +239,7 @@ class _RemotePageState extends State<RemotePage>
visible: _showRemoteCursor.isTrue && _remoteCursorMoved.isTrue,
child: CursorPaint(
id: widget.id,
zoomCursor: _zoomCursor,
))));
paints.add(QualityMonitor(_ffi.qualityMonitorModel));
paints.add(RemoteMenubar(
@@ -253,6 +260,7 @@ class _RemotePageState extends State<RemotePage>
class ImagePaint extends StatefulWidget {
final String id;
final Rx<bool> zoomCursor;
final Rx<bool> cursorOverImage;
final Rx<bool> keyboardEnabled;
final Rx<bool> remoteCursorMoved;
@@ -261,6 +269,7 @@ class ImagePaint extends StatefulWidget {
ImagePaint(
{Key? key,
required this.id,
required this.zoomCursor,
required this.cursorOverImage,
required this.keyboardEnabled,
required this.remoteCursorMoved,
@@ -277,6 +286,7 @@ class _ImagePaintState extends State<ImagePaint> {
final ScrollController _vertical = ScrollController();
String get id => widget.id;
Rx<bool> get zoomCursor => widget.zoomCursor;
Rx<bool> get cursorOverImage => widget.cursorOverImage;
Rx<bool> get keyboardEnabled => widget.keyboardEnabled;
Rx<bool> get remoteCursorMoved => widget.remoteCursorMoved;
@@ -357,7 +367,7 @@ class _ImagePaintState extends State<ImagePaint> {
if (cache == null) {
return MouseCursor.defer;
} else {
final key = cache.updateGetKey(scale);
final key = cache.updateGetKey(scale, zoomCursor.value);
cursor.addKey(key);
return FlutterCustomMemoryImageCursor(
pixbuf: cache.data,
@@ -500,8 +510,13 @@ class _ImagePaintState extends State<ImagePaint> {
class CursorPaint extends StatelessWidget {
final String id;
final RxBool zoomCursor;
const CursorPaint({Key? key, required this.id}) : super(key: key);
const CursorPaint({
Key? key,
required this.id,
required this.zoomCursor,
}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -516,13 +531,21 @@ class CursorPaint extends StatelessWidget {
hoty = m.defaultImage!.height / 2;
}
}
return CustomPaint(
painter: ImagePainter(
image: m.image ?? m.defaultImage,
x: m.x - hotx + c.x / c.scale,
y: m.y - hoty + c.y / c.scale,
scale: c.scale),
);
return zoomCursor.isTrue
? CustomPaint(
painter: ImagePainter(
image: m.image ?? m.defaultImage,
x: m.x - hotx + c.x / c.scale,
y: m.y - hoty + c.y / c.scale,
scale: c.scale),
)
: CustomPaint(
painter: ImagePainter(
image: m.image ?? m.defaultImage,
x: (m.x - hotx) * c.scale + c.x,
y: (m.y - hoty) * c.scale + c.y,
scale: 1.0),
);
}
}

View File

@@ -47,7 +47,8 @@ class MenubarState {
}
_initSet(bool s, bool p) {
show = RxBool(s);
// Show remubar when connection is established.
show = RxBool(true);
_pin = RxBool(p);
}
@@ -1109,6 +1110,25 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
);
}());
/// Show remote cursor
displayMenu.add(() {
final opt = 'zoom-cursor';
final state = PeerBoolOption.find(widget.id, opt);
return MenuEntrySwitch2<String>(
switchType: SwitchType.scheckbox,
text: translate('Zoom cursor'),
getter: () {
return state;
},
setter: (bool v) async {
state.value = v;
await bind.sessionToggleOption(id: widget.id, value: opt);
},
padding: padding,
dismissOnClicked: true,
);
}());
/// Show quality monitor
displayMenu.add(MenuEntrySwitch<String>(
switchType: SwitchType.scheckbox,