PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #7902: Slice Select: the selected slice's handles resize it (#7863)
aiongg0c965366d5e8
diff --cc crates/ui-egui/src/slice_ui.rsindex 983cdda73,775af8131..32945c81b--- a/crates/ui-egui/src/slice_ui.rs+++ b/crates/ui-egui/src/slice_ui.rs@@@ -60,17 -119,22 +119,27 @@@ pub fn pointer(app: &mut PhotocraftApplet Some(doc) = app.session.active().map(|d| d.doc.clone()) else { return true };let locked = app.session.file_menu.slices_locked;match ev {+ // View › Lock Slices: neither tool draws, selects or moves a slice, and the press says+ // why, as Photoshop's error does (#7865).+ ToolEvent::Down { .. } if locked => {+ app.ui.slices.selected = None;+ app.ui.status = tl!("Slices are locked (View › Lock Slices)").to_string();+ app.ui.status_error = true;+ }ToolEvent::Down { x, y, .. } => {if tool == Tool::Slice {- if !locked {- app.ui.slices.drag = Some(SliceDrag::New { start: [x, y], cur: [x, y] });- }+ app.ui.slices.drag = Some(SliceDrag::New { start: [x, y], cur: [x, y] });} else {+ // A handle of the selected user slice resizes it (#7863).+ let reach = HANDLE_REACH / f64::from(app.point_zoom().max(0.01));+ let grabbed = app.ui.slices.selected.filter(|_| !locked).and_then(|n| {+ let r = slices::resolve(&doc).into_iter().find(|r| r.number == n && r.origin == SliceOrigin::User)?;+ Some((r.id?, r.rect, handle_at(r.rect, [x, y], reach)?))+ });+ if let Some((id, rect, handle)) = grabbed {+ app.ui.slices.drag = Some(SliceDrag::Resize { id, handle, start: [x, y], cur: [x, y], rect });+ return true;+ }let hit = slice_at(&doc, x, y);app.ui.slices.selected = hit.as_ref().map(|r| r.number);// The whole slice moves, also when the press hits one piece of a covered slice.