mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Guides: ⌥ turns a dragged guide; dropping one on either ruler deletes it (#5034)
As in Photoshop, holding ⌥ while dragging a guide turns it between horizontal and vertical about the pointer, whether it comes out of a ruler or an existing guide is dragged with the Move tool (or ⌘ with another tool); an ⌥-click turns a guide in place, and letting go of ⌥ before the release turns it back. A guide dropped on either ruler is deleted whichever way it runs: before, a horizontal guide dropped on the left ruler was still level with the image and only moved. - engine: `view.moveGuide` takes an optional `toOrientation`, so a turned guide is one undo step and keeps its colour; a % position is of the new axis. - ui: `GuideDrag` keeps the guide's own orientation plus `flipped` (⌥ held) and `over_ruler` (set by the rulers from the pointer each frame); `GuideDrag::track` follows the pointer for both drag paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b8ae1cd92f
commit
4b1bd6fb6d
5 files changed
+208
-26
No files matched your search
@@ -838,7 +838,18 @@ fn guide_color(p: &Value) -> Result<Option<[u8; 3]>> {
|
||||
/// View › New Guide / guide moves (undoable, like Photoshop's "New Guide"/"Move Guide" states).
|
||||
fn guide_cmd(s: &mut Session, p: &Value, op: &str) -> Result<Value> {
|
||||
let vertical = p.get("orientation").and_then(Value::as_str).unwrap_or("horizontal") == "vertical";
|
||||
let pos = guide_position(s, p, vertical)?;
|
||||
// Move Guide can turn the guide (⌥ while dragging it, as in Photoshop): `toOrientation`.
|
||||
let to_vertical = match p.get("toOrientation").map(|v| v.as_str()) {
|
||||
None => vertical,
|
||||
Some(Some("vertical")) => true,
|
||||
Some(Some("horizontal")) => false,
|
||||
Some(_) => return Err(EngineError::Other("`toOrientation` must be \"horizontal\" or \"vertical\"".into())),
|
||||
};
|
||||
if to_vertical != vertical && op != "move" {
|
||||
return Err(EngineError::Other("`toOrientation` applies to view.moveGuide only".into()));
|
||||
}
|
||||
// A % position is of the axis the guide ends up on.
|
||||
let pos = guide_position(s, p, to_vertical)?;
|
||||
let color = if op == "new" { guide_color(p)? } else { None };
|
||||
let index = p.get("index").and_then(Value::as_u64).map(|v| v as usize);
|
||||
let label = match op {
|
||||
@@ -861,10 +872,20 @@ fn guide_cmd(s: &mut Session, p: &Value, op: &str) -> Result<Value> {
|
||||
"move" => {
|
||||
let i = index.filter(|i| *i < g.len()).ok_or(EngineError::Other("no such guide".into()))?;
|
||||
let to = pos.ok_or(EngineError::Other("missing `position`".into()))?;
|
||||
let from = std::mem::replace(&mut g[i], to);
|
||||
let from = if to_vertical == vertical {
|
||||
std::mem::replace(&mut g[i], to)
|
||||
} else {
|
||||
let from = g.remove(i);
|
||||
if to_vertical {
|
||||
guides.vertical.push(to)
|
||||
} else {
|
||||
guides.horizontal.push(to)
|
||||
}
|
||||
from
|
||||
};
|
||||
// The guide takes its colour along; another guide left at the old position keeps it.
|
||||
if let Some(rgb) = guides.color(vertical, from) {
|
||||
guides.set_color(vertical, to, Some(rgb));
|
||||
guides.set_color(to_vertical, to, Some(rgb));
|
||||
}
|
||||
guides.prune_colors();
|
||||
}
|
||||
@@ -1010,7 +1031,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Move Guide",
|
||||
&[],
|
||||
None,
|
||||
r##"{"orientation":"horizontal|vertical","index":n,"position":px or "<number><unit>"} (units as for view.newGuide)"##,
|
||||
r##"{"orientation":"horizontal|vertical","index":n,"position":px or "<number><unit>","toOrientation":"horizontal|vertical"?} (units as for view.newGuide; toOrientation turns the guide, its position then on the new axis)"##,
|
||||
has_doc,
|
||||
|s, p| guide_cmd(s, p, "move")
|
||||
),
|
||||
@@ -1969,6 +1990,35 @@ mod tests {
|
||||
assert!(s.execute("view.moveGuide", json!({"orientation": "vertical", "index": 3, "position": 1})).is_err());
|
||||
}
|
||||
|
||||
/// #5034: Move Guide turns a guide with `toOrientation` (⌥ while dragging it), in one undo
|
||||
/// step, taking its colour along; a % position is of the new axis.
|
||||
#[test]
|
||||
fn move_guide_turns_a_guide() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
s.execute("view.newGuide", json!({"orientation": "horizontal", "position": 30, "color": "magenta"})).unwrap();
|
||||
s.execute("view.newGuide", json!({"orientation": "horizontal", "position": 70})).unwrap();
|
||||
s.execute("view.moveGuide", json!({"orientation": "horizontal", "index": 0, "position": "50%", "toOrientation": "vertical"})).unwrap();
|
||||
let g = &s.active().unwrap().doc.guides;
|
||||
assert_eq!((g.horizontal.clone(), g.vertical.clone()), (vec![70.0], vec![100.0]), "50% of the width");
|
||||
assert_eq!(g.color(true, 100.0), Some([255, 0, 255]), "the colour moves with the guide");
|
||||
assert_eq!(g.color(false, 30.0), None);
|
||||
// The same orientation is a plain move.
|
||||
s.execute("view.moveGuide", json!({"orientation": "vertical", "index": 0, "position": 20, "toOrientation": "vertical"})).unwrap();
|
||||
assert_eq!(s.active().unwrap().doc.guides.vertical, vec![20.0]);
|
||||
s.undo();
|
||||
s.undo();
|
||||
let g = &s.active().unwrap().doc.guides;
|
||||
assert_eq!((g.horizontal.clone(), g.vertical.clone()), (vec![30.0, 70.0], vec![]), "one undo step per move");
|
||||
// Bad params are refused and leave the guides alone.
|
||||
assert!(s.execute("view.moveGuide", json!({"orientation": "horizontal", "index": 0, "position": 5, "toOrientation": "diagonal"})).is_err());
|
||||
assert!(s.execute("view.moveGuide", json!({"orientation": "horizontal", "index": 0, "position": 5, "toOrientation": 1})).is_err());
|
||||
assert!(s.execute("view.newGuide", json!({"orientation": "horizontal", "position": 5, "toOrientation": "vertical"})).is_err());
|
||||
assert!(s.execute("view.moveGuide", json!({"orientation": "horizontal", "index": 9, "position": 5, "toOrientation": "vertical"})).is_err());
|
||||
let g = &s.active().unwrap().doc.guides;
|
||||
assert_eq!((g.horizontal.clone(), g.vertical.clone()), (vec![30.0, 70.0], vec![]));
|
||||
}
|
||||
|
||||
/// #2955: the rulers' zero point is set and reset by command, undoable, and bad params are
|
||||
/// refused without touching the document.
|
||||
#[test]
|
||||
|
||||
@@ -4945,7 +4945,9 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)
|
||||
if let ToolEvent::Down { x, y, .. } = raw
|
||||
&& let Some((vertical, i)) = command_guide_at(app, app.active_tool(), [x, y], mods)
|
||||
{
|
||||
app.guide_drag = Some(crate::rulers::GuideDrag { vertical, index: Some(i), pos: if vertical { x } else { y } });
|
||||
let mut g = crate::rulers::GuideDrag { vertical, index: Some(i), ..Default::default() };
|
||||
g.track([x, y], mods.alt);
|
||||
app.guide_drag = Some(g);
|
||||
crate::snap_ui::begin_guide(app, [x, y]);
|
||||
return;
|
||||
}
|
||||
@@ -4989,7 +4991,10 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)
|
||||
match ev {
|
||||
ToolEvent::Down { x, y, pressure } if tool == Tool::Move => {
|
||||
if let Some((vertical, i)) = crate::rulers::guide_at(app, x, y) {
|
||||
app.guide_drag = Some(crate::rulers::GuideDrag { vertical, index: Some(i), pos: if vertical { x } else { y } });
|
||||
// ⌥ as you press or drag turns the guide, as in Photoshop (#5034).
|
||||
let mut g = crate::rulers::GuideDrag { vertical, index: Some(i), ..Default::default() };
|
||||
g.track([x, y], mods.alt);
|
||||
app.guide_drag = Some(g);
|
||||
return;
|
||||
}
|
||||
// Auto-Select (or ⌘-click while it is off) picks the layer under the pointer first
|
||||
@@ -5048,14 +5053,14 @@ pub fn tool_event(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers)
|
||||
}
|
||||
ToolEvent::Move { x, y, .. } => {
|
||||
if let Some(d) = app.guide_drag.as_mut().filter(|d| d.index.is_some()) {
|
||||
d.pos = if d.vertical { x } else { y };
|
||||
d.track([x, y], mods.alt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ToolEvent::Up { x, y } => {
|
||||
if let Some(mut d) = app.guide_drag.filter(|d| d.index.is_some()) {
|
||||
app.guide_drag = None;
|
||||
d.pos = if d.vertical { x } else { y };
|
||||
d.track([x, y], mods.alt);
|
||||
crate::rulers::finish_drag(app, d);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ mod tests {
|
||||
assert_eq!(active_outline(&mut app, None, false, false), Some(a));
|
||||
|
||||
// When a drag or transform is in progress, no outline:
|
||||
app.guide_drag = Some(crate::rulers::GuideDrag { vertical: false, index: None, pos: 10.0 });
|
||||
app.guide_drag = Some(crate::rulers::GuideDrag { vertical: false, index: None, pos: 10.0, ..Default::default() });
|
||||
assert_eq!(active_outline(&mut app, None, false, false), None);
|
||||
app.guide_drag = None;
|
||||
|
||||
|
||||
+141
-16
@@ -88,11 +88,32 @@ pub(crate) fn unit_menu(ui: &mut egui::Ui, current: Unit) -> Option<&'static str
|
||||
}
|
||||
|
||||
/// A guide being dragged: from a ruler (new) or an existing one (index).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct GuideDrag {
|
||||
/// The ruler's orientation for a new guide, the guide's own for an existing one (`index`
|
||||
/// is into that list).
|
||||
pub vertical: bool,
|
||||
pub index: Option<usize>,
|
||||
/// Where it is, along the axis it [`shows`](Self::shows_vertical).
|
||||
pub pos: f64,
|
||||
/// ⌥ is held: the guide turns, as in Photoshop (a vertical one drags horizontal and back).
|
||||
pub flipped: bool,
|
||||
/// The pointer is over a ruler: dropped there, an existing guide is deleted whichever way
|
||||
/// it runs (#5034).
|
||||
pub over_ruler: bool,
|
||||
}
|
||||
|
||||
impl GuideDrag {
|
||||
/// The orientation the guide is drawn and dropped with.
|
||||
pub fn shows_vertical(&self) -> bool {
|
||||
self.vertical != self.flipped
|
||||
}
|
||||
|
||||
/// Follow the pointer at document point `at`, turned while `alt` is held.
|
||||
pub fn track(&mut self, at: [f64; 2], alt: bool) {
|
||||
self.flipped = alt;
|
||||
self.pos = if self.shows_vertical() { at[0] } else { at[1] };
|
||||
}
|
||||
}
|
||||
|
||||
/// Canvas area left after the rulers.
|
||||
@@ -187,7 +208,7 @@ pub fn draw_guides(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform,
|
||||
if let Some(d) = drag {
|
||||
// A guide being moved shows its own colour; a new one dragged from a ruler the preference's.
|
||||
let list = if d.vertical { &doc.guides.vertical } else { &doc.guides.horizontal };
|
||||
line(d.vertical, d.pos, d.index.and_then(|i| list.get(i)).map_or(guide, |p| own(d.vertical, *p)));
|
||||
line(d.shows_vertical(), d.pos, d.index.and_then(|i| list.get(i)).map_or(guide, |p| own(d.vertical, *p)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,16 +234,19 @@ pub fn guide_at(app: &PhotocraftApp, x: f64, y: f64) -> Option<(bool, usize)> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Finish a guide drag: create, move, or delete (dropped outside the canvas).
|
||||
/// Finish a guide drag: create, move (turned, with ⌥), or delete (dropped outside the canvas or
|
||||
/// on a ruler).
|
||||
pub fn finish_drag(app: &mut PhotocraftApp, d: GuideDrag) {
|
||||
let Some(size) = app.session.active().map(|s| s.doc.size) else { return };
|
||||
let extent = if d.vertical { size.width } else { size.height } as f64;
|
||||
let orientation = if d.vertical { "vertical" } else { "horizontal" };
|
||||
let inside = d.pos >= 0.0 && d.pos <= extent;
|
||||
let shows = d.shows_vertical();
|
||||
let extent = if shows { size.width } else { size.height } as f64;
|
||||
let name = |vertical: bool| if vertical { "vertical" } else { "horizontal" };
|
||||
let orientation = name(d.vertical);
|
||||
let inside = d.pos >= 0.0 && d.pos <= extent && !d.over_ruler;
|
||||
let pos = (d.pos * 1000.0).round() / 1000.0;
|
||||
let _ = match (d.index, inside) {
|
||||
(None, true) => app.run("view.newGuide", json!({"orientation": orientation, "position": pos})),
|
||||
(Some(i), true) => app.run("view.moveGuide", json!({"orientation": orientation, "index": i, "position": pos})),
|
||||
(None, true) => app.run("view.newGuide", json!({"orientation": name(shows), "position": pos})),
|
||||
(Some(i), true) => app.run("view.moveGuide", json!({"orientation": orientation, "index": i, "position": pos, "toOrientation": name(shows)})),
|
||||
(Some(i), false) => app.run("view.deleteGuide", json!({"orientation": orientation, "index": i})),
|
||||
(None, false) => Ok(serde_json::Value::Null),
|
||||
};
|
||||
@@ -331,6 +355,11 @@ pub fn draw_rulers(app: &mut PhotocraftApp, ui: &mut egui::Ui, full: Rect, xf: &
|
||||
let top = Rect::from_min_max(pos2(full.left() + RULER, full.top()), pos2(full.right(), full.top() + RULER));
|
||||
let left = Rect::from_min_max(pos2(full.left(), full.top() + RULER), pos2(full.left() + RULER, full.bottom()));
|
||||
let corner = Rect::from_min_size(full.min, vec2(RULER, RULER));
|
||||
// A guide dragged onto either ruler is deleted when dropped there (`finish_drag`); the
|
||||
// release is handled before this frame's rulers, so it reads the last frame's answer.
|
||||
if let Some(g) = app.guide_drag.as_mut() {
|
||||
g.over_ruler = ui.ctx().pointer_latest_pos().is_some_and(|p| [top, left, corner].iter().any(|r| r.contains(p)));
|
||||
}
|
||||
let p = ui.painter_at(full);
|
||||
let bg = t.chrome;
|
||||
for r in [top, left, corner] {
|
||||
@@ -399,10 +428,13 @@ pub fn draw_rulers(app: &mut PhotocraftApp, ui: &mut egui::Ui, full: Rect, xf: &
|
||||
ui.ctx().set_cursor_icon(if vertical { egui::CursorIcon::ResizeHorizontal } else { egui::CursorIcon::ResizeVertical });
|
||||
}
|
||||
if let Some(pos) = resp.interact_pointer_pos().filter(|_| salt != "ruler-corner" && (resp.dragged() || resp.drag_started())) {
|
||||
let d = xf.to_doc(pos);
|
||||
let along = if vertical { d[0] } else { d[1] };
|
||||
let pos = if ui.input(|i| i.modifiers.shift) { snap_to_tick(app, xf, vertical, along) } else { crate::snap_ui::snap_guide(app, vertical, along) };
|
||||
app.guide_drag = Some(GuideDrag { vertical, index: None, pos });
|
||||
// ⌥ turns the new guide: from the top ruler it comes out vertical, as in Photoshop.
|
||||
let mods = ui.input(|i| i.modifiers);
|
||||
let mut g = GuideDrag { vertical, over_ruler: app.guide_drag.is_some_and(|g| g.over_ruler), ..Default::default() };
|
||||
g.track(xf.to_doc(pos), mods.alt);
|
||||
let shows = g.shows_vertical();
|
||||
g.pos = if mods.shift { snap_to_tick(app, xf, shows, g.pos) } else { crate::snap_ui::snap_guide(app, shows, g.pos) };
|
||||
app.guide_drag = Some(g);
|
||||
}
|
||||
if resp.drag_stopped()
|
||||
&& let Some(d) = app.guide_drag.take()
|
||||
@@ -757,14 +789,14 @@ mod tests {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.session.execute("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
app.sync_views();
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: None, pos: 50.0 });
|
||||
finish_drag(&mut app, GuideDrag { vertical: false, index: None, pos: 500.0 }); // off canvas: ignored
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: None, pos: 50.0, ..Default::default() });
|
||||
finish_drag(&mut app, GuideDrag { vertical: false, index: None, pos: 500.0, ..Default::default() }); // off canvas: ignored
|
||||
assert_eq!(app.session.active().unwrap().doc.guides.vertical, vec![50.0]);
|
||||
assert!(app.session.active().unwrap().doc.guides.horizontal.is_empty());
|
||||
assert_eq!(guide_at(&app, 51.0, 10.0), Some((true, 0)));
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: 120.0 });
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: 120.0, ..Default::default() });
|
||||
assert_eq!(app.session.active().unwrap().doc.guides.vertical, vec![120.0]);
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: -30.0 });
|
||||
finish_drag(&mut app, GuideDrag { vertical: true, index: Some(0), pos: -30.0, ..Default::default() });
|
||||
assert!(app.session.active().unwrap().doc.guides.vertical.is_empty());
|
||||
app.ui.extras.lock_guides = true;
|
||||
assert_eq!(guide_at(&app, 0.0, 0.0), None);
|
||||
@@ -948,4 +980,97 @@ mod tests {
|
||||
assert_eq!(snap_to_tick(&app, &xf, true, 37.0), 33.0);
|
||||
assert_eq!(snap_to_tick(&app, &xf, false, 37.0), 40.0);
|
||||
}
|
||||
|
||||
/// #5034: ⌥ turns a guide dragged out of a ruler, as in Photoshop: out of the left ruler it
|
||||
/// comes out horizontal, at the pointer's y.
|
||||
#[test]
|
||||
fn alt_turns_a_guide_dragged_out_of_a_ruler() {
|
||||
let full = Rect::from_min_size(Pos2::ZERO, vec2(400.0, 300.0));
|
||||
let rect = Rect::from_min_max(full.min + vec2(RULER, RULER), full.max);
|
||||
let xf = ViewXform { rect, zoom: 1.0, center: [128.0, 64.0], flip: false, rotation: 0.0, aspect: 1.0 };
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 256, "height": 128})).unwrap();
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(400.0, 300.0)).build_ui_state(move |ui, app| draw_rulers(app, ui, full, &xf), app);
|
||||
// ⌥ held for the whole drag (`event_modifiers` would let go of it after each event).
|
||||
let alt = egui::Modifiers::ALT;
|
||||
h.event(egui::Event::ModifiersChanged(alt));
|
||||
let (from, to) = (pos2(RULER / 2.0, 100.0), xf.to_screen(37.0, 51.0));
|
||||
h.event(egui::Event::PointerMoved(from));
|
||||
h.event(egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers: alt });
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerMoved(to));
|
||||
h.run_steps(1);
|
||||
assert!(h.state().guide_drag.is_some_and(|d| !d.shows_vertical()), "drawn horizontal while ⌥ is held");
|
||||
h.event(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: alt });
|
||||
h.run_steps(2);
|
||||
let g = &h.state().session.active().unwrap().doc.guides;
|
||||
assert_eq!((g.vertical.clone(), g.horizontal.clone()), (vec![], vec![51.0]));
|
||||
}
|
||||
|
||||
/// #5034: with the Move tool, ⌥ while dragging a guide turns it about the pointer, in one
|
||||
/// undo step; letting go of ⌥ before the release turns it back. An ⌥-click turns it in place.
|
||||
#[test]
|
||||
fn alt_turns_a_guide_moved_with_the_move_tool() {
|
||||
use crate::canvas::{ToolEvent, tool_event};
|
||||
let new_app = || {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 80, "height": 60})).unwrap();
|
||||
app.sync_views();
|
||||
app.ui.tool = crate::state::Tool::Move;
|
||||
app.run("view.newGuide", json!({"orientation": "vertical", "position": 50})).unwrap();
|
||||
app
|
||||
};
|
||||
let guides = |app: &PhotocraftApp| {
|
||||
let g = &app.session.active().unwrap().doc.guides;
|
||||
(g.vertical.clone(), g.horizontal.clone())
|
||||
};
|
||||
let (none, alt) = (egui::Modifiers::NONE, egui::Modifiers::ALT);
|
||||
|
||||
let mut app = new_app();
|
||||
tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 44.0, pressure: 1.0 }, none);
|
||||
tool_event(&mut app, ToolEvent::Move { x: 63.0, y: 17.0, pressure: 1.0 }, alt);
|
||||
assert!(app.guide_drag.is_some_and(|d| !d.shows_vertical() && d.pos == 17.0));
|
||||
tool_event(&mut app, ToolEvent::Up { x: 63.0, y: 17.0 }, alt);
|
||||
assert_eq!(guides(&app), (vec![], vec![17.0]));
|
||||
assert!(app.session.undo());
|
||||
assert_eq!(guides(&app), (vec![50.0], vec![]), "one undo step");
|
||||
|
||||
// ⌥ let go before the release: still vertical, moved along x.
|
||||
let mut app = new_app();
|
||||
tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 44.0, pressure: 1.0 }, none);
|
||||
tool_event(&mut app, ToolEvent::Move { x: 63.0, y: 17.0, pressure: 1.0 }, alt);
|
||||
tool_event(&mut app, ToolEvent::Up { x: 63.0, y: 17.0 }, none);
|
||||
assert_eq!(guides(&app), (vec![63.0], vec![]));
|
||||
|
||||
// An ⌥-click turns the guide where it was clicked.
|
||||
let mut app = new_app();
|
||||
tool_event(&mut app, ToolEvent::Down { x: 50.0, y: 44.0, pressure: 1.0 }, alt);
|
||||
tool_event(&mut app, ToolEvent::Up { x: 50.0, y: 44.0 }, alt);
|
||||
assert_eq!(guides(&app), (vec![], vec![44.0]));
|
||||
}
|
||||
|
||||
/// #5034: a guide dropped on either ruler is deleted, whichever way it runs; a horizontal
|
||||
/// guide over the left ruler is still level with the image, so this needs the pointer.
|
||||
#[test]
|
||||
fn a_guide_dropped_on_either_ruler_is_deleted() {
|
||||
let full = Rect::from_min_size(Pos2::ZERO, vec2(400.0, 300.0));
|
||||
let rect = Rect::from_min_max(full.min + vec2(RULER, RULER), full.max);
|
||||
let xf = ViewXform { rect, zoom: 1.0, center: [128.0, 64.0], flip: false, rotation: 0.0, aspect: 1.0 };
|
||||
for (pointer, over) in [(pos2(RULER / 2.0, 150.0), true), (pos2(200.0, RULER / 2.0), true), (pos2(200.0, 150.0), false)] {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 256, "height": 128})).unwrap();
|
||||
app.run("view.newGuide", json!({"orientation": "horizontal", "position": 30})).unwrap();
|
||||
app.guide_drag = Some(GuideDrag { vertical: false, index: Some(0), pos: 64.0, ..Default::default() });
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(400.0, 300.0)).build_ui_state(move |ui, app| draw_rulers(app, ui, full, &xf), app);
|
||||
h.event(egui::Event::PointerMoved(pointer));
|
||||
h.run_steps(1);
|
||||
let d = h.state().guide_drag.unwrap();
|
||||
assert_eq!(d.over_ruler, over, "{pointer:?}");
|
||||
let app = h.state_mut();
|
||||
app.guide_drag = None;
|
||||
finish_drag(app, d);
|
||||
let left = app.session.active().unwrap().doc.guides.horizontal.clone();
|
||||
assert_eq!(left, if over { vec![] } else { vec![64.0] }, "{pointer:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
# UI parity: tools, handles, modifiers and feel
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (⌥ turns a dragged guide and either ruler deletes one, #5034; earlier: smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
|
||||
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,
|
||||
@@ -151,6 +151,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme
|
||||
| Smart guide distance and spacing labels | missing | |
|
||||
| Ruler units px/in/cm/mm/pt/pica/% | done | |
|
||||
| ⇧-drag a guide out of a ruler: it lands on the nearest ruler tick | done | `rulers.rs` `snap_to_tick` (#3770) |
|
||||
| ⌥ while dragging a guide (out of a ruler, or with the Move tool) turns it; a guide dropped on either ruler is deleted | done | `rulers.rs` `GuideDrag::track`, `view.moveGuide` `toOrientation` (#5034) |
|
||||
| Status bar follows the ruler unit | partial | #2602 |
|
||||
| Ruler corner and gaps drawn as Photoshop | partial | #2600, #2601, #2551 |
|
||||
| Guides stored as f64 | missing | `Vec<f32>` (UI-217-20) |
|
||||
@@ -217,6 +218,7 @@ Paragraph; the rest open as in-app floating windows.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-14 | minor | ⌥ while dragging a guide turns it horizontal ↔ vertical, as in Photoshop; a guide dropped on either ruler is deleted (#5034) |
|
||||
| 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the P flyout cycle) are live toolbar tools, so only Art History Brush is missing; no percentage or estimate changed |
|
||||
| 2026-10-13 | minor | Smart object perspective (non-affine) corrected to done: #426 landed four-corner placements with PSD round trip; scorecard FILE-215-6 flipped |
|
||||
| 2026-10-10 | major | First version, from a source audit against Photoshop 2026 27.11.0's shortcuts file and the open issues |
|
||||
|
||||
Reference in new issue
Block a user