win32: natural sizes and paddings at the monitor's DPI (#171) - #172
Merged
Merged
Conversation
Closes #171. The measure's defaults for a control with no size of its own (a field 140x26, a progress bar 140x16, a text area 200x80, a button's 24/10 of padding, a checkbox's box and gap) were 96-DPI numbers used as pixels, so on a 150% monitor they were two thirds of themselves around a font that had grown. w32_px scales them at the window's DPI; a DPI change already lays the tree out again through w32_refont_tree. The dead second WK_DIVIDER branch (2x2, unreachable behind the 12x12 one) is gone.
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.
Closes #171.
The measure's defaults for a control with no size of its own — a field 140×26, a slider 140×26, a progress bar 140×16, a text area 200×80, a button's 24/10 of padding, a label's 4/4, a checkbox's 18px box and 28px gap, a divider's 12, the catch-all 100×24 — were 96-DPI numbers used as pixels. After #170 the font follows the monitor's DPI, so on a 150% monitor these were two thirds of themselves around a face that had grown: a 26px field around an 18px font clips.
w32_px(hwnd, n)=MulDiv(n, dpi, 96)at the window's DPI (the system's while the widget sits on the hidden holder), applied to every default and padding inmeasure_widget_intrinsic. A DPI change already lays the tree out again throughw32_refont_tree(#170), so the new sizes take effect on the monitor the window moves to. The dead secondWK_DIVIDERbranch (2×2, unreachable behind the 12×12 one) is removed.At 96 DPI this is the identity, which is what this box and CI run at: the 74-spec headless sweep and the on-screen subset from #170 apply unchanged (same backend, identity numbers). The non-96 case is correct by construction; a screen grab on a 125%/150% monitor would be the proof, and this machine has none.