Skip to content

Gradient tool snapping with locked angle #4613

Description

@0HyperCube

Reproduction

  1. New document
  2. Draw rectangle
  3. Use the gradient tool to draw a gradient
  4. Press Ctrl or Shift to lock the angle
  5. Observe how the snapping to the rectangle no longer occurs and any old overlays get stuck until finishing the drag

Video

gradient_no_constrained_snapping.mp4

Relevant code

The line tool uses SnapConstraint::Line to snap when constrained to an angle:

if constrained {
let constraint = SnapConstraint::Line {
origin: document_points[0],
direction: document_points[1] - document_points[0],
};
if center {
let snapped = snap.constrained_snap(&snap_data, &near_point, constraint, config);
let snapped_far = snap.constrained_snap(&snap_data, &far_point, constraint, config);

The gradient tool completely ignores snapping when an angle constraint exists:

pub fn update_gradient(
&mut self,
mut mouse: DVec2,
responses: &mut VecDeque<Message>,
snap_rotate: bool,
lock_angle: bool,
gradient_form: GradientForm,
drag_start: DVec2,
snap_data: SnapData,
snap_manager: &mut SnapManager,
gradient_angle: &mut f64,
) {

if (lock_angle || snap_rotate) && matches!(self.dragging, GradientDragTarget::End | GradientDragTarget::Start | GradientDragTarget::New) {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions