pattern_grid: explicit side through PatternGrid::size
The grid's preferred size was the theme's fluid constant (264 px at the reference surface) capped by the width the parent allocates, so a caller could only shrink it: a lock screen that wants the grid to span most of a phone's width had no way to ask for it, and a container's max_width did nothing past the default. PatternGrid gains a size field with a size( impl Into<Length> ) builder; preferred_size resolves it through Canvas::resolve_geom like the other geometry overrides and still caps it at max_width, and map_msg carries it across. Without the builder the fluid default applies as before. docs/widgets.md describes the builder next to hide_stroke and error; CHANGELOG lists it under Unreleased.
This commit is contained in:
@@ -6,6 +6,7 @@ All notable changes to `ltk` are documented here. The format is based on [Keep a
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- **`PatternGrid::size( impl Into<Length> )`** — explicit side for the square grid, resolved through `Canvas::resolve_geom` like the other geometry overrides; without it the theme's fluid default still applies. A lock screen can now size the grid from the surface (a share of the width in portrait, of the free height in landscape) instead of being capped at the default.
|
||||||
- **`xdg-session-management-v1` (client)** — before the first commit of a `ShellMode::Window` toplevel the runtime binds `xdg_session_manager_v1`, issues `get_session( reason, stored_id )` and `restore_toplevel( toplevel, "main" )`, so a supporting compositor restores window geometry on every launch. Bindings are generated in-tree from the vendored XML under `protocols/` with `wayland-scanner` (`src/protocol/`).
|
- **`xdg-session-management-v1` (client)** — before the first commit of a `ShellMode::Window` toplevel the runtime binds `xdg_session_manager_v1`, issues `get_session( reason, stored_id )` and `restore_toplevel( toplevel, "main" )`, so a supporting compositor restores window geometry on every launch. Bindings are generated in-tree from the vendored XML under `protocols/` with `wayland-scanner` (`src/protocol/`).
|
||||||
- **Runtime session persistence** — `$XDG_STATE_HOME/<app_id>/session.json` (compositor session id, clean-exit marker, pid) plus `state.bin` (the bytes from `App::save_state`), written atomically with mode `0600`; saved every 30 s when the bytes changed, on close and on signal; handed back through `App::restore_state` before the first frame only on a session restore (`LTK_SESSION_RESTORE=1`) or after an unclean exit. Module `src/session_state.rs`.
|
- **Runtime session persistence** — `$XDG_STATE_HOME/<app_id>/session.json` (compositor session id, clean-exit marker, pid) plus `state.bin` (the bytes from `App::save_state`), written atomically with mode `0600`; saved every 30 s when the bytes changed, on close and on signal; handed back through `App::restore_state` before the first frame only on a session restore (`LTK_SESSION_RESTORE=1`) or after an unclean exit. Module `src/session_state.rs`.
|
||||||
- **`Layer::Window` overlays** — an `OverlaySpec` with `layer: Layer::Window` is materialised as an ordinary `xdg_toplevel` of the given fixed size instead of a layer-shell surface: decorated, stacked and listed by the compositor like an application window. Anchor, exclusive zone and keyboard exclusivity are ignored; the compositor's close button delivers `on_dismiss`. `App::overlay_title( id )` (defaulted to the app id) names it. Layer-shell apps now bind `xdg_wm_base` when available so they can open one.
|
- **`Layer::Window` overlays** — an `OverlaySpec` with `layer: Layer::Window` is materialised as an ordinary `xdg_toplevel` of the given fixed size instead of a layer-shell surface: decorated, stacked and listed by the compositor like an application window. Anchor, exclusive zone and keyboard exclusivity are ignored; the compositor's close button delivers `on_dismiss`. `App::overlay_title( id )` (defaulted to the app id) names it. Layer-shell apps now bind `xdg_wm_base` when available so they can open one.
|
||||||
|
|||||||
@@ -368,6 +368,8 @@ repeat, or taking in the node a straight stroke crosses is the app's
|
|||||||
rule, not the widget's. `on_release( msg )` fires when the finger lifts.
|
rule, not the widget's. `on_release( msg )` fires when the finger lifts.
|
||||||
`hide_stroke( true )` draws only the dots, against shoulder surfing;
|
`hide_stroke( true )` draws only the dots, against shoulder surfing;
|
||||||
`error( true )` paints the current path in the palette's `danger` colour.
|
`error( true )` paints the current path in the palette's `danger` colour.
|
||||||
|
`size( len )` sets the side of the square grid (any `Length`); without it the
|
||||||
|
theme's fluid default applies, capped by the width the parent allocates.
|
||||||
|
|
||||||
It sizes itself square to `min( max_width, 264 )` design pixels; wrap it
|
It sizes itself square to `min( max_width, 264 )` design pixels; wrap it
|
||||||
in a `container( … ).max_width( … )` to pin it.
|
in a `container( … ).max_width( … )` to pin it.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
//! `on_release`.
|
//! `on_release`.
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::types::{ Color, Point, Rect };
|
use crate::types::{ Color, Length, Point, Rect };
|
||||||
use crate::render::Canvas;
|
use crate::render::Canvas;
|
||||||
use super::Element;
|
use super::Element;
|
||||||
|
|
||||||
@@ -25,13 +25,21 @@ pub struct PatternGrid<Msg: Clone>
|
|||||||
pub( crate ) on_release: Option<Msg>,
|
pub( crate ) on_release: Option<Msg>,
|
||||||
pub( crate ) hide_stroke: bool,
|
pub( crate ) hide_stroke: bool,
|
||||||
pub( crate ) error: bool,
|
pub( crate ) error: bool,
|
||||||
|
pub( crate ) size: Option<Length>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Msg: Clone> PatternGrid<Msg>
|
impl<Msg: Clone> PatternGrid<Msg>
|
||||||
{
|
{
|
||||||
pub fn new( path: Vec<u8> ) -> Self
|
pub fn new( path: Vec<u8> ) -> Self
|
||||||
{
|
{
|
||||||
Self { path, on_node: None, on_release: None, hide_stroke: false, error: false }
|
Self { path, on_node: None, on_release: None, hide_stroke: false, error: false, size: None }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Side of the square grid; without it the theme's fluid default applies.
|
||||||
|
pub fn size( mut self, s: impl Into<Length> ) -> Self
|
||||||
|
{
|
||||||
|
self.size = Some( s.into() );
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_node( mut self, f: impl Fn( u8 ) -> Msg + 'static ) -> Self
|
pub fn on_node( mut self, f: impl Fn( u8 ) -> Msg + 'static ) -> Self
|
||||||
@@ -77,12 +85,18 @@ impl<Msg: Clone> PatternGrid<Msg>
|
|||||||
on_release: self.on_release.map( |m| ( *f )( m ) ),
|
on_release: self.on_release.map( |m| ( *f )( m ) ),
|
||||||
hide_stroke: self.hide_stroke,
|
hide_stroke: self.hide_stroke,
|
||||||
error: self.error,
|
error: self.error,
|
||||||
|
size: self.size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preferred_size( &self, max_width: f32, canvas: &Canvas ) -> ( f32, f32 )
|
pub fn preferred_size( &self, max_width: f32, canvas: &Canvas ) -> ( f32, f32 )
|
||||||
{
|
{
|
||||||
let size = canvas.geom_px( theme::SIZE ).min( max_width );
|
let size = match self.size
|
||||||
|
{
|
||||||
|
Some( l ) => canvas.resolve_geom( l ),
|
||||||
|
None => canvas.geom_px( theme::SIZE ),
|
||||||
|
};
|
||||||
|
let size = size.min( max_width );
|
||||||
( size, size )
|
( size, size )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user