Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Variables: the nothing-applied message clears when a later data set applies

dotCooCoo5660a15b7532
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 2d4970a12..f0044fe03 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -807,6 +807,11 @@ impl VectorcraftApp {
self.ui.view.pixel_preview = true;
}
}
+ // Choosing a data set, or stepping to one, clears the status bar. The reply's `warning`
+ // below then shows when no object is bound to a variable the data set has a value for.
+ if matches!(id, "dataset.select" | "dataset.next" | "dataset.prev") {
+ self.ui.status.clear();
+ }
if id == "text.setStyle"
&& let Some(font) = params.get("font").and_then(Value::as_str)
{
diff --git a/crates/ui-egui/src/panels/variables.rs b/crates/ui-egui/src/panels/variables.rs
index ca1fc29f6..4133b488a 100644
--- a/crates/ui-egui/src/panels/variables.rs
+++ b/crates/ui-egui/src/panels/variables.rs
@@ -392,7 +392,8 @@ mod tests {
/// Choosing a data set, or stepping to one with the arrows, shows a status message when no
/// object is bound to a variable it has a value for, for example after Import Data Sets…
- /// defines new variables. With such an object bound, it shows none.
+ /// defines new variables. With such an object bound, choosing a data set or stepping to one
+ /// clears the message.
#[test]
fn a_data_set_with_nothing_bound_shows_a_status_message() {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
@@ -407,10 +408,18 @@ mod tests {
app.run("dataset.prev", json!({})).unwrap();
assert_eq!(app.ui.status, message("A"));
- app.ui.status.clear();
app.run("variable.bind", json!({"variable": "Name", "ids": [t]})).unwrap();
app.run("dataset.select", json!({"name": "B"})).unwrap();
assert_eq!(app.ui.status, "");
+ // Stepping to a data set that applies clears the message as well.
+ for step in ["dataset.next", "dataset.prev"] {
+ app.run("variable.unbind", json!({"variable": "Name", "ids": [t]})).unwrap();
+ app.run("dataset.select", json!({"name": "A"})).unwrap();
+ assert_eq!(app.ui.status, message("A"));
+ app.run("variable.bind", json!({"variable": "Name", "ids": [t]})).unwrap();
+ app.run(step, json!({})).unwrap();
+ assert_eq!(app.ui.status, "", "{step}");
+ }
}
#[test]