4 Commits

Author SHA1 Message Date
John Beard
01133d6150 Eeschema: move all pin text layout to PIN_LAYOUT_CACHE 2024-10-26 15:31:12 +08:00
John Beard
ede31b6252 Pin layout: unify bounding box calcs
The logic for this was duplicated, in two very different forms,
between the SCH_PIN bounding box function and the
SCH_PAINTER draw function.

And the SCH_PIN one was slightly wrong, as it didn't take into
account the PIN_TEXT_MARGIN, or the electrical types.

Provide a way for clients of the PIN_LAYOUT_CACHE to access
the name and number boxes.
2024-10-26 15:04:51 +08:00
John Beard
f29d1fafe4 Include dangling indicator in SCH_PIN bbox
Delegate computation of the size and location of the pin dangling
indicator to the PIN_LAYOUT_CACHE.

Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/18894
2024-10-26 15:04:51 +08:00
John Beard
fe48e51315 SCH_PIN: break out layout calculations
The bounding box calculations of SCH_PINs are pretty complicated.
There is already caching of the name and number texts, but the
SCH_PAINTER (for example) has to repeat this work and sometimes
slightly diverges. For example, dangling indicators and alt
icons are painted, but not included in the bbox.

This commit introduces a more encapsulated 'layout cache' object which will
take care of caching the current extents, but also providing layout
geometry to SCH_PAINTER (and other interested code, like hit testers
on a given field) witohut requiring recomputation or reimplementation.

The extents calculations use exclusively the public API, so it's nice
and easy to split it out.

In this commit, nothing is functionally changed - the name and number
are still cached, and everything else is computed in the exact same way.
This is the groundwork for fixing this issue:

Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/18894
2024-10-26 15:04:51 +08:00