Image Trace: a quick trace leaves the panel as it was; the Image Trace button opens it

This commit is contained in:
bflatastic
2026-10-16 01:36:25 +07:00
parent 313b1a52b9
commit baadbe2c67
2 changed files with 22 additions and 17 deletions
+16 -10
View File
@@ -133,10 +133,9 @@ pub(crate) fn view_row(app: &mut VectorcraftApp, ui: &mut Ui, current: TraceView
/// Trace the selected image, or trace the selected Image Trace object again, with built-in `preset`. /// Trace the selected image, or trace the selected Image Trace object again, with built-in `preset`.
fn trace_with(app: &mut VectorcraftApp, preset: &str) { fn trace_with(app: &mut VectorcraftApp, preset: &str) {
// Only reveal the controls after a successful trace; failures stay in the status bar. // A failure is reported in the status bar. The panel stays as it was: the Image Trace
if app.run("imageTrace.make", json!({ "preset": preset })).is_ok() { // button (Properties, Control bar) opens it.
open_settings(app); let _ = app.run("imageTrace.make", json!({ "preset": preset }));
}
} }
/// Reveal the editable tracing controls, including fidelity, in the panel's current location. /// Reveal the editable tracing controls, including fidelity, in the panel's current location.
@@ -503,6 +502,12 @@ mod tests {
traced_app_with_ink(0) traced_app_with_ink(0)
} }
/// A quick trace, then the Image Trace button.
fn trace_and_open(app: &mut VectorcraftApp, preset: &str) {
trace_with(app, preset);
open_settings(app);
}
fn traced_app_with_ink(ink: u8) -> VectorcraftApp { fn traced_app_with_ink(ink: u8) -> VectorcraftApp {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
@@ -520,7 +525,7 @@ mod tests {
let mut app = traced_app(); let mut app = traced_app();
app.run("imageTrace.release", json!({})).unwrap(); app.run("imageTrace.release", json!({})).unwrap();
app.ui.image_trace_advanced = false; app.ui.image_trace_advanced = false;
trace_with(&mut app, "Sketched Art"); trace_and_open(&mut app, "Sketched Art");
assert_eq!(app.ui.open_panel.as_deref(), Some("imageTrace")); assert_eq!(app.ui.open_panel.as_deref(), Some("imageTrace"));
assert!(app.ui.image_trace_advanced); assert!(app.ui.image_trace_advanced);
assert_eq!(selected_trace(&app).unwrap().0, "Sketched Art"); assert_eq!(selected_trace(&app).unwrap().0, "Sketched Art");
@@ -560,12 +565,13 @@ mod tests {
} }
#[test] #[test]
fn a_failed_quick_trace_does_not_open_settings() { fn a_quick_trace_leaves_the_panel_as_it_was() {
let mut app = traced_app(); let mut app = traced_app();
app.run("select.none", json!({})).unwrap(); app.run("imageTrace.release", json!({})).unwrap();
app.ui.open_panel = None; app.ui.open_panel = None;
app.ui.image_trace_advanced = false; app.ui.image_trace_advanced = false;
trace_with(&mut app, "Sketched Art"); trace_with(&mut app, "Sketched Art");
assert!(is_trace(&first_selected(&app).unwrap()));
assert!(app.ui.open_panel.is_none()); assert!(app.ui.open_panel.is_none());
assert!(!app.ui.image_trace_advanced); assert!(!app.ui.image_trace_advanced);
} }
@@ -575,7 +581,7 @@ mod tests {
let mut app = traced_app(); let mut app = traced_app();
app.run("window.panel.float", json!({"panel": "imageTrace"})).unwrap(); app.run("window.panel.float", json!({"panel": "imageTrace"})).unwrap();
let before = app.ui.docking.clone().unwrap(); let before = app.ui.docking.clone().unwrap();
trace_with(&mut app, "Sketched Art"); trace_and_open(&mut app, "Sketched Art");
let after = app.ui.docking.as_ref().unwrap(); let after = app.ui.docking.as_ref().unwrap();
assert_eq!(after.floating.len(), before.floating.len()); assert_eq!(after.floating.len(), before.floating.len());
assert!(after.floating.iter().any(|g| g.panels == ["imageTrace"])); assert!(after.floating.iter().any(|g| g.panels == ["imageTrace"]));
@@ -585,7 +591,7 @@ mod tests {
#[test] #[test]
fn adjusting_sketch_threshold_changes_the_vector_result_and_can_be_undone() { fn adjusting_sketch_threshold_changes_the_vector_result_and_can_be_undone() {
let mut app = traced_app_with_ink(100); let mut app = traced_app_with_ink(100);
trace_with(&mut app, "Sketched Art"); trace_and_open(&mut app, "Sketched Art");
let ctx = egui::Context::default(); let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx); crate::theme::install_fonts(&ctx);
frame(&mut app, &ctx, vec![]); frame(&mut app, &ctx, vec![]);
@@ -613,7 +619,7 @@ mod tests {
#[test] #[test]
fn sketch_adjustment_sliders_retrace_on_release() { fn sketch_adjustment_sliders_retrace_on_release() {
let mut app = traced_app(); let mut app = traced_app();
trace_with(&mut app, "Sketched Art"); trace_and_open(&mut app, "Sketched Art");
let ctx = egui::Context::default(); let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx); crate::theme::install_fonts(&ctx);
for (label, key) in [("Threshold", "threshold"), ("Paths", "paths"), ("Corners", "corners"), ("Noise", "noise")] { for (label, key) in [("Threshold", "threshold"), ("Paths", "paths"), ("Corners", "corners"), ("Noise", "noise")] {
+6 -7
View File
@@ -1,12 +1,11 @@
# Adjusting an Image Trace # Adjusting an Image Trace
Select a placed raster image, then choose **Image Trace** or a preset from its arrow Select a placed raster image, then choose **Image Trace** or a preset from its arrow
in Properties or the Control bar. A successful trace opens the Image Trace panel with in Properties or the Control bar. The original image stays inside the tracing object so
**Advanced** expanded, including when choosing **Sketched Art**. The original image stays that subsequent adjustments always use the original pixels.
inside the tracing object so that subsequent adjustments always use the original pixels.
If the panel was closed, select the tracing object and click **Image Trace** in Properties To adjust the result, select the tracing object and click **Image Trace** in Properties or the
or the image icon in the Control bar. An existing floating or docked panel is activated in image icon in the Control bar: the Image Trace panel opens with **Advanced** expanded. An existing floating or docked panel is activated in
its current location. Opening the controls does not add a document undo step. its current location. Opening the controls does not add a document undo step.
| Control | Range | Effect | | Control | Range | Effect |
@@ -32,6 +31,6 @@ implementation; they do not claim pixel-identical results with another applicati
The terminology and general control behavior are described in the The terminology and general control behavior are described in the
[public Image Trace panel documentation](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/image-trace-panel-options.html). [public Image Trace panel documentation](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/image-trace-panel-options.html).
Regression coverage: `crates/ui-egui/src/panels/image_trace.rs` tests panel discovery, Regression coverage: `crates/ui-egui/src/panels/image_trace.rs` tests opening the panel,
failure handling, repeated opening, floating ownership, slider commits, visible threshold a quick trace leaving it as it was, repeated opening, floating ownership, slider commits, visible threshold
changes, undo, and the Properties entry point. Tracer tests live in `crates/trace/src/tests.rs`. changes, undo, and the Properties entry point. Tracer tests live in `crates/trace/src/tests.rs`.