diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index ecb89bd289..df6671f455 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1208,6 +1208,7 @@ fn build() -> Vec { v.extend(crate::video_cmds::specs()); v.extend(crate::jobs::specs()); v.extend(crate::wia_cmds::specs()); + v.extend(crate::rasterize_style_cmds::specs()); v.extend(crate::variables_cmds::specs()); v.extend(crate::plugin_cmds::specs()); v.extend(crate::group_view_cmds::specs()); diff --git a/crates/engine/src/extra_cmds.rs b/crates/engine/src/extra_cmds.rs index 02374d06be..e38a9d01f4 100644 --- a/crates/engine/src/extra_cmds.rs +++ b/crates/engine/src/extra_cmds.rs @@ -68,7 +68,7 @@ pub(crate) fn style_targets(s: &Session, p: &Value, fits: impl Fn(&Layer) -> boo } /// A key that makes the sub-commands of one command share a single history step. -fn step_key(s: &Session, what: &str) -> String { +pub(crate) fn step_key(s: &Session, what: &str) -> String { format!("{what}#{}", s.active().map_or(0, |d| d.revision)) } @@ -617,7 +617,7 @@ fn content_pixels(doc: &Document, l: &Layer) -> photocraft_raster::Surface { s } -fn kind_of(s: &Session, id: LayerId) -> Option<&'static str> { +pub(crate) fn kind_of(s: &Session, id: LayerId) -> Option<&'static str> { let d = s.active()?; Some(match &d.doc.layer(id)?.content { LayerContent::Text(_) => "type", @@ -628,8 +628,19 @@ fn kind_of(s: &Session, id: LayerId) -> Option<&'static str> { }) } -/// Rasterize one layer; `only` restricts it to one kind. Returns false when there was nothing to do. -fn rasterize_one(s: &mut Session, id: LayerId, only: Option<&str>, key: &str) -> Result { +/// Rasterize one layer; `only` restricts it to one kind. Without `only` (Rasterize › Layer / All +/// Layers: "all vector data") a vector mask becomes a pixel mask too; layer effects stay live, as +/// in Photoshop (Rasterize › Layer Style bakes them). Returns false when there was nothing to do. +pub(crate) fn rasterize_one(s: &mut Session, id: LayerId, only: Option<&str>, key: &str) -> Result { + let vector_mask = only.is_none() && s.active().and_then(|d| d.doc.layer(id)).is_some_and(|l| l.vector_mask.is_some()); + let content = rasterize_content(s, id, only, key)?; + if vector_mask { + s.execute("layer.rasterize.vectorMask", json!({"layer": id.0, "coalesce": key}))?; + } + Ok(content || vector_mask) +} + +fn rasterize_content(s: &mut Session, id: LayerId, only: Option<&str>, key: &str) -> Result { let Some(kind) = kind_of(s, id).filter(|k| only.is_none_or(|o| o == *k)) else { return Ok(false) }; match kind { "type" => { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 32d0834232..ca09663707 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -81,6 +81,7 @@ pub mod preset_store; pub mod presets; pub mod print_cmds; pub mod proof_sim; +pub mod rasterize_style_cmds; pub mod redeye_cmds; pub mod render_cmds; pub mod retouch_cmds; diff --git a/crates/engine/src/rasterize_style_cmds.rs b/crates/engine/src/rasterize_style_cmds.rs new file mode 100644 index 0000000000..db8af142be --- /dev/null +++ b/crates/engine/src/rasterize_style_cmds.rs @@ -0,0 +1,135 @@ +//! Layer › Rasterize › Layer Style (#2245): bake a layer's effects into its pixels. +//! +//! The layer is rendered alone by the compositor (the same path as the canvas) at 100 % opacity +//! in Normal mode, so its effects, fill opacity and masks end up in the pixels; its own opacity, +//! blend mode, knockout and Blend If stay layer properties and apply to the baked pixels. For a +//! Normal layer whose effects blend Normal the document looks the same before and after. An +//! effect in another mode (a Multiply shadow, a Screen glow) is evaluated against the +//! transparent backdrop of the isolated layer, so it can look different afterwards; no single +//! layer of pixels can blend one part Multiply and another Screen. + +use photocraft_color::BlendMode; +use photocraft_doc::{Knockout, Layer, LayerContent, LayerId}; +use photocraft_raster::{Surface, from_rgba_into}; +use serde_json::{Value, json}; + +use crate::commands::CommandSpec; +use crate::{EngineError, Result, Session}; + +const ID: &str = "layer.rasterize.layerStyle"; + +/// Whether Rasterize › Layer Style applies to `l`: visible effects on a layer whose content can +/// become pixels (not a group or an adjustment layer). +pub fn can_bake(l: &Layer) -> bool { + photocraft_compose::effects::has_effects(l) && !matches!(l.content, LayerContent::Group(_) | LayerContent::Adjustment(_)) +} + +/// Some selected layer (or the active one) has effects to bake. +fn enabled(s: &Session) -> std::result::Result<(), String> { + let d = s.active().ok_or("no document open")?; + let ids = d.selected_layers().into_iter().chain(d.active_layer); + if ids.filter_map(|id| d.doc.layer(id)).any(can_bake) { Ok(()) } else { Err("no selected layer has layer effects to rasterize".into()) } +} + +/// Bake one layer (type, shape, fill and Smart Object content is rasterized first, in the same +/// history step). Returns false when the layer has nothing to bake. +fn bake_one(s: &mut Session, id: LayerId, key: &str) -> Result { + let d = s.active().ok_or(EngineError::NoDocument)?; + if !d.doc.layer(id).is_some_and(can_bake) { + return Ok(false); + } + if let Some(kind) = crate::extra_cmds::kind_of(s, id) { + crate::extra_cmds::rasterize_one(s, id, Some(kind), key)?; + } + s.coalesce_request = Some(key.to_string()); + let r = s.edit("Rasterize Layer Style", |doc, _| { + let l = doc.layer(id).cloned().ok_or(EngineError::NoLayer(id))?; + if !matches!(l.content, LayerContent::Raster(_)) { + return Err(EngineError::Other("the layer could not be rasterized".into())); + } + let canvas = doc.bounds(); + let fmt = doc.pixel_format(); + // The pixels (also those past the canvas) and everything the effects reach from them. + let area = photocraft_compose::layer_bounds(&l, canvas).inflate(photocraft_compose::effects::margin(&l).max(0)); + let mut alone = l.clone(); + alone.visible = true; + alone.opacity = 1.0; + alone.blend = BlendMode::Normal; + alone.clipped = false; + // These depend on the layers beneath and stay on the layer, applied to the baked pixels. + alone.advanced.knockout = Knockout::None; + alone.blend_if = Default::default(); + alone.excluded_channels = 0; + let mut data = Vec::new(); + if !area.is_empty() { + // Render the layer on its own with the document's settings (mode, depth, global + // light, patterns), then put the real stack back. + let stack = std::mem::replace(&mut doc.layers, vec![alone]); + let buf = photocraft_compose::render(doc, area); + doc.layers = stack; + let n = fmt.channels(); + data = vec![0.0f32; buf.px.len() * n]; + for (p, out) in buf.px.iter().zip(data.chunks_exact_mut(n)) { + from_rgba_into(&fmt, *p, out); + } + } + let mut px = Surface::new(fmt); + if !area.is_empty() { + px.write_region(area, &data); + } + px.prune(); + let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?; + l.content = LayerContent::Raster(px); + l.fill_cache = None; + // Fill opacity, the masks and the effects are in the pixels now. + l.fill_opacity = 1.0; + l.mask = None; + l.vector_mask = None; + l.effects.items.clear(); + l.effects.psd_raw = None; + l.effects.reference = None; + l.effects.enabled = true; + l.advanced.blend_interior = false; + l.advanced.layer_mask_hides_effects = false; + l.advanced.vector_mask_hides_effects = false; + Ok(()) + }); + s.coalesce_request = None; + r?; + Ok(true) +} + +/// `{"layer":id?}`: with a layer, just that one; otherwise every selected layer with effects, in +/// one history step. +fn rasterize_layer_style(s: &mut Session, p: &Value) -> Result { + let ids = crate::layer_multi_cmds::targets(s, p)?; + let many = ids.len() > 1; + let key = crate::extra_cmds::step_key(s, "rasterizeLayerStyle"); + let mut done = Vec::new(); + for id in ids { + if bake_one(s, id, &key)? { + done.push(id.0); + } + } + let Some(&first) = done.first() else { + return Err(EngineError::Other(if many { "none of the selected layers has layer effects" } else { "the layer has no layer effects" }.into())); + }; + let active = s.active().and_then(|d| d.active_layer).map(|id| id.0).filter(|id| done.contains(id)); + Ok(json!({"layer": active.unwrap_or(first), "layers": done})) +} + +pub fn specs() -> Vec { + vec![CommandSpec { + id: ID, + label: "Layer Style", + menu: &["Layer", "Rasterize"], + shortcut: None, + params: r##"{"layer":id?} (no layer: every selected layer with effects; bakes the effects, fill opacity and masks into the pixels)"##, + enabled, + run: rasterize_layer_style, + journal: true, + }] +} + +#[cfg(test)] +mod tests; diff --git a/crates/engine/src/rasterize_style_cmds/tests.rs b/crates/engine/src/rasterize_style_cmds/tests.rs new file mode 100644 index 0000000000..9b5ef7d359 --- /dev/null +++ b/crates/engine/src/rasterize_style_cmds/tests.rs @@ -0,0 +1,165 @@ +use super::*; +use photocraft_doc::Document; + +fn doc(s: &Session) -> &Document { + &s.active().unwrap().doc +} + +fn layer(s: &Session, id: u64) -> &Layer { + doc(s).layer(LayerId(id)).unwrap() +} + +fn composite(s: &Session) -> photocraft_compose::Buffer { + let d = doc(s); + photocraft_compose::render(d, d.bounds()) +} + +fn max_diff(a: &photocraft_compose::Buffer, b: &photocraft_compose::Buffer) -> f32 { + a.px.iter().zip(&b.px).flat_map(|(p, q)| p.iter().zip(q).map(|(x, y)| (x - y).abs())).fold(0.0, f32::max) +} + +/// The quantisation step of one stored sample: the baked layer is stored at the document's depth. +fn tolerance(depth: u32) -> f32 { + match depth { + 8 => 2.5 / 255.0, + 16 => 2.0 / 32768.0 + 1e-4, + _ => 1e-4, + } +} + +/// A white Background and a red rectangle (partly off the right edge of the canvas) with a +/// Normal-mode drop shadow, outer glow, inner shadow, outside stroke and a half colour overlay. +fn scene(depth: u32) -> (Session, u64) { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 64, "height": 48, "depth": depth})).unwrap(); + let id = s.execute("layer.new.layer", json!({"name": "a"})).unwrap()["layer"].as_u64().unwrap(); + s.execute("select.rect", json!({"x": 14, "y": 10, "width": 56, "height": 20})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#e02010"})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + s.execute("layer.layerStyle.dropShadow", json!({"blend": "normal", "distance": 6, "size": 4, "color": "#102040"})).unwrap(); + s.execute("layer.layerStyle.outerGlow", json!({"blend": "normal", "size": 5, "color": "#20c040", "add": true})).unwrap(); + s.execute("layer.layerStyle.innerShadow", json!({"blend": "normal", "distance": 3, "size": 3, "add": true})).unwrap(); + s.execute("layer.layerStyle.stroke", json!({"size": 2, "position": "outside", "color": "#0000ff", "add": true})).unwrap(); + s.execute("layer.layerStyle.colorOverlay", json!({"color": "#ffff00", "opacity": 50, "add": true})).unwrap(); + (s, id) +} + +fn bake_and_check(s: &mut Session, id: u64, depth: u32) { + let before = composite(s); + let steps = s.active().unwrap().history.past_len(); + let r = s.execute(ID, json!({})).unwrap(); + assert_eq!(r["layers"], json!([id])); + assert_eq!(s.active().unwrap().history.past_len(), steps + 1, "one history step"); + let l = layer(s, id); + assert!(l.effects.items.is_empty(), "effects baked"); + assert!(matches!(l.content, LayerContent::Raster(_))); + assert!(l.mask.is_none() && l.vector_mask.is_none(), "masks applied"); + assert_eq!(l.fill_opacity, 1.0); + let after = composite(s); + let d = max_diff(&before, &after); + assert!(d <= tolerance(depth), "depth {depth}: composite changed by {d}"); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(layer(s, id).effects.items.len(), 5, "undo restores the effects"); + assert_eq!(max_diff(&before, &composite(s)), 0.0, "undo restores the picture"); +} + +#[test] +fn bakes_effects_without_changing_the_composite() { + for depth in [8, 16, 32] { + let (mut s, id) = scene(depth); + bake_and_check(&mut s, id, depth); + } +} + +#[test] +fn fill_opacity_masks_and_layer_opacity_survive_the_bake() { + for depth in [8, 16, 32] { + let (mut s, id) = scene(depth); + s.execute("layer.setProps", json!({"layer": id, "fill": 0.4, "opacity": 0.7})).unwrap(); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 34, "height": 48})).unwrap(); + s.execute("layer.layerMask.revealSelection", json!({})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + let square = json!({"subpaths": [{"closed": true, "knots": [[4, 4], [60, 4], [60, 26], [4, 26]]}]}); + s.execute("layer.vectorMask.add", json!({"layer": id, "path": square})).unwrap(); + bake_and_check(&mut s, id, depth); + s.execute("edit.redo", json!({})).unwrap(); + assert_eq!(layer(&s, id).opacity, 0.7, "the layer's own opacity stays a property"); + } +} + +#[test] +fn keeps_the_pixels_past_the_canvas() { + let (mut s, id) = scene(8); + s.execute(ID, json!({"layer": id})).unwrap(); + let LayerContent::Raster(px) = &layer(&s, id).content else { panic!() }; + // The rectangle runs to x = 70 and its stroke and glow further, past the 64 px canvas. + assert!(px.content_bounds().x1 > 70, "{:?}", px.content_bounds()); +} + +#[test] +fn rasterizes_fill_content_first() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 40, "height": 30})).unwrap(); + s.execute("layer.newFillLayer.solidColor", json!({"color": "#3366cc"})).unwrap(); + let id = s.active().unwrap().active_layer.unwrap().0; + let square = json!({"subpaths": [{"closed": true, "knots": [[8, 8], [28, 8], [28, 20], [8, 20]]}]}); + s.execute("layer.vectorMask.add", json!({"layer": id, "path": square})).unwrap(); + s.execute("layer.layerStyle.stroke", json!({"size": 3, "position": "outside", "color": "#ff0000"})).unwrap(); + let before = composite(&s); + let steps = s.active().unwrap().history.past_len(); + s.execute(ID, json!({})).unwrap(); + assert_eq!(s.active().unwrap().history.past_len(), steps + 1, "rasterize and bake are one step"); + assert!(matches!(layer(&s, id).content, LayerContent::Raster(_))); + assert!(layer(&s, id).effects.items.is_empty()); + assert!(max_diff(&before, &composite(&s)) <= tolerance(8)); +} + +#[test] +fn rasterize_layer_turns_a_vector_mask_into_a_pixel_mask_and_keeps_effects() { + let (mut s, id) = scene(8); + // Effects alone: Rasterize › Layer has nothing to do (Rasterize › Layer Style bakes them). + assert!(s.execute("layer.rasterize.layer", json!({})).is_err()); + let square = json!({"subpaths": [{"closed": true, "knots": [[4, 4], [40, 4], [40, 40], [4, 40]]}]}); + s.execute("layer.vectorMask.add", json!({"layer": id, "path": square})).unwrap(); + let before = composite(&s); + s.execute("layer.rasterize.layer", json!({})).unwrap(); + let l = layer(&s, id); + assert!(l.vector_mask.is_none() && l.mask.is_some(), "vector mask became a pixel mask"); + assert_eq!(l.effects.items.len(), 5, "effects stay live"); + assert!(max_diff(&before, &composite(&s)) <= tolerance(8)); +} + +#[test] +fn several_selected_layers_bake_in_one_step() { + let (mut s, a) = scene(8); + let b = s.execute("layer.new.layer", json!({"name": "b"})).unwrap()["layer"].as_u64().unwrap(); + s.execute("select.rect", json!({"x": 2, "y": 34, "width": 10, "height": 8})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#00ff00"})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + s.execute("layer.layerStyle.stroke", json!({"size": 2})).unwrap(); + let plain = s.execute("layer.new.layer", json!({"name": "plain"})).unwrap()["layer"].as_u64().unwrap(); + s.active_mut().unwrap().selected_layers = vec![LayerId(a), LayerId(b), LayerId(plain)]; + let steps = s.active().unwrap().history.past_len(); + let r = s.execute(ID, json!({})).unwrap(); + assert_eq!(r["layers"], json!([a, b])); + assert_eq!(s.active().unwrap().history.past_len(), steps + 1); + assert!(layer(&s, a).effects.items.is_empty() && layer(&s, b).effects.items.is_empty()); +} + +#[test] +fn disabled_and_bad_params_fail_gracefully() { + let mut empty = Session::new(); + assert!(empty.execute(ID, json!({})).is_err(), "no document"); + let (mut s, id) = scene(8); + let bg = doc(&s).layers[0].id.0; + assert!(s.execute(ID, json!({"layer": bg})).is_err(), "the Background has no effects"); + assert!(s.execute(ID, json!({"layer": 9999})).is_err(), "no such layer"); + assert!(s.execute(ID, json!({"layer": u64::MAX})).is_err(), "no such layer"); + assert_eq!(layer(&s, id).effects.items.len(), 5, "a bad call changes nothing"); + s.execute("layer.layerStyle.hideAllEffects", json!({})).unwrap(); + assert!(s.execute(ID, json!({"layer": id})).is_err(), "hidden effects: nothing to bake"); + s.execute("layer.layerStyle.showAllEffects", json!({})).unwrap(); + let g = s.execute("layer.new.group", json!({})).unwrap()["layer"].as_u64().unwrap(); + s.execute("layer.layerStyle.stroke", json!({"layer": g})).unwrap(); + assert!(s.execute(ID, json!({"layer": g})).is_err(), "group styles are not baked"); +} diff --git a/crates/ui-egui/src/enable_rules.rs b/crates/ui-egui/src/enable_rules.rs index 593589051c..05cf7b6ab0 100644 --- a/crates/ui-egui/src/enable_rules.rs +++ b/crates/ui-egui/src/enable_rules.rs @@ -42,10 +42,12 @@ fn kind_blocks(id: &str, l: &Layer) -> bool { "layer.rasterize.fillContent" => !matches!(c, LayerContent::Fill(_)), "layer.rasterize.smartObject" => !matches!(c, LayerContent::Smart(_)), "layer.rasterize.vectorMask" => l.vector_mask.is_none(), - // What the command converts: type, shape, fill and Smart Object layers (a raster layer with a - // vector mask has Rasterize › Vector Mask; the command used to be enabled for layers with - // effects or a vector mask and then fail with "nothing to rasterize"). - "layer.rasterize.layer" => !matches!(c, LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Fill(_) | LayerContent::Smart(_)), + // What the command converts: type, shape, fill and Smart Object layers, and vector masks + // ("all vector data"). Effects stay live: Rasterize › Layer Style bakes them. + "layer.rasterize.layer" => { + l.vector_mask.is_none() && !matches!(c, LayerContent::Text(_) | LayerContent::Shape(_) | LayerContent::Fill(_) | LayerContent::Smart(_)) + } + "layer.rasterize.layerStyle" => !photocraft_engine::rasterize_style_cmds::can_bake(l), "layer.layerStyle.copyLayerStyle" | "layer.layerStyle.clear" => l.effects.items.is_empty(), _ => id.starts_with("layer.combineShapes.") && !matches!(c, LayerContent::Shape(_)), } @@ -84,9 +86,12 @@ enum Targets { /// layers happened to be active). fn selection_targets(id: &str) -> Option { Some(match id { - "layer.rasterize.layer" | "layer.rasterize.type" | "layer.rasterize.shape" | "layer.rasterize.fillContent" | "layer.rasterize.smartObject" => { - Targets::Any - } + "layer.rasterize.layer" + | "layer.rasterize.layerStyle" + | "layer.rasterize.type" + | "layer.rasterize.shape" + | "layer.rasterize.fillContent" + | "layer.rasterize.smartObject" => Targets::Any, "layer.releaseClippingMask" | "layer.layerStyle.pasteLayerStyle" | "layer.layerStyle.clear" => Targets::Any, "layer.createClippingMask" => Targets::AllButLowest, "layer.layerMask.revealAll" | "layer.layerMask.hideAll" | "layer.layerMask.revealSelection" | "layer.layerMask.hideSelection" => Targets::WithoutMask, @@ -204,7 +209,7 @@ mod tests { } } - /// A document with a Background, plain layers, one with a mask, a type layer, a shape, a Smart + /// A document with a Background, plain layers, one with a mask, one with a vector mask, a type layer, a shape, a Smart /// Object, an adjustment layer and one with a drop shadow; `select` picks a selection (the last /// layer is active) and `copied` has a layer style on the clipboard. fn world(select: &[&str], copied: bool) -> photocraft_engine::Session { @@ -216,6 +221,8 @@ mod tests { ids.insert("R1", id(s.execute("layer.new.layer", json!({"name": "R1"})).unwrap())); ids.insert("R2", id(s.execute("layer.new.layer", json!({"name": "R2"})).unwrap())); s.execute("layer.layerMask.revealAll", json!({})).unwrap(); + ids.insert("V", id(s.execute("layer.new.layer", json!({"name": "V"})).unwrap())); + s.execute("layer.vectorMask.revealAll", json!({})).unwrap(); ids.insert("T", id(s.execute("type.create", json!({"text": "T", "size": 12, "x": 2, "y": 12})).unwrap())); ids.insert("S", id(s.execute("shape.create", json!({"kind": "rect", "rect": [4, 4, 6, 6]})).unwrap())); s.execute("layer.new.layer", json!({"name": "M"})).unwrap(); @@ -234,14 +241,16 @@ mod tests { s } - /// What a layer command can change: kind, clipping, mask and style of every layer. + /// What a layer command can change: kind, clipping, masks and style of every layer. fn fingerprint(s: &photocraft_engine::Session) -> Vec { s.active() .unwrap() .doc .walk() .iter() - .map(|(_, _, l)| format!("{:?}|{}|{}|{}", std::mem::discriminant(&l.content), l.clipped, l.mask.is_some(), l.effects.items.len())) + .map(|(_, _, l)| { + format!("{:?}|{}|{}|{}|{}", std::mem::discriminant(&l.content), l.clipped, l.mask.is_some(), l.vector_mask.is_some(), l.effects.items.len()) + }) .collect() } @@ -254,6 +263,7 @@ mod tests { // (command, an enabled item must really change something) let commands = [ ("layer.rasterize.layer", true), + ("layer.rasterize.layerStyle", true), ("layer.createClippingMask", true), ("layer.layerMask.revealAll", true), ("layer.layerMask.hideAll", true), @@ -282,6 +292,10 @@ mod tests { &["R1"], &["BG"], &["FX"], + &["V", "R1"], + &["R1", "V"], + &["V"], + &["V", "FX", "T"], ]; let mut checked = 0; for sel in selections { diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index d633426e72..23339c72f5 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2036,6 +2036,7 @@ Create Warped Text Vytvořit deformovaný text Rasterize Smart Object Rastrovat chytrý objekt Rasterize Fill Content Rastrovat obsah výplně + Rasterize Layer Style Rastrovat styl vrstvy Unlock: picking a preset replaces these settings Odemknout: výběr přednastavení tato nastavení nahradí Lock: keep these settings when picking another preset Zamknout: zachovat tato nastavení při výběru jiného přednastavení Diameter: Průměr: diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 2eefe31baa..fa9bd5bf0f 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2003,6 +2003,7 @@ Create Warped Text Verkrümmten Text erstellen Rasterize Smart Object Smart-Objekt rasterisieren Rasterize Fill Content Füllinhalt rasterisieren + Rasterize Layer Style Ebenenstil rasterisieren Unlock: picking a preset replaces these settings Entsperren: das Wählen einer Vorgabe ersetzt diese Einstellungen Lock: keep these settings when picking another preset Sperren: diese Einstellungen beim Wählen einer anderen Vorgabe behalten Diameter: Durchmesser: diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 009253d871..4c79317146 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1487,6 +1487,7 @@ Create Warped Text Δημιουργία παραμορφωμένου κειμένου Rasterize Smart Object Ραστεροποίηση έξυπνου αντικειμένου Rasterize Fill Content Ραστεροποίηση περιεχομένου γεμίσματος + Rasterize Layer Style Ραστεροποίηση στυλ επιπέδου Unlock: picking a preset replaces these settings Ξεκλείδωμα: η επιλογή προεπιλογής αντικαθιστά αυτές τις ρυθμίσεις Lock: keep these settings when picking another preset Κλείδωμα: διατήρηση ρυθμίσεων κατά την αλλαγή προεπιλογής Diameter: Διάμετρος: diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 041c385604..a8be679f29 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2019,6 +2019,7 @@ Create Warped Text Crear texto deformado Rasterize Smart Object Rasterizar objeto inteligente Rasterize Fill Content Rasterizar contenido de relleno + Rasterize Layer Style Rasterizar estilo de capa Unlock: picking a preset replaces these settings Desbloquear: al elegir un preajuste se reemplazan estos ajustes Lock: keep these settings when picking another preset Bloquear: conservar estos ajustes al elegir otro preajuste Diameter: Diámetro: diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index ffca084638..25c8e0f377 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1985,6 +1985,7 @@ Create Warped Text Créer un texte déformé Rasterize Smart Object Rastériser l'objet intelligent Rasterize Fill Content Rastériser le contenu du remplissage + Rasterize Layer Style Rastériser le style de calque Unlock: picking a preset replaces these settings Déverrouiller : choisir un préréglage remplace ces paramètres Lock: keep these settings when picking another preset Verrouiller : conserver ces paramètres en choisissant un autre préréglage Diameter: Diamètre : diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index dfa1df0669..9030e72525 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1979,6 +1979,7 @@ Create Warped Text Buat Teks Warp Rasterize Smart Object Rasterisasi Smart Object Rasterize Fill Content Rasterisasi Isi Konten + Rasterize Layer Style Rasterisasi Gaya Layer Unlock: picking a preset replaces these settings Buka kunci: memilih preset akan mengganti pengaturan ini Lock: keep these settings when picking another preset Kunci: pertahankan pengaturan ini saat memilih preset lain Diameter: Diameter: diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index bb4ba0d514..9993449c5a 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2017,6 +2017,7 @@ Create Warped Text Crea testo deformato Rasterize Smart Object Rasterizza oggetto avanzato Rasterize Fill Content Rasterizza contenuto riempimento + Rasterize Layer Style Rasterizza stile livello Unlock: picking a preset replaces these settings Sblocca: scegliendo un predefinito sostituisce queste impostazioni Lock: keep these settings when picking another preset Blocca: mantiene queste impostazioni scegliendo altro predefinito Diameter: Diametro: diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index af6b2b9fbb..310650e1dc 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2022,6 +2022,7 @@ Create Warped Text ワープテキストを作成 Rasterize Smart Object スマートオブジェクトをラスタライズ Rasterize Fill Content 塗りの内容をラスタライズ + Rasterize Layer Style レイヤースタイルをラスタライズ Unlock: picking a preset replaces these settings ロック解除: プリセットを選ぶとこの設定は置き換わります Lock: keep these settings when picking another preset ロック: 別のプリセットを選んでもこの設定を保持します Diameter: 直径: diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 6ee384127a..21cf014d52 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -1978,6 +1978,7 @@ Create Warped Text 뒤틀린 텍스트 만들기 Rasterize Smart Object 스마트 오브젝트 래스터화 Rasterize Fill Content 칠 내용 래스터화 + Rasterize Layer Style 레이어 스타일 래스터화 Unlock: picking a preset replaces these settings 잠금 해제: 사전 설정 선택 시 이 설정 대체 Lock: keep these settings when picking another preset 잠금: 다른 사전 설정 선택 시 이 설정 유지 Diameter: 직경: diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 0ea0dbb5a0..20370b4326 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1991,6 +1991,7 @@ Create Warped Text Verbogen tekst maken Rasterize Smart Object Slim object rasteren Rasterize Fill Content Vulinhoud rasteren + Rasterize Layer Style Laagstijl rasteren Unlock: picking a preset replaces these settings Ontgrendelen: een voorinstelling kiezen vervangt deze instellingen Lock: keep these settings when picking another preset Vergrendelen: deze instellingen behouden bij het kiezen van een andere voorinstelling Diameter: Diameter: diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 6ac0c030d5..ac086df7a4 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -2012,6 +2012,7 @@ Create Warped Text Utwórz wypaczony tekst Rasterize Smart Object Rasteryzuj obiekt inteligentny Rasterize Fill Content Rasteryzuj zawartość wypełnienia + Rasterize Layer Style Rasteryzuj styl warstwy Unlock: picking a preset replaces these settings Odblokuj: wybór ustawienia wstępnego zastąpi te ustawienia Lock: keep these settings when picking another preset Zablokuj: zachowaj te ustawienia po wybraniu innego ustawienia wstępnego Diameter: Średnica: diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 3f79af4d49..a664352cc2 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1984,6 +1984,7 @@ Create Warped Text Criar texto deformado Rasterize Smart Object Rasterizar objeto inteligente Rasterize Fill Content Rasterizar conteúdo do preenchimento + Rasterize Layer Style Rasterizar estilo de camada Unlock: picking a preset replaces these settings Desbloquear: escolher uma predefinição substitui estas configurações Lock: keep these settings when picking another preset Bloquear: manter estas configurações ao escolher outra predefinição Diameter: Diâmetro: diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 82d9c2d9f2..f7d3cee401 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2722,5 +2722,6 @@ fontWeight Italic Курсив W x H x Resolution Ш x В x Разрешение Front Image Изображение переднего плана Swaps height and width Меняет местами высоту и ширину + Rasterize Layer Style Растрировать стиль слоя Search settings… Поиск настроек… No matching settings Нет подходящих настроек diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index c2cbafd1ca..1f9a076d8d 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2780,6 +2780,7 @@ fontWeight Italic Курсивний Create Warped Text Створити деформований текст Rasterize Smart Object Растеризувати смартоб'єкт Rasterize Fill Content Растеризувати вміст заливки + Rasterize Layer Style Растеризувати стиль шару Toggle the Brush Settings panel (F5) Перемкнути панель налаштувань пензля (F5) Create new brush preset from the current settings Створити новий набір пензля з поточних параметрів Brush Settings… (F5): every option of this brush Налаштування пензля… (F5): усі параметри цього пензля diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index d5eba247e7..de1d2dcac2 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2078,6 +2078,7 @@ cameraRaw Blending 混合 Create Warped Text 创建变形文字 Rasterize Smart Object 栅格化智能对象 Rasterize Fill Content 栅格化填充内容 + Rasterize Layer Style 栅格化图层样式 Unlock: picking a preset replaces these settings 解锁:选择预设时替换这些设置 Lock: keep these settings when picking another preset 锁定:选择其他预设时保留这些设置 Diameter: 直径: diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 4ae14ce75e..697e5312ca 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2018,6 +2018,7 @@ Create Warped Text 建立彎曲文字 Rasterize Smart Object 點陣化智慧型物件 Rasterize Fill Content 點陣化填滿內容 + Rasterize Layer Style 點陣化圖層樣式 Unlock: picking a preset replaces these settings 解除鎖定:選擇預設集會取代這些設定 Lock: keep these settings when picking another preset 鎖定:選擇其他預設集時保留這些設定 Diameter: 直徑: diff --git a/crates/ui-egui/src/layer_menu_ui.rs b/crates/ui-egui/src/layer_menu_ui.rs index 3ed3f9f09b..dbd359012b 100644 --- a/crates/ui-egui/src/layer_menu_ui.rs +++ b/crates/ui-egui/src/layer_menu_ui.rs @@ -85,6 +85,10 @@ pub fn entries(l: &Layer, multi: bool, has_selection: bool) -> Vec { _ => v.push(Some(("Rasterize Layer", "layer.rasterize.layer"))), } } + // Photoshop offers it under Rasterize Layer for a layer with a style (it bakes the effects). + if multi || !l.effects.items.is_empty() { + v.push(Some(("Rasterize Layer Style", "layer.rasterize.layerStyle"))); + } v.push(None); // A selection has no single mask to toggle, apply or delete, so its menu offers Add Layer Mask only. if let Some(mask) = l.mask.as_ref().filter(|_| !multi) { diff --git a/crates/ui-egui/src/menu_catalog.rs b/crates/ui-egui/src/menu_catalog.rs index 94355aa514..355a08261e 100644 --- a/crates/ui-egui/src/menu_catalog.rs +++ b/crates/ui-egui/src/menu_catalog.rs @@ -394,6 +394,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Layer", "Rasterize"], "Vector Mask", None, "layer.rasterize.vectorMask"), (&["Layer", "Rasterize"], "Smart Object", None, "layer.rasterize.smartObject"), (&["Layer", "Rasterize"], "Video", None, "layer.rasterize.video"), + (&["Layer", "Rasterize"], "Layer Style", None, "layer.rasterize.layerStyle"), (&["Layer", "Rasterize"], "---", None, "---"), (&["Layer", "Rasterize"], "Layer", None, "layer.rasterize.layer"), (&["Layer", "Rasterize"], "All Layers", None, "layer.rasterize.allLayers"), diff --git a/crates/ui-egui/src/parity.rs b/crates/ui-egui/src/parity.rs index db8de4e506..dedd0e810a 100644 --- a/crates/ui-egui/src/parity.rs +++ b/crates/ui-egui/src/parity.rs @@ -7,7 +7,7 @@ use crate::menu_catalog::CATALOG; use crate::menus::is_live; /// Minimum number of live catalog items. Raise it when parity grows; never lower it. -pub const FLOOR: usize = 629; +pub const FLOOR: usize = 630; /// One top-level menu's coverage. #[derive(Clone, Debug, serde::Serialize)] diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index a479b2b7e1..763c0c826e 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -2,14 +2,14 @@ Generated by `cargo xtask parity` from `crates/ui-egui/src/menu_catalog.rs` (Photoshop's menu tree) and the live command registry. Do not edit by hand. -**629 of 629 menu items live (100.0%).** +**630 of 630 menu items live (100.0%).** | Menu | Live | Total | % | |---|---:|---:|---:| | File | 52 | 52 | 100% | | Edit | 75 | 75 | 100% | | Image | 61 | 61 | 100% | -| Layer | 162 | 162 | 100% | +| Layer | 163 | 163 | 100% | | Type | 44 | 44 | 100% | | Select | 25 | 25 | 100% | | Filter | 75 | 75 | 100% | diff --git a/docs/scorecard.md b/docs/scorecard.md index 1a518d3bbf..6c7f540004 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -11,7 +11,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [Tools](#tools) | 21 | 16 | 5 | | | [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 43 of 150 (target 0) | | [Type](#type) | 0 | 3 | 6 | | -| [Automation](#automation) | 3 | 2 | 6 | 628 of 628 menu items live (100.0%) | +| [Automation](#automation) | 3 | 2 | 6 | 630 of 630 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | | [Distribution](#distribution) | 4 | 4 | 3 | | | [Open bugs](#open-bugs) | 22 | 2 | 8 | | @@ -221,7 +221,7 @@ Unread: `general.color_picker`, `general.beep_when_done`, `general.always_create ## Automation -Menu wiring (`docs/parity-checklist.md`): 628 of 628 menu items live (100.0%). This counts dispatch, not behaviour. +Menu wiring (`docs/parity-checklist.md`): 630 of 630 menu items live (100.0%). This counts dispatch, not behaviour. | Id | Target | Status | Issue | Note | |---|---|---|---|---|