Merge pull request #3586 from 21pages/fix

open menubars only when clicked
This commit is contained in:
RustDesk 2023-03-10 14:55:19 +08:00 committed by GitHub
commit 0fade39527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -414,7 +414,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: Theme( child: Theme(
data: themeData(), data: themeData(),
child: MenuBar( child: Row(
children: [ children: [
SizedBox(width: _MenubarTheme.buttonHMargin), SizedBox(width: _MenubarTheme.buttonHMargin),
...menubarItems, ...menubarItems,
@ -440,6 +440,8 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
), ),
), ),
dividerTheme: DividerThemeData(space: 4), dividerTheme: DividerThemeData(space: 4),
menuBarTheme: MenuBarThemeData(
style: MenuStyle(padding: MaterialStatePropertyAll(EdgeInsets.zero))),
); );
} }
} }
@ -514,6 +516,7 @@ class _MonitorMenu extends StatelessWidget {
return Offstage(); return Offstage();
} }
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Select Monitor',
icon: icon(), icon: icon(),
ffi: ffi, ffi: ffi,
color: _MenubarTheme.blueColor, color: _MenubarTheme.blueColor,
@ -552,6 +555,7 @@ class _MonitorMenu extends StatelessWidget {
final pi = ffi.ffiModel.pi; final pi = ffi.ffiModel.pi;
for (int i = 0; i < pi.displays.length; i++) { for (int i = 0; i < pi.displays.length; i++) {
rowChildren.add(_IconMenuButton( rowChildren.add(_IconMenuButton(
topLevel: false,
color: _MenubarTheme.blueColor, color: _MenubarTheme.blueColor,
hoverColor: _MenubarTheme.hoverBlueColor, hoverColor: _MenubarTheme.hoverBlueColor,
tooltip: "", tooltip: "",
@ -604,6 +608,7 @@ class _ControlMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Control Actions',
svg: "assets/actions.svg", svg: "assets/actions.svg",
color: _MenubarTheme.blueColor, color: _MenubarTheme.blueColor,
hoverColor: _MenubarTheme.hoverBlueColor, hoverColor: _MenubarTheme.hoverBlueColor,
@ -925,6 +930,7 @@ class _DisplayMenuState extends State<_DisplayMenu> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
_updateScreen(); _updateScreen();
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Display Settings',
svg: "assets/display.svg", svg: "assets/display.svg",
ffi: widget.ffi, ffi: widget.ffi,
color: _MenubarTheme.blueColor, color: _MenubarTheme.blueColor,
@ -1608,6 +1614,7 @@ class _KeyboardMenu extends StatelessWidget {
return Offstage(); return Offstage();
} }
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Keyboard Settings',
svg: "assets/keyboard.svg", svg: "assets/keyboard.svg",
ffi: ffi, ffi: ffi,
color: _MenubarTheme.blueColor, color: _MenubarTheme.blueColor,
@ -1695,6 +1702,7 @@ class _ChatMenuState extends State<_ChatMenu> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Chat',
key: chatButtonKey, key: chatButtonKey,
svg: 'assets/chat.svg', svg: 'assets/chat.svg',
ffi: widget.ffi, ffi: widget.ffi,
@ -1813,22 +1821,24 @@ class _CloseMenu extends StatelessWidget {
class _IconMenuButton extends StatefulWidget { class _IconMenuButton extends StatefulWidget {
final String? assetName; final String? assetName;
final Widget? icon; final Widget? icon;
final String tooltip; final String? tooltip;
final Color color; final Color color;
final Color hoverColor; final Color hoverColor;
final VoidCallback? onPressed; final VoidCallback? onPressed;
final double? hMargin; final double? hMargin;
final double? vMargin; final double? vMargin;
final bool topLevel;
const _IconMenuButton({ const _IconMenuButton({
Key? key, Key? key,
this.assetName, this.assetName,
this.icon, this.icon,
required this.tooltip, this.tooltip,
required this.color, required this.color,
required this.hoverColor, required this.hoverColor,
required this.onPressed, required this.onPressed,
this.hMargin, this.hMargin,
this.vMargin, this.vMargin,
this.topLevel = true,
}) : super(key: key); }) : super(key: key);
@override @override
@ -1848,7 +1858,7 @@ class _IconMenuButtonState extends State<_IconMenuButton> {
width: _MenubarTheme.buttonSize, width: _MenubarTheme.buttonSize,
height: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize,
); );
return SizedBox( final button = SizedBox(
width: _MenubarTheme.buttonSize, width: _MenubarTheme.buttonSize,
height: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize,
child: MenuItemButton( child: MenuItemButton(
@ -1859,25 +1869,28 @@ class _IconMenuButtonState extends State<_IconMenuButton> {
hover = value; hover = value;
}), }),
onPressed: widget.onPressed, onPressed: widget.onPressed,
child: Tooltip(
message: translate(widget.tooltip),
child: Material( child: Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Ink( child: Ink(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius: BorderRadius.circular(_MenubarTheme.iconRadius),
BorderRadius.circular(_MenubarTheme.iconRadius),
color: hover ? widget.hoverColor : widget.color, color: hover ? widget.hoverColor : widget.color,
), ),
child: icon))), child: icon)),
), ),
).marginSymmetric( ).marginSymmetric(
horizontal: widget.hMargin ?? _MenubarTheme.buttonHMargin, horizontal: widget.hMargin ?? _MenubarTheme.buttonHMargin,
vertical: widget.vMargin ?? _MenubarTheme.buttonVMargin); vertical: widget.vMargin ?? _MenubarTheme.buttonVMargin);
if (widget.topLevel) {
return MenuBar(children: [button]);
} else {
return button;
}
} }
} }
class _IconSubmenuButton extends StatefulWidget { class _IconSubmenuButton extends StatefulWidget {
final String tooltip;
final String? svg; final String? svg;
final Widget? icon; final Widget? icon;
final Color color; final Color color;
@ -1890,6 +1903,7 @@ class _IconSubmenuButton extends StatefulWidget {
{Key? key, {Key? key,
this.svg, this.svg,
this.icon, this.icon,
required this.tooltip,
required this.color, required this.color,
required this.hoverColor, required this.hoverColor,
required this.menuChildren, required this.menuChildren,
@ -1914,7 +1928,7 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
width: _MenubarTheme.buttonSize, width: _MenubarTheme.buttonSize,
height: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize,
); );
return SizedBox( final button = SizedBox(
width: _MenubarTheme.buttonSize, width: _MenubarTheme.buttonSize,
height: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize,
child: SubmenuButton( child: SubmenuButton(
@ -1936,10 +1950,12 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
child: icon)), child: icon)),
menuChildren: widget.menuChildren menuChildren: widget.menuChildren
.map((e) => _buildPointerTrackWidget(e, widget.ffi)) .map((e) => _buildPointerTrackWidget(e, widget.ffi))
.toList())) .toList()));
.marginSymmetric( return MenuBar(children: [
button.marginSymmetric(
horizontal: _MenubarTheme.buttonHMargin, horizontal: _MenubarTheme.buttonHMargin,
vertical: _MenubarTheme.buttonVMargin); vertical: _MenubarTheme.buttonVMargin)
]);
} }
} }