Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
877047c09d | ||
|
|
78b92fded8 | ||
|
|
1c20828e69 | ||
|
|
f2416fd056 |
@@ -0,0 +1,50 @@
|
||||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
unix:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: linux gcc, runner: ubuntu-24.04, cc: gcc }
|
||||
- { name: linux clang, runner: ubuntu-24.04, cc: clang }
|
||||
- { name: macos clang, runner: macos-15, cc: clang }
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Float coordinates
|
||||
run: |
|
||||
${{ matrix.cc }} -std=c99 -Wall -Wextra -Werror -DLAY_FLOAT=1 -o test_float test_onlay.c onlay.c
|
||||
./test_float
|
||||
- name: int16_t coordinates
|
||||
run: |
|
||||
${{ matrix.cc }} -std=c99 -Wall -Wextra -Werror -o test_int test_onlay.c onlay.c
|
||||
./test_int
|
||||
|
||||
windows:
|
||||
name: windows msvc
|
||||
runs-on: windows-2025
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Float and int16_t coordinates
|
||||
shell: cmd
|
||||
run: |
|
||||
for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do call "%%i\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cl /nologo /W4 /WX /DLAY_FLOAT=1 /Fe:test_float.exe test_onlay.c onlay.c || exit /b 1
|
||||
test_float.exe || exit /b 1
|
||||
cl /nologo /W4 /WX /Fe:test_int.exe test_onlay.c onlay.c || exit /b 1
|
||||
test_int.exe
|
||||
@@ -53,16 +53,14 @@ fraction.
|
||||
**Gaps.** `lay_set_gap(ctx, item, n)` puts space between an item's children
|
||||
without putting it outside them, so 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 — otherwise a
|
||||
container came out exactly one gap per child too short.
|
||||
and counts when a container is sized to its contents — otherwise a container
|
||||
came out one gap per child too short.
|
||||
|
||||
**Padding**, from [randrew/layout#23](https://github.com/randrew/layout/pull/23)
|
||||
by [codecat](https://github.com/codecat), ported onto the struct rect. A margin
|
||||
is space outside an item and a padding is space inside it: a padding insets the
|
||||
rect an item lays its children into, and is added when that item is sized to
|
||||
its contents.
|
||||
|
||||
Every change is marked `// ONLAY:` in the source with the reason next to it.
|
||||
rect an item lays its children into, and is added on both sides when that item
|
||||
is sized to its contents.
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -72,10 +70,13 @@ weighted columns, floors that grow, template rows, and padding against margin.
|
||||
Upstream's own `test_layout.c` is not carried: it assumes the vector rect.
|
||||
|
||||
```
|
||||
cc -DLAY_FLOAT=1 -o onlaytest test_onlay.c && ./onlaytest
|
||||
cc -DLAY_FLOAT=1 -o onlaytest test_onlay.c onlay.c && ./onlaytest
|
||||
```
|
||||
|
||||
## Licence
|
||||
CI runs it with float and `int16_t` coordinates on GCC, Clang and MSVC, warnings
|
||||
as errors.
|
||||
|
||||
## License
|
||||
|
||||
MIT, as upstream. See `LICENSE` — the original copyright is Andrew Richards's
|
||||
and is unchanged.
|
||||
|
||||
+7
-7
@@ -114,9 +114,9 @@ test_weighted_columns(void)
|
||||
for (i = 0; i < n; i++) {
|
||||
lay_vec4 r = lay_get_rect(&ctx, kid[i]);
|
||||
char label[32];
|
||||
sprintf(label, "%.0f%% width", (double)(cols[i].w * 100.0f));
|
||||
snprintf(label, sizeof label, "%.0f%% width", (double)(cols[i].w * 100.0f));
|
||||
check(label, (int)r.v[2], cols[i].expect_w);
|
||||
sprintf(label, "%.0f%% x", (double)(cols[i].w * 100.0f));
|
||||
snprintf(label, sizeof label, "%.0f%% x", (double)(cols[i].w * 100.0f));
|
||||
check(label, (int)r.v[0], cols[i].expect_x);
|
||||
}
|
||||
lay_destroy_context(&ctx);
|
||||
@@ -183,16 +183,16 @@ test_template_rows(void)
|
||||
lay_reserve_items_capacity(&ctx, 32);
|
||||
|
||||
page = lay_item(&ctx);
|
||||
lay_set_size_xy(&ctx, page, W, 200);
|
||||
lay_set_size_xy(&ctx, page, (lay_scalar)W, 200);
|
||||
lay_set_contain(&ctx, page, LAY_COLUMN | LAY_START);
|
||||
lay_set_gap(&ctx, page, ROW_GAP2);
|
||||
lay_set_gap(&ctx, page, (lay_scalar)ROW_GAP2);
|
||||
|
||||
for (r = 0; r < ROWS; r++) {
|
||||
row = lay_item(&ctx);
|
||||
lay_set_behave(&ctx, row, LAY_HFILL);
|
||||
lay_set_size_xy(&ctx, row, 0, 30);
|
||||
lay_set_contain(&ctx, row, LAY_ROW | LAY_START);
|
||||
lay_set_gap(&ctx, row, COL_GAP);
|
||||
lay_set_gap(&ctx, row, (lay_scalar)COL_GAP);
|
||||
lay_insert(&ctx, page, row);
|
||||
|
||||
for (c = 0; c < 3; c++) {
|
||||
@@ -213,9 +213,9 @@ test_template_rows(void)
|
||||
for (c = 0; c < 3; c++) {
|
||||
lay_vec4 q = lay_get_rect(&ctx, cell[r][c]);
|
||||
char label[40];
|
||||
sprintf(label, "row %d col %d x", r, c);
|
||||
snprintf(label, sizeof label, "row %d col %d x", r, c);
|
||||
check(label, (int)q.v[0], (int)want_x[c]);
|
||||
sprintf(label, "row %d col %d w", r, c);
|
||||
snprintf(label, sizeof label, "row %d col %d w", r, c);
|
||||
check(label, (int)q.v[2], (int)want_w[c]);
|
||||
}
|
||||
lay_destroy_context(&ctx);
|
||||
|
||||
Reference in New Issue
Block a user