Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/simrig-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion crates/simrig-gui/src/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion crates/simrig-gui/ui/home.slint
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ component DeviceCard inherits Card {
in property <Device> device;
// Unplugged or failed: ghosted. A device that needs attention still works.
property <bool> 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 <bool> 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); }
Expand Down Expand Up @@ -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 : "";
Expand Down
Loading