layout: adaptive grid and vertical flex; enforce the mechanical style rules
CI / build + test (push) Has been cancelled
CI / cargo audit (push) Has been cancelled

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:
2026-07-30 22:20:21 +02:00
parent 1fd697aa6d
commit a7f953ca42
33 changed files with 380 additions and 115 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ pub struct AppData<A: App>
/// failed to initialise or `LTK_FORCE_SOFTWARE=1` — every surface then
/// falls back to the SHM path.
pub egl_context: Option<Arc<EglContext>>,
#[allow(dead_code)]
#[ allow( dead_code ) ]
pub xdg_shell: Option<XdgShell>,
/// Shared layer-shell binding used for the main surface and every
/// overlay. `None` when the compositor does not advertise the protocol.
@@ -289,7 +289,7 @@ impl<A: App> AppData<A>
/// refers to an overlay that is not currently registered — callers must
/// only pass focus values obtained from [`focus_for_surface`] or from the
/// per-device focus fields, which the run loop keeps in sync.
#[allow( dead_code )]
#[ allow( dead_code ) ]
pub( crate ) fn surface( &self, focus: SurfaceFocus ) -> &SurfaceState<A::Message>
{
match focus
@@ -313,7 +313,7 @@ impl<A: App> AppData<A>
}
/// Mutable counterpart of [`surface`].
#[allow( dead_code )]
#[ allow( dead_code ) ]
pub( crate ) fn surface_mut( &mut self, focus: SurfaceFocus ) -> &mut SurfaceState<A::Message>
{
match focus