Repository navigation
macOS: centre the window buttons in the title bar (#170) - #323
Merged
Merged
Conversation
AppKit draws the traffic lights centred in its standard 28 pt title-bar band, but GridCraft's title bar was 38 pt tall, so the lights sat above its centre line. On macOS the title bar is now 28 pt with 22 pt controls, and content starts after the lights with the same gap they keep from the top. Other platforms are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Merged — thank you for the contribution! (I resolved a small conflict in the title bar: the Save button keeps #223's commit-edit fix and uses your If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #170
Root cause
On macOS the window has no system title bar (
with_fullsize_content_view,with_titlebar_shown(false)inapps/gridcraft/src/main.rs). AppKit still draws the traffic lights, centred in its standard 28 pt title-bar band at the top of the window. GridCraft's own title bar was 38 pt tall, so the lights sat about 5 pt above its centre line, and the content started 76 pt from the left. This is the same issue as storytold/wordcraft#225, fixed there by wordcraft#255; this PR uses the same analysis.Neither winit 0.30 nor egui/eframe 0.36 can move the traffic lights, and doing it directly means AppKit calls (
unsafe), which the workspace forbids. So the title bar now fits the lights instead.What changed
crates/ui-egui/src/ribbon.rs, macOS only (cfg!(target_os = "macos"), asTITLE_LEFT_PADalready did). Linux, Windows and web are unchanged.MAC_CONTENT_LEFT: the end of the three lights (12 pt buttons, 20 pt pitch, the first at about 10 pt) plus the 8 pt gap the lights keep from the top. That is 70 pt instead of 76.Tests and commands run
cargo test -p gridcraft-ui-egui --lib title_bar,cargo test -p gridcraft-ui-egui --test interactioncargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings,cargo fmt -p gridcraft-ui-egui -- --check,cargo check --target wasm32-unknown-unknown -p gridcraft-ui-eguiNot done
title_bar(Linux window controls and desktop polish), so whichever merges second will need a small rebase. Neither changes the macOS geometry.Unverified assumptions (needs confirmation on macOS)
🤖 Generated with Claude Code