PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #6708: Paths: the path selected in the Paths panel is drawn on the canvas (#6550)
aiongg1a5d22ca94b6
diff --cc crates/ui-egui/src/vector_ui.rsindex a1f472e51,9878e10b8..84ee36bfc--- a/crates/ui-egui/src/vector_ui.rs+++ b/crates/ui-egui/src/vector_ui.rs@@@ -978,15 -978,15 +978,23 @@@ pub(crate) fn draw_handle(painter: &egupainter.circle_filled(handle, 3.0, accent);}+/// Does `tool` draw the anchor squares of the paths it can edit? Path Selection does, and so do+/// the Pen tools: as in Photoshop, a path finished with Enter or by closing it keeps its anchors+/// on screen, so it can still be edited (⌘/Ctrl-drag, Auto Add/Delete) (#6884, #4716).+pub(crate) fn shows_anchors(tool: Tool) -> bool {+ // Add/Delete Anchor Point and Convert Point draw Direct Selection's overlay instead.+ matches!(tool, Tool::PathSelection | Tool::Pen | Tool::FreeformPen | Tool::CurvaturePen)+}+- /// Work path / active shape path outlines, anchors, and the pen path in progress.+ /// The saved path selected in the Paths panel: Photoshop's target path, drawn on the canvas with+ /// any tool (#6550). `None` when the panel selects the work path, a layer's path or nothing.+ pub(crate) fn selected_saved_path(app: &PhotocraftApp) -> Option<&Path> {+ let sel = app.ui.selected_path.as_deref().filter(|s| !matches!(*s, "work" | "layer"))?;+ app.session.active()?.doc.paths.iter().find(|p| p.name == sel).map(|p| &p.path)+ }++ /// Work path / active shape path / selected saved path outlines, anchors, and the pen path in+ /// progress.pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform, doc: &Document) {let tool = app.ui.tool;let accent = Tokens::get(painter.ctx()).accent;@@@ -1009,12 -1013,15 +1021,16 @@@crate::anchor_tools::draw_hover(app, painter, &to_scr, accent, painter.ctx().input(|i| i.modifiers));}} else if paths {- // Paths remain visible as outlines with any tool. Path Selection adds anchor squares; Direct- // Selection has its own overlay above.+ // Paths remain visible as outlines with any tool. Path Selection and the Pen tools add+ // anchor squares; Direct Selection has its own overlay above.+ let anchors = shows_anchors(tool);if let Some(wp) = &doc.work_path {- draw_path(wp, tool == Tool::PathSelection);+ draw_path(wp, anchors);}+ // The saved path selected in the Paths panel is the target path (#6550).+ if let Some(p) = selected_saved_path(app) {- draw_path(p, tool == Tool::PathSelection);++ draw_path(p, anchors);+ }let st = app.session.active();if let Some(l) = st.and_then(|s| s.active_layer.and_then(|id| s.doc.layer(id)))&& let LayerContent::Shape(sh) = &l.content