mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 12:59:43 +00:00
Merge pull request #9443 from dotCooCoo/fix/status-rotation-without-document
Disable status bar rotation without a document view
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user