tsoding / nn.h

Simple stb-style header-only library for Neural Networks
MIT License
342 stars 35 forks source link

[layout] Fix inconsistent widths in horizontal/vertical layouts #12

Closed Demki closed 1 year ago

Demki commented 1 year ago

We get the size of each widget in the layout by adding a "phantom" gap at the end, then divide the new width by the number of slots to get how wide each slot + its gap is.

This makes it each slot has a gap after it (the final slot gets the "phantom" gap), and so all slots get the same width (unlike before where the first and last slot were wider).

Furthermore this fixes a minor bug that occurs when you have a layout with just 1 item, where you would get a gap after it which makes it not take up the full width available. (This is unlikely to happen if you're designing the layout by hand, but could happen if you generate it from, say, a list of items)

Demki commented 1 year ago

Implemented in 39782727be834643c0d13b20b75bc624c7b544f3.