Disable status bar rotation without a view

This commit is contained in:
dotCooCoo
2026-11-26 08:57:51 -08:00
parent f040538a39
commit d75870a055
2 changed files with 17 additions and 1 deletions
+3 -1
View File
@@ -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<Entry<usize>> = 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();
+14
View File
@@ -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]