Compare commits

...
24 changed files with 110 additions and 7 deletions

No files matched your search

+6 -4
View File
@@ -422,8 +422,10 @@ pub struct CopiedStyle {
pub mode: photocraft_color::ColorMode,
}
/// The commands whose [`Session::precheck`] is complete: it accepts exactly what `execute` does
/// (Free Transform applies its box before these, and only when they will run). Layer via Copy and
/// The commands whose [`Session::precheck`] is complete: it accepts what `execute` does (Free
/// Transform applies its box before these, and only when they will run), but for the group
/// nesting limit ([`photocraft_doc::MAX_GROUP_DEPTH`]): grouping layers already that deep is
/// refused only as the edit is made. Layer via Copy and
/// Cut aren't: whether they have anything to copy (a selection over transparent pixels, a group
/// or fill layer) is known only when they run.
pub const PRECHECKED: &[&str] = &["layer.new.layer", "layer.new.group", "layer.new.groupFromLayers", "layer.new.layerFromBackground"];
@@ -671,8 +673,8 @@ impl Session {
/// something first only when the command will go through: Free Transform applies its box
/// before a new layer is made.
///
/// Complete for the commands in [`PRECHECKED`]: there it accepts exactly what `execute`
/// accepts (a test holds the two together). For others it checks only what they share.
/// Complete for the commands in [`PRECHECKED`]: there it accepts what `execute` accepts, but
/// for the group nesting limit (a test holds the two together). For others it checks only what they share.
pub fn precheck(&mut self, id: &str, params: &Value) -> Result<()> {
let spec = crate::commands::find(id).ok_or_else(|| EngineError::UnknownCommand(id.to_string()))?;
if !(params.is_object() || params.is_null()) {
+37
View File
@@ -878,3 +878,40 @@ fn exports_are_written_all_or_nothing() {
assert_eq!(leftovers(), 1, "only c.kys.photocraft-tmp itself");
let _ = std::fs::remove_dir_all(&dir);
}
/// A backup that can't be put back after a failed export is named in the error, and stays where
/// it is with the user's previous text.
#[test]
fn a_stranded_backup_is_named_in_the_error() {
use super::write_files_atomically;
let dir = std::env::temp_dir().join(format!("photocraft-stranded-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let (a, b) = (dir.join("a.kys"), dir.join("b.html"));
std::fs::write(&a, "old A").unwrap();
std::fs::write(&b, "old B").unwrap();
let (pa, pb) = (a.to_str().unwrap(), b.to_str().unwrap());
let staged = std::cell::Cell::new(0);
// The second staged move fails, and so does putting a.kys's backup back.
let rename = |from: &std::path::Path, to: &std::path::Path| {
let f = from.to_string_lossy();
if f.ends_with("photocraft-tmp") {
staged.set(staged.get() + 1);
if staged.get() == 2 {
return Err(std::io::Error::other("disk gone"));
}
}
if f.ends_with("photocraft-bak") && to == a.as_path() {
return Err(std::io::Error::other("locked"));
}
std::fs::rename(from, to)
};
let e = write_files_atomically(&[(pa, "new A"), (pb, "new B")], &rename).unwrap_err();
assert!(e.contains(&format!("the previous {} is at", a.display())), "{e}");
let backup: Vec<_> =
std::fs::read_dir(&dir).unwrap().filter_map(|e| e.ok()).map(|e| e.path()).filter(|p| p.to_string_lossy().ends_with("photocraft-bak")).collect();
assert_eq!(backup.len(), 1, "{backup:?}");
assert!(e.contains(&backup[0].display().to_string()), "{e}");
assert_eq!(std::fs::read_to_string(&backup[0]).unwrap(), "old A");
assert_eq!(std::fs::read_to_string(&b).unwrap(), "old B");
let _ = std::fs::remove_dir_all(&dir);
}
+5 -1
View File
@@ -1,4 +1,5 @@
//! `Session::precheck` accepts exactly what `execute` accepts for the commands it covers
//! `Session::precheck` accepts what `execute` accepts for the commands it covers (all but the
//! group nesting limit, which only the edit checks)
//! (`PRECHECKED`): Free Transform applies its box before them only when they will run (#5859).
use photocraft_engine::{PRECHECKED, Session};
@@ -47,6 +48,9 @@ fn params() -> Vec<Value> {
json!({"name": "ok"}),
json!({"color": "chartreuse"}),
json!({"layer": 999_999}),
json!({"layer": 1}),
json!({"layer": 2}),
json!({"layer": null}),
json!({"layer": "Layer 1"}),
json!({"layer": "no such layer"}),
json!({"layer": true}),
+3
View File
@@ -3805,3 +3805,6 @@ navigator Zoom Zvětšení
Undo Changes Vrátit změny
{shortcut} is reserved by the system and can't be assigned. {shortcut} je vyhrazena systémem a nelze ji přiřadit.
Low-Latency Drawing (vsync off, applies at next launch) Kreslení s nízkou latencí (bez vertikální synchronizace, platí po dalším spuštění)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Volná transformace se stále použije; zkuste to znovu, až skončí.
The transform couldn't be applied. Transformaci nelze použít.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3199,3 +3199,6 @@ curves Smooth Glätten
Undo Changes Änderungen rückgängig machen
{shortcut} is reserved by the system and can't be assigned. {shortcut} ist vom System reserviert und kann nicht zugewiesen werden.
Low-Latency Drawing (vsync off, applies at next launch) Zeichnen mit geringer Latenz (ohne VSync, gilt ab dem nächsten Start)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Frei transformieren wird noch angewendet; versuchen Sie es erneut, wenn es fertig ist.
The transform couldn't be applied. Die Transformation konnte nicht angewendet werden.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3897,3 +3897,6 @@ curves Smooth Εξομάλυνση
Undo Changes Αναίρεση αλλαγών
{shortcut} is reserved by the system and can't be assigned. Η συντόμευση {shortcut} δεσμεύεται από το σύστημα και δεν μπορεί να εκχωρηθεί.
Low-Latency Drawing (vsync off, applies at next launch) Σχεδίαση χαμηλής καθυστέρησης (χωρίς vsync, ισχύει στην επόμενη εκκίνηση)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Ο Ελεύθερος μετασχηματισμός εφαρμόζεται ακόμη· δοκιμάστε ξανά όταν ολοκληρωθεί.
The transform couldn't be applied. Δεν ήταν δυνατή η εφαρμογή του μετασχηματισμού.
Can't render this file because it contains an unexpected character in line 1030 and column 18.
+3
View File
@@ -4159,3 +4159,6 @@ navigator Zoom Zoom
Undo Changes Deshacer cambios
{shortcut} is reserved by the system and can't be assigned. {shortcut} está reservado por el sistema y no se puede asignar.
Low-Latency Drawing (vsync off, applies at next launch) Dibujo de baja latencia (sin sincronización vertical, se aplica al volver a iniciar)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Transformación libre aún se está aplicando; inténtelo de nuevo cuando termine.
The transform couldn't be applied. No se pudo aplicar la transformación.
Can't render this file because it contains an unexpected character in line 4 and column 47.
+3
View File
@@ -3202,3 +3202,6 @@ curves Smooth Lisser
Undo Changes Annuler les modifications
{shortcut} is reserved by the system and can't be assigned. {shortcut} est réservé par le système et ne peut pas être attribué.
Low-Latency Drawing (vsync off, applies at next launch) Dessin à faible latence (sans synchronisation verticale, au prochain lancement)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. La transformation manuelle est encore en cours d'application ; réessayez quand elle sera terminée.
The transform couldn't be applied. Impossible d'appliquer la transformation.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -4116,3 +4116,6 @@ cameraRaw Yellow Sárga
Undo Changes Változások visszavonása
{shortcut} is reserved by the system and can't be assigned. A(z) {shortcut} a rendszer számára fenntartott, nem rendelhető hozzá.
Low-Latency Drawing (vsync off, applies at next launch) Kis késleltetésű rajzolás (vsync nélkül, a következő indításkor lép életbe)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. A szabad alakítás alkalmazása még folyamatban van; próbáld újra, ha befejeződött.
The transform couldn't be applied. Az átalakítás nem alkalmazható.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3189,3 +3189,6 @@ curves Smooth Haluskan
Undo Changes Batalkan Perubahan
{shortcut} is reserved by the system and can't be assigned. {shortcut} dicadangkan oleh sistem dan tidak dapat ditetapkan.
Low-Latency Drawing (vsync off, applies at next launch) Menggambar latensi rendah (tanpa vsync, berlaku saat peluncuran berikutnya)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Transformasi Bebas masih diterapkan; coba lagi setelah selesai.
The transform couldn't be applied. Transformasi tidak dapat diterapkan.
Can't render this file because it contains an unexpected character in line 4 and column 47.
+3
View File
@@ -4318,3 +4318,6 @@ shape Appearance Aspetto
Undo Changes Annulla modifiche
{shortcut} is reserved by the system and can't be assigned. {shortcut} è riservata dal sistema e non può essere assegnata.
Low-Latency Drawing (vsync off, applies at next launch) Disegno a bassa latenza (senza vsync, si applica al prossimo avvio)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Trasformazione libera è ancora in corso di applicazione; riprova quando è terminata.
The transform couldn't be applied. Impossibile applicare la trasformazione.
Can't render this file because it contains an unexpected character in line 2654 and column 53.
+3
View File
@@ -3873,3 +3873,6 @@ curves Smooth スムーズ
Undo Changes 変更を取り消し
{shortcut} is reserved by the system and can't be assigned. {shortcut} はシステムで予約されているため割り当てられません。
Low-Latency Drawing (vsync off, applies at next launch) 低遅延描画(垂直同期オフ、次回起動時に適用)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 自由変形を適用中です。完了してからもう一度お試しください。
The transform couldn't be applied. 変形を適用できませんでした。
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3375,3 +3375,6 @@ curves Smooth 매끄럽게
Undo Changes 변경 사항 취소
{shortcut} is reserved by the system and can't be assigned. {shortcut}은(는) 시스템에서 예약되어 할당할 수 없습니다.
Low-Latency Drawing (vsync off, applies at next launch) 저지연 그리기(수직 동기화 끔, 다음 실행 시 적용)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 자유 변형을 아직 적용하는 중입니다. 완료된 후 다시 시도하세요.
The transform couldn't be applied. 변형을 적용할 수 없습니다.
Can't render this file because it contains an unexpected character in line 3166 and column 53.
+3
View File
@@ -3957,3 +3957,6 @@ curves Smooth Vloeiend maken
Undo Changes Wijzigingen ongedaan maken
{shortcut} is reserved by the system and can't be assigned. {shortcut} is door het systeem gereserveerd en kan niet worden toegewezen.
Low-Latency Drawing (vsync off, applies at next launch) Tekenen met lage latentie (zonder vsync, na de volgende start)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Vrije transformatie wordt nog toegepast; probeer het opnieuw als die klaar is.
The transform couldn't be applied. De transformatie kon niet worden toegepast.
Can't render this file because it contains an unexpected character in line 8 and column 34.
+3
View File
@@ -3795,3 +3795,6 @@ curves Smooth Wygładź
Undo Changes Cofnij zmiany
{shortcut} is reserved by the system and can't be assigned. {shortcut} jest zarezerwowany przez system i nie można go przypisać.
Low-Latency Drawing (vsync off, applies at next launch) Rysowanie z małym opóźnieniem (bez synchronizacji pionowej, od następnego uruchomienia)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Przekształcanie swobodne jest nadal stosowane; spróbuj ponownie, gdy się zakończy.
The transform couldn't be applied. Nie można zastosować przekształcenia.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3987,3 +3987,6 @@ layerLabel No Color Sem cor
Undo Changes Desfazer alterações
{shortcut} is reserved by the system and can't be assigned. {shortcut} é reservado pelo sistema e não pode ser atribuído.
Low-Latency Drawing (vsync off, applies at next launch) Desenho de baixa latência (sem sincronização vertical, aplicado na próxima inicialização)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. A Transformação livre ainda está sendo aplicada; tente novamente quando terminar.
The transform couldn't be applied. Não foi possível aplicar a transformação.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3167,3 +3167,6 @@ curves Smooth Сгладить
Undo Changes Отменить изменения
{shortcut} is reserved by the system and can't be assigned. Комбинация {shortcut} зарезервирована системой и не может быть назначена.
Low-Latency Drawing (vsync off, applies at next launch) Рисование с малой задержкой (без вертикальной синхронизации, после перезапуска)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Свободное трансформирование ещё применяется; повторите попытку, когда оно завершится.
The transform couldn't be applied. Не удалось применить трансформирование.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -4270,3 +4270,6 @@ shape Appearance Izgled
Undo Changes Poništi izmene
{shortcut} is reserved by the system and can't be assigned. {shortcut} je rezervisana od strane sistema i ne može se dodeliti.
Low-Latency Drawing (vsync off, applies at next launch) Crtanje sa malim kašnjenjem (bez vsync-a, primenjuje se pri sledećem pokretanju)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Slobodna transformacija se još primenjuje; pokušajte ponovo kad se završi.
The transform couldn't be applied. Transformacija nije mogla da se primeni.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -3927,3 +3927,6 @@ cameraData Lens Lens
Undo Changes Değişiklikleri Geri Al
{shortcut} is reserved by the system and can't be assigned. {shortcut} sistem tarafından ayrılmıştır ve atanamaz.
Low-Latency Drawing (vsync off, applies at next launch) Düşük gecikmeli çizim (dikey eşitleme kapalı, sonraki açılışta geçerli)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Serbest Dönüştürme hâlâ uygulanıyor; bittiğinde yeniden deneyin.
The transform couldn't be applied. Dönüştürme uygulanamadı.
Can't render this file because it contains an unexpected character in line 8 and column 34.
+3
View File
@@ -3896,3 +3896,6 @@ curves Smooth Згладити
Undo Changes Скасувати зміни
{shortcut} is reserved by the system and can't be assigned. {shortcut} зарезервовано системою, його не можна призначити.
Low-Latency Drawing (vsync off, applies at next launch) Малювання з малою затримкою (без вертикальної синхронізації, після перезапуску)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Вільне трансформування ще застосовується; спробуйте знову, коли воно завершиться.
The transform couldn't be applied. Не вдалося застосувати трансформування.
Can't render this file because it contains an unexpected character in line 1388 and column 18.
+3
View File
@@ -3683,3 +3683,6 @@ curves Smooth Làm mượt
Undo Changes Hoàn tác thay đổi
{shortcut} is reserved by the system and can't be assigned. {shortcut} được hệ thống dành riêng và không thể gán.
Low-Latency Drawing (vsync off, applies at next launch) Vẽ độ trễ thấp (tắt vsync, áp dụng ở lần khởi động sau)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Biến đổi tự do vẫn đang được áp dụng; hãy thử lại khi hoàn tất.
The transform couldn't be applied. Không thể áp dụng phép biến đổi.
Can't render this file because it contains an unexpected character in line 6 and column 47.
+3
View File
@@ -2813,3 +2813,6 @@ curves Smooth 平滑
Undo Changes 撤消更改
{shortcut} is reserved by the system and can't be assigned. {shortcut} 由系统保留,无法指定。
Low-Latency Drawing (vsync off, applies at next launch) 低延迟绘画(关闭垂直同步,下次启动时生效)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 自由变换仍在应用中;请在完成后重试。
The transform couldn't be applied. 无法应用变换。
Can't render this file because it contains an unexpected character in line 2600 and column 53.
+3
View File
@@ -2798,3 +2798,6 @@ curves Smooth 平滑
Undo Changes 還原變更
{shortcut} is reserved by the system and can't be assigned. {shortcut} 由系統保留,無法指定。
Low-Latency Drawing (vsync off, applies at next launch) 低延遲繪圖(關閉垂直同步,下次啟動時生效)
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 任意變形仍在套用中;請在完成後再試一次。
The transform couldn't be applied. 無法套用變形。
Can't render this file because it contains an unexpected character in line 6 and column 47.
+2 -2
View File
@@ -1061,10 +1061,10 @@ impl PhotocraftApp {
self.session.precheck(id, &params).map_err(|e| e.to_string())?;
transform_tool::commit(self);
if transform_tool::committing(self).is_some() {
return Err("the transform is still being applied; try again when it has finished".into());
return Err(tl!("Free Transform is still being applied; try again when it has finished.").into());
}
if self.ui.transform.is_some() {
return Err(if self.ui.status.is_empty() { "the transform couldn't be applied".into() } else { self.ui.status.clone() });
return Err(if self.ui.status.is_empty() { tl!("The transform couldn't be applied.").into() } else { self.ui.status.clone() });
}
}
if let Some(result) = panel_docking::command(self, id, &params) {