layout: adaptive grid and vertical flex; enforce the mechanical style rules
grid_min_cell( width ) adds the adaptive mode WrapGrid was missing: instead of a fixed column count, the count is derived at layout time from the available width so every cell is at least `width` wide (any Length, so a fluid threshold works; never fewer than one column), re-derived on every resize. Cells then share the width equally, and WrapGrid::max_columns( n ) caps the derived count so cells grow instead of multiplying on very wide surfaces — the cap only applies to the adaptive mode, grid( n ) keeps the fixed behaviour untouched. Four new layout tests cover width derivation, spacing accounting, the one-column floor and the cap; the row-wrap assertions check X positions rather than Y because zero-height spacer children produce zero-height rows. flex( child ) now distributes leftover height inside a Column, mirroring its leftover-width behaviour in a Row: flex children join the weight pool alongside weight-only spacers and y-scrolls, draw their child inside the allocated share at full inner width, and contribute zero to the column's natural height exactly like a row counts flex width. This closes the documented "vertical flex is not yet implemented" gap; the Flex rustdoc and the widgets.md entry now describe both axes. Add scripts/style-check.sh and a make stylecheck target, wired into CI: mechanical verification of the grep-checkable subset of code_style_guide.md — tab indentation and spaces inside attribute brackets — with comment lines skipped so prose may cite raw attribute syntax. To turn the check on green, the 82 unspaced attribute sites across 24 files (#[test], #[derive(...)], #[cfg(...)], #[allow(...)]) were normalized to the spaced form. CONTRIBUTING and the style guide reference the new target; brace placement and paren spacing remain review concerns.
This commit is contained in:
@@ -583,12 +583,15 @@ viewport( panel_view )
|
||||
|
||||
### `flex`
|
||||
|
||||
A row-only filler wrapper. Treats its non-spacer child like a
|
||||
[`spacer`](#spacer) for leftover-width distribution but draws the child
|
||||
inside the allocated rect.
|
||||
A filler wrapper for both flow layouts. Treats its non-spacer child
|
||||
like a [`spacer`](#spacer) for leftover-space distribution but draws
|
||||
the child inside the allocated rect: leftover width inside a
|
||||
[`row`](#row), leftover height inside a [`column`](#column). Weights
|
||||
split the leftover proportionally between flex / spacer siblings.
|
||||
|
||||
**When**: a row where one non-trivial child should fill the remaining
|
||||
width (a card next to a fixed-size icon).
|
||||
width (a card next to a fixed-size icon), or a column where a child
|
||||
should absorb the remaining height (a log pane under fixed toolbars).
|
||||
|
||||
```rust,no_run
|
||||
# use ltk::{ column, flex, row, Element };
|
||||
@@ -998,6 +1001,14 @@ centred under the full rows above instead of left-aligned — useful for
|
||||
app switchers and gallery layouts where a 7-of-9 leftover band reads
|
||||
better balanced.
|
||||
|
||||
`grid_min_cell( width )` is the adaptive variant: instead of a fixed
|
||||
column count, it fits as many columns as the available width allows
|
||||
while keeping every cell at least `width` wide (never fewer than one),
|
||||
re-deriving the count on every layout — so the same grid shows more
|
||||
columns on a wide window and fewer on a phone. `width` accepts any
|
||||
`Length`; `max_columns( n )` caps the derived count so cells grow
|
||||
instead of multiplying on very wide surfaces.
|
||||
|
||||
### `spacer`
|
||||
|
||||
An invisible flexible filler. Inside a column / row, absorbs leftover
|
||||
|
||||
Reference in New Issue
Block a user