Files
adminandClaude Opus 5 a20a3cca7b Onlay: plain C99, weighted tracks, gaps, and #23's padding
A fork of randrew/layout, which is unmaintained and excellent. Three things
were needed by a declarative UI built on it, and one had to be fixed before
any of them could be built at all.

C99 EVERYWHERE. Upstream stores a rect in a GCC vector_size type and falls
back, on MSVC, to a C++ class with operator[] - which forces the whole library
to be compiled as C++ on that toolchain. Both are replaced by a struct holding
an array. The algorithm still indexes by dimension; the only change to the API
is that a rect is read as r.v[0] rather than r[0].

WEIGHTED TRACKS. lay_set_weight gives a filling item its share of the leftover
relative to its siblings, where upstream splits it equally. Weight 0 reads as
1, so an item that says nothing behaves as it did. A size on a weighted item is
a floor rather than a size, which makes one rule out of what CSS spells as
three: a fixed track, a minimum that grows, and a fraction.

GAPS. lay_set_gap puts space between an item's children without putting it
outside them - a row of three has two gaps and no leading or trailing one. It
applies down a wrapped row's lines as well as along them, and it is counted
when a container is sized to its contents, which a container was not: it came
out exactly one gap per child too short.

PADDING, from randrew/layout#23 by codecat, merged and then ported onto the
struct rect. A margin is space outside an item and a padding is space inside
it. The PR is carried as its own commit so its authorship stays where it
belongs.

The upstream tests are not carried: test_layout.c assumes the vector rect.
test_onlay.c replaces them and checks the arithmetic against numbers taken
from a running application rather than from this library - a login card,
weighted columns, floors that grow, template rows, and padding told apart from
margin on both halves, because a padding that only inset the children would
pass a test that looked at the children alone.

Every change is marked // ONLAY: in the source with the reason beside it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 21:38:16 +02:00

30 lines
1.3 KiB
Plaintext

Layout - Simple 2D stacking boxes calculations
Copyright (c) 2016 Andrew Richards <randrew@gmail.com>
Blendish - Blender 2.5 UI based theming functions for NanoVG
Copyright (c) 2014 Leonard Ritter <leonard.ritter@duangle.com>
Onlay - a fork of the above, converted to plain C99 and extended
Copyright (c) 2026 Roman Chojnacki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.