Expand description
Pixel-alignment policy for widget bounds and draw-time translation.
§Port of MatterCAD / agg-sharp
GuiWidget.DefaultEnforceIntegerBounds (static) controls whether widgets
round their bounds / padding / margin to the physical pixel grid, and is
then mirrored on each widget as EnforceIntegerBounds so individual
widgets can opt out (e.g. a smooth-scrolling marker or a zoomed canvas
that genuinely wants sub-pixel positioning).
We default to true because the vast majority of UI widgets want crisp text and strokes — fractional bounds are the exception, not the rule.
§Read site
paint_subtree reads the effective flag (widget’s override, falling back
to the global default) and rounds the child-translation to the nearest
integer pixel before calling the child’s paint. That single snap kills
fractional CTM accumulated by cumulative-heights flex layout (e.g. Label
line_h = font_size × 1.5 is fractional for most font sizes), which is
what caused the Y-axis pixel fringe on crisp rectangle fills downstream.
§Opt-out
// Globally disable (rare — only for fully sub-pixel render targets):
agg_gui::pixel_bounds::set_default_enforce_integer_bounds(false);
// Per-widget:
my_widget.widget_base_mut().enforce_integer_bounds = false;Functions§
- default_
enforce_ integer_ bounds - Current process-wide default used to initialise each new widget’s
enforce_integer_boundsfield. - set_
default_ enforce_ integer_ bounds - Change the process-wide default. Only affects widgets constructed
after this call; existing widgets keep whichever value they captured
when they were built. Match MatterCAD semantics (
DefaultEnforceIntegerBoundssetter) exactly.