widgets, input: PatternGrid for pattern unlock, framed icon buttons, and text keys that bubble past a focused non-text widget; Debian 0.3.0-2
PatternGrid is a 3×3 drag widget for the unlock pattern. It is stateless: the app owns the visited nodes and passes them back in for drawing; a press or a drag that reaches a node within the snap radius fires on_node with the index, 0 to 8 row-major, and release fires on_release, so the crossing and minimum-length rules stay in the app. Geometry lives in widget/pattern_grid/theme.rs (size, dot and node radii, stroke width, snap radius, ring alpha), and the snap radius is resolved through the widget-scaling mode at layout time like the slider thumb (set_pattern_snap_px). The gesture machine reuses the slider's drag ownership: WidgetHandlers::is_drag_target covers both, so hover painting, pointer capture and release behave the same, and hover_affects_paint no longer special-cases sliders. The a11y tree maps it to GenericContainer, since a drawn gesture has no assistive equivalent and the app must offer another method. Exported as pattern_grid / PatternGrid, documented in widgets.md, theming.md and architecture.md, with tests for node centres, a wide rect, snapping, the builders, the handler snapshot and map_msg, and a Security tab in examples/widgets.rs that shows the drawn path. Icon buttons given a width or height are framed keys: preferred_size honours the explicit size instead of the icon size, and drawing paints the variant's background, border and focus ring, shared with text buttons through paint_frame, then centres the icon. An icon button without a size keeps the circular hover overlay it had. This is what lets the PIN keypad's backspace and OK keys sit in the same circles as the digits. Keyboard routing now matches what App::on_key documents. handle_key_default, Backspace, Delete and Space checked focused_idx.is_some() and sent the key into text insertion whenever any widget had focus, which is a no-op on a button, so a focused button or pressable swallowed typed characters. focused_text_input replaces the five copies of that check; characters, Backspace and Delete stay in a focused text input and reach the app otherwise, Return and Space still go to the focused widget's submit or press message when it has one, and the arrow, Home and End handlers use the same helper. The lockscreen relies on this to take PIN digits with its dots row focused. debian/changelog: 0.3.0-2.
This commit is contained in:
+3
-1
@@ -88,7 +88,7 @@
|
||||
//! - **Stateful binary controls** — [`toggle()`], [`checkbox()`],
|
||||
//! [`radio()`].
|
||||
//! - **Continuous controls** — [`slider()`], [`vslider()`],
|
||||
//! [`progress_bar()`].
|
||||
//! [`progress_bar()`], [`pattern_grid()`].
|
||||
//! - **Text** — [`text()`], [`text_edit()`].
|
||||
//! - **Decoration** — [`container()`], [`separator()`], [`img_widget()`].
|
||||
//! - **Clipping wrappers** — [`scroll()`], [`viewport()`], [`flex()`].
|
||||
@@ -358,6 +358,7 @@ pub use widget::rich_text::{ rich_text, RichText, LinkSpan };
|
||||
pub use widget::button::ButtonVariant;
|
||||
pub use widget::slider::{ Slider, slider, SliderAxis };
|
||||
pub use widget::vslider::{ VSlider, vslider };
|
||||
pub use widget::pattern_grid::{ PatternGrid, pattern_grid };
|
||||
pub use widget::text::TextAlign;
|
||||
pub use widget::toggle::{ Toggle, toggle };
|
||||
pub use widget::separator::{ Separator, separator };
|
||||
@@ -426,6 +427,7 @@ pub mod widgets
|
||||
// Continuous controls
|
||||
Slider, slider, SliderAxis,
|
||||
VSlider, vslider,
|
||||
PatternGrid, pattern_grid,
|
||||
ProgressBar, progress_bar,
|
||||
// Composite picker
|
||||
Combo, ComboState, combo,
|
||||
|
||||
Reference in New Issue
Block a user