mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Right-click with a selection tool and choose Delete and Fill Selection to fill the selection from its surroundings with Content-Aware Fill's default settings, without the dialog. Engine command edit.deleteAndFillSelection, one undo step, translated in every shipped language. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c833294e34
commit
3e8d788441
15 files changed
+51
-4
No files matched your search
@@ -322,8 +322,17 @@ fn rect_param(p: &Value, key: &str, cmd: &str) -> Result<Rect> {
|
||||
}
|
||||
|
||||
fn content_aware_fill(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
content_aware_fill_as(s, p, "edit.contentAwareFill", "Content-Aware Fill")
|
||||
}
|
||||
|
||||
/// Delete and Fill Selection (#1286): Photoshop's one-click removal from the selection-tool
|
||||
/// context menu. Content-Aware Fill with its default settings into the layer, no dialog.
|
||||
fn delete_and_fill(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
content_aware_fill_as(s, &json!({}), "edit.deleteAndFillSelection", "Delete and Fill Selection")
|
||||
}
|
||||
|
||||
fn content_aware_fill_as(s: &mut Session, p: &Value, cmd: &'static str, label: &'static str) -> Result<Value> {
|
||||
use photocraft_algo::content_aware::{FillOptions, color_level, fill_with, rotation_level};
|
||||
let cmd = "edit.contentAwareFill";
|
||||
let id = pixel_layer(s).map_err(EngineError::Other)?;
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let doc = st.doc.clone();
|
||||
@@ -365,7 +374,6 @@ fn content_aware_fill(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let fmt = surf.format();
|
||||
let n = fmt.channels();
|
||||
let (w, h) = (window.width() as usize, window.height() as usize);
|
||||
let label = "Content-Aware Fill";
|
||||
// A background job when started with `Session::start` (#210): reading the window and the
|
||||
// PatchMatch fill run on a worker against the document snapshot, cancellable per row band.
|
||||
crate::jobs::run(
|
||||
@@ -957,6 +965,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
can_caf,
|
||||
content_aware_fill
|
||||
),
|
||||
spec!("edit.deleteAndFillSelection", "Delete and Fill Selection", [], None, "{}", can_caf, delete_and_fill),
|
||||
spec!(
|
||||
"edit.contentAwareScale",
|
||||
"Content-Aware Scale",
|
||||
|
||||
@@ -135,6 +135,30 @@ fn content_aware_fill_removes_object_at_all_depths() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_and_fill_selection_removes_the_object_in_one_step() {
|
||||
// #1286: Content-Aware Fill's defaults, no dialog, one history step named for the command.
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = blob_session(depth);
|
||||
let base = s.active().unwrap().active_layer.unwrap();
|
||||
assert!(s.is_enabled("edit.deleteAndFillSelection"));
|
||||
let r = s.execute("edit.deleteAndFillSelection", json!({})).unwrap();
|
||||
assert_eq!(r["layer"].as_u64(), Some(base.0), "fills the layer itself");
|
||||
assert!(r["filled"].as_u64().unwrap() > 100);
|
||||
let v = px(&s, 30, 20);
|
||||
assert!(!(v[0] > 0.9 && v[1] < 0.1), "depth {depth}: red left: {v:?}");
|
||||
assert_eq!(s.active().unwrap().history.undo_label(), Some("Delete and Fill Selection"));
|
||||
s.undo();
|
||||
assert_eq!(px(&s, 30, 20)[1], 0.0, "undo restores the blob");
|
||||
}
|
||||
// Parameters are ignored, never a crash; nothing selected greys it out and refuses.
|
||||
let mut s = blob_session(8);
|
||||
assert!(s.execute("edit.deleteAndFillSelection", json!({"output": 7, "sampling": [1]})).is_ok());
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
assert!(!s.is_enabled("edit.deleteAndFillSelection"));
|
||||
assert!(s.execute("edit.deleteAndFillSelection", json!({})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_aware_fill_outputs_and_sampling() {
|
||||
let mut s = blob_session(8);
|
||||
|
||||
@@ -35,8 +35,8 @@ pub const TRANSFORM_MENU: &[Row] = &[
|
||||
];
|
||||
|
||||
/// Photoshop's selection-tool context menu with an active selection, in its order. Its Generative
|
||||
/// Fill and Delete and Fill Selection rows have no PhotoCraft command and are left out. Rows
|
||||
/// stay visible and grey out exactly like their menu-bar twins.
|
||||
/// Fill row has no PhotoCraft command and is left out. Rows stay visible and grey out exactly like
|
||||
/// their menu-bar twins.
|
||||
pub const SELECTION_MENU: &[Row] = &[
|
||||
Some(("Deselect", "select.deselect")),
|
||||
Some(("Select Inverse", "select.inverse")),
|
||||
@@ -55,6 +55,7 @@ pub const SELECTION_MENU: &[Row] = &[
|
||||
Some(("Distort", "edit.transform.distort")),
|
||||
Some(("Perspective", "edit.transform.perspective")),
|
||||
None,
|
||||
Some(("Delete and Fill Selection", "edit.deleteAndFillSelection")),
|
||||
Some(("Fill…", "edit.fill")),
|
||||
Some(("Stroke…", "edit.stroke")),
|
||||
Some(("Content-Aware Fill…", "edit.contentAwareFill")),
|
||||
@@ -440,6 +441,7 @@ mod tests {
|
||||
Some("Distort"),
|
||||
Some("Perspective"),
|
||||
None,
|
||||
Some("Delete and Fill Selection"),
|
||||
Some("Fill…"),
|
||||
Some("Stroke…"),
|
||||
Some("Content-Aware Fill…"),
|
||||
|
||||
@@ -107,6 +107,7 @@
|
||||
Fill… Vyplnit…
|
||||
Stroke… Tah…
|
||||
Content-Aware Fill… Výplň s ohledem na obsah…
|
||||
Delete and Fill Selection Odstranit a vyplnit výběr
|
||||
Content-Aware Scale Změna velikosti s ohledem na obsah
|
||||
Puppet Warp Loutková deformace
|
||||
Perspective Warp Perspektivní deformace
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -103,6 +103,7 @@
|
||||
Fill… Füllen…
|
||||
Stroke… Nachziehen…
|
||||
Content-Aware Fill… Inhaltsbasiert füllen…
|
||||
Delete and Fill Selection Auswahl löschen und füllen
|
||||
Content-Aware Scale Inhaltsbasiert skalieren
|
||||
Puppet Warp Marionetten-Verkrümmung
|
||||
Perspective Warp Perspektivisch verkrümmen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -99,6 +99,7 @@
|
||||
Fill… Rellenar…
|
||||
Stroke… Contornear…
|
||||
Content-Aware Fill… Relleno de contenido…
|
||||
Delete and Fill Selection Eliminar y rellenar selección
|
||||
Content-Aware Scale Escalado de contenido
|
||||
Puppet Warp Deformación de clavos
|
||||
Perspective Warp Deformación en perspectiva
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -105,6 +105,7 @@
|
||||
Fill… Remplir…
|
||||
Stroke… Contourner…
|
||||
Content-Aware Fill… Remplissage d'après le contenu…
|
||||
Delete and Fill Selection Supprimer et remplir la sélection
|
||||
Content-Aware Scale Mise à l'échelle d'après le contenu
|
||||
Puppet Warp Déformation par épingles
|
||||
Perspective Warp Déformation de la perspective
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -98,6 +98,7 @@
|
||||
Fill… Isi…
|
||||
Stroke… Stroke…
|
||||
Content-Aware Fill… Isi Content-Aware…
|
||||
Delete and Fill Selection Hapus dan Isi Seleksi
|
||||
Content-Aware Scale Skala Content-Aware
|
||||
Puppet Warp Puppet Warp
|
||||
Perspective Warp Perspective Warp
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -99,6 +99,7 @@
|
||||
Fill… Riempi…
|
||||
Stroke… Traccia…
|
||||
Content-Aware Fill… Riempimento in base al contenuto…
|
||||
Delete and Fill Selection Elimina e riempi selezione
|
||||
Content-Aware Scale Scala in base al contenuto
|
||||
Puppet Warp Altera marionetta
|
||||
Perspective Warp Altera prospettiva
|
||||
|
||||
|
@@ -103,6 +103,7 @@
|
||||
Fill… 塗りつぶし…
|
||||
Stroke… 境界線を描く…
|
||||
Content-Aware Fill… コンテンツに応じた塗りつぶし…
|
||||
Delete and Fill Selection 選択範囲を削除して塗りつぶし
|
||||
Content-Aware Scale コンテンツに応じた拡大・縮小
|
||||
Puppet Warp パペットワープ
|
||||
Perspective Warp 遠近法ワープ
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -95,6 +95,7 @@
|
||||
Fill… 채우기…
|
||||
Stroke… 획…
|
||||
Content-Aware Fill… 내용 인식 채우기…
|
||||
Delete and Fill Selection 선택 영역 삭제 및 채우기
|
||||
Content-Aware Scale 내용 인식 비율
|
||||
Puppet Warp 퍼펫 뒤틀기
|
||||
Perspective Warp 원근 뒤틀기
|
||||
|
||||
|
@@ -102,6 +102,7 @@
|
||||
Fill… Preencher…
|
||||
Stroke… Traçado…
|
||||
Content-Aware Fill… Preenchimento sensível ao conteúdo…
|
||||
Delete and Fill Selection Excluir e preencher seleção
|
||||
Content-Aware Scale Escala sensível ao conteúdo
|
||||
Puppet Warp Distorção de marionete
|
||||
Perspective Warp Distorção de perspectiva
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -82,6 +82,7 @@
|
||||
Fill… Выполнить заливку…
|
||||
Stroke… Обвести…
|
||||
Content-Aware Fill… Заливка с учётом содержимого…
|
||||
Delete and Fill Selection Удалить и заполнить выделение
|
||||
Define Brush Preset… Определить кисть…
|
||||
Define Pattern… Определить паттерн…
|
||||
Define Custom Shape… Определить свою фигуру…
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -99,6 +99,7 @@
|
||||
Fill… 填充…
|
||||
Stroke… 描边…
|
||||
Content-Aware Fill… 内容识别填充…
|
||||
Delete and Fill Selection 删除并填充选区
|
||||
Content-Aware Scale 内容识别缩放
|
||||
Puppet Warp 操控变形
|
||||
Perspective Warp 透视变形
|
||||
|
||||
|
@@ -107,6 +107,7 @@
|
||||
Fill… 填滿…
|
||||
Stroke… 筆畫…
|
||||
Content-Aware Fill… 內容感知填滿…
|
||||
Delete and Fill Selection 刪除並填滿選取範圍
|
||||
Content-Aware Scale 內容感知縮放
|
||||
Puppet Warp 操控彎曲
|
||||
Perspective Warp 透視彎曲
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
Reference in new issue
Block a user