Misc · Codes and checks: a QR code scanner and a captcha

misc::QrCodeScanner reads QR codes with rqrr 0.11 from the frames the
host hands in, one at a time off the main thread, and hands each code
to the owner once. misc::Captcha shows the owner's picture over an
answer field that empties and keeps focus with each answer; the owner
says how it stood. BarcodeDisplay, Signature and Rating Widget point
to their homes.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-28 01:40:15 -04:00
1 parent dc4911a68f
commit 692fae6244
14 files changed
+785 -10

No files matched your search

+13 -1
View File
@@ -13,6 +13,7 @@ use crate::{
theme::Theme,
};
mod codes;
mod numbers;
struct Stage {
@@ -29,7 +30,7 @@ impl Render for Stage {
}
}
fn settle(cx: &mut VisualTestContext) {
pub(super) fn settle(cx: &mut VisualTestContext) {
for _ in 0..3 {
cx.run_until_parked();
cx.update(|window, _| window.refresh());
@@ -55,6 +56,7 @@ pub(super) fn stage(
part,
});
let root = view.read_with(cx, |stage, _| stage.root.clone());
ROOT.with(|kept| kept.replace(Some(root.clone())));
let wakes = Rc::new(Cell::new(0));
let count = wakes.clone();
cx.update(|window, cx| {
@@ -66,6 +68,16 @@ pub(super) fn stage(
(wakes, cx)
}
thread_local! {
static ROOT: std::cell::RefCell<Option<FocusHandle>> = const { std::cell::RefCell::new(None) };
}
/// Whether focus fell to the stage's root scope.
pub(super) fn at_root(cx: &mut VisualTestContext) -> bool {
let root = ROOT.with(|root| root.borrow().clone().expect("a staged root"));
cx.update(|window, _| root.is_focused(window))
}
pub(super) fn press(key: &str, cx: &mut VisualTestContext) {
cx.simulate_keystrokes(key);
settle(cx);