diff --git a/Cargo.lock b/Cargo.lock index b4d75ec9a0..d780911c11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1204,9 +1204,19 @@ dependencies = [ ] [[package]] -name = "craft-pdf" +name = "craft-mime" version = "0.1.0" source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +dependencies = [ + "chrono", + "craft-codepage", + "encoding_rs", +] + +[[package]] +name = "craft-pdf" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1214,6 +1224,14 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-plotter" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9101c4fc226f5f111b5a890a6c5c19bf3991fd76#9101c4fc226f5f111b5a890a6c5c19bf3991fd76" +dependencies = [ + "thiserror 2.0.21", +] + [[package]] name = "craft-print" version = "0.1.0" @@ -1262,7 +1280,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "fax", "hayro-ccitt", @@ -2516,7 +2534,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "brotli", "hayro-postscript", @@ -2525,7 +2543,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -2543,7 +2561,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -2561,12 +2579,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "flate2", "hayro-ccitt", @@ -3366,7 +3384,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "base64 0.22.1", "bumpalo", @@ -3475,7 +3493,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd#a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" +source = "git+https://github.com/storytold/craft-libs?rev=0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e#0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -6710,6 +6728,7 @@ version = "0.24.1" dependencies = [ "craft-dxf", "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd)", + "craft-plotter", "image", "kurbo 0.13.1", "serde_json", @@ -7098,6 +7117,7 @@ version = "0.24.1" dependencies = [ "craft-docpath", "craft-image-codecs 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a499742a9389f47d10cdc61e4cdbf4e5f07f48cd)", + "craft-mime", "craft-svg", "data-url", "flate2", diff --git a/Cargo.toml b/Cargo.toml index ba06f8d332..891cce208d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ rust-version = "1.95" repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd", default-features = false, features = ["interpret", "write"] } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e", default-features = false, features = ["interpret", "write"] } craft-print = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd", features = ["serde"] } @@ -28,9 +28,11 @@ craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9 craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "431f704478962677ec47e512754464d372901830", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } # DXF tags, reader and writer (craft-libs#778, #926, #927). +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "9101c4fc226f5f111b5a890a6c5c19bf3991fd76" } craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } # WMF, EMF and EMF+ reader (craft-libs#778). craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } @@ -40,7 +42,7 @@ craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "a499742a93 craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "a80c0f25f1c4767374a27a444fbf95e3e8162e14", default-features = false, features = ["write"] } craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd", features = ["egui"] } # internal @@ -182,13 +184,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "a499742a9389f47d10cdc61e4cdbf4e5f07f48cd" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "0cca4ac66f9f4576b3acc5f84d7a2a2ae9fb943e" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } diff --git a/ROADMAP.md b/ROADMAP.md index f658cccb58..4358817b60 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -137,6 +137,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-14: Packaging Tools add-on (Object › Plug-ins › Packaging Tools): fold line roles for dielines (Cut, Crease, Partial Cut, Perforation), each carried by the swatch on a path's top stroke through a per-document role table that native files keep; PDF prints a role line on its swatch's separation when that swatch is a spot color, as the default role swatches are, and SVG, DXF and HP-GL keep the stroke's color. Make Cut Line, Make Crease Line, Make Partial Cut Line and Make Perforation Line give the selected paths a role, overprinting by default, and make a missing role swatch; the Fold Lines panel counts each role in the selection or the document, and its Role Swatches… picks another swatch for a role (`addon.packaging.setRole`, `addon.packaging.roles`, `addon.packaging.setRoleSwatch`). A VectorCraft addition: headline numbers unchanged. - 2026-11-16: Check Fold Lines in the Packaging Tools add-on (Object › Plug-ins › Packaging Tools, and the Fold Lines panel's Check button): the fold lines of the selection or the document are split into blanks, panels and hinges (cut lines bound the material, and creases, partial cuts and perforations divide it into panels), and 15 kinds of issue are listed, errors and warnings, each naming its lines: cut lines that enclose nothing or end loose, gaps closed within a tolerance, a cut on top of a crease, duplicate lines, creases that end inside a panel, divide nothing, lie outside the blank or are not straight, gaps too narrow to map, fold lines in a hole, panels joined by no crease, and fold lines on a non-printing layer. The panel lists the issues in the interface language; clicking one selects its lines (`addon.packaging.check`). A VectorCraft addition: headline numbers unchanged. - 2026-11-02: Mouse wheel over a closed font-family field in Character, Properties or Control changes selected text through the family list using saved font filters (excluding search text), one undo step per notch, stopping at the ends (#5253). Scores and estimates unchanged. +- 2026-11-15: Circle through three points: three Shift-clicks with the Ellipse tool, or `shape.circleThroughPoints` with three points or three selected anchor points, draw the circle whose edge passes through them, with the current paint, in one undo step; after two points the tool previews the circle through the pointer, and two points that are the same or three on one line are refused with a message. Scores and estimates unchanged. - 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`). - 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged. - 2026-11-11: Pattern libraries: Patterns › Optical Effects, a third built-in pattern library, of VectorCraft's own designs, holds eight black wave, moiré and op-art tiles (Sine Bands, Ripple Lines, Interference Rings, Offset Rings, Warped Checks, Pinched Stripes, Chevron Pulse and Radiating Lenses) of 32 to 48 pt, each drawn the same way every time; each tile is one period of its design, and art that reaches past a tile edge continues on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged. diff --git a/apps/vectorcraft/src/host_services.rs b/apps/vectorcraft/src/host_services.rs index 94419b1049..2ed939245f 100644 --- a/apps/vectorcraft/src/host_services.rs +++ b/apps/vectorcraft/src/host_services.rs @@ -1,5 +1,7 @@ #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))] use super::portal_save; +#[cfg(windows)] +use super::windows_screen_color; #[cfg(all(windows, not(target_vendor = "win7")))] use super::windows_stylus; use super::{ClipboardProbeFactory, FilePick, PickRequest, Services, clipboard, cursor_theme, fileio, printing}; @@ -354,7 +356,7 @@ pub(crate) fn services(parent: Parent, ui: egui::Context) -> Services { .is_some_and(|h| matches!(h.as_raw(), RawWindowHandle::Xlib(_) | RawWindowHandle::Xcb(_))); let (clip, clip_probe) = (parent.clone(), parent.clone()); let (p1, p2, p3, p4, p5) = (parent.clone(), parent.clone(), parent.clone(), parent.clone(), parent); - #[cfg(any(target_os = "macos", target_os = "linux"))] + #[cfg(any(target_os = "macos", target_os = "linux", windows))] let sampled_ui = ui.clone(); #[cfg(target_os = "linux")] let sampled_parent = p1.clone(); @@ -413,6 +415,8 @@ pub(crate) fn services(parent: Parent, ui: egui::Context) -> Services { screen_color: Some(mac_screen_color::sampler(sampled_ui)), #[cfg(target_os = "linux")] screen_color: Some(linux_screen_color::sampler(sampled_ui, sampled_parent)), + #[cfg(windows)] + screen_color: Some(windows_screen_color::sampler(sampled_ui)), // File → Print: the system's printers and print queue. print: Some(Box::new(printing::SystemPrint)), ..Default::default() diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 8a892a381a..adc52f9d8c 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -77,6 +77,7 @@ mod window_frame; mod windows_alt_codes; #[cfg(windows)] mod windows_cores; +mod windows_screen_color; mod windows_stylus; mod xwayland; diff --git a/apps/vectorcraft/src/windows_screen_color.rs b/apps/vectorcraft/src/windows_screen_color.rs new file mode 100644 index 0000000000..56ea45eb7d --- /dev/null +++ b/apps/vectorcraft/src/windows_screen_color.rs @@ -0,0 +1,655 @@ +//! Windows: Sample Color from Screen (`vectorcraft_ui_egui::screen_color`). Windows has no system +//! color sampler, so a thread of its own copies the virtual screen, the bounding rectangle of all +//! the monitors (), +//! into a bitmap with `BitBlt` from the screen's device context +//! (), then covers +//! the virtual screen with a borderless topmost window that shows that copy under a crosshair +//! cursor. The window has its own message loop on that thread, so the UI keeps drawing. +//! +//! A left click answers the copied pixel under the pointer as sRGB; Escape, a click of any other +//! button, closing the window, and the window losing the keyboard focus or the mouse capture answer +//! `None`. Each +//! click is answered when its button is released, so the release does not reach the window +//! underneath. The color comes from the copy taken before the window was shown, so the window +//! never samples itself, and moving content shows the frame it had when the copy was taken. +//! +//! The pixels are 8-bit GDI colors, read as sRGB: GDI content is taken to be sRGB when the display +//! does not use Advanced Color +//! (). The colors +//! of HDR and wide-gamut displays are not converted. +//! +//! winit makes the process per-monitor DPI aware, so the virtual screen, the pointer and the copy +//! are in physical pixels on every monitor, whatever its scale, and a monitor left of or above the +//! main one has negative coordinates +//! (). +//! +//! The Win32 calls have no safe binding; [`overlay`] allows `unsafe_code`. +#![cfg_attr(not(windows), allow(dead_code))] + +/// The status message for every failure; the details go to the log. +const FAILED: &str = "the screen color sampler failed"; + +/// The largest copy of the virtual screen, in bytes of 32-bit pixels: 1 GiB, eight 7680 × 4320 +/// monitors. VectorCraft's own limit. +const MAX_SNAPSHOT_BYTES: u64 = 1 << 30; + +/// `CLR_INVALID` (`wingdi.h`): what `GetPixel` answers for a pixel it can't read. +const CLR_INVALID: u32 = 0xFFFF_FFFF; + +/// The virtual screen in physical pixels: its top-left corner (negative when a monitor is left of +/// or above the main one) and its size. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +struct VirtualScreen { + left: i32, + top: i32, + width: i32, + height: i32, +} + +impl VirtualScreen { + /// The virtual screen `GetSystemMetrics` reports, checked before any memory is taken for its + /// copy: an error when it is empty, larger than [`MAX_SNAPSHOT_BYTES`], or reaches past the + /// coordinates Windows can address. + fn new(left: i32, top: i32, width: i32, height: i32) -> Result { + if width <= 0 || height <= 0 { + return Err(format!("the virtual screen is {width} × {height} pixels")); + } + let bytes = u64::from(width.unsigned_abs()).saturating_mul(u64::from(height.unsigned_abs())).saturating_mul(4); + if bytes > MAX_SNAPSHOT_BYTES { + return Err(format!("the virtual screen ({width} × {height} pixels) is larger than the {MAX_SNAPSHOT_BYTES}-byte limit")); + } + if left.checked_add(width).is_none() || top.checked_add(height).is_none() { + return Err(format!("the virtual screen at ({left}, {top}) reaches past the coordinate range")); + } + Ok(Self { left, top, width, height }) + } + + /// The pixel of the copy at the screen point (`x`, `y`), or `None` when the point is outside the + /// virtual screen. + fn pixel(&self, x: i32, y: i32) -> Option<(i32, i32)> { + let (px, py) = (x.checked_sub(self.left)?, y.checked_sub(self.top)?); + ((0..self.width).contains(&px) && (0..self.height).contains(&py)).then_some((px, py)) + } +} + +/// The sRGB components (0 to 1) of a `COLORREF` (`0x00bbggrr`), or `None` for `CLR_INVALID` or any +/// other value with its high byte set. +fn srgb(colorref: u32) -> Option<[f32; 3]> { + if colorref == CLR_INVALID { + return None; + } + let [r, g, b, high] = colorref.to_le_bytes(); + (high == 0).then(|| [r, g, b].map(|v| f32::from(v) / 255.0)) +} + +/// The client point of a mouse message. Its `lParam` holds each coordinate as a signed 16-bit +/// value (`GET_X_LPARAM` and `GET_Y_LPARAM`, +/// ), so a coordinate past +/// 32,767 pixels in a wide virtual screen loses its high bits. Each coordinate becomes the value +/// with the same low 16 bits nearest to `near`, the message's own pointer position (`MSG.pt`, +/// ) in client +/// coordinates. +fn message_point(lparam: isize, near: (i32, i32)) -> (i32, i32) { + let widen = |low: i16, near: i32| near.saturating_add(i32::from(i32::from(low).wrapping_sub(near) as i16)); + (widen(lparam as i16, near.0), widen((lparam >> 16) as i16, near.1)) +} + +/// A mouse button: the left one picks, and any other one cancels. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Button { + Left, + Right, + /// The middle button or a side button. + Other, +} + +/// What the person did in the sampler's window. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Input { + Down(Button), + Up(Button), + Escape, + /// The window became the active window. + Activated, + /// The window stopped being the active window. + Deactivated, + /// Another window took the mouse capture. + CaptureLost, + /// The window was asked to close (Alt+F4). + Closed, +} + +/// What the sampler does next. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Step { + Wait, + Pick, + Cancel, +} + +/// The mouse button last pressed in the window, and whether the window has been active. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +struct Press { + down: Option