The draw list speaks floats over four corners, so every widget spelled out
the same conversion. draw_fill(), draw_border(), clip_to() and clip_pop()
take the Rect that layout already produced.
They live on Kit, not OverlayList: overlay.hpp includes only Vulkan and two
standard headers, and pulling Rect down would couple the drawing layer to
the widget layer for nothing. focus_ring() and draw_shadow() set the
precedent.
Distinct names rather than overloads of the four-float entry points, so a
call site says which one runs.
right(), bottom() and empty() replace hand-written edge arithmetic where it
reads as an edge -- not where the expression merely happens to contain one.
empty() also absorbs the guards that compared int fields against 0.0f.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Kit::dpr_ is a positive invariant: it starts at 1.0f, and both writers
clamp, so the "dpr > 0 ? dpr : 1" dance at every read was checking
something that cannot happen. thumb_dest_params() keeps its clamp, being
the one that takes dpr as a parameter.
Browser's set_dpr() re-tested a delta that its callee had already decided
on; Splitter::min_w's fallback repeated the same 8.0f its default and its
only assignment already spell out.
GridRow::y/h and layout_w_ held integers in floats. Kit::px() was
open-coded three times. kGlow duplicated kGlowPts. Also removes
kWinPadY, which had no uses before this series either.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Widget geometry is in device pixels now, so the draw list's own grid is
1:1: the sole caller of begin() passed a literal 1.0f, making every
multiplication and division by fb_scale a no-op.
Rounding stays. Drawing still adds fractions on top of integer layout --
glyph origins, the entry caret's scroll offset, glow edges -- so snap_fb()
keeps rounding, just without the scale.
Also renames begin()'s width_pts/height_pts to _px, which is what they
have carried since the conversion, and what makes them correct as the NDC
divisor.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Kit::text_ascent() had no callers: baseline placement goes through
text_height() and centring. Titlebar::paint() only called the base
Panel::paint() it overrode.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Moving the draw list to device pixels left its default stroke thickness
of 1.0 meaning one device pixel, where it used to mean one point that
the overlay scaled up. Every rule, border and caret therefore came out
a single physical pixel at any scale, which at 200% is half as thick as
it should be.
Add Kit::hairline() for the thinnest visible line at the current scale,
and pass it explicitly at every stroke and line call site, rather than
leaning on a default whose unit is no longer what the callers assume.
Panel's bottom rule keeps its half-width inset, since add_line() still
centres an axis-aligned band on a pixel centre.
The same oversight hid in three more places that consumed a point
constant as if it were a pixel extent: the glow quad, which has to match
a ramp rasterised at kGlowPts * dpr or it stretches; MenuItem's check
marks and chevrons; and the browser's thumbnail frame.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The toolkit laid out in logical points and reconciled with the pixel
grid by multiplying by dpr, rounding, and dividing back -- Kit::snap,
snap_size and snap_rect, called from nearly every measure() and
arrange(). That bought a class of rounding errors rather than removing
one: positions rounded to nearest while sizes rounded up, so insetting a
rect grew it back out (hence the workaround in focus_ring); neighbours
snapped independently and disagreed, most visibly across the toolbar's
three slots; and grow-shares divided in floats lost up to a pixel per
child with no way to recover it. The draw list then snapped everything
again on emit, so none of it was what made drawing crisp.
Widget geometry is now integral device pixels, and the arithmetic is
exact by construction. Rect holds ints, the three snap primitives are
gone along with the round-versus-ceil asymmetry, and text metrics answer
in pixels directly rather than dividing by dpr for a caller that only
multiplied it back. Growing children now share the remainder a pixel at
a time, so they fill their container exactly.
Design constants stay in points -- 6pt of padding has to stay 6pt on any
display -- and convert on use through Kit::px(). Converting rather than
baking keeps a sum of point terms rounding once instead of once per
term, and covers the per-widget pad_x/pad_y fields too. Persistent
geometry stays in points for the same reason: dpr is per-window and
changes when a window moves between displays, so a stored pixel count
would change physical size. That is why Page::sidebar_w is still a
point value.
Genuinely continuous quantities stay float and round only where they
become geometry: scroll offsets, the viewer's pan, zoom and rotation,
and pointer positions. The scroll thumb keeps its ratios so its length
does not jitter mid-drag.
Points meet pixels at three boundaries now, each converting once: input
events and the host size on the way in, and the input method's caret
rectangle, the window-menu position and the resize mask on the way out.
The draw list is fed device pixels with a scale of 1.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Widget geometry is moving to integral device pixels, where an implicit
float-to-int conversion is a layout bug rather than a rounding detail.
Make it an error, so the compiler produces the worklist.
Scoped to the dn target: vendored dependencies do not build clean under
it. -Wimplicit-int-conversion is Clang-only, hence the second block.
This turns up four stray double literals in the CIE diagram, which the
flag reports as double-to-float narrowing; spell them as floats.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>