Skip to content

[222_70] compact toolbar and fix native menu bar empty strip (#2877)#2878

Open
AnvarAtayev wants to merge 1 commit intoMoganLab:mainfrom
AnvarAtayev:AnvarAtayev/222_45/compact-toolbar
Open

[222_70] compact toolbar and fix native menu bar empty strip (#2877)#2878
AnvarAtayev wants to merge 1 commit intoMoganLab:mainfrom
AnvarAtayev:AnvarAtayev/222_45/compact-toolbar

Conversation

@AnvarAtayev
Copy link
Copy Markdown
Contributor

Closes Issue #2877

Summary

Two related UI improvements for the liii/liii-night themes on macOS:

  1. Compact toolbars - reduce toolbar row height from 36 px to 28 px and tighten button padding, giving a denser, more native-feeling toolbar layout.
  2. Fix empty white strip with native menu bar - when use_native_menubar is enabled, the menuToolBar container remained visible at full height even though its content moved to the system menu bar. The toolbar is now hidden in this case.

Also removes an incorrect setFixedHeight(108 * devicePixelRatio) on the QMenuBar widget, which was setting a physical-pixel value on a logical-pixel widget (resulting in a 216 px tall menu bar on Retina displays).

Files Changed

  • TeXmacs/misc/themes/liii.css
  • TeXmacs/misc/themes/liii-night.css
  • src/Plugins/Qt/qt_tm_widget.cpp

How to Test

  • Build and launch with the default (liii) theme; verify toolbar rows are more compact
  • Enable use_native_menubar in Preferences -> User Interface; verify no empty strip remains below the title bar
  • Disable use_native_menubar; verify the in-window menu bar returns correctly

OLD - use_nativebar=True
CleanShot 2026-02-27 at 10 22 58@2x

OLD - use_nativebar=False
CleanShot 2026-02-27 at 10 23 57@2x

NEW
Image

@MoonL79
Copy link
Copy Markdown
Contributor

MoonL79 commented Mar 4, 2026

The code you modified exists to fix another issue. Here is the corresponding commit:

85a6a4e

Your modifications only run successfully on specific devices. The effect on my Debian 13 is as follows:

image

If you would like to further improve it, this pull request will remain open for you. If you prefer not to continue, I will close it.

@AnvarAtayev
Copy link
Copy Markdown
Contributor Author

Hi @MoonL79 , thank you for your feedback. I will improve the change and will submit changes to this PR

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 3, 2026

Greptile Summary

本 PR 针对 macOS 上 liii/liii-night 主题进行了两项 UI 改进:将工具栏行高从 36px 压缩至 28px,并修复了启用原生菜单栏时 menuToolBar 残留空白条的问题,同时移除了对 QMenuBar 错误使用物理像素值调用 setFixedHeight 的 macOS 路径。

  • Linux 分支中仍存在相同的原始 bug:108 * devicePixelRatio() 被传入逻辑像素 API setFixedHeight,在 2× HiDPI Linux 显示器上会产生 216px 高的菜单栏(详见内联注释)。

Confidence Score: 4/5

macOS 修复正确,但 Linux HiDPI 菜单栏高度 bug 仍未解决,建议合并前一并处理

macOS 相关修复逻辑清晰,CSS 变更对称且合理。但 Linux 非 macOS 路径中 108 * devicePixelRatio() 传入逻辑像素 API 的问题是一个现存的实际视觉缺陷,本 PR 已经处理了 macOS 同类问题,Linux 路径理应一并修复。

src/Plugins/Qt/qt_tm_widget.cpp — install_main_menu() 中 Linux 分支的 setFixedHeight 计算

Important Files Changed

Filename Overview
src/Plugins/Qt/qt_tm_widget.cpp 在 update_visibility() 和 install_main_menu() 中增加了 macOS 原生菜单栏检测逻辑,隐藏 menuToolBar 以消除空白条;移除了 macOS 上对 QMenuBar 错误使用 setFixedHeight 物理像素值的问题;并为 macOS 自定义主题下菜单栏设置了合理的最小高度
TeXmacs/misc/themes/liii.css 将工具栏高度从 36px 压缩到 28px,减小按钮内边距和菜单栏间距,新增 QToolBar#menuToolBar 专属规则,保持视觉一致性
TeXmacs/misc/themes/liii-night.css 与 liii.css 变更对称,将工具栏高度从 36px 压缩到 28px,并新增 QToolBar#menuToolBar 专属规则(之前缺少该规则)
devel/222_70.md 新增任务文档,描述紧凑工具栏和原生菜单栏修复的测试步骤,与实现一致

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[update_visibility 或 install_main_menu 被调用] --> B{当前平台是否为 macOS?}
    B -- 是 --> C{use_native_menubar 是否启用?}
    B -- 否 --> D[use_native_menu_bar_in_window = false]
    C -- 是 --> E[use_native_menu_bar_in_window = true]
    C -- 否 --> F[use_native_menu_bar_in_window = false]
    D --> G[new_menuVisibility 正常计算]
    F --> G
    E --> H[new_menuVisibility = false]
    G --> I[menuToolBar 正常显示]
    H --> J[menuToolBar 隐藏,消除空白条]
    I --> K{install_main_menu: 需要显示?}
    K -- 是 --> L[menuToolBar.setVisible true]
    K -- 否 --> M[跳过,保持当前状态]
Loading

Comments Outside Diff (1)

  1. src/Plugins/Qt/qt_tm_widget.cpp, line 1353-1367 (link)

    Linux 非 macOS 路径仍在逻辑像素 API 中使用物理像素值

    #ifndef Q_OS_MAC 块中,Linux 分支继续使用 screen->devicePixelRatio() 乘以 108 后调用 setFixedHeight(h)setFixedHeight 接受的是逻辑像素,而 devicePixelRatio() 是物理/逻辑像素之比(HiDPI 下为 2.0),因此在 2× 缩放的 Linux 显示器上菜单栏高度将被设置为 216 逻辑像素,与 macOS 的原始 bug 完全相同。本 PR 已正确修复了 macOS 路径,Linux 路径同样需要改为使用逻辑 DPI 缩放(如 Windows 分支那样用 logicalDotsPerInch() / 96.0),或改用 setMinimumHeight 而非 setFixedHeight

    #else  // Linux
      double dpi  = screen ? screen->logicalDotsPerInch () : 96.0;
      double scale= dpi / 96.0;
      int    h    = (int) floor (108 * scale + 0.5);
    #endif
      dest->setFixedHeight (h);

Reviews (4): Last reviewed commit: "[222_70] compact toolbar and fix native ..." | Re-trigger Greptile

@AnvarAtayev AnvarAtayev changed the title [222_45] compact toolbar and fix native menu bar empty strip (#2877) [222_70] compact toolbar and fix native menu bar empty strip (#2877) Apr 3, 2026
@AnvarAtayev AnvarAtayev marked this pull request as draft April 3, 2026 05:19
@AnvarAtayev AnvarAtayev force-pushed the AnvarAtayev/222_45/compact-toolbar branch from 6d4d81c to 6293775 Compare April 3, 2026 11:55
@AnvarAtayev AnvarAtayev force-pushed the AnvarAtayev/222_45/compact-toolbar branch from 6293775 to fe401fa Compare April 3, 2026 11:56
@AnvarAtayev AnvarAtayev marked this pull request as ready for review April 3, 2026 11:57
@AnvarAtayev
Copy link
Copy Markdown
Contributor Author

Hi @MoonL79, I have now modified the PR to revert some of the changes that caused regressions for Debian systems, and made the native menubar changes specific for MacOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants