From 9fbd1a6fa1613c9c684242e1d84cbf1f6c7c3aa2 Mon Sep 17 00:00:00 2001 From: Adiakys Date: Wed, 4 Nov 2026 00:05:46 +0100 Subject: [PATCH 1/2] Keep the press badge animation from redrawing every live frame twice --- crates/simrig-gui/ui/home.slint | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/simrig-gui/ui/home.slint b/crates/simrig-gui/ui/home.slint index 76e73bc..3487b22 100644 --- a/crates/simrig-gui/ui/home.slint +++ b/crates/simrig-gui/ui/home.slint @@ -43,6 +43,10 @@ component DeviceCard inherits Card { in property device; // Unplugged or failed: ghosted. A device that needs attention still works. property down: device.state != "ready" && device.state != "attention"; + // Set only when it changes: an animation bound to `device` itself would start again, and + // redraw the window once more, on every live frame. + property pressed-show: device.pressed-show; + changed device => { pressed-show = device.pressed-show; } interactive: true; label: device.kind-label + " " + device.name; activated => { Api.open-component(device.address); } @@ -122,7 +126,7 @@ component DeviceCard inherits Card { background: Theme.raised; border-width: 1px; border-color: Theme.rule; - opacity: root.device.pressed-show ? 1 : 0; + opacity: root.pressed-show ? 1 : 0; animate opacity { duration: 200ms; easing: cubic-bezier(0.25, 1, 0.5, 1); } accessible-role: AccessibleRole.text; accessible-label: root.device.pressed-show ? root.device.pressed + " " + root.device.pressed-label : ""; From 7522e155247ce856b3886c9f433599c0d3436db8 Mon Sep 17 00:00:00 2001 From: Adiakys Date: Wed, 4 Nov 2026 00:13:36 +0100 Subject: [PATCH 2/2] Draw the text of CPU-drawn layers with the bundled font --- crates/simrig-gui/Cargo.toml | 2 +- crates/simrig-gui/src/raster.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/simrig-gui/Cargo.toml b/crates/simrig-gui/Cargo.toml index 8918ee2..a3f00e7 100644 --- a/crates/simrig-gui/Cargo.toml +++ b/crates/simrig-gui/Cargo.toml @@ -21,7 +21,7 @@ simrig-model.workspace = true slint = { version = "1.18", default-features = false, features = ["std", "compat-1-2", "backend-winit", "renderer-femtovg", "renderer-software", "software-renderer-systemfonts", "software-renderer-path", "image-default-formats", "accessibility"] } png = "0.17" # Already used by Slint: draws rotated layers when the renderer cannot rotate (software). -resvg = { version = "0.48", default-features = false } +resvg = { version = "0.48", default-features = false, features = ["text"] } serde_json.workspace = true # Updates: the releases on GitHub (HTTPS with rustls, no system TLS library), the download's # checksum and version order. diff --git a/crates/simrig-gui/src/raster.rs b/crates/simrig-gui/src/raster.rs index c226022..c77db81 100644 --- a/crates/simrig-gui/src/raster.rs +++ b/crates/simrig-gui/src/raster.rs @@ -11,6 +11,9 @@ const WHEEL_ROUND: &[u8] = include_bytes!("../../../assets/devices/wheel-round.s const WHEEL_GT: &[u8] = include_bytes!("../../../assets/devices/wheel-gt.svg"); const WHEEL_FORMULA: &[u8] = include_bytes!("../../../assets/devices/wheel-formula.svg"); const LEVER: &[u8] = include_bytes!("../../../assets/devices/handbrake-lever.svg"); +/// The font of the drawings' text (the gear on the formula rim's display): without it the text +/// is left out. +const MARTIAN_MONO: &[u8] = include_bytes!("../../../assets/fonts/MartianMono-Variable.ttf"); /// Angles are rounded to this step, so a still device draws nothing new. const STEP_DEG: f32 = 0.5; @@ -57,7 +60,9 @@ impl Raster { "handbrake-lever" => LEVER, _ => WHEEL_ROUND, }; - usvg::Tree::from_data(data, &usvg::Options::default()).expect("core drawings parse") + let mut options = usvg::Options::default(); + options.fontdb_mut().load_font_data(MARTIAN_MONO.to_vec()); + usvg::Tree::from_data(data, &options).expect("core drawings parse") }); let size = tree.size().to_int_size(); let Some(mut pixmap) = tiny_skia::Pixmap::new(size.width(), size.height()) else {