Skip to content

Modern title bars: the windows draw their own caption - #149

Open
Tkyoxx wants to merge 6 commits into
Lemxy:mainfrom
Tkyoxx:pr/6-title-bars
Open

Tkyoxx wants to merge 6 commits into
Lemxy:mainfrom
Tkyoxx:pr/6-title-bars

Conversation

@Tkyoxx

@Tkyoxx Tkyoxx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Stacked on #144. Until that one is merged this branch also carries its commit, so the diff below is bigger than this PR. Its own change is 5 commits; I will rebase it as soon as #144 is in.

What

common::caption: the window draws its own caption (flat min / max / close, Windows 11 hover shades, red close) while the hit test returns the real HT* codes: drag, double-click, Snap, Shake, the window menu, resizing, Windows 11 snap layouts. Used by the installer (the header is the title bar), rust-settings, rust-explorer (the tab row, like a browser), wiztree, photoview and rtaskmgr (the top band).

Screenshot (rust-settings on Windows 10 21H2, Spanish UI)

rust-settings with its own title bar

Test

Each window on Windows 10 and 11: hover / press / click each button, maximize and restore (content stays on screen), drag, double-click, snap, right click the caption, Alt+Space, resize from every edge, two monitors with different DPI.

- winrust-common: Lang::Es and Lang::ALL; t!/tf! take an optional es: arm
  after zh: (or after pt: in calls without zh:), and any language left out
  shows the English text, so nothing is ever blank or a raw key.
- No lang.txt: the Windows UI language when WinRust has it, else English.
- lang() re-reads lang.txt at most once a second and set_lang broadcasts
  style::msg(), so open windows switch without a restart: topbar now listens
  for the broadcast, rust-settings rebuilds its pages and rust-explorer its
  column headers and navigation pane when the language moved. The "restart
  the programs" notes say the switch is immediate now.
- The installer list, rust-settings and the bar's language page take their
  languages from Lang::ALL (Spanish included); --lang accepts es.
- Spanish for every t!/tf! call (1,246), the installer table, the Run box
  commands and the Start button menu, plus the few strings still English-only
  in rust-explorer.
- rs-launcher's counts gave "2 registry entrys" and Portuguese had no plural
  at all: every language now spells out its singular and plural.
The WinRust windows paint everything themselves except the caption, so on
Windows 10 each one wore the old system title bar on top of a modern page.

caption.rs takes the standard caption away (WM_NCCALCSIZE: the whole window
is client area) and lets the window paint flat minimize / maximize / close
buttons in its own colours, with Windows 11's hover shades and the red close.
The hit test answers with the real HT* codes, so dragging, double-click to
maximize, Aero Snap and Shake, the window menu (right click, Alt+Space),
resizing from every edge and Windows 11's snap layouts keep working. Clicks
on the buttons are handled here, not by DefWindowProc, which would paint the
classic buttons over ours while tracking them. A maximized window keeps its
frame off-screen out of the client area; one pixel of DWM frame keeps the
shadow on Windows 10. A child window lying over the caption can paint the
buttons and pass the free parts through with HTTRANSPARENT.

The installer's dark header is the title bar now: it drags the window, the
language list moved left to clear the buttons.
The buttons sit at the top right and the page title's band drags the window, as in Windows 11 Settings; the sidebar's page list stays clickable where it reaches into that band. The caption colour attributes are gone with the caption.
Like a browser: the tabs sit in the caption, its free space drags the window and the buttons sit at its right end. The chrome child answers HTTRANSPARENT there, so the top-level window does the caption's work, and it paints the buttons itself. Tabs leave room for them. The desktop window (--desktop) is left alone.
WinRust Disk's path line is the caption. The photo viewer gets a thin strip with the file's name, position and size over the picture area; zoom and panning count from under it.
The band drags the window except over the menu button and the page buttons, which move left to clear the caption buttons. The search box is a window of its own and keeps working as before.
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.

1 participant