From d75870a0551f8586bf214f8e21f7adc09c9afb17 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 08:57:51 -0800 Subject: [PATCH] Disable status bar rotation without a view --- crates/ui-egui/src/chrome/status_bar.rs | 4 +++- crates/ui-egui/src/chrome/tests.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/chrome/status_bar.rs b/crates/ui-egui/src/chrome/status_bar.rs index 04a7240cf7..aef6749bbc 100644 --- a/crates/ui-egui/src/chrome/status_bar.rs +++ b/crates/ui-egui/src/chrome/status_bar.rs @@ -32,7 +32,8 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { .map(|d| d.doc.artboards.iter().enumerate().map(|(i, a)| Entry::new(i, format!("{} {}", i + 1, a.name))).collect()) .unwrap_or_default(); let angles: Vec> = ROTATE_VIEW_ANGLES.iter().enumerate().map(|(i, (label, _))| Entry::new(i, *label)).collect(); - let rotation = app.view().map_or(0.0, |v| v.rotation); + let view = app.view(); + let rotation = view.map_or(0.0, |v| v.rotation); let turned = ROTATE_VIEW_ANGLES.iter().position(|(_, a)| (rotation - a).abs() < 1e-9).unwrap_or(usize::MAX); // An angle between the presets, from the Rotate View tool or `view.rotate`, shows in whole degrees; adding 0.0 // turns the -0 of a small negative angle into 0. @@ -80,6 +81,7 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { rotate_to = Select::new(tl!("Rotation"), Bind::given(turned), &angles) .placeholder(angle.clone()) .look(SelectLook::Filled) + .enabled(view.is_some()) .show(ui) .value() .copied(); diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 6484290054..fdf7dd9068 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -743,6 +743,20 @@ fn the_status_bar_rotation_box_shows_the_view_angle() { assert_eq!(bar.tree().value_of(rotation.node), Some("-45°")); } +#[test] +fn the_status_bar_rotation_picker_requires_a_document_view() { + let mut bar = status_readout_app(); + bar.app().run("file.close", json!({})).unwrap(); + assert!(bar.app().view().is_none()); + bar.settle().click("Rotation").settle(); + assert!(bar.find("-45°").is_none(), "the picker stays closed without a view"); + + bar.app().run("file.new", json!({"width": 100, "height": 100})).unwrap(); + bar.settle().click("Rotation").settle(); + bar.click("-45°").settle(); + assert_eq!(bar.app().view().map(|v| v.rotation), Some(-45.0)); +} + /// While background work runs the status bar shows it where the message was, with the count of the jobs after the /// first, and the message of the work's result takes the same place when it ends. Screen readers find the progress. #[test]