mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Adjustment dialogs: live CPU preview on masks, channels and modes the layer path refuses
An Image > Adjustments dialog whose target is a layer mask, the Quick Mask, a channel, or a document or layer the adjustment-layer preview refuses (CMYK, Lab, Blend If, smart objects) showed no live preview. adjust_preview hands those targets to the CPU proxy preview, but since the move to the framework's dialog host (#15449) ensure_filter_preview took only Smart Filter adjustment edits and parameter dialogs, so a plain adjustment dialog fell out. ensure_filter_preview now takes every open adjustment dialog, with the command and parameters OK runs (adjust_dialog::confirmed_command, shared with OK). A compare hold shows the original for every adjustment preview, Smart Filter edits included, as the layer path already did.
This commit is contained in:
1 parent
9cf019ed37
commit
6097755e17
2 files changed
+21
-14
No files matched your search
@@ -33,18 +33,18 @@ pub(crate) fn filter_preview_factor(app: &PhotocraftApp, doc: &Document, cmd: &s
|
||||
if cfg!(target_arch = "wasm32") { k } else { crate::proxy::view_factor(k, app.current_zoom(), doc.size.area()) }
|
||||
}
|
||||
|
||||
/// The open Smart Filter adjustment editor with its Preview box on: its dialog id, the adjustment command, the
|
||||
/// captured Smart Filter target and the settings it would send. A plain adjustment dialog previews through
|
||||
/// `adjust_preview` instead.
|
||||
fn smart_adjust_preview(app: &PhotocraftApp) -> Option<(craft::ui::dialog::DialogId, String, serde_json::Value, serde_json::Value)> {
|
||||
/// The open adjustment dialog (a plain one or a Smart Filter edit) while its preview shows: its dialog id and what OK
|
||||
/// would run (`adjust_dialog::confirmed_command`). A plain dialog previews through `adjust_preview`'s layer path where
|
||||
/// that matches the command (checked before this); every other target (a mask, the Quick Mask, a channel, a mode or
|
||||
/// layer the layer path refuses) runs the command here. A compare hold shows the original, as on the layer path.
|
||||
fn adjust_request(app: &PhotocraftApp) -> Option<(craft::ui::dialog::DialogId, String, serde_json::Value)> {
|
||||
let open = crate::adjust_dialog::open_value(app)?;
|
||||
let (_, captured) = open.smart_filter.as_ref()?;
|
||||
let hosted = crate::adjust_dialog::hosted(app, open.id)?;
|
||||
if !hosted.is_previewing() {
|
||||
if !hosted.is_previewing() || hosted.is_comparing() {
|
||||
return None;
|
||||
}
|
||||
let params = crate::adjust_dialog::smart_filter_params(app, open, hosted.value(), hosted.edited()).ok()?;
|
||||
Some((open.id, open.command.clone(), captured.clone(), params))
|
||||
let (cmd, params, _) = crate::adjust_dialog::confirmed_command(app, open, hosted.value(), hosted.edited()).ok()?;
|
||||
Some((open.id, cmd, params))
|
||||
}
|
||||
|
||||
/// Live preview for an open filter dialog: run the filter on the proxy and upload it. With
|
||||
@@ -64,9 +64,8 @@ pub(crate) fn ensure_filter_preview(app: &mut PhotocraftApp, idx: usize, ctx: &e
|
||||
return None;
|
||||
}
|
||||
// The open dialog with its Preview box on, whichever family hosts it; its key is the command.
|
||||
let (id, cmd, params) = if let Some((id, key, captured, params)) = smart_adjust_preview(app) {
|
||||
let (cmd, params) = crate::smart_filter_dialog::params_command(app, &captured, &key, params).ok()?;
|
||||
(id, cmd, params)
|
||||
let (id, cmd, params) = if let Some(request) = adjust_request(app) {
|
||||
request
|
||||
} else {
|
||||
let (id, key, dialog_fields, fields) = {
|
||||
let d = app.framework.dialogs.get::<HostedParamDialog>()?;
|
||||
|
||||
@@ -833,15 +833,23 @@ fn follow_target(app: &mut PhotocraftApp, id: DialogId) {
|
||||
(open.mode, open.target, open.picker_base, open.picked) = (smart_mode, target, None, None);
|
||||
}
|
||||
|
||||
/// Authorizes and runs the confirmed command (one history step), then remembers the settings.
|
||||
fn run_confirmed(app: &mut PhotocraftApp, ctx: &egui::Context, open: &OpenAdjust, value: &DialogValue, edited: bool) -> Result<(), String> {
|
||||
/// What OK on the open dialog runs, `(command, its params, the dialog's params)`: the adjustment command on the dialog's
|
||||
/// value, or for a Smart Filter edit the command that replaces the captured filter. OK and the CPU proxy preview
|
||||
/// (`canvas::ensure_filter_preview`) both take it from here, so the preview is what OK commits.
|
||||
pub(crate) fn confirmed_command(app: &PhotocraftApp, open: &OpenAdjust, value: &DialogValue, edited: bool) -> Result<(String, Value, Value), String> {
|
||||
let params = match open.smart_filter {
|
||||
Some(_) => smart_filter_params(app, open, value, edited)?,
|
||||
None => value.params(edited),
|
||||
};
|
||||
crate::actions::authorize_panel_preview(app, open.id, &open.command, ¶ms)?;
|
||||
let captured = open.smart_filter.as_ref().map_or(Value::Null, |(_, target)| target.clone());
|
||||
let (command, run_params) = crate::smart_ui::confirm_command(app, &captured, open.command.clone(), params.clone())?;
|
||||
Ok((command, run_params, params))
|
||||
}
|
||||
|
||||
/// Authorizes and runs the confirmed command (one history step), then remembers the settings.
|
||||
fn run_confirmed(app: &mut PhotocraftApp, ctx: &egui::Context, open: &OpenAdjust, value: &DialogValue, edited: bool) -> Result<(), String> {
|
||||
let (command, run_params, params) = confirmed_command(app, open, value, edited)?;
|
||||
crate::actions::authorize_panel_preview(app, open.id, &open.command, ¶ms)?;
|
||||
// The editor Record Again opened answers the step it was opened for, not a new run of the command.
|
||||
if crate::actions::record_again::owns_dialog(app, open.id) {
|
||||
crate::actions::record_again::confirm(app, open.id, &command, run_params)?;
|
||||
|
||||
Reference in new issue
Block a user