Design-lint: non-exhaustive types, focus through runtime::egui, prop setters, relation in guides trial

This commit is contained in:
aiongg
2026-11-17 01:46:42 +00:00
parent 9df7f30d95
commit ca71fda229
6 changed files with 12 additions and 19 deletions
+1
View File
@@ -6,6 +6,7 @@ use std::sync::Arc;
/// What an input method counts the text around the caret in.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum SurroundingUnit {
/// Characters.
Chars,
+1
View File
@@ -64,6 +64,7 @@ const CLOSED: &[&str] = &[
"SurfaceStyle", // built or matched in craft-ui-widgets
"Target", // built or matched in craft-ui-canvas
"TextOptions", // built or matched in craft-ui-widgets
"TransformReach", // `MoveOnly { points }` is built in PhotoCraft's type tool
"ToastEnd", // built or matched in craft-ui-widgets
"TrackLook", // built or matched in craft-ui-widgets
"VariantParts", // built or matched in craft-ui-widgets
+3 -3
View File
@@ -165,7 +165,7 @@ impl State {
/// is recorded under that root.
pub(super) fn focus_stop(&mut self, rec: StopRec) -> Vec<Act> {
let key = rec.stop.key();
let acts = self.move_focus(rec, FocusOrigin::Request);
let acts = self.enter_stop(rec, FocusOrigin::Request);
self.revealed = Some(key);
acts
}
@@ -173,10 +173,10 @@ impl State {
/// Moves focus to `rec` without a reveal: a press focuses a stop under the pointer, which is on screen already,
/// and scrolling it in would move the content under the held press.
pub(super) fn focus_stop_in_place(&mut self, rec: StopRec) -> Vec<Act> {
self.move_focus(rec, FocusOrigin::Press)
self.enter_stop(rec, FocusOrigin::Press)
}
fn move_focus(&mut self, rec: StopRec, origin: FocusOrigin) -> Vec<Act> {
fn enter_stop(&mut self, rec: StopRec, origin: FocusOrigin) -> Vec<Act> {
self.note_entry(&rec);
let stop = &rec.stop;
let roving = stop.group.is_some();
@@ -161,11 +161,12 @@ fn position_text_that_does_not_parse_keeps_ok_from_making_a_guide() {
let position = fixture.by_label("Position").expect("the Position field");
fixture.click(&position).settle();
fixture.key(egui::Key::A, egui::Modifiers::COMMAND);
fixture.type_text("40").settle();
let typed = 40.0;
fixture.type_text(&typed.to_string()).settle();
assert!(enabled.get(), "a number enables OK again");
let ok = fixture.by_label("OK").expect("the footer has OK");
fixture.click(&ok).settle();
assert!(!open.get(), "OK closes the dialog");
let confirmed: Vec<_> = made.borrow().iter().map(|guide| guide.position).collect();
assert_eq!(confirmed, [40.0]);
assert_eq!(confirmed, [typed], "OK makes the guide at the typed position");
}
@@ -164,7 +164,8 @@ pub struct CanvasSize<'a> {
/// The bytes one pixel takes, for the file size readouts.
#[prop(quantity = "bytes per pixel")]
bytes_per_pixel: f64,
/// The held OK of a hosted dialog.
/// The held OK of a hosted dialog ([`Hold`]).
#[prop(name = "hold_ok", vis = "pub(crate)")]
hold: Hold<CanvasSizeValues>,
}
@@ -174,12 +175,6 @@ impl<'a> CanvasSize<'a> {
CanvasSize { values, open: None, bytes_per_pixel: 4.0, hold: Hold::default() }
}
/// Holds the OK of a hosted dialog ([`Hold`]).
fn hold_ok(mut self, hold: Hold<CanvasSizeValues>) -> Self {
self.hold = hold;
self
}
/// Shows the dialog.
pub fn show(self, ui: &mut Ui) -> CanvasSizeOutput {
let CanvasSize { values, open, bytes_per_pixel, hold } = self;
@@ -163,7 +163,8 @@ pub struct ImageSize<'a> {
/// document's depth, no alpha (1/8 for Bitmap, 1 for Indexed).
#[prop(quantity = "bytes per pixel")]
bytes_per_pixel: f64,
/// The held OK of a hosted dialog.
/// The held OK of a hosted dialog ([`Hold`]).
#[prop(name = "hold_ok", vis = "pub(crate)")]
hold: Hold<ImageSizeValues>,
}
@@ -173,12 +174,6 @@ impl<'a> ImageSize<'a> {
ImageSize { values, open: None, methods: Vec::new(), bytes_per_pixel: 4.0, hold: Hold::default() }
}
/// Holds the OK of a hosted dialog ([`Hold`]).
fn hold_ok(mut self, hold: Hold<ImageSizeValues>) -> Self {
self.hold = hold;
self
}
/// Shows the dialog.
pub fn show(self, ui: &mut Ui) -> ImageSizeOutput {
let ImageSize { values, open, methods, bytes_per_pixel, hold } = self;