mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-06 08:13:40 -10:00
Fix the Gradient tool showing the new gradient's pointer dot over a stop insertion point
This commit is contained in:
1 parent
8d6efb057c
commit
9a574b891c
3 files changed
+41
-2
No files matched your search
@@ -92,6 +92,8 @@ pub struct PointOptions {
|
||||
pub box_features: Option<BoxFeatures>,
|
||||
/// Whether the grid is left out, as for a turn, which the grid would otherwise step at odd angles.
|
||||
pub ignores_grid: bool,
|
||||
/// Whether the tool marks where a press would land in its own way, so nothing marks it there unless a snap is named.
|
||||
pub marked_by_tool: bool,
|
||||
}
|
||||
|
||||
/// Which features of a gesture make up a box.
|
||||
@@ -122,6 +124,8 @@ pub struct Shown {
|
||||
pub features: Vec<DVec2>,
|
||||
/// The index of the feature the pointer carries.
|
||||
pub lead: usize,
|
||||
/// Whether the tool marks where a press would land, as [`PointOptions::marked_by_tool`] tells.
|
||||
pub marked_by_tool: bool,
|
||||
}
|
||||
|
||||
/// What a kept set of constructions was found for, which it stays good for.
|
||||
@@ -321,6 +325,7 @@ impl SnapSession {
|
||||
features: features.iter().map(|feature| feature.position(parameters)).collect(),
|
||||
lead,
|
||||
outcome,
|
||||
marked_by_tool: options.marked_by_tool,
|
||||
});
|
||||
|
||||
// A crossing, or the grid, can hold the box anywhere along the track that evens out its gaps, so they are measured again where it landed
|
||||
@@ -399,6 +404,7 @@ impl SnapSession {
|
||||
features: vec![position_of(snapped)],
|
||||
lead: 0,
|
||||
outcome,
|
||||
marked_by_tool: false,
|
||||
});
|
||||
|
||||
snapped
|
||||
|
||||
@@ -19,14 +19,24 @@ impl SnapSession {
|
||||
self.draw_awake(target, to_viewport, overlay_context);
|
||||
}
|
||||
|
||||
let Some(Shown { outcome, features, lead, .. }) = &self.shown else { return };
|
||||
let Some(Shown {
|
||||
outcome,
|
||||
features,
|
||||
lead,
|
||||
marked_by_tool,
|
||||
}) = &self.shown
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Before a press, the point is marked where the press would place it, even with no snap to name
|
||||
if matches!(outcome.snap, Snap::Grid | Snap::Free)
|
||||
&& self.gesture.is_none()
|
||||
&& let Some(&position) = features.get(*lead)
|
||||
{
|
||||
overlay_context.square(to_viewport.transform_point2(position), Some(4.), Some(COLOR_OVERLAY_BLUE), Some(COLOR_OVERLAY_BLUE));
|
||||
if !marked_by_tool {
|
||||
overlay_context.square(to_viewport.transform_point2(position), Some(4.), Some(COLOR_OVERLAY_BLUE), Some(COLOR_OVERLAY_BLUE));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2272,6 +2272,8 @@ fn snap_onto_line(snap_session: &mut SnapSession, view: SnapView, mouse: DVec2,
|
||||
pointer,
|
||||
PointOptions {
|
||||
required: Some(line),
|
||||
// The insertion guide, or the stop being dragged, marks where it lands
|
||||
marked_by_tool: true,
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
@@ -4829,6 +4831,27 @@ mod test_gradient {
|
||||
assert_curvatures(curvature_values(&editor, curvature_node_id), [0., center_curvature(GradientEnd::End, center + 0.1)], "the slid end");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn only_the_insertion_guide_marks_where_a_press_would_insert_a_stop() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let (layer, _) = fill_gradient_layer(&mut editor).await;
|
||||
let marked_by_tool = |editor: &EditorTestUtils| {
|
||||
let snap_session = &editor.editor.dispatcher.message_handlers.tool_message_handler.snap_session;
|
||||
snap_session.shown().map(|shown| shown.marked_by_tool)
|
||||
};
|
||||
|
||||
// On the line, where a press inserts a stop, the tool marks the spot with its insertion guide rather than the snapping's dot
|
||||
let on_line = gradient_point(&editor, layer, DVec2::new(0.3, 0.));
|
||||
editor.move_mouse(on_line.x, on_line.y, ModifierKeys::empty(), MouseKeys::empty()).await;
|
||||
assert_eq!(marked_by_tool(&editor), Some(true), "the insertion point should be marked by the tool");
|
||||
|
||||
// Off it, where a press draws a new gradient, the snapping's dot marks where it would start
|
||||
let off_line = gradient_point(&editor, layer, DVec2::new(0.3, 0.5));
|
||||
editor.move_mouse(off_line.x, off_line.y, ModifierKeys::empty(), MouseKeys::empty()).await;
|
||||
assert_eq!(marked_by_tool(&editor), Some(false), "a new gradient's start should be marked by the snapping");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn dragging_the_aspect_handle_of_a_fill_gradient_stretches_its_transform() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
|
||||
Reference in new issue
Block a user