From 1d7a9487b4b5de7ab77d375d27b576d9efbad794 Mon Sep 17 00:00:00 2001 From: AnvarAtayev Date: Fri, 27 Feb 2026 09:58:07 +1100 Subject: [PATCH] [222_45] compact toolbar and fix native menu bar empty strip (#2877) --- TeXmacs/misc/themes/liii-night.css | 35 ++++++++++++++++++++-------- TeXmacs/misc/themes/liii.css | 32 +++++++++++++++----------- devel/222_45.md | 37 ++++++++++++++++++++++++++++++ src/Plugins/Qt/qt_tm_widget.cpp | 22 ++++-------------- 4 files changed, 85 insertions(+), 41 deletions(-) create mode 100644 devel/222_45.md diff --git a/TeXmacs/misc/themes/liii-night.css b/TeXmacs/misc/themes/liii-night.css index 83c0449abb..259fdc1fa9 100644 --- a/TeXmacs/misc/themes/liii-night.css +++ b/TeXmacs/misc/themes/liii-night.css @@ -26,13 +26,13 @@ QMenuBar QWidget { } QMenuBar { - padding-top: 6px; - spacing: 8px; + padding-top: 2px; + spacing: 4px; } QMenuBar::item { background: transparent; - padding: 6px 12px; + padding: 3px 10px; border-radius: 4px; } @@ -119,16 +119,31 @@ QToolBar { background: #2c2c2c; color: #ffffff; border-bottom: none; - spacing: 3px; - padding: 4px; - min-height: 36px !important; - max-height: 36px !important; + spacing: 1px; + padding: 1px; + min-height: 28px !important; + max-height: 28px !important; +} + +QToolBar#focusToolBar, +QToolBar#modeToolBar, +QToolBar#mainToolBar, +QToolBar#tabToolBar { + min-height: 28px !important; + max-height: 28px !important; + padding: 2px; +} + +QToolBar#menuToolBar { + min-height: 28px !important; + max-height: 28px !important; + padding: 0px; } QToolButton { - border-radius: 8px; - padding: 4px; - margin: 2px; + border-radius: 6px; + padding: 2px; + margin: 1px; background-color: transparent; border: 1px solid transparent; color: #ffffff; diff --git a/TeXmacs/misc/themes/liii.css b/TeXmacs/misc/themes/liii.css index 39567ab073..849dd13501 100644 --- a/TeXmacs/misc/themes/liii.css +++ b/TeXmacs/misc/themes/liii.css @@ -26,13 +26,13 @@ QMenuBar QWidget { } QMenuBar { - padding-top: 6px; - spacing: 8px; + padding-top: 2px; + spacing: 4px; } QMenuBar::item { background: transparent; - padding: 6px 12px; + padding: 3px 10px; border-radius: 4px; } @@ -115,25 +115,31 @@ QToolBar { background: #f3f3f3; color: #2c2c2c; border-bottom: none; - spacing: 3px; - padding: 2px; - min-height: 36px !important; - max-height: 36px !important; + spacing: 1px; + padding: 1px; + min-height: 28px !important; + max-height: 28px !important; } QToolBar#focusToolBar, QToolBar#modeToolBar, QToolBar#mainToolBar, QToolBar#tabToolBar { - min-height: 36px !important; - max-height: 36px !important; - padding: 4px; + min-height: 28px !important; + max-height: 28px !important; + padding: 2px; +} + +QToolBar#menuToolBar { + min-height: 28px !important; + max-height: 28px !important; + padding: 0px; } QToolButton { - border-radius: 8px; - padding: 4px; - margin: 2px; + border-radius: 6px; + padding: 2px; + margin: 1px; background-color: transparent; border: 1px solid transparent; } diff --git a/devel/222_45.md b/devel/222_45.md new file mode 100644 index 0000000000..e6f3dfc584 --- /dev/null +++ b/devel/222_45.md @@ -0,0 +1,37 @@ +# 222_45 Compact toolbar and native menu bar fix + +Issue #2877 + +## Summary + +Reduce vertical height of the `liii` and `liii-night` toolbars for a more compact UI, +and fix an empty white strip left behind when `use_native_menubar` is enabled. + +## How to Test + +### Compact toolbar (liii / liii-night theme) + +- Build and launch Mogan with the default (`liii`) or `liii Dark` theme. +- Verify the toolbar rows (main, mode, focus, tab) are visually more compact than before. +- Verify the menu bar (File, Edit, etc.) is visible and items are readable. +- Verify icon hover/press states still render correctly. + +### Native menu bar (macOS) + +- In Preferences -> User Interface, enable `use_native_menubar`. +- Restart Mogan. +- Verify the macOS system menu bar shows File, Edit, etc. correctly. +- Verify no empty white strip appears where the in-window menu bar used to be. +- Disable `use_native_menubar`, restart - verify the in-window menu bar returns. + +## Files Changed + +- `TeXmacs/misc/themes/liii.css` - reduced toolbar `min/max-height` from 36 px to 28 px; + reduced `QToolButton` and `QMenuBar` padding to fit the new height. +- `TeXmacs/misc/themes/liii-night.css` - same changes as `liii.css` for the dark theme. +- `src/Plugins/Qt/qt_tm_widget.cpp`: + - Removed erroneous `dest->setFixedHeight(108 * devicePixelRatio)` in + `install_main_menu()` (physical-pixel value used for a logical-pixel widget height). + - Guard `menuToolBar` visibility on `!use_native_menubar` in both + `update_visibility()` and `install_main_menu()` so the toolbar is hidden when + the native menu bar is active. diff --git a/src/Plugins/Qt/qt_tm_widget.cpp b/src/Plugins/Qt/qt_tm_widget.cpp index 1c16cf6c35..59b62d8513 100644 --- a/src/Plugins/Qt/qt_tm_widget.cpp +++ b/src/Plugins/Qt/qt_tm_widget.cpp @@ -814,7 +814,7 @@ qt_tm_widget_rep::update_visibility () { bool old_titleVisibility = windowAgent->titleBar ()->isVisible (); bool new_mainVisibility = visibility[1] && visibility[0]; - bool new_menuVisibility = visibility[0]; + bool new_menuVisibility = visibility[0] && !use_native_menubar; bool new_modeVisibility = visibility[2] && visibility[0]; bool new_focusVisibility = visibility[3] && visibility[0]; bool new_userVisibility = visibility[4] && visibility[0]; @@ -1205,21 +1205,7 @@ qt_tm_widget_rep::install_main_menu () { main_menu_widget = waiting_main_menu_widget; QList* src= main_menu_widget->get_qactionlist (); if (!src) return; - QMenuBar* dest = new QMenuBar (); - QScreen* screen= QGuiApplication::primaryScreen (); -#ifdef Q_OS_WIN - // 设置与 menuToolBar 匹配的固定高度 - // 使用 devicePixelRatio() 获取正确的屏幕缩放比 - // 获取屏幕DPI缩放比例 - double dpi = screen ? screen->logicalDotsPerInch () : 96.0; - double scale= dpi / 96.0; - - int h= (int) floor (72 * scale + 0.5); -#else - double scale= screen ? screen->devicePixelRatio () : 1.0; // 正确的屏幕缩放比 - int h = (int) floor (108 * scale + 0.5); -#endif - dest->setFixedHeight (h); + QMenuBar* dest= new QMenuBar (); if (tm_style_sheet == "") dest->setStyle (qtmstyle ()); if (!use_native_menubar) { @@ -1249,8 +1235,8 @@ qt_tm_widget_rep::install_main_menu () { for (QWidget* w : widgets) { w->setParent (nullptr); } - // 确保 menuToolBar 可见 - if (!menuToolBar->isVisible ()) { + // 确保 menuToolBar 可见 (only when not using native menu bar) + if (!use_native_menubar && !menuToolBar->isVisible ()) { menuToolBar->setVisible (true); }