From bb201a47cb88b331dc0081c9da12d647f69d0e68 Mon Sep 17 00:00:00 2001 From: 21pages Date: Fri, 10 Mar 2023 13:54:23 +0800 Subject: [PATCH 1/2] separate menubars open only when clicked Signed-off-by: 21pages --- flutter/lib/desktop/widgets/remote_menubar.dart | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_menubar.dart b/flutter/lib/desktop/widgets/remote_menubar.dart index 173ed038c..e7ca23ea6 100644 --- a/flutter/lib/desktop/widgets/remote_menubar.dart +++ b/flutter/lib/desktop/widgets/remote_menubar.dart @@ -414,7 +414,7 @@ class _RemoteMenubarState extends State { scrollDirection: Axis.horizontal, child: Theme( data: themeData(), - child: MenuBar( + child: Row( children: [ SizedBox(width: _MenubarTheme.buttonHMargin), ...menubarItems, @@ -440,6 +440,8 @@ class _RemoteMenubarState extends State { ), ), dividerTheme: DividerThemeData(space: 4), + menuBarTheme: MenuBarThemeData( + style: MenuStyle(padding: MaterialStatePropertyAll(EdgeInsets.zero))), ); } } @@ -552,6 +554,7 @@ class _MonitorMenu extends StatelessWidget { final pi = ffi.ffiModel.pi; for (int i = 0; i < pi.displays.length; i++) { rowChildren.add(_IconMenuButton( + topLevel: false, color: _MenubarTheme.blueColor, hoverColor: _MenubarTheme.hoverBlueColor, tooltip: "", @@ -1819,6 +1822,7 @@ class _IconMenuButton extends StatefulWidget { final VoidCallback? onPressed; final double? hMargin; final double? vMargin; + final bool topLevel; const _IconMenuButton({ Key? key, this.assetName, @@ -1829,6 +1833,7 @@ class _IconMenuButton extends StatefulWidget { required this.onPressed, this.hMargin, this.vMargin, + this.topLevel = true, }) : super(key: key); @override @@ -1848,7 +1853,7 @@ class _IconMenuButtonState extends State<_IconMenuButton> { width: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize, ); - return SizedBox( + final button = SizedBox( width: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize, child: MenuItemButton( @@ -1874,6 +1879,11 @@ class _IconMenuButtonState extends State<_IconMenuButton> { ).marginSymmetric( horizontal: widget.hMargin ?? _MenubarTheme.buttonHMargin, vertical: widget.vMargin ?? _MenubarTheme.buttonVMargin); + if (widget.topLevel) { + return MenuBar(children: [button]); + } else { + return button; + } } } @@ -1914,7 +1924,7 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { width: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize, ); - return SizedBox( + final button = SizedBox( width: _MenubarTheme.buttonSize, height: _MenubarTheme.buttonSize, child: SubmenuButton( @@ -1940,6 +1950,7 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { .marginSymmetric( horizontal: _MenubarTheme.buttonHMargin, vertical: _MenubarTheme.buttonVMargin); + return MenuBar(children: [button]); } } From d28aa6eeb09d428cf1849835526cffb8b1c8966c Mon Sep 17 00:00:00 2001 From: 21pages Date: Fri, 10 Mar 2023 14:16:18 +0800 Subject: [PATCH 2/2] not show menubar tooltip Signed-off-by: 21pages --- .../lib/desktop/widgets/remote_menubar.dart | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_menubar.dart b/flutter/lib/desktop/widgets/remote_menubar.dart index e7ca23ea6..3e37cef40 100644 --- a/flutter/lib/desktop/widgets/remote_menubar.dart +++ b/flutter/lib/desktop/widgets/remote_menubar.dart @@ -516,6 +516,7 @@ class _MonitorMenu extends StatelessWidget { return Offstage(); } return _IconSubmenuButton( + tooltip: 'Select Monitor', icon: icon(), ffi: ffi, color: _MenubarTheme.blueColor, @@ -607,6 +608,7 @@ class _ControlMenu extends StatelessWidget { @override Widget build(BuildContext context) { return _IconSubmenuButton( + tooltip: 'Control Actions', svg: "assets/actions.svg", color: _MenubarTheme.blueColor, hoverColor: _MenubarTheme.hoverBlueColor, @@ -928,6 +930,7 @@ class _DisplayMenuState extends State<_DisplayMenu> { Widget build(BuildContext context) { _updateScreen(); return _IconSubmenuButton( + tooltip: 'Display Settings', svg: "assets/display.svg", ffi: widget.ffi, color: _MenubarTheme.blueColor, @@ -1611,6 +1614,7 @@ class _KeyboardMenu extends StatelessWidget { return Offstage(); } return _IconSubmenuButton( + tooltip: 'Keyboard Settings', svg: "assets/keyboard.svg", ffi: ffi, color: _MenubarTheme.blueColor, @@ -1698,6 +1702,7 @@ class _ChatMenuState extends State<_ChatMenu> { @override Widget build(BuildContext context) { return _IconSubmenuButton( + tooltip: 'Chat', key: chatButtonKey, svg: 'assets/chat.svg', ffi: widget.ffi, @@ -1816,7 +1821,7 @@ class _CloseMenu extends StatelessWidget { class _IconMenuButton extends StatefulWidget { final String? assetName; final Widget? icon; - final String tooltip; + final String? tooltip; final Color color; final Color hoverColor; final VoidCallback? onPressed; @@ -1827,7 +1832,7 @@ class _IconMenuButton extends StatefulWidget { Key? key, this.assetName, this.icon, - required this.tooltip, + this.tooltip, required this.color, required this.hoverColor, required this.onPressed, @@ -1864,17 +1869,14 @@ class _IconMenuButtonState extends State<_IconMenuButton> { hover = value; }), onPressed: widget.onPressed, - child: Tooltip( - message: translate(widget.tooltip), - child: Material( - type: MaterialType.transparency, - child: Ink( - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(_MenubarTheme.iconRadius), - color: hover ? widget.hoverColor : widget.color, - ), - child: icon))), + child: Material( + type: MaterialType.transparency, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(_MenubarTheme.iconRadius), + color: hover ? widget.hoverColor : widget.color, + ), + child: icon)), ), ).marginSymmetric( horizontal: widget.hMargin ?? _MenubarTheme.buttonHMargin, @@ -1888,6 +1890,7 @@ class _IconMenuButtonState extends State<_IconMenuButton> { } class _IconSubmenuButton extends StatefulWidget { + final String tooltip; final String? svg; final Widget? icon; final Color color; @@ -1900,6 +1903,7 @@ class _IconSubmenuButton extends StatefulWidget { {Key? key, this.svg, this.icon, + required this.tooltip, required this.color, required this.hoverColor, required this.menuChildren, @@ -1925,32 +1929,33 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> { height: _MenubarTheme.buttonSize, ); final button = SizedBox( - width: _MenubarTheme.buttonSize, - height: _MenubarTheme.buttonSize, - child: SubmenuButton( - menuStyle: widget.menuStyle, - style: ButtonStyle( - padding: MaterialStatePropertyAll(EdgeInsets.zero), - overlayColor: MaterialStatePropertyAll(Colors.transparent)), - onHover: (value) => setState(() { - hover = value; - }), - child: Material( - type: MaterialType.transparency, - child: Ink( - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(_MenubarTheme.iconRadius), - color: hover ? widget.hoverColor : widget.color, - ), - child: icon)), - menuChildren: widget.menuChildren - .map((e) => _buildPointerTrackWidget(e, widget.ffi)) - .toList())) - .marginSymmetric( - horizontal: _MenubarTheme.buttonHMargin, - vertical: _MenubarTheme.buttonVMargin); - return MenuBar(children: [button]); + width: _MenubarTheme.buttonSize, + height: _MenubarTheme.buttonSize, + child: SubmenuButton( + menuStyle: widget.menuStyle, + style: ButtonStyle( + padding: MaterialStatePropertyAll(EdgeInsets.zero), + overlayColor: MaterialStatePropertyAll(Colors.transparent)), + onHover: (value) => setState(() { + hover = value; + }), + child: Material( + type: MaterialType.transparency, + child: Ink( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(_MenubarTheme.iconRadius), + color: hover ? widget.hoverColor : widget.color, + ), + child: icon)), + menuChildren: widget.menuChildren + .map((e) => _buildPointerTrackWidget(e, widget.ffi)) + .toList())); + return MenuBar(children: [ + button.marginSymmetric( + horizontal: _MenubarTheme.buttonHMargin, + vertical: _MenubarTheme.buttonVMargin) + ]); } }