Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #8296: fix(ui): Free Transform corners show the diagonal resize arrow on wide or tall boxes

aiongg1273077cda97
diff --cc crates/ui-egui/src/type_transform.rs
index 0a48d8449,72c5c05d3..8144a7991
--- a/crates/ui-egui/src/type_transform.rs
+++ b/crates/ui-egui/src/type_transform.rs
@@@ -446,20 -380,13 +446,16 @@@ pub(crate) fn cursor(app: &mut Photocra
if !visible(app, mods) {
let id = LayerId(app.ui.text_edit.as_ref()?.layer);
let q = xf.to_doc(p);
- let handle = crate::type_tool::box_handle_at(app, id, q[0], q[1])?;
+ let Some(handle) = crate::type_tool::box_handle_at(app, id, q[0], q[1]) else {
+ // Just outside the text a press moves it (#5956): the Move cursor, as in Photoshop.
+ return move_zone(app, q).map(|_| CursorIcon::Move);
+ };
let t = frame(app)?;
- let direction = if handle < 4 {
- let a = *t.quad.get(usize::from(handle))?;
- let b = *t.quad.get((usize::from(handle) + 2) % 4)?;
- [a[0] - b[0], a[1] - b[1]]
- } else {
- let b = if handle.is_multiple_of(2) { t.quad[3] } else { t.quad[1] };
- [b[0] - t.quad[0][0], b[1] - t.quad[0][1]]
- };
- return Some(crate::tool_cursor::resize(direction, xf));
+ if handle < 4 {
+ return Some(crate::tool_cursor::corner_resize(&t.quad, usize::from(handle), xf));
+ }
+ let b = if handle.is_multiple_of(2) { t.quad[3] } else { t.quad[1] };
+ return Some(crate::tool_cursor::resize([b[0] - t.quad[0][0], b[1] - t.quad[0][1]], xf));
}
let Some(t) = frame(app) else { return Some(CursorIcon::Default) };
let h = app.ui.type_transform.as_ref().map(|t| t.gesture.hit).or_else(|| hit(app, &t, xf.to_doc(p)));