mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge remote-tracking branch 'origin/main' into HEAD
This commit is contained in:
31 files changed
+648
-104
No files matched your search
@@ -277,6 +277,8 @@ flatpak run ai.storyteller.photocraft
|
||||
|
||||
The AppImage needs no install: the first run registers its launcher icon and menu entry in `~/.local/share` so the dock shows PhotoCraft's icon on Wayland. Set `PHOTOCRAFT_NO_DESKTOP_INTEGRATION=1` to skip that, and see [`docs/releasing.md`](docs/releasing.md) › Linux to undo it.
|
||||
|
||||
On a Wayland session, files dropped on the window don't open yet: winit 0.30, the windowing library under egui, has no Wayland drag and drop (#386). Use File › Open, or copy the image in your file manager and paste it with Ctrl+V. To drag and drop, start PhotoCraft under XWayland: `WAYLAND_DISPLAY= photocraft`, `WAYLAND_DISPLAY= ./photocraft-<version>-linux-x86_64.AppImage`, or `flatpak run --nosocket=wayland --socket=x11 ai.storyteller.photocraft`. On Wayland, PhotoCraft shows the command for your install in a notice until you dismiss it.
|
||||
|
||||
On macOS, the command-line tool comes as `photocraft-cli-<version>-macos-universal.zip`. The binary is signed with the same Developer ID as the app and notarized by Apple. A bare binary can't carry a stapled notarization ticket the way the DMG does, so the first time you run it macOS checks the notarization online. You can confirm it yourself:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -94,7 +94,7 @@ fn serve(stream: TcpStream, token: &str, tx: Sender<ControlRequest>, ctx: egui::
|
||||
}
|
||||
r
|
||||
}
|
||||
Err(e) => json!({"ok": false, "error": format!("bad JSON: {e}")}),
|
||||
Err(e) => json!({"id": null, "ok": false, "error": format!("bad JSON: {e}")}),
|
||||
};
|
||||
if write_reply(&mut out, &reply).is_err() {
|
||||
break;
|
||||
@@ -154,4 +154,46 @@ mod tests {
|
||||
handler.join().unwrap();
|
||||
server.join().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_json_reply_carries_a_null_id_and_the_connection_keeps_serving() {
|
||||
const TOKEN: &str = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let (tx, rx) = channel::<ControlRequest>();
|
||||
let server = std::thread::spawn(move || {
|
||||
let (stream, _) = listener.accept().unwrap();
|
||||
serve(stream, TOKEN, tx, egui::Context::default());
|
||||
});
|
||||
let handler = std::thread::spawn(move || {
|
||||
let req = rx.recv_timeout(Duration::from_secs(5)).unwrap();
|
||||
assert_eq!(req.method, "test.after");
|
||||
req.reply.send(json!({"ok": true, "result": "still serving"})).unwrap();
|
||||
});
|
||||
let mut stream = TcpStream::connect(addr).unwrap();
|
||||
stream.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||
let mut reader = BufReader::new(stream.try_clone().unwrap());
|
||||
writeln!(stream, "{}", json!({"id": "auth", "method": "auth", "params": {"token": TOKEN}})).unwrap();
|
||||
let mut line = String::new();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
assert_eq!(serde_json::from_str::<Value>(&line).unwrap()["ok"], true);
|
||||
writeln!(stream, "{{not json}}").unwrap();
|
||||
line.clear();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
let bad: Value = serde_json::from_str(&line).unwrap();
|
||||
let bad = bad.as_object().unwrap();
|
||||
assert_eq!(bad.get("id"), Some(&Value::Null), "bad JSON reply must carry `id: null`: {line}");
|
||||
assert_eq!(bad.get("ok"), Some(&Value::Bool(false)));
|
||||
assert!(bad.get("error").and_then(Value::as_str).unwrap().starts_with("bad JSON: "));
|
||||
writeln!(stream, "{}", json!({"id": 7, "method": "test.after"})).unwrap();
|
||||
line.clear();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
let after: Value = serde_json::from_str(&line).unwrap();
|
||||
assert_eq!(after["id"], 7);
|
||||
assert_eq!(after["result"], "still serving");
|
||||
drop(reader);
|
||||
drop(stream);
|
||||
handler.join().unwrap();
|
||||
server.join().unwrap();
|
||||
}
|
||||
}
|
||||
@@ -323,6 +323,11 @@ fn main() -> eframe::Result {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
services.is_wayland = display == Some(tablet::DisplayKind::Wayland);
|
||||
if services.is_wayland {
|
||||
let var = |name| std::env::var(name).ok();
|
||||
services.xwayland_command =
|
||||
services::xwayland_command(var("FLATPAK_ID").as_deref(), var("APPIMAGE").as_deref(), std::env::var_os("DISPLAY").is_some());
|
||||
}
|
||||
}
|
||||
let mut app = PhotocraftApp::new(Session::new(), services);
|
||||
app.integrated_titlebar = cfg!(target_os = "macos");
|
||||
|
||||
@@ -200,6 +200,25 @@ fn image_from_files(paths: &[PathBuf]) -> Option<(u32, u32, Vec<u8>)> {
|
||||
})
|
||||
}
|
||||
|
||||
/// The shell command that starts this install under XWayland, where winit delivers file drops
|
||||
/// (winit 0.30 has none on Wayland, #386). A Flatpak gets the X11 socket only without the Wayland
|
||||
/// one, an AppImage relaunches by its own path, and anything else is `photocraft` on the PATH.
|
||||
/// `None` outside Flatpak when there is no X server (`DISPLAY` unset) to run on.
|
||||
#[cfg(any(target_os = "linux", test))]
|
||||
pub fn xwayland_command(flatpak_id: Option<&str>, appimage: Option<&str>, x_display: bool) -> Option<String> {
|
||||
if let Some(id) = flatpak_id.filter(|id| !id.is_empty()) {
|
||||
return Some(format!("flatpak run --nosocket=wayland --socket=x11 {}", shell_word(id)));
|
||||
}
|
||||
let exe = appimage.filter(|path| !path.is_empty()).map_or_else(|| "photocraft".to_string(), shell_word);
|
||||
x_display.then(|| format!("WAYLAND_DISPLAY= {exe}"))
|
||||
}
|
||||
|
||||
/// `s` as one POSIX shell word: bare when every character is safe there, else single-quoted.
|
||||
#[cfg(any(target_os = "linux", test))]
|
||||
fn shell_word(s: &str) -> String {
|
||||
if s.bytes().all(|b| b.is_ascii_alphanumeric() || b"/._-+:,@".contains(&b)) { s.to_string() } else { format!("'{}'", s.replace('\'', r"'\''")) }
|
||||
}
|
||||
|
||||
pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) -> Services {
|
||||
let clip: Rc<RefCell<Option<arboard::Clipboard>>> = Rc::default();
|
||||
let automation_read = automation.clone().map(|workspace| {
|
||||
@@ -362,6 +381,23 @@ mod tests {
|
||||
use photocraft_ui_egui::{PhotocraftApp, prefs_ui};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
#[test]
|
||||
fn xwayland_command_matches_how_photocraft_was_installed() {
|
||||
// Flatpak: WAYLAND_DISPLAY doesn't reach the sandbox's socket choice; flatpak's flags do.
|
||||
let flatpak = xwayland_command(Some("ai.storyteller.photocraft"), None, false);
|
||||
assert_eq!(flatpak.as_deref(), Some("flatpak run --nosocket=wayland --socket=x11 ai.storyteller.photocraft"));
|
||||
// AppImage: its own path, quoted for the shell (spaces, quotes).
|
||||
let appimage = xwayland_command(None, Some("/home/me/My Apps/it's.AppImage"), true);
|
||||
assert_eq!(appimage.as_deref(), Some(r"WAYLAND_DISPLAY= '/home/me/My Apps/it'\''s.AppImage'"));
|
||||
let bare = xwayland_command(None, Some("/opt/photocraft-0.3.0-linux-x86_64.AppImage"), true);
|
||||
assert_eq!(bare.as_deref(), Some("WAYLAND_DISPLAY= /opt/photocraft-0.3.0-linux-x86_64.AppImage"));
|
||||
// deb, rpm, AUR, tarball: the binary on the PATH.
|
||||
assert_eq!(xwayland_command(None, None, true).as_deref(), Some("WAYLAND_DISPLAY= photocraft"));
|
||||
assert_eq!(xwayland_command(Some(""), Some(""), true).as_deref(), Some("WAYLAND_DISPLAY= photocraft"));
|
||||
// No X server (XWayland disabled): nothing to suggest.
|
||||
assert_eq!(xwayland_command(None, Some("/opt/p.AppImage"), false), None);
|
||||
}
|
||||
|
||||
/// Tests every native save dialog and records the suggested file name. Each name's file type must come first
|
||||
/// in the save panel, or the panel appends the first type's extension (`photo.webp.psd`, `photo.gif.psd`).
|
||||
#[test]
|
||||
|
||||
@@ -156,6 +156,16 @@ fn pt(p: &Value, k: &str) -> Option<(f64, f64)> {
|
||||
/// stroke's first point. With `"aligned"` strokes the slot remembers the anchor so later
|
||||
/// strokes keep sampling relative to the original pairing.
|
||||
pub fn mapping(s: &mut Session, p: &Value, first: (f64, f64), cmd: &str) -> Result<Mapping> {
|
||||
let (m, anchor) = resolve(s, p, first, cmd)?;
|
||||
if let Some(a) = anchor {
|
||||
s.presets.clone.active_mut().anchor = Some(a);
|
||||
}
|
||||
Ok(m)
|
||||
}
|
||||
|
||||
/// [`mapping`] without remembering anything: the mapping, and the anchor an aligned stroke from
|
||||
/// the slot stores (a live preview resolves the same mapping the commit will).
|
||||
pub fn resolve(s: &Session, p: &Value, first: (f64, f64), cmd: &str) -> Result<(Mapping, Option<[f64; 2]>)> {
|
||||
let aligned = p.get("aligned").and_then(Value::as_bool).unwrap_or(true);
|
||||
let slot = s.presets.clone.active().clone();
|
||||
let explicit_tf = ["scale", "rotation", "flipH", "flipV"].iter().any(|k| p.get(*k).is_some());
|
||||
@@ -172,10 +182,10 @@ pub fn mapping(s: &mut Session, p: &Value, first: (f64, f64), cmd: &str) -> Resu
|
||||
let anchor_param = pt(p, "anchor");
|
||||
if let Some(off) = pt(p, "offset") {
|
||||
let a = anchor_param.unwrap_or(first);
|
||||
return Ok(Mapping { source: (a.0 + off.0, a.1 + off.1), anchor: a, m });
|
||||
return Ok((Mapping { source: (a.0 + off.0, a.1 + off.1), anchor: a, m }, None));
|
||||
}
|
||||
if let Some(src) = pt(p, "source") {
|
||||
return Ok(Mapping { source: src, anchor: anchor_param.unwrap_or(first), m });
|
||||
return Ok((Mapping { source: src, anchor: anchor_param.unwrap_or(first), m }, None));
|
||||
}
|
||||
let Some(src) = slot.source else { return Err(bad(cmd, "missing `source` ([x,y]) or `offset` ([dx,dy]); or set one with cloneSource.set")) };
|
||||
let src = (src[0], src[1]);
|
||||
@@ -183,10 +193,7 @@ pub fn mapping(s: &mut Session, p: &Value, first: (f64, f64), cmd: &str) -> Resu
|
||||
(true, Some(a)) => (a[0], a[1]),
|
||||
_ => first,
|
||||
};
|
||||
if aligned {
|
||||
s.presets.clone.active_mut().anchor = Some([anchor.0, anchor.1]);
|
||||
}
|
||||
Ok(Mapping { source: src, anchor, m })
|
||||
Ok((Mapping { source: src, anchor, m }, aligned.then_some([anchor.0, anchor.1])))
|
||||
}
|
||||
|
||||
/// Bilinear resample of `src` (covering [`Mapping::source_rect`]) onto `dst`, interpolating
|
||||
|
||||
@@ -303,6 +303,97 @@ fn clone_stamp(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(clone_result(dmg, off, aligned, p, &stroke))
|
||||
}
|
||||
|
||||
/// A Clone Stamp stroke shown while it is drawn: the dabs so far composited from the clone source
|
||||
/// onto a copy of the active document, as `paint.cloneStamp` with the same params commits them
|
||||
/// (the same coverage, sampling and blend; a smoothing catch-up appears on release).
|
||||
pub struct LiveClone {
|
||||
/// The active document with the stroke so far.
|
||||
pub doc: std::sync::Arc<Document>,
|
||||
renderer: photocraft_paint::StrokeRenderer,
|
||||
pre: std::sync::Arc<Document>,
|
||||
pre_surf: Surface,
|
||||
id: Option<LayerId>,
|
||||
params: Value,
|
||||
which: SampleLayers,
|
||||
map: crate::presets::clone_source::Mapping,
|
||||
mode: BlendMode,
|
||||
opacity: f32,
|
||||
sel: Option<Surface>,
|
||||
lock: bool,
|
||||
/// Where the doc shows what finishing the stroke now would add (a lone first dab, the
|
||||
/// smoothing catch-up), redrawn on every step as the Brush's live stroke does.
|
||||
tail: Rect,
|
||||
}
|
||||
|
||||
impl LiveClone {
|
||||
/// Start from `paint.cloneStamp` params; their `points` are rendered.
|
||||
pub fn begin(s: &Session, p: &Value) -> Result<Self> {
|
||||
const CMD: &str = "paint.cloneStamp";
|
||||
has_pixel_layer(s).map_err(EngineError::Other)?;
|
||||
let (stroke, id) = parse_brush(s, p, CMD)?;
|
||||
let which = sample_layers(p, CMD)?;
|
||||
let mode = blend_param(p, CMD)?;
|
||||
let f = *stroke.points.first().ok_or_else(|| bad(CMD, "`points` is empty"))?;
|
||||
let (map, _) = crate::presets::clone_source::resolve(s, p, (f.x, f.y), CMD)?;
|
||||
let pre = s.active().ok_or(EngineError::NoDocument)?.doc.clone();
|
||||
let mut doc = (*pre).clone();
|
||||
let sel = doc.selection.clone();
|
||||
let (surf, lock) = crate::channel_cmds::target_surface(&mut doc, id, p)?;
|
||||
let pre_surf = surf.clone();
|
||||
// As `stroke_coverage`, which the commit uses.
|
||||
let renderer = photocraft_paint::StrokeRenderer::new(&stroke.brush, None, 1.0);
|
||||
let opacity = stroke.brush.opacity;
|
||||
let mut live =
|
||||
Self { doc: std::sync::Arc::new(doc), renderer, pre, pre_surf, id, params: p.clone(), which, map, mode, opacity, sel, lock, tail: Rect::EMPTY };
|
||||
live.push(&stroke.points)?;
|
||||
Ok(live)
|
||||
}
|
||||
|
||||
/// Everything the stroke has touched so far.
|
||||
pub fn bounds(&self) -> Rect {
|
||||
self.renderer.bounds().union(&self.tail)
|
||||
}
|
||||
|
||||
/// Render more points; returns the rectangle that changed. Each changed area is redrawn from
|
||||
/// the pre-stroke pixels with the stroke's coverage so far, so overlapping dabs build up as in
|
||||
/// the commit, and pixels painted earlier in the stroke are never re-cloned. What finishing
|
||||
/// the stroke now would add is drawn too (a lone first dab shows on the press), and redrawn on
|
||||
/// every step.
|
||||
pub fn push(&mut self, pts: &[StrokePoint]) -> Result<Rect> {
|
||||
self.renderer.push(pts);
|
||||
let old = std::mem::replace(&mut self.tail, Rect::EMPTY);
|
||||
let mut dmg = Rect::EMPTY;
|
||||
if !old.is_empty() {
|
||||
// Back to the stroke without the previous tail.
|
||||
let (surf, _) = crate::channel_cmds::target_surface(std::sync::Arc::make_mut(&mut self.doc), self.id, &self.params)?;
|
||||
surf.write_region(old, &self.pre_surf.read_region(old));
|
||||
self.renderer.mark_dirty(old);
|
||||
dmg = old;
|
||||
}
|
||||
let r = self.renderer.take_dirty_rect();
|
||||
let cov = self.renderer.coverage_in(r);
|
||||
dmg = dmg.union(&self.composite(r, &cov)?);
|
||||
if let Some(mut tail) = self.renderer.tail_preview() {
|
||||
let r = tail.take_dirty_rect();
|
||||
let cov = tail.coverage_in(r);
|
||||
self.tail = self.composite(r, &cov)?;
|
||||
dmg = dmg.union(&self.tail);
|
||||
}
|
||||
Ok(dmg)
|
||||
}
|
||||
|
||||
/// Redraw `r` from the pre-stroke pixels with the clone source through coverage `cov`.
|
||||
fn composite(&mut self, r: Rect, cov: &[f32]) -> Result<Rect> {
|
||||
if r.is_empty() {
|
||||
return Ok(r);
|
||||
}
|
||||
let paint = clone_sample(&self.pre, self.id, &self.pre_surf, self.which, r, &self.map, "paint.cloneStamp")?;
|
||||
let (surf, _) = crate::channel_cmds::target_surface(std::sync::Arc::make_mut(&mut self.doc), self.id, &self.params)?;
|
||||
surf.write_region(r, &self.pre_surf.read_region(r));
|
||||
Ok(apply_coverage(surf, r, cov, self.opacity, self.sel.as_ref(), self.lock, &paint, self.mode).union(&r))
|
||||
}
|
||||
}
|
||||
|
||||
/// Grow a stroke's coverage map by `m` pixels of zero coverage (a Dirichlet boundary for the solve).
|
||||
fn pad_coverage(bounds: Rect, cov: &[f32], m: i32) -> (Rect, Vec<f32>) {
|
||||
let g = bounds.inflate(m);
|
||||
|
||||
@@ -1090,3 +1090,28 @@ fn pattern_stamp_rejects_hostile_input() {
|
||||
s.execute("layer.setProps", json!({"locks": {"pixels": true}})).unwrap();
|
||||
assert!(stamp(&mut s, json!({"points": [[16, 16]]})).is_err());
|
||||
}
|
||||
|
||||
/// The live Clone Stamp shows what the commit paints: the same pixels, fed in pieces or at once,
|
||||
/// with soft overlapping dabs (built-up coverage) and opacity.
|
||||
#[test]
|
||||
fn live_clone_matches_the_commit() {
|
||||
let mut s = session(96, 64, 8, "rgb");
|
||||
paint_layer(&mut s, texture);
|
||||
let p = json!({"points": [[50, 30], [60, 34], [70, 30], [80, 36]], "source": [20, 20], "size": 14, "hardness": 40, "opacity": 70});
|
||||
let pts = |v: &[[f64; 2]]| v.iter().map(|q| StrokePoint::new(q[0], q[1], 1.0)).collect::<Vec<_>>();
|
||||
let mut live = LiveClone::begin(&s, &json!({"points": [[50, 30]], "source": [20, 20], "size": 14, "hardness": 40, "opacity": 70})).unwrap();
|
||||
live.push(&pts(&[[60.0, 34.0], [70.0, 30.0]])).unwrap();
|
||||
live.push(&pts(&[[80.0, 36.0]])).unwrap();
|
||||
let shown = live.doc.clone();
|
||||
s.execute("paint.cloneStamp", p).unwrap();
|
||||
let id = s.active().unwrap().active_layer.unwrap();
|
||||
let (a, b) = (shown.layer(id).unwrap().surface().unwrap(), s.active().unwrap().doc.layer(id).unwrap().surface().unwrap());
|
||||
for y in 20..46 {
|
||||
for x in 40..92 {
|
||||
let (got, want) = (a.rgba(x, y), b.rgba(x, y));
|
||||
for c in 0..4 {
|
||||
assert!((got[c] - want[c]).abs() <= tol(8), "({x}, {y}): live {got:?} vs commit {want:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,6 +523,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
Some(Value::String(value)) if value == "vertical" => Orientation::Vertical,
|
||||
_ => return Err(bad("type.create", "orientation must be horizontal or vertical")),
|
||||
};
|
||||
check_kerning(p).map_err(|m| bad("type.create", m))?;
|
||||
check_size_tracking(p).map_err(|m| bad("type.create", m))?;
|
||||
let text = norm_text(p.get("text").and_then(Value::as_str).unwrap_or(""));
|
||||
// Type › Save Default Type Styles sets the starting styles; the colour is always
|
||||
@@ -1114,6 +1115,17 @@ mod tests {
|
||||
}
|
||||
assert!(s.execute("type.setStyle", json!({"layer": id, "kerning": "tight"})).is_err());
|
||||
assert_eq!(text_layer(&s, id).runs, before.runs);
|
||||
// type.create rejects the same values and creates no layer (#994).
|
||||
let layers = s.active().unwrap().doc.layer_count();
|
||||
for k in [json!("tight"), json!(1e9), json!(-5000), json!(true), json!([1])] {
|
||||
let p = json!({"x": 0, "y": 10, "text": "AV", "kerning": k});
|
||||
assert!(s.execute("type.create", p.clone()).is_err(), "{p}");
|
||||
}
|
||||
assert_eq!(s.active().unwrap().doc.layer_count(), layers);
|
||||
let id = s.execute("type.create", json!({"x": 0, "y": 10, "text": "AV", "kerning": "optical"})).unwrap()["layer"].as_u64().unwrap();
|
||||
assert!(kerning_of(&s, id).iter().all(|k| *k == (Kerning::Optical, 0.0)));
|
||||
let id = s.execute("type.create", json!({"x": 0, "y": 10, "text": "AV", "kerning": -50})).unwrap()["layer"].as_u64().unwrap();
|
||||
assert!(kerning_of(&s, id).iter().all(|k| *k == (Kerning::Off, -50.0)));
|
||||
}
|
||||
|
||||
/// Cost of one Alt+←/→ press (`kernPair`: two measuring layouts + the edit's re-render) on
|
||||
|
||||
@@ -574,6 +574,27 @@ impl StrokeRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/// The coverage tiles touched since the last call (or `composite`), as one rectangle clipped to
|
||||
/// the stroke bounds, and forget them: what a live preview that composites its own paint has
|
||||
/// to redraw.
|
||||
pub fn take_dirty_rect(&mut self) -> Rect {
|
||||
let r = self
|
||||
.cov
|
||||
.take_dirty()
|
||||
.into_iter()
|
||||
.fold(Rect::EMPTY, |acc, (tx, ty)| acc.union(&Rect::new(tx * COV_TILE, ty * COV_TILE, (tx + 1) * COV_TILE, (ty + 1) * COV_TILE)));
|
||||
if let Some(d) = self.dual.as_mut() {
|
||||
d.dirty.clear();
|
||||
}
|
||||
r.intersect(&self.bounds())
|
||||
}
|
||||
|
||||
/// Final coverage over `r`, one value per pixel in rows (as [`dense_coverage`](Self::dense_coverage)
|
||||
/// over its bounds).
|
||||
pub fn coverage_in(&self, r: Rect) -> Vec<f32> {
|
||||
(r.y0..r.y1).flat_map(|y| (r.x0..r.x1).map(move |x| (x, y))).map(|(x, y)| self.coverage_at(x, y)).collect()
|
||||
}
|
||||
|
||||
/// Final stroke coverage at a pixel (stroke-level masks applied, before opacity/selection).
|
||||
pub fn coverage_at(&self, x: i32, y: i32) -> f32 {
|
||||
let c = self.cov.get(x, y);
|
||||
|
||||
@@ -66,6 +66,7 @@ fn main() {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
let mut services = services;
|
||||
services.is_wayland = wayland_notice;
|
||||
services.xwayland_command = wayland_notice.then(|| "WAYLAND_DISPLAY= photocraft".into());
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services);
|
||||
app.background_jobs = background_jobs;
|
||||
app.custom_titlebar = custom_titlebar;
|
||||
|
||||
+107
-16
@@ -237,10 +237,45 @@ pub(crate) fn draw_readout(ctx: &egui::Context, id: &str, cursor: Pos2, labels:
|
||||
});
|
||||
}
|
||||
|
||||
/// A Brush/Eraser stroke shown while it is drawn: the engine renders the real dabs onto a copy of
|
||||
/// the document, and the canvas redraws only what each step changed.
|
||||
/// The engine's live stroke of a tool: the Brush, Pencil and Eraser paint dabs, the Clone Stamp
|
||||
/// composites its source.
|
||||
enum EngineStroke {
|
||||
Brush(Box<photocraft_engine::brush_cmds::LiveStroke>),
|
||||
Clone(Box<photocraft_engine::retouch_cmds::LiveClone>),
|
||||
}
|
||||
|
||||
impl EngineStroke {
|
||||
fn doc(&self) -> &std::sync::Arc<photocraft_doc::Document> {
|
||||
match self {
|
||||
Self::Brush(s) => &s.doc,
|
||||
Self::Clone(s) => &s.doc,
|
||||
}
|
||||
}
|
||||
fn bounds(&self) -> DRect {
|
||||
match self {
|
||||
Self::Brush(s) => s.bounds(),
|
||||
Self::Clone(s) => s.bounds(),
|
||||
}
|
||||
}
|
||||
fn push(&mut self, pts: &[photocraft_engine::paint::StrokePoint]) -> photocraft_engine::Result<DRect> {
|
||||
match self {
|
||||
Self::Brush(s) => s.push(pts),
|
||||
Self::Clone(s) => s.push(pts),
|
||||
}
|
||||
}
|
||||
/// The jitter seed the commit must reuse (the Clone Stamp's comes from the session brush).
|
||||
fn seed(&self) -> Option<u64> {
|
||||
match self {
|
||||
Self::Brush(s) => Some(s.seed),
|
||||
Self::Clone(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A stroke shown while it is drawn: the engine renders the real result onto a copy of the
|
||||
/// document, and the canvas redraws only what each step changed.
|
||||
pub(crate) struct LiveStroke {
|
||||
stroke: photocraft_engine::brush_cmds::LiveStroke,
|
||||
stroke: EngineStroke,
|
||||
doc: photocraft_doc::DocId,
|
||||
revision: u64,
|
||||
/// Preview key of the stroke; step `n` displays as `key + n`.
|
||||
@@ -281,7 +316,7 @@ fn stroke_params(app: &PhotocraftApp, tool: Tool, erase: bool, points: &[Vec<f64
|
||||
|
||||
/// Tools whose strokes the engine renders while they are drawn (`LiveStroke`).
|
||||
pub(crate) fn strokes_live(tool: Tool) -> bool {
|
||||
matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser)
|
||||
matches!(tool, Tool::Brush | Tool::Pencil | Tool::Eraser | Tool::CloneStamp)
|
||||
}
|
||||
|
||||
/// The command a live-stroking tool commits: the Pencil's `paint.pencil`, else `paint.stroke`.
|
||||
@@ -381,8 +416,16 @@ fn begin_live_stroke(app: &PhotocraftApp) -> Option<LiveStroke> {
|
||||
static STROKES: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
let st = app.session.active()?;
|
||||
let d = app.drag.as_ref()?;
|
||||
let p = stroke_params(app, d.tool, d.erase, &app.stylus.stroke_points(&d.points));
|
||||
let stroke = photocraft_engine::brush_cmds::LiveStroke::begin_with(&app.session, stroke_command(d.tool), &p).ok()?;
|
||||
let stroke = if d.tool == Tool::CloneStamp {
|
||||
// The params `retouch_ui::finish_stroke` commits.
|
||||
let mut p = crate::retouch_ui::clone_params(app)?;
|
||||
p["points"] = json!(d.points);
|
||||
p["target"] = paint_target(app);
|
||||
EngineStroke::Clone(Box::new(photocraft_engine::retouch_cmds::LiveClone::begin(&app.session, &p).ok()?))
|
||||
} else {
|
||||
let p = stroke_params(app, d.tool, d.erase, &app.stylus.stroke_points(&d.points));
|
||||
EngineStroke::Brush(Box::new(photocraft_engine::brush_cmds::LiveStroke::begin_with(&app.session, stroke_command(d.tool), &p).ok()?))
|
||||
};
|
||||
let n = STROKES.fetch_add(1, std::sync::atomic::Ordering::Relaxed) & 0xff_ffff;
|
||||
let damage = vec![stroke.bounds()];
|
||||
Some(LiveStroke { stroke, doc: st.doc.id, revision: st.revision, key: (1 << 44) | (n << 20), damage, fed: d.points.len() })
|
||||
@@ -637,7 +680,7 @@ fn display_doc(app: &mut PhotocraftApp, idx: usize) -> (std::sync::Arc<Document>
|
||||
}
|
||||
let st = &app.session.documents()[idx];
|
||||
if let Some(l) = live_stroke(app, idx) {
|
||||
return (l.stroke.doc.clone(), l.display_key());
|
||||
return (l.stroke.doc().clone(), l.display_key());
|
||||
}
|
||||
if let (Some(t), Some(pv)) = (&app.ui.transform, &app.transform_preview)
|
||||
&& app.session.active_index() == Some(idx)
|
||||
@@ -852,7 +895,7 @@ fn damage_since(app: &PhotocraftApp, idx: usize, seen: (u64, u64), now: (u64, u6
|
||||
}
|
||||
let l = live_stroke(app, idx).filter(|l| seen.0 == now.0 && l.display_key() == now.1)?;
|
||||
let r = l.since(seen.1 ^ display_key)?;
|
||||
Some(if r.is_empty() { r } else { r.inflate(effect_reach(&l.stroke.doc.layers)) })
|
||||
Some(if r.is_empty() { r } else { r.inflate(effect_reach(&l.stroke.doc().layers)) })
|
||||
}
|
||||
|
||||
/// Document `doc`'s canvas caches showed a preview that the edit just committed reproduces
|
||||
@@ -1668,8 +1711,8 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
ui.add_space(22.0);
|
||||
ui.horizontal(|ui| {
|
||||
let msg = start_screen_drop_hint(app.services.is_wayland);
|
||||
let g = ui.painter().layout_no_wrap(msg.into(), egui::FontId::proportional(12.5), t.text_faint);
|
||||
let msg = start_screen_drop_hint(app);
|
||||
let g = ui.painter().layout_no_wrap(msg.to_string(), egui::FontId::proportional(12.5), t.text_faint);
|
||||
ui.add_space(((card.width() - g.size().x - 24.0) / 2.0).max(0.0));
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 18.0), Sense::hover());
|
||||
crate::icons::paint(ui, r, "image", 15.0, t.text_faint);
|
||||
@@ -1687,8 +1730,13 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
fn start_screen_drop_hint(is_wayland: bool) -> &'static str {
|
||||
if is_wayland { tl!("Use File › Open to open an image.") } else { tl!("Drop an image or PSD anywhere to open it.") }
|
||||
/// Wayland has no native file drops (winit 0.30, #386), so the hint offers File › Open and paste.
|
||||
fn start_screen_drop_hint(app: &PhotocraftApp) -> std::borrow::Cow<'static, str> {
|
||||
if app.services.is_wayland {
|
||||
crate::i18n::fmt(tl!("Use File › Open, or paste a copied image with {paste}."), &[("paste", &crate::notices::paste_hint(app))]).into()
|
||||
} else {
|
||||
tl!("Drop an image or PSD anywhere to open it.").into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Recent files listed on the Home screen.
|
||||
@@ -2165,6 +2213,25 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
|
||||
// A drag is only recognised once the pointer has moved past egui's click distance: the
|
||||
// gesture starts where the button went down, not where it is now (#123).
|
||||
let gesture_active_before = app.drag.is_some();
|
||||
// Live painting tools start on the press, not once the pointer passes egui's click
|
||||
// distance: the first dab shows at once. The drag recognised later continues that stroke,
|
||||
// and a click (or a long press that never moved) just ends it.
|
||||
if strokes_live(tool)
|
||||
&& app.drag.is_none()
|
||||
&& response.is_pointer_button_down_on()
|
||||
&& ui.input(|i| i.pointer.primary_pressed())
|
||||
&& let Some(p) = ui.input(|i| i.pointer.press_origin()).filter(|p| rect.contains(*p))
|
||||
{
|
||||
let d = xf.to_doc(p);
|
||||
// The press's own modifiers: a ⇧ that arrives with the click still connects the line.
|
||||
let press_mods = ui.input(|i| pointer_button_modifiers(&i.events, PointerButton::Primary)).unwrap_or(mods);
|
||||
tool_event(app, ToolEvent::Down { x: d[0], y: d[1], pressure: app.stylus.pressure() }, press_mods);
|
||||
app.press_stroke = app.drag.is_some();
|
||||
}
|
||||
let press_stroke = app.press_stroke;
|
||||
if press_stroke {
|
||||
buttons.started = false;
|
||||
}
|
||||
if buttons.started
|
||||
&& let Some(p) = ui.input(|i| i.pointer.press_origin()).filter(|p| rect.contains(*p)).or(response.interact_pointer_pos())
|
||||
{
|
||||
@@ -2226,6 +2293,20 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
|
||||
tool_event(app, ToolEvent::Up { x: d[0], y: d[1] }, mods);
|
||||
}
|
||||
}
|
||||
// A stroke started on the press ends with the release, whether egui saw a drag, a click,
|
||||
// or neither (a long press that never moved).
|
||||
if press_stroke && !buttons.stopped && ui.input(|i| i.pointer.primary_released()) {
|
||||
buttons.clicked = false;
|
||||
let p = response.interact_pointer_pos().map(|p| xf.to_doc(p)).or_else(|| app.drag.as_ref().and_then(|d| d.points.last().map(|q| [q[0], q[1]])));
|
||||
if let Some(d) = p
|
||||
&& app.drag.is_some()
|
||||
{
|
||||
tool_event(app, ToolEvent::Up { x: d[0], y: d[1] }, mods);
|
||||
}
|
||||
}
|
||||
if press_stroke && (app.drag.is_none() || !ui.input(|i| i.pointer.primary_down())) {
|
||||
app.press_stroke = false;
|
||||
}
|
||||
if buttons.clicked
|
||||
&& let Some(p) = response.interact_pointer_pos()
|
||||
{
|
||||
@@ -2658,7 +2739,7 @@ fn draw_drag_preview(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &View
|
||||
}
|
||||
match d.tool {
|
||||
// The canvas shows the live stroke itself (`LiveStroke`).
|
||||
Tool::Brush | Tool::Pencil | Tool::Eraser => {}
|
||||
t if strokes_live(t) => {}
|
||||
t if t.is_brushlike() || t == Tool::QuickSelection => {
|
||||
// Retouching strokes preview as a translucent trail of the brush footprint: a mask,
|
||||
// not a brush-wide egui polyline (which zoomed in tessellates into wedges, #189).
|
||||
@@ -3201,6 +3282,10 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) {
|
||||
{
|
||||
app.last_stroke_end = Some((st.doc.id, [end[0], end[1]]));
|
||||
}
|
||||
// A live Clone Stamp preview ends here; the commit below replaces it.
|
||||
if d.tool == Tool::CloneStamp {
|
||||
app.live_stroke = None;
|
||||
}
|
||||
if crate::eraser_ui::finish_stroke(app, d.tool, &d.points) || crate::retouch_ui::finish_stroke(app, d.tool, &d.points, d.modifiers) {
|
||||
return;
|
||||
}
|
||||
@@ -3212,8 +3297,8 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) {
|
||||
Tool::Brush | Tool::Pencil | Tool::Eraser => {
|
||||
let live = app.live_stroke.take();
|
||||
let mut p = stroke_params(app, d.tool, d.erase, &app.stylus.stroke_points(&d.points));
|
||||
if let Some(l) = &live {
|
||||
p["seed"] = json!(l.stroke.seed);
|
||||
if let Some(seed) = live.as_ref().and_then(|l| l.stroke.seed()) {
|
||||
p["seed"] = json!(seed);
|
||||
}
|
||||
// The canvas already shows the stroke: let the commit's damage rect refresh it rather
|
||||
// than recompositing the whole document.
|
||||
@@ -3576,7 +3661,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn wayland_start_screen_hint_does_not_claim_file_drop_works() {
|
||||
assert_ne!(start_screen_drop_hint(true), start_screen_drop_hint(false));
|
||||
let x11 = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
|
||||
let wayland = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services { is_wayland: true, ..Default::default() });
|
||||
assert!(start_screen_drop_hint(&x11).starts_with("Drop"));
|
||||
// Pasting a copied image file works on Wayland (#338): the hint says how.
|
||||
let hint = start_screen_drop_hint(&wayland);
|
||||
assert!(!hint.contains("Drop"), "{hint}");
|
||||
assert!(hint.ends_with(&format!("paste a copied image with {}.", crate::notices::paste_hint(&wayland))), "{hint}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -990,11 +990,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. Kreslete nástrojem pero (P) nebo vytvořte pracovní cestu z výběru.
|
||||
Drop an image or PSD anywhere to open it. Přetáhněte sem obrázek nebo PSD a otevře se.
|
||||
Native file drag-and-drop is unavailable Nativní přetahování souborů ve Waylandu není dostupné
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Nativní přetahování souborů ve Waylandu zatím není podporováno. Použijte Soubor › Otevřít nebo spusťte PhotoCraft v XWayland s `WAYLAND_DISPLAY= photocraft`.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Nativní přetahování souborů ve Waylandu zatím není podporováno. Použijte Soubor › Otevřít, nebo obrázek zkopírujte ve správci souborů a vložte ho pomocí {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Chcete-li soubory přetahovat, spusťte PhotoCraft v XWayland: `{command}`
|
||||
Edit › Paste Úpravy › Vložit
|
||||
Duplicate Layers… Duplikovat vrstvy…
|
||||
Duplicate style Duplikovat styl
|
||||
Edit Toolbar… Upravit panel nástrojů…
|
||||
Use File › Open to open an image. Obrázek otevřete přes Soubor › Otevřít.
|
||||
Use File › Open, or paste a copied image with {paste}. Použijte Soubor › Otevřít, nebo vložte zkopírovaný obrázek pomocí {paste}.
|
||||
Edit in Quick Mask Mode (Q) Upravit v režimu rychlé masky (Q)
|
||||
Edit in Standard Mode (Q) Upravit ve standardním režimu (Q)
|
||||
Effects Efekty
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -974,11 +974,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. Zeichne mit dem Stift-Werkzeug (P) oder erzeuge einen Arbeitspfad aus einer Auswahl.
|
||||
Drop an image or PSD anywhere to open it. Ziehe ein Bild oder PSD an eine beliebige Stelle, um es zu öffnen.
|
||||
Native file drag-and-drop is unavailable Natives Ziehen und Ablegen von Dateien ist nicht verfügbar
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Natives Ziehen und Ablegen von Dateien wird unter Wayland noch nicht unterstützt. Nutze Datei › Öffnen oder starte PhotoCraft unter XWayland mit `WAYLAND_DISPLAY= photocraft`.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Natives Ziehen und Ablegen von Dateien wird unter Wayland noch nicht unterstützt. Nutze Datei › Öffnen oder kopiere das Bild im Dateimanager und füge es mit {paste} ein.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Um Dateien abzulegen, starte PhotoCraft unter XWayland: `{command}`
|
||||
Edit › Paste Bearbeiten › Einfügen
|
||||
Duplicate Layers… Ebenen duplizieren…
|
||||
Duplicate style Stil duplizieren
|
||||
Edit Toolbar… Werkzeugleiste bearbeiten…
|
||||
Use File › Open to open an image. Nutze Datei › Öffnen, um ein Bild zu öffnen.
|
||||
Use File › Open, or paste a copied image with {paste}. Nutze Datei › Öffnen oder füge ein kopiertes Bild mit {paste} ein.
|
||||
Edit in Quick Mask Mode (Q) Im Schnellmaskenmodus bearbeiten (Q)
|
||||
Edit in Standard Mode (Q) Im Standardmodus bearbeiten (Q)
|
||||
Effects Effekte
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -975,11 +975,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. Dibuja con la herramienta Pluma (P) o crea un trazado de trabajo a partir de una selección.
|
||||
Drop an image or PSD anywhere to open it. Suelte una imagen o un PSD en cualquier lugar para abrirlo.
|
||||
Native file drag-and-drop is unavailable El arrastrar y soltar archivos de forma nativa no está disponible en Wayland
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. El arrastrar y soltar archivos de forma nativa aún no está disponible en Wayland. Usa Archivo › Abrir o ejecuta PhotoCraft bajo XWayland con `WAYLAND_DISPLAY= photocraft`.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. El arrastrar y soltar archivos de forma nativa aún no está disponible en Wayland. Usa Archivo › Abrir, o copia la imagen en tu gestor de archivos y pégala con {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Para soltar archivos, inicia PhotoCraft bajo XWayland: `{command}`
|
||||
Edit › Paste Edición › Pegar
|
||||
Duplicate Layers… Duplicar capas…
|
||||
Duplicate style Duplicar estilo
|
||||
Edit Toolbar… Editar barra de herramientas…
|
||||
Use File › Open to open an image. Usa Archivo › Abrir para abrir una imagen.
|
||||
Use File › Open, or paste a copied image with {paste}. Usa Archivo › Abrir, o pega una imagen copiada con {paste}.
|
||||
Edit in Quick Mask Mode (Q) Editar en modo de máscara rápida (Q)
|
||||
Edit in Standard Mode (Q) Editar en modo estándar (Q)
|
||||
Effects Efectos
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -2464,8 +2464,10 @@
|
||||
Floating point Virgule flottante
|
||||
Use Global Light Utiliser la lumière globale
|
||||
Native file drag-and-drop is unavailable Le glisser-déposer natif de fichiers n'est pas disponible
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Le glisser-déposer natif de fichiers n'est pas encore pris en charge sous Wayland. Utilisez Fichier › Ouvrir, ou lancez PhotoCraft sous XWayland avec `WAYLAND_DISPLAY= photocraft`.
|
||||
Use File › Open to open an image. Utilisez Fichier › Ouvrir pour ouvrir une image.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Le glisser-déposer natif de fichiers n'est pas encore pris en charge sous Wayland. Utilisez Fichier › Ouvrir, ou copiez l'image dans votre gestionnaire de fichiers et collez-la avec {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Pour déposer des fichiers, lancez PhotoCraft sous XWayland : `{command}`
|
||||
Edit › Paste Édition › Coller
|
||||
Use File › Open, or paste a copied image with {paste}. Utilisez Fichier › Ouvrir, ou collez une image copiée avec {paste}.
|
||||
Mixer Brush Tool Outil Pinceau mélangeur
|
||||
Invalid {mode} profile Profil {mode} non valide
|
||||
Unnamed {mode} profile Profil {mode} sans nom
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2453,8 +2453,10 @@
|
||||
Floating point Titik mengambang
|
||||
Use Global Light Gunakan Cahaya Global
|
||||
Native file drag-and-drop is unavailable Seret dan lepas berkas native tidak tersedia
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Seret dan lepas berkas native belum didukung di Wayland. Gunakan Berkas › Buka, atau jalankan PhotoCraft di XWayland dengan `WAYLAND_DISPLAY= photocraft`.
|
||||
Use File › Open to open an image. Gunakan Berkas › Buka untuk membuka gambar.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Seret dan lepas berkas native belum didukung di Wayland. Gunakan Berkas › Buka, atau salin gambar di pengelola berkas lalu tempel dengan {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Untuk menjatuhkan berkas, jalankan PhotoCraft di XWayland: `{command}`
|
||||
Edit › Paste Edit › Tempel
|
||||
Use File › Open, or paste a copied image with {paste}. Gunakan Berkas › Buka, atau tempel gambar yang disalin dengan {paste}.
|
||||
Mixer Brush Tool Alat Kuas Pencampur
|
||||
Invalid {mode} profile Profil {mode} tidak valid
|
||||
Unnamed {mode} profile Profil {mode} tanpa nama
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -974,11 +974,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. Disegna con Penna (P) o crea un tracciato di lavoro da una selezione.
|
||||
Drop an image or PSD anywhere to open it. Trascina un'immagine o PSD ovunque per aprirlo.
|
||||
Native file drag-and-drop is unavailable Il drag-and-drop nativo file non è disponibile su Wayland
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Il drag-and-drop nativo non è ancora supportato su Wayland. Usa File › Apri, o avvia PhotoCraft sotto XWayland con `WAYLAND_DISPLAY= photocraft`.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Il drag-and-drop nativo non è ancora supportato su Wayland. Usa File › Apri, oppure copia l'immagine nel file manager e incollala con {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Per trascinare file, avvia PhotoCraft sotto XWayland: `{command}`
|
||||
Edit › Paste Modifica › Incolla
|
||||
Duplicate Layers… Duplica livelli…
|
||||
Duplicate style Duplica stile
|
||||
Edit Toolbar… Modifica barra strumenti…
|
||||
Use File › Open to open an image. Usa File › Apri per aprire un'immagine.
|
||||
Use File › Open, or paste a copied image with {paste}. Usa File › Apri, oppure incolla un'immagine copiata con {paste}.
|
||||
Edit in Quick Mask Mode (Q) Modifica in maschera veloce (Q)
|
||||
Edit in Standard Mode (Q) Modifica in modalità standard (Q)
|
||||
Effects Effetti
|
||||
|
||||
|
@@ -980,11 +980,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. ペンツール(P)で描くか、選択範囲から作業用パスを作成します。
|
||||
Drop an image or PSD anywhere to open it. 画像や PSD をここにドロップすると開きます。
|
||||
Native file drag-and-drop is unavailable Wayland ではネイティブのファイルドラッグ&ドロップを利用できません
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland ではネイティブのファイルドラッグ&ドロップはまだ利用できません。[ファイル › 開く] を使うか、`WAYLAND_DISPLAY= photocraft` を指定して PhotoCraft を XWayland 上で起動してください。
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland ではネイティブのファイルドラッグ&ドロップはまだ利用できません。[ファイル › 開く] を使うか、ファイルマネージャーで画像をコピーして {paste} で貼り付けてください。
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` ファイルをドロップするには、XWayland 上で PhotoCraft を起動してください: `{command}`
|
||||
Edit › Paste [編集 › 貼り付け]
|
||||
Duplicate Layers… レイヤーを複製…
|
||||
Duplicate style スタイルを複製
|
||||
Edit Toolbar… ツールバーを編集…
|
||||
Use File › Open to open an image. 画像を開くには [ファイル › 開く] を使ってください。
|
||||
Use File › Open, or paste a copied image with {paste}. [ファイル › 開く] を使うか、コピーした画像を {paste} で貼り付けてください。
|
||||
Edit in Quick Mask Mode (Q) クイックマスクモードで編集(Q)
|
||||
Edit in Standard Mode (Q) 標準モードで編集(Q)
|
||||
Effects 効果
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1995,8 +1995,10 @@
|
||||
Floating point 부동 소수점
|
||||
Use Global Light 전체 조명 사용
|
||||
Native file drag-and-drop is unavailable 파일 드래그 앤 드롭을 사용할 수 없습니다
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland에서는 아직 파일 드래그 앤 드롭을 지원하지 않습니다. 파일 › 열기를 사용하거나 `WAYLAND_DISPLAY= photocraft`로 XWayland에서 PhotoCraft를 실행하세요.
|
||||
Use File › Open to open an image. 파일 › 열기에서 이미지를 여세요.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland에서는 아직 파일 드래그 앤 드롭을 지원하지 않습니다. 파일 › 열기를 사용하거나, 파일 관리자에서 이미지를 복사한 뒤 {paste}(으)로 붙여넣으세요.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` 파일을 끌어다 놓으려면 XWayland에서 PhotoCraft를 실행하세요: `{command}`
|
||||
Edit › Paste 편집 › 붙여넣기
|
||||
Use File › Open, or paste a copied image with {paste}. 파일 › 열기를 사용하거나, 복사한 이미지를 {paste}(으)로 붙여넣으세요.
|
||||
Invalid {mode} profile 유효하지 않은 {mode} 프로파일
|
||||
Unnamed {mode} profile 이름 없는 {mode} 프로파일
|
||||
Show bounding box when dragging layer 레이어를 드래그할 때 테두리 상자 표시
|
||||
|
||||
|
@@ -3196,6 +3196,10 @@ cameraRaw Roughness Chropowatość
|
||||
Camera Raw ({name}) Camera Raw ({name})
|
||||
Could not open Nie można otworzyć
|
||||
{path}: the path is not valid Unicode; rename the file and open it again. {path}: ścieżka nie jest prawidłowym Unicode; zmień nazwę pliku i otwórz go ponownie.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Natywne przeciąganie i upuszczanie plików nie jest jeszcze obsługiwane w Wayland. Użyj Plik › Otwórz albo skopiuj obraz w menedżerze plików i wklej go za pomocą {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Aby upuszczać pliki, uruchom PhotoCraft pod XWayland: `{command}`
|
||||
Edit › Paste Edycja › Wklej
|
||||
Use File › Open, or paste a copied image with {paste}. Użyj Plik › Otwórz albo wklej skopiowany obraz za pomocą {paste}.
|
||||
|
||||
# Swatches panel
|
||||
Create new swatch Utwórz nową próbkę
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2460,8 +2460,10 @@
|
||||
Floating point Ponto flutuante
|
||||
Use Global Light Usar luz global
|
||||
Native file drag-and-drop is unavailable Arrastar e soltar arquivos nativo indisponível
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Arrastar e soltar arquivos nativo ainda não é compatível com Wayland. Use Arquivo › Abrir ou execute o PhotoCraft no XWayland com `WAYLAND_DISPLAY= photocraft`.
|
||||
Use File › Open to open an image. Use Arquivo › Abrir para abrir uma imagem.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Arrastar e soltar arquivos nativo ainda não é compatível com Wayland. Use Arquivo › Abrir ou copie a imagem no gerenciador de arquivos e cole-a com {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Para soltar arquivos, execute o PhotoCraft no XWayland: `{command}`
|
||||
Edit › Paste Editar › Colar
|
||||
Use File › Open, or paste a copied image with {paste}. Use Arquivo › Abrir ou cole uma imagem copiada com {paste}.
|
||||
Mixer Brush Tool Ferramenta Pincel misturador
|
||||
Invalid {mode} profile Perfil {mode} inválido
|
||||
Unnamed {mode} profile Perfil {mode} sem nome
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1387,9 +1387,11 @@
|
||||
BLANK DOCUMENT PRESETS ({n}) НАБОРЫ ПУСТЫХ ДОКУМЕНТОВ ({n})
|
||||
Create a new document or open an existing file. Создайте новый документ или откройте существующий файл.
|
||||
Drop an image or PSD anywhere to open it. Перетащите изображение или PSD в любое место окна, чтобы открыть.
|
||||
Use File › Open to open an image. Чтобы открыть изображение, выберите Файл › Открыть.
|
||||
Use File › Open, or paste a copied image with {paste}. Выберите Файл › Открыть или вставьте скопированное изображение с помощью {paste}.
|
||||
Native file drag-and-drop is unavailable Нативное перетаскивание файлов в Wayland недоступно
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Нативное перетаскивание файлов в Wayland пока не поддерживается. Откройте файл через Файл › Открыть или запустите PhotoCraft в XWayland с `WAYLAND_DISPLAY= photocraft`.
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Нативное перетаскивание файлов в Wayland пока не поддерживается. Откройте файл через Файл › Открыть или скопируйте изображение в файловом менеджере и вставьте его с помощью {paste}.
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` Чтобы перетаскивать файлы, запустите PhotoCraft в XWayland: `{command}`
|
||||
Edit › Paste Редактирование › Вставить
|
||||
Photo Фото
|
||||
Print Печать
|
||||
Art & Illustration Искусство и иллюстрация
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -980,11 +980,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. 使用钢笔工具(P)绘制,或从选区创建工作路径。
|
||||
Drop an image or PSD anywhere to open it. 将图像或 PSD 拖放到任意位置即可打开。
|
||||
Native file drag-and-drop is unavailable Wayland 上不支持原生文件拖放
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland 尚不支持原生文件拖放。请使用“文件 › 打开”,或通过 `WAYLAND_DISPLAY= photocraft` 在 XWayland 下运行 PhotoCraft。
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland 尚不支持原生文件拖放。请使用“文件 › 打开”,或在文件管理器中复制图像后使用 {paste} 粘贴。
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` 要拖放文件,请在 XWayland 下启动 PhotoCraft:`{command}`
|
||||
Edit › Paste “编辑 › 粘贴”
|
||||
Duplicate Layers… 复制图层…
|
||||
Duplicate style 复制样式
|
||||
Edit Toolbar… 编辑工具栏…
|
||||
Use File › Open to open an image. 使用“文件 › 打开”打开图像。
|
||||
Use File › Open, or paste a copied image with {paste}. 请使用“文件 › 打开”,或使用 {paste} 粘贴复制的图像。
|
||||
Edit in Quick Mask Mode (Q) 在快速蒙版模式下编辑 (Q)
|
||||
Edit in Standard Mode (Q) 在标准模式下编辑 (Q)
|
||||
Effects 效果
|
||||
|
||||
|
@@ -981,11 +981,13 @@
|
||||
Draw with the Pen tool (P) or make a work path from a selection. 使用筆型工具 (P) 繪製,或從選取範圍建立工作路徑。
|
||||
Drop an image or PSD anywhere to open it. 將影像或 PSD 拖放到任何位置即可開啟。
|
||||
Native file drag-and-drop is unavailable Wayland 不支援原生檔案拖放
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`. Wayland 尚未支援原生檔案拖放。請使用「檔案 › 開啟」,或透過 `WAYLAND_DISPLAY= photocraft` 在 XWayland 下執行 PhotoCraft。
|
||||
Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}. Wayland 尚未支援原生檔案拖放。請使用「檔案 › 開啟」,或在檔案管理員中複製影像後使用 {paste} 貼上。
|
||||
To drop files, start PhotoCraft under XWayland: `{command}` 若要拖放檔案,請在 XWayland 下啟動 PhotoCraft:`{command}`
|
||||
Edit › Paste 「編輯 › 貼上」
|
||||
Duplicate Layers… 複製圖層…
|
||||
Duplicate style 複製樣式
|
||||
Edit Toolbar… 編輯工具列…
|
||||
Use File › Open to open an image. 使用「檔案 › 開啟」開啟影像。
|
||||
Use File › Open, or paste a copied image with {paste}. 請使用「檔案 › 開啟」,或使用 {paste} 貼上複製的影像。
|
||||
Edit in Quick Mask Mode (Q) 在快速遮色片模式下編輯 (Q)
|
||||
Edit in Standard Mode (Q) 在標準模式下編輯 (Q)
|
||||
Effects 效果
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -267,6 +267,9 @@ pub struct Services {
|
||||
pub save_prefs: Option<SaveTextFn>,
|
||||
/// The native window is connected directly to a Wayland compositor.
|
||||
pub is_wayland: bool,
|
||||
/// On Wayland, the shell command that starts this install under XWayland, where native file
|
||||
/// drops work (#386); `None` when there is no X server to run it on.
|
||||
pub xwayland_command: Option<String>,
|
||||
/// Crash-recovery autosave (Preferences › File Handling) and recovery at launch.
|
||||
pub autosave: Option<AutosaveFn>,
|
||||
pub discard_autosave: Option<DiscardAutosaveFn>,
|
||||
@@ -322,6 +325,9 @@ pub struct PhotocraftApp {
|
||||
/// While a batch of recovered pointer samples is replayed, defer the live-stroke update to one
|
||||
/// call for the whole frame (see `canvas::canvas_view`).
|
||||
defer_live_stroke: bool,
|
||||
/// A live painting stroke started on the press (`canvas_view`): the drag egui recognises later,
|
||||
/// or the click, continues or ends it rather than starting another.
|
||||
press_stroke: bool,
|
||||
/// End of the last painting stroke: ⇧-click draws a straight line from it (#178).
|
||||
last_stroke_end: Option<(DocId, [f64; 2])>,
|
||||
/// Control+Alt-drag brush resize in progress (`brush_resize`, #231).
|
||||
@@ -487,6 +493,7 @@ impl PhotocraftApp {
|
||||
magnetic: Default::default(),
|
||||
secondary_erase: false,
|
||||
defer_live_stroke: false,
|
||||
press_stroke: false,
|
||||
last_stroke_end: None,
|
||||
brush_resize: None,
|
||||
quick_pick: false,
|
||||
|
||||
@@ -27,12 +27,23 @@ pub struct Notice {
|
||||
/// Preference key to set when this notice is dismissed.
|
||||
#[serde(default)]
|
||||
pub dismiss_pref: Option<String>,
|
||||
/// `{name}` values filled into the title and lines after they are translated.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub args: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl Notice {
|
||||
/// `s` (the title or a line) in the current language, with [`Notice::args`] filled in.
|
||||
pub fn text(&self, s: &str) -> String {
|
||||
let args: Vec<(&str, &str)> = self.args.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
|
||||
crate::i18n::fmt(crate::i18n::t(s), &args)
|
||||
}
|
||||
}
|
||||
|
||||
/// Show a notice (newest last); returns its id.
|
||||
pub fn post(app: &mut PhotocraftApp, title: impl Into<String>, lines: Vec<String>, error: bool, dismiss_pref: Option<&str>) -> u64 {
|
||||
let id = app.ui.alloc_id();
|
||||
app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned) });
|
||||
app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned), args: Vec::new() });
|
||||
cap_notices(app);
|
||||
id
|
||||
}
|
||||
@@ -44,7 +55,14 @@ fn cap_notices(app: &mut PhotocraftApp) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Show the Wayland-specific fallback guidance unless the user dismissed it in preferences.
|
||||
/// How to paste in hints: Edit › Paste's effective shortcut (`Ctrl+V`), else the menu path.
|
||||
pub(crate) fn paste_hint(app: &PhotocraftApp) -> String {
|
||||
crate::shortcuts::shortcut_label(app, "edit.paste").unwrap_or_else(|| tl!("Edit › Paste").to_string())
|
||||
}
|
||||
|
||||
/// Show the Wayland-specific fallback guidance unless the user dismissed it in preferences: winit
|
||||
/// 0.30 delivers no file drops on Wayland, so point at File › Open, pasting a copied file, and the
|
||||
/// command that starts this install under XWayland (where drops work), when there is one.
|
||||
pub fn wayland_file_drop_guidance(app: &mut PhotocraftApp) {
|
||||
if !app.services.is_wayland
|
||||
|| app.session.prefs().dialogs.get(WAYLAND_FILE_DROP_DISMISSED).and_then(serde_json::Value::as_bool) == Some(true)
|
||||
@@ -52,16 +70,20 @@ pub fn wayland_file_drop_guidance(app: &mut PhotocraftApp) {
|
||||
{
|
||||
return;
|
||||
}
|
||||
post(
|
||||
app,
|
||||
"Native file drag-and-drop is unavailable",
|
||||
vec![
|
||||
"Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or run PhotoCraft under XWayland with `WAYLAND_DISPLAY= photocraft`."
|
||||
.into(),
|
||||
],
|
||||
false,
|
||||
Some(WAYLAND_FILE_DROP_DISMISSED),
|
||||
);
|
||||
// English templates, translated and filled in when drawn, so the notice follows a language change.
|
||||
let mut lines = vec![
|
||||
"Native file drag-and-drop is not supported on Wayland yet. Use File › Open, or copy the image in your file manager and paste it with {paste}."
|
||||
.to_owned(),
|
||||
];
|
||||
let mut args = vec![("paste".to_owned(), paste_hint(app))];
|
||||
if let Some(command) = &app.services.xwayland_command {
|
||||
lines.push("To drop files, start PhotoCraft under XWayland: `{command}`".to_owned());
|
||||
args.push(("command".to_owned(), command.clone()));
|
||||
}
|
||||
let id = post(app, "Native file drag-and-drop is unavailable", lines, false, Some(WAYLAND_FILE_DROP_DISMISSED));
|
||||
if let Some(notice) = app.ui.notices.iter_mut().find(|notice| notice.id == id) {
|
||||
notice.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/// A full refresh of document `doc` fell back to the CPU compositor (`reason`, the GPU's) and took
|
||||
@@ -140,7 +162,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(340.0);
|
||||
ui.horizontal(|ui| {
|
||||
let title = egui::RichText::new(crate::i18n::t(&n.title)).strong().color(if n.error { t.warning } else { t.text });
|
||||
let title = egui::RichText::new(n.text(&n.title)).strong().color(if n.error { t.warning } else { t.text });
|
||||
ui.add(egui::Label::new(title).wrap());
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
|
||||
if ui.add(egui::Button::new(egui::RichText::new("×").color(t.text_dim)).frame(false)).on_hover_text(tl!("Dismiss")).clicked() {
|
||||
@@ -149,7 +171,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
});
|
||||
});
|
||||
for line in n.lines.iter().take(MAX_LINES) {
|
||||
let line = crate::i18n::t(line);
|
||||
let line = n.text(line);
|
||||
ui.add(egui::Label::new(egui::RichText::new(format!("• {line}")).color(t.text_dim)).wrap());
|
||||
}
|
||||
if n.lines.len() > MAX_LINES {
|
||||
@@ -174,8 +196,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn wayland_guidance_follows_language_changes_after_startup() {
|
||||
let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });
|
||||
let command = Some("WAYLAND_DISPLAY= photocraft".to_string());
|
||||
let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, xwayland_command: command, ..Default::default() });
|
||||
let notice = &app.ui.notices[0];
|
||||
assert!(notice.lines.iter().all(|line| crate::i18n::tr(crate::i18n::Lang::from_code("es").unwrap(), line) != line), "every line is a catalog template");
|
||||
// the notice keeps its English source text and is translated when drawn (`i18n::t` with
|
||||
// the current language); `tr` with an explicit language leaves the process-wide language,
|
||||
// which other tests running in parallel draw with, untouched
|
||||
@@ -185,17 +209,26 @@ mod tests {
|
||||
assert_eq!(crate::i18n::tr(crate::i18n::Lang::EN, ¬ice.title), "Native file drag-and-drop is unavailable");
|
||||
}
|
||||
|
||||
/// A notice's lines in English with their arguments filled in.
|
||||
fn english(notice: &Notice) -> String {
|
||||
let args: Vec<(&str, &str)> = notice.args.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
|
||||
notice.lines.iter().map(|line| crate::i18n::fmt(line, &args)).collect::<Vec<_>>().join(" ")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wayland_guidance_is_only_shown_in_wayland_sessions() {
|
||||
let mut app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });
|
||||
let command = Some("WAYLAND_DISPLAY= '/apps/Photo Craft.AppImage'".to_string());
|
||||
let mut app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, xwayland_command: command, ..Default::default() });
|
||||
assert_eq!(app.ui.notices.len(), 1);
|
||||
assert_eq!(app.ui.notices[0].title, "Native file drag-and-drop is unavailable");
|
||||
let guidance = app.ui.notices[0].lines.join(" ");
|
||||
let guidance = english(&app.ui.notices[0]);
|
||||
assert!(guidance.contains("not supported on Wayland yet"));
|
||||
assert!(guidance.contains("File › Open"));
|
||||
assert!(!guidance.contains("Ctrl+V"));
|
||||
assert!(guidance.contains("XWayland"));
|
||||
assert!(guidance.contains("WAYLAND_DISPLAY= photocraft"));
|
||||
// Pasting a copied file works on Wayland (#338), so the notice offers it.
|
||||
let paste = paste_hint(&app);
|
||||
assert!(guidance.contains(&format!("paste it with {paste}")), "{guidance}");
|
||||
// The relaunch command is the one for this install (an AppImage here), not a guess.
|
||||
assert!(guidance.contains("under XWayland: `WAYLAND_DISPLAY= '/apps/Photo Craft.AppImage'`"), "{guidance}");
|
||||
assert_eq!(app.ui.notices[0].dismiss_pref.as_deref(), Some(WAYLAND_FILE_DROP_DISMISSED));
|
||||
for i in 0..MAX_NOTICES {
|
||||
post(&mut app, format!("Transient {i}"), Vec::new(), false, None);
|
||||
@@ -207,6 +240,24 @@ mod tests {
|
||||
assert!(app.ui.notices.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wayland_guidance_without_an_x_server_does_not_suggest_xwayland() {
|
||||
let app = PhotocraftApp::new(Session::new(), Services { is_wayland: true, ..Default::default() });
|
||||
let guidance = english(&app.ui.notices[0]);
|
||||
assert!(guidance.contains("File › Open"));
|
||||
assert!(!guidance.contains("XWayland"), "{guidance}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paste_hint_follows_the_shortcut_and_falls_back_to_the_menu() {
|
||||
let mut app = PhotocraftApp::new(Session::new(), Services::default());
|
||||
assert_eq!(paste_hint(&app), crate::shortcuts::shortcut_label(&app, "edit.paste").unwrap());
|
||||
app.session.prefs.edit(|prefs| {
|
||||
prefs.shortcuts.insert("edit.paste".into(), String::new());
|
||||
});
|
||||
assert_eq!(paste_hint(&app), "Edit › Paste");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dismissing_wayland_guidance_persists_across_launches() {
|
||||
let saved = Arc::new(Mutex::new(None::<String>));
|
||||
|
||||
@@ -21,6 +21,24 @@ pub(crate) fn alt_flipped(tool: Tool, alt: bool) -> Tool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clone Stamp / Healing Brush params for the options bar and the clone source (without
|
||||
/// `points` and `target`): shared by the live preview and the commit. `None` when no source
|
||||
/// point is set yet.
|
||||
pub(crate) fn clone_params(app: &PhotocraftApp) -> Option<Value> {
|
||||
let o = &app.ui.tool_options;
|
||||
let mut p = json!({"aligned": o.clone_aligned, "sampleLayer": o.clone_sample});
|
||||
// The Clone Source panel's active slot (set by ⌥-click) drives the stroke: the engine keeps
|
||||
// the aligned pairing and applies the slot's scale/rotation/flip.
|
||||
let slot = app.session.presets.clone.active().source.is_some();
|
||||
match (app.ui.clone_offset.filter(|_| o.clone_aligned && !slot), app.ui.clone_source.filter(|_| !slot)) {
|
||||
_ if slot => {}
|
||||
(Some(off), _) => p["offset"] = json!(off),
|
||||
(None, Some(src)) => p["source"] = json!(src),
|
||||
(None, None) => return None,
|
||||
}
|
||||
Some(p)
|
||||
}
|
||||
|
||||
/// Finish a stroke with a retouching tool. Returns false if `tool` isn't one.
|
||||
pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], mods: egui::Modifiers) -> bool {
|
||||
let o = app.ui.tool_options.clone();
|
||||
@@ -46,26 +64,17 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], m
|
||||
("paint.patternStamp", p)
|
||||
}
|
||||
Tool::Healing | Tool::CloneStamp => {
|
||||
let mut p = json!({"aligned": o.clone_aligned, "sampleLayer": o.clone_sample});
|
||||
// The Clone Source panel's active slot (set by ⌥-click) drives the stroke: the engine
|
||||
// keeps the aligned pairing and applies the slot's scale/rotation/flip.
|
||||
let slot = app.session.presets.clone.active().source.is_some();
|
||||
match (app.ui.clone_offset.filter(|_| o.clone_aligned && !slot), app.ui.clone_source.filter(|_| !slot)) {
|
||||
_ if slot => {}
|
||||
(Some(off), _) => p["offset"] = json!(off),
|
||||
(None, Some(src)) => p["source"] = json!(src),
|
||||
(None, None) => {
|
||||
// Photoshop says Option-click on the Mac and Alt-click on Windows.
|
||||
app.ui.status = if cfg!(target_os = "macos") {
|
||||
tl!("Option-click to define a source point to clone from")
|
||||
} else {
|
||||
tl!("Alt-click to define a source point to clone from")
|
||||
}
|
||||
.into();
|
||||
app.ui.status_error = true;
|
||||
return true;
|
||||
let Some(p) = clone_params(app) else {
|
||||
// Option-click on the Mac, Alt-click on Windows.
|
||||
app.ui.status = if cfg!(target_os = "macos") {
|
||||
tl!("Option-click to define a source point to clone from")
|
||||
} else {
|
||||
tl!("Alt-click to define a source point to clone from")
|
||||
}
|
||||
}
|
||||
.into();
|
||||
app.ui.status_error = true;
|
||||
return true;
|
||||
};
|
||||
(if tool == Tool::Healing { "paint.healingBrush" } else { "paint.cloneStamp" }, p)
|
||||
}
|
||||
Tool::HistoryBrush => ("paint.historyBrush", json!({})),
|
||||
|
||||
@@ -390,12 +390,29 @@ pub fn install_fonts_with(ctx: &egui::Context, cjk: crate::cjk_fonts::Sources) {
|
||||
size_ui_font(ctx, name, Arc::make_mut(data));
|
||||
}
|
||||
ctx.set_fonts(fonts);
|
||||
ctx.add_plugin(UiFontSizePlugin { applied: size });
|
||||
// egui keeps the first plugin of a type, so a re-install (language change) resets the
|
||||
// existing one. The new definitions land next pass: the plugin must not rescale before then.
|
||||
if ctx
|
||||
.with_plugin::<UiFontSizePlugin, _>(|plugin| {
|
||||
plugin.applied = size;
|
||||
plugin.defer_after_install = true;
|
||||
})
|
||||
.is_none()
|
||||
{
|
||||
ctx.add_plugin(UiFontSizePlugin { applied: size, defer_after_install: true });
|
||||
}
|
||||
// Japanese / Chinese / Korean fallback fonts (craft-fonts' Japanese ones if built in, then
|
||||
// the system's) are registered on demand (cjk_fonts.rs).
|
||||
crate::cjk_fonts::install_with(ctx, cjk);
|
||||
}
|
||||
|
||||
/// Has [`install_fonts`]'s stack reached the active fonts? Before that (the first pass, when
|
||||
/// the desktop app installs fonts and loads preferences in the same frame) the active fonts
|
||||
/// are egui's defaults, and rescaling a copy of those would overwrite the queued stack.
|
||||
fn ui_fonts_active(ctx: &egui::Context) -> bool {
|
||||
ctx.fonts(|f| f.definitions().families.contains_key(&FontFamily::Name("medium".into())))
|
||||
}
|
||||
|
||||
fn ui_fonts_id() -> egui::Id {
|
||||
egui::Id::new("photocraft-ui-fonts")
|
||||
}
|
||||
@@ -434,6 +451,9 @@ pub(crate) fn set_ui_font_size(ctx: &egui::Context, size: UiFontSize) {
|
||||
/// Keep only the original multipliers, not a second copy of large system font files.
|
||||
struct UiFontSizePlugin {
|
||||
applied: UiFontSize,
|
||||
/// `set_fonts` takes effect next pass: skip one hook so the rescale starts from that stack
|
||||
/// and not from the one it replaces.
|
||||
defer_after_install: bool,
|
||||
}
|
||||
|
||||
impl egui::Plugin for UiFontSizePlugin {
|
||||
@@ -443,9 +463,16 @@ impl egui::Plugin for UiFontSizePlugin {
|
||||
|
||||
fn output_hook(&mut self, ctx: &egui::Context, _output: &mut egui::FullOutput) {
|
||||
let size = ui_font_size(ctx);
|
||||
let deferred = std::mem::take(&mut self.defer_after_install);
|
||||
if size == self.applied {
|
||||
return;
|
||||
}
|
||||
if deferred || !ui_fonts_active(ctx) {
|
||||
// Cloning the active definitions now would discard the queued stack (the desktop
|
||||
// app installs fonts and loads the saved size in its first frame).
|
||||
ctx.request_repaint();
|
||||
return;
|
||||
}
|
||||
// Start from the current stack so lazily registered fallback faces are retained.
|
||||
let mut fonts = ctx.fonts(|f| f.definitions().clone());
|
||||
for (name, data) in &mut fonts.font_data {
|
||||
@@ -594,6 +621,53 @@ mod tests {
|
||||
assert_eq!(ctx.zoom_factor(), 1.0);
|
||||
}
|
||||
|
||||
/// The desktop app installs fonts and loads the saved UI Font Size in its first frame, while
|
||||
/// egui's default fonts are still active. Any size but Small then panicked on the next pass
|
||||
/// ("FontFamily::Name("medium") is not bound to any fonts") because the plugin rescaled a
|
||||
/// copy of the defaults and that replaced the queued Inter stack.
|
||||
#[test]
|
||||
fn saved_ui_font_size_survives_first_frame_install() {
|
||||
let ctx = egui::Context::default();
|
||||
let medium_bound = |ctx: &egui::Context| ctx.fonts(|f| f.families().contains(&FontFamily::Name("medium".into())));
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
assert!(!medium_bound(ui.ctx()), "egui's defaults are active in the first frame");
|
||||
install_fonts(ui.ctx());
|
||||
apply(ui.ctx(), ThemeKind::Pro);
|
||||
set_ui_font_size(ui.ctx(), UiFontSize::Medium);
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
let mut width = 0.0;
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
assert!(medium_bound(ui.ctx()), "the installed stack reaches the second pass");
|
||||
width = ui.painter().layout_no_wrap("PhotoCraft".into(), medium(13.0), Color32::WHITE).size().x;
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
assert!(width > 0.0);
|
||||
// The saved size applies one pass later, from the installed stack.
|
||||
ctx.run_ui(Default::default(), |_| {}).textures_delta.clear();
|
||||
let mut scaled = 0.0;
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
assert!(medium_bound(ui.ctx()));
|
||||
scaled = ui.painter().layout_no_wrap("PhotoCraft".into(), medium(13.0), Color32::WHITE).size().x;
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
assert!((scaled - width * font_scale(UiFontSize::Medium)).abs() < 1.0, "{scaled} vs {width} × 14/12");
|
||||
// Re-installing (a language change) keeps the size and the named families.
|
||||
ctx.run_ui(Default::default(), |ui| install_fonts(ui.ctx())).textures_delta.clear();
|
||||
for _ in 0..2 {
|
||||
ctx.run_ui(Default::default(), |ui| {
|
||||
assert!(medium_bound(ui.ctx()));
|
||||
let w = ui.painter().layout_no_wrap("PhotoCraft".into(), medium(13.0), Color32::WHITE).size().x;
|
||||
assert!((w - scaled).abs() < 1.0, "{w} vs {scaled}");
|
||||
})
|
||||
.textures_delta
|
||||
.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn theme_names_parse() {
|
||||
assert_eq!(ThemeKind::from_name("Classic"), Some(ThemeKind::Classic));
|
||||
|
||||
@@ -181,7 +181,9 @@ pub fn value_field(ui: &mut Ui, value: &mut f32, range: std::ops::RangeInclusive
|
||||
// Round to the step before adding it, so whole-number fields drop decimals (55.4 + 1 = 56).
|
||||
let v = (*value / grid).round() * grid + step;
|
||||
// Round to 4 decimal places, so repeated 0.1 steps don't leave float errors.
|
||||
*value = ((v * 1e4).round() / 1e4).clamp(lo, hi);
|
||||
let v = (v * 1e4).round() / 1e4;
|
||||
// `f32::clamp` panics on a reversed or NaN range, which `DragValue::range` accepts.
|
||||
*value = if lo <= hi { v.clamp(lo, hi) } else { v };
|
||||
ui.memory_mut(|m| m.request_focus(resp.id));
|
||||
resp.mark_changed();
|
||||
}
|
||||
@@ -931,6 +933,14 @@ mod tests {
|
||||
assert_eq!(h.state().1, 6, "every step reports a change, so callers apply it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arrow_keys_on_a_field_with_a_reversed_range_do_not_panic() {
|
||||
let mut h = focused(5.0, 10.0..=0.0);
|
||||
let _ = press(&mut h, Modifiers::NONE, Key::ArrowUp);
|
||||
let mut h = focused(5.0, f32::NAN..=10.0);
|
||||
let _ = press(&mut h, Modifiers::NONE, Key::ArrowDown);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arrow_keys_round_decimals_step_fine_fields_and_clamp() {
|
||||
for (start, mods, key, want) in [
|
||||
|
||||
@@ -275,6 +275,26 @@ fn custom_par(app: &mut PhotocraftApp, p: &Value) -> Result<Value, String> {
|
||||
Ok(json!({"pixelAspectRatio": c.ratio, "name": c.name}))
|
||||
}
|
||||
|
||||
/// The Show Extras Options… checkboxes as (field, label). The fields are the serialized
|
||||
/// [`crate::view_cmds::Show`] names, the keys the dialog is seeded with and its command accepts.
|
||||
fn extras_options() -> [(&'static str, &'static str); 13] {
|
||||
[
|
||||
("layer_edges", tl!("Layer Edges")),
|
||||
("selection_edges", tl!("Selection Edges")),
|
||||
("target_path", tl!("Target Path")),
|
||||
("notes", tl!("Notes")),
|
||||
("pixel_grid", tl!("Pixel Grid")),
|
||||
("slices", tl!("Slices")),
|
||||
("count", tl!("Count")),
|
||||
("smart_guides", tl!("Smart Guides")),
|
||||
("brush_preview", tl!("Brush Preview")),
|
||||
("mesh", tl!("Mesh")),
|
||||
("edit_pins", tl!("Edit Pins")),
|
||||
("canvas_guides", tl!("Canvas Guides")),
|
||||
("artboard_guides", tl!("Artboard Guides")),
|
||||
]
|
||||
}
|
||||
|
||||
/// The open dialog's OK as (command id, params).
|
||||
pub fn dialog_command(kind: &str, f: &Map<String, Value>) -> Option<(&'static str, Value)> {
|
||||
Some(match kind {
|
||||
@@ -396,21 +416,7 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
for (k, label) in [
|
||||
("layerEdges", tl!("Layer Edges")),
|
||||
("selectionEdges", tl!("Selection Edges")),
|
||||
("targetPath", tl!("Target Path")),
|
||||
("notes", tl!("Notes")),
|
||||
("pixelGrid", tl!("Pixel Grid")),
|
||||
("slices", tl!("Slices")),
|
||||
("count", tl!("Count")),
|
||||
("smartGuides", tl!("Smart Guides")),
|
||||
("brushPreview", tl!("Brush Preview")),
|
||||
("mesh", tl!("Mesh")),
|
||||
("editPins", tl!("Edit Pins")),
|
||||
("canvasGuides", tl!("Canvas Guides")),
|
||||
("artboardGuides", tl!("Artboard Guides")),
|
||||
] {
|
||||
for (k, label) in extras_options() {
|
||||
check(ui, &mut f, k, label);
|
||||
}
|
||||
}
|
||||
@@ -553,6 +559,31 @@ mod tests {
|
||||
crate::analysis_ui::tests::render(&mut app, &ctx, windows);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extras_options_checkboxes_show_and_change_every_flag() {
|
||||
let (mut app, ctx) = app();
|
||||
let before = serde_json::to_value(app.ui.view.show).unwrap();
|
||||
crate::menus::invoke(&mut app, &ctx, "view.show.showExtrasOptions", json!({})).unwrap();
|
||||
let (kind, mut f) = app.ui.shell.dialog.clone().unwrap();
|
||||
// Every checkbox reads the seeded value of its flag (Selection Edges is on by default).
|
||||
assert_eq!(extras_options().len(), f.len());
|
||||
for (k, _) in extras_options() {
|
||||
assert!(before[k].is_boolean(), "{k} is not a Show field");
|
||||
assert_eq!(f.get(k).and_then(Value::as_bool), before[k].as_bool(), "{k}");
|
||||
}
|
||||
// Ticking every box (one- and multi-word flags in one submission) applies them all on OK.
|
||||
for (k, _) in extras_options() {
|
||||
let on = !f.get(k).and_then(Value::as_bool).unwrap();
|
||||
f.insert(k.into(), json!(on));
|
||||
}
|
||||
let (id, p) = dialog_command(&kind, &f).unwrap();
|
||||
crate::menus::invoke(&mut app, &ctx, id, p).unwrap();
|
||||
let after = serde_json::to_value(app.ui.view.show).unwrap();
|
||||
for (k, _) in extras_options() {
|
||||
assert_eq!(after[k].as_bool(), before[k].as_bool().map(|b| !b), "{k}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thirty_two_bit_preview_dialog() {
|
||||
let (mut app, ctx) = app();
|
||||
|
||||
+2
-1
@@ -8,7 +8,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|
||||
|---|---:|---:|---:|---|
|
||||
| [Performance](#performance) | 3 | 22 | 13 | 47 scenarios: 3 within budget, 22 over budget or failing, 15 tracked only, 6 not run, 7 not measurable yet (baseline 2026-10-05) |
|
||||
| [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |
|
||||
| [Tools](#tools) | 9 | 14 | 8 | |
|
||||
| [Tools](#tools) | 10 | 14 | 8 | |
|
||||
| [Workspace and UI](#workspace-and-ui) | 0 | 6 | 17 | settings that do nothing: 56 of 140 (target 0) |
|
||||
| [Type](#type) | 0 | 3 | 6 | |
|
||||
| [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) |
|
||||
@@ -135,6 +135,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
|
||||
| TOOL-213-12 | Import an image file as a brush tip | missing | [#213](https://github.com/storytold/photocraft/issues/213) | Only brush.defineFromSelection and brush.presets.importAbr |
|
||||
| TOOL-213-13 | Brush regression tests: no seams, hard edge, zero-scatter defaults, ABR never black | done | [#213](https://github.com/storytold/photocraft/issues/213) | Seam, hard-edge and zero-scatter tests in brush_tests.rs; ABR tip colour test in abr_map/tests.rs |
|
||||
| TOOL-213-14 | Tablet: no OS arrow cursor over the canvas on macOS, Windows and Linux | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Brush tools set CursorIcon::None (canvas.rs:1259-1275); not verified per OS |
|
||||
| TOOL-213-18 | Pattern Stamp tool: sibling of Clone Stamp in the S flyout | done | [#213](https://github.com/storytold/photocraft/issues/213) | Tool::PatternStamp in the S group; paint.patternStamp stamps the Patterns-panel tile with Aligned and Impressionist (an approximation: it jitters each dab's tile phase, not Photoshop's smeared impressionist look); engine tests cover depths, seams, hostile input |
|
||||
| TOOL-214-1 | Select and Mask workspace: view modes, Refine Edge brush, 6 outputs | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Opens the generic select.refineEdge dialog (menus.rs:308) |
|
||||
| TOOL-214-2 | Marquee: Shift square, Alt from centre, live W x H readout | partial | [#214](https://github.com/storytold/photocraft/issues/214) | marquee_end supports shift (chrome_ui.rs:167) but canvas.rs passes false (#208) |
|
||||
| TOOL-214-3 | Color Range test: Sampled Colors at Fuzziness 0 selects the exact match only | partial | [#214](https://github.com/storytold/photocraft/issues/214) | Fuzziness-0 tests cover midtones/shadows only (selection_cmds.rs:444-447) |
|
||||
|
||||
Reference in new issue
Block a user