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:
+6
-5
@@ -33,7 +33,7 @@
|
||||
//! ```rust,no_run
|
||||
//! use ltk::{App, Element, column, text, button, spacer, Color, ButtonVariant};
|
||||
//!
|
||||
//! #[derive(Clone)]
|
||||
//! #[ derive( Clone ) ]
|
||||
//! enum Msg { Quit }
|
||||
//!
|
||||
//! struct MyApp;
|
||||
@@ -101,7 +101,8 @@
|
||||
//! - [`column()`] — vertical flow.
|
||||
//! - [`row()`] — horizontal flow.
|
||||
//! - [`stack()`] — z-order overlay with per-child alignment.
|
||||
//! - [`grid()`] — fixed-column-count wrapping grid.
|
||||
//! - [`grid()`] — fixed-column-count wrapping grid; [`grid_min_cell()`]
|
||||
//! derives the column count from the width instead.
|
||||
//! - [`spacer()`] — invisible flexible filler.
|
||||
//!
|
||||
//! See [`layouts`] for the grouped landing page.
|
||||
@@ -380,7 +381,7 @@ pub use layout::column::{ Column, column };
|
||||
pub use layout::row::{ Row, row };
|
||||
pub use layout::stack::{ Stack, stack, HAlign, VAlign };
|
||||
// push_aligned_margin is available as a method on Stack — no separate re-export needed.
|
||||
pub use layout::wrap_grid::{ WrapGrid, grid };
|
||||
pub use layout::wrap_grid::{ WrapGrid, grid, grid_min_cell };
|
||||
pub use widget::scroll::{ scroll, ScrollAxis };
|
||||
pub use widget::viewport::{ Viewport, viewport };
|
||||
pub use widget::carousel::{ Carousel, carousel };
|
||||
@@ -458,7 +459,7 @@ pub mod layouts
|
||||
Column, column,
|
||||
Row, row,
|
||||
Stack, stack, HAlign, VAlign,
|
||||
WrapGrid, grid,
|
||||
WrapGrid, grid, grid_min_cell,
|
||||
Spacer, spacer,
|
||||
};
|
||||
}
|
||||
@@ -490,7 +491,7 @@ pub mod window
|
||||
button, icon_button, text, text_edit, img_widget,
|
||||
container, checkbox, radio, toggle, separator,
|
||||
progress_bar, list_item, slider, vslider, scroll, viewport,
|
||||
column, row, stack, grid, spacer,
|
||||
column, row, stack, grid, grid_min_cell, spacer,
|
||||
TextAlign, SliderAxis,
|
||||
run,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user