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:
+8
-8
@@ -23,7 +23,7 @@ pub enum ToplevelEvent
|
||||
}
|
||||
|
||||
/// Wayland shell mode for the application surface.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
|
||||
pub enum ShellMode
|
||||
{
|
||||
/// Normal application window using xdg-shell protocol.
|
||||
@@ -41,7 +41,7 @@ pub enum ShellMode
|
||||
}
|
||||
|
||||
/// Layer-shell layer position.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
|
||||
pub enum Layer
|
||||
{
|
||||
/// Below normal windows (wallpapers, desktop backgrounds).
|
||||
@@ -72,7 +72,7 @@ impl Layer
|
||||
|
||||
/// Layer-shell anchor edges.
|
||||
/// Determines which screen edges the surface is attached to.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
|
||||
pub struct Anchor
|
||||
{
|
||||
pub top: bool,
|
||||
@@ -115,13 +115,13 @@ impl Anchor
|
||||
/// overlay list between frames: if the same `OverlayId` is returned from
|
||||
/// [`App::overlays`] on consecutive frames the underlying Wayland surface
|
||||
/// and its internal state are kept; if it disappears the surface is destroyed.
|
||||
#[derive( Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord )]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord ) ]
|
||||
pub struct OverlayId( pub u32 );
|
||||
|
||||
/// Stable identifier for a subsurface, used to diff the list returned by
|
||||
/// [`App::subsurfaces`] between frames the same way [`OverlayId`] diffs
|
||||
/// overlays.
|
||||
#[derive( Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord )]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord ) ]
|
||||
pub struct SubsurfaceId( pub u32 );
|
||||
|
||||
/// Which surface a [`SubsurfaceSpec`] is composited as a child of. `Main`
|
||||
@@ -129,7 +129,7 @@ pub struct SubsurfaceId( pub u32 );
|
||||
/// parents to one of the [`App::overlays`] surfaces, so a slide can ride
|
||||
/// above app windows the way an overlay panel does. An `Overlay` parent that
|
||||
/// is absent or not yet configured is skipped for that frame.
|
||||
#[derive( Debug, Clone, Copy, PartialEq, Eq )]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
|
||||
pub enum SubsurfaceParent
|
||||
{
|
||||
Main,
|
||||
@@ -138,7 +138,7 @@ pub enum SubsurfaceParent
|
||||
|
||||
/// One of the surfaces an [`App`] can target with an invalidation. Used inside
|
||||
/// [`InvalidationScope::Only`] to name the affected surfaces.
|
||||
#[derive( Debug, Clone, Copy, PartialEq, Eq, Hash )]
|
||||
#[ derive( Debug, Clone, Copy, PartialEq, Eq, Hash ) ]
|
||||
pub enum SurfaceTarget
|
||||
{
|
||||
/// The application's main surface (the one returned by [`App::view`]).
|
||||
@@ -153,7 +153,7 @@ pub enum SurfaceTarget
|
||||
/// to let the runtime skip redraws on surfaces whose contents could not
|
||||
/// possibly have changed by the message in question. On a shell with many
|
||||
/// overlays most messages only touch one of them, so the savings are large.
|
||||
#[derive( Debug, Clone )]
|
||||
#[ derive( Debug, Clone ) ]
|
||||
pub enum InvalidationScope
|
||||
{
|
||||
/// Treat every surface as potentially affected (safe default).
|
||||
|
||||
Reference in New Issue
Block a user