Address CodeRabbit review: no path pointer while a text box is dragged out (#6230)

Dragging out a paragraph box with the Type tool sets app.drag and no type
edit is open yet, so the hover lookup showed the area-type or path-type
pointer over a path although the release makes a box. hover_path_target now
returns nothing during a drag or an open type edit (the edit check moved in
from canvas.rs), and a test drives a drag over a shape.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Mann
2026-10-23 00:30:36 +02:00
co-authored by Claude Opus 5.5
parent 72bafe9d25
commit 81bcf7f3df
3 changed files with 26 additions and 4 deletions
+3 -3
View File
@@ -4639,9 +4639,9 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
draw_clone_preview(app, &painter, &xf, xf.to_doc(p), output);
}
// The Type tool over a path shows Photoshop's area-type or type-on-a-path pointer (#218).
// Not while a type edit is open (a click then commits rather than starting new type),
// nor over type a click would edit.
let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) && app.ui.text_edit.is_none() {
// Not while a type edit is open or a text box is dragged out, nor over type a click
// would edit (`hover_path_target`).
let type_path = if matches!(tool, Tool::Type | Tool::VerticalType) {
let [x, y] = xf.to_doc(p);
let shift = crate::workspace_ui::sticky_mods(app, ui.input(|i| i.modifiers)).shift;
crate::type_tool::hover_path_target(app, x, y, shift)
+6 -1
View File
@@ -459,8 +459,13 @@ pub(crate) fn path_target(app: &PhotocraftApp, x: f64, y: f64) -> Option<PathCli
/// What the Type tool's pointer over document `(x, y)` shows (#218): the path click a press there
/// would make, unless the press edits the type layer under it instead (`pointer_down`: an
/// unshifted press on shown type), where Photoshop keeps the plain I-beam. The type hit is only
/// tested over a path, so a hover elsewhere lays out nothing.
/// tested over a path, so a hover elsewhere lays out nothing. Nothing while a type edit is open
/// (a click then commits rather than starting new type) or during a drag (dragging out a text
/// box, whose release makes a box, not path type).
pub(crate) fn hover_path_target(app: &mut PhotocraftApp, x: f64, y: f64, shift: bool) -> Option<PathClick> {
if app.ui.text_edit.is_some() || app.drag.is_some() {
return None;
}
let target = path_target(app, x, y)?;
(shift || hit_layer(app, x, y).is_none()).then_some(target)
}
+17
View File
@@ -2837,6 +2837,23 @@ fn clicking_on_a_path_outline_starts_type_on_the_path_where_clicked() {
);
}
/// The path pointer shows what a click would do: none while a text box is dragged out over a
/// path (the release makes a box) or while a type edit is open (a click commits).
#[test]
fn the_path_pointer_is_off_while_dragging_a_text_box_or_editing() {
use crate::canvas::{ToolEvent, tool_event};
let mut app = new_app();
ellipse_layer(&mut app);
assert!(matches!(super::hover_path_target(&mut app, 400.0, 350.0, false), Some(PathClick::Area { .. })), "a hover inside the shape");
tool_event(&mut app, ToolEvent::Down { x: 1200.0, y: 700.0, pressure: 1.0 }, Modifiers::NONE);
tool_event(&mut app, ToolEvent::Move { x: 400.0, y: 350.0, pressure: 1.0 }, Modifiers::NONE);
assert!(app.drag.is_some(), "dragging out a box");
assert!(super::hover_path_target(&mut app, 400.0, 350.0, false).is_none(), "the drag makes a box, not area type");
tool_event(&mut app, ToolEvent::Up { x: 400.0, y: 350.0 }, Modifiers::NONE);
assert!(app.ui.text_edit.is_some(), "the box is being edited");
assert!(super::hover_path_target(&mut app, 400.0, 350.0, false).is_none(), "a click now commits");
}
#[test]
fn click_outside_paths_still_makes_point_text() {
use photocraft_doc::text::TextShape;