PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #6338: Smart filters: an edited filter's dialog previews again (fixes #6324)
aionggb9b4a73cc0dc
diff --cc crates/ui-egui/src/filter_dialog.rsindex 3290dacee,80bcd57d2..72126a69c--- a/crates/ui-egui/src/filter_dialog.rs+++ b/crates/ui-egui/src/filter_dialog.rs@@@ -965,11 -898,11 +967,12 @@@ pub(crate) fn preview_document_for_targreturn crate::select_mask_view::preview_document(doc, active, params, k, cancel);}// Warp Text renders the type again from the layer model (font size, position), which a- // reduced proxy doesn't scale: it runs at full size and the result is reduced (#218).- let (run_k, reduce_k) = if command == "type.warpText" { (1, k) } else { (k, 1) };+ // reduced proxy doesn't scale: it runs at full size and the result is reduced (#218). So does+ // a smart filter being edited: the smart object renders again from its source (#6324).+ let (run_k, reduce_k) = if command == "type.warpText" || command == SMART_FILTER_SET_PARAMS { (1, k) } else { (k, 1) };let proxy = crate::proxy::proxy_document(doc, run_k);let mut s = photocraft_engine::Session::new();+ s.color.settings = color.clone();s.set_inline_job_ctx(cancel.cloned());let doc_id = proxy.id;s.add_document(proxy, None);diff --cc crates/ui-egui/src/filter_preview_ui.rsindex e4afdb756,859a82956..b068f3339--- a/crates/ui-egui/src/filter_preview_ui.rs+++ b/crates/ui-egui/src/filter_preview_ui.rs@@@ -43,17 -43,16 +43,21 @@@ pub(crate) fn window(app: &PhotocraftAp// decides whether the filtered result (rather than the original) is shown.let preview_on = f.get("__preview").and_then(Value::as_bool) == Some(true);let filtered: Option<(FilterPreviewKey, std::sync::Arc<Document>)> = app.filter_preview.as_ref().and_then(|p| {- (preview_on && p.key.dialog == dialog && p.key.doc == doc_id && p.key.command == cmd).then(|| p.result.clone().map(|r| (p.key.clone(), r))).flatten()+ // An edited smart filter previews as `layer.smartFilter.setParams` (#6324).+ let previewed = crate::smart_ui::preview_command(f, &cmd);+ (preview_on && p.key.dialog == dialog && p.key.doc == doc_id && p.key.command == previewed)+ .then(|| p.result.clone().map(|r| (p.key.clone(), r)))+ .flatten()});// The proxy factor the preview runs at (the filtered key's when it exists, else the request's).+ // The fallback must be the factor the canvas will ask for, not the document's own: since #6326+ // the canvas caps it with the view's zoom, and a window that sized its textures from the+ // uncapped factor built a proxy the canvas never asked for, then rebuilt it (a full-size copy+ // and upload on the UI thread at 100 %) the moment the first result arrived, shifting this+ // window's 100 % mapping and pan clamp for a frame.let base_k = filtered.as_ref().map(|(k, _)| k.k).unwrap_or_else(|| {let params = app.with_mask_target(&cmd, crate::filter_dialog::params_of(f));- crate::filter_dialog::preview_factor(&cmd, ¶ms, crate::proxy::preview_factor(&st.doc, crate::proxy::reduced_previews(app)))+ crate::canvas::filter_preview_factor(app, &st.doc, &cmd, ¶ms)});let t = Tokens::get(ui.ctx());