Skip to content

Commit b4fc3d0

Browse files
Desktop: Fix pivot and axis constraint overlays (#3463)
* fix pivot gizmo native dowel_pin overlay * fix native snapping overlay
1 parent 8208653 commit b4fc3d0

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

editor/src/messages/portfolio/document/overlays/utility_types_native.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -804,34 +804,32 @@ impl OverlayContextInternal {
804804

805805
let transform = self.get_transform();
806806

807-
// Draw the background circle with a white fill and colored outline
808807
let circle = kurbo::Circle::new((x, y), DOWEL_PIN_RADIUS);
809808
self.scene.fill(peniko::Fill::NonZero, transform, Self::parse_color(COLOR_OVERLAY_WHITE), None, &circle);
810809
self.scene.stroke(&kurbo::Stroke::new(1.), transform, Self::parse_color(color), None, &circle);
811810

812-
// Draw the two filled sectors using paths
813811
let mut path = BezPath::new();
814812

815-
// Top-left sector
813+
let start1 = FRAC_PI_2 + angle;
814+
let start1_x = x + DOWEL_PIN_RADIUS * start1.cos();
815+
let start1_y = y + DOWEL_PIN_RADIUS * start1.sin();
816816
path.move_to(kurbo::Point::new(x, y));
817-
let end_x = x + DOWEL_PIN_RADIUS * (FRAC_PI_2 + angle.cos());
818-
let end_y = y + DOWEL_PIN_RADIUS * (FRAC_PI_2 + angle.sin());
819-
path.line_to(kurbo::Point::new(end_x, end_y));
820-
// Draw arc manually
821-
let arc = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), FRAC_PI_2 + angle, FRAC_PI_2, 0.0);
822-
arc.to_cubic_beziers(0.1, |p1, p2, p| {
817+
path.line_to(kurbo::Point::new(start1_x, start1_y));
818+
819+
let arc1 = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), start1, FRAC_PI_2, 0.0);
820+
arc1.to_cubic_beziers(0.1, |p1, p2, p| {
823821
path.curve_to(p1, p2, p);
824822
});
825823
path.close_path();
826824

827-
// Bottom-right sector
825+
let start2 = PI + FRAC_PI_2 + angle;
826+
let start2_x = x + DOWEL_PIN_RADIUS * start2.cos();
827+
let start2_y = y + DOWEL_PIN_RADIUS * start2.sin();
828828
path.move_to(kurbo::Point::new(x, y));
829-
let end_x = x + DOWEL_PIN_RADIUS * (PI + FRAC_PI_2 + angle.cos());
830-
let end_y = y + DOWEL_PIN_RADIUS * (PI + FRAC_PI_2 + angle.sin());
831-
path.line_to(kurbo::Point::new(end_x, end_y));
832-
// Draw arc manually
833-
let arc = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), PI + FRAC_PI_2 + angle, FRAC_PI_2, 0.0);
834-
arc.to_cubic_beziers(0.1, |p1, p2, p| {
829+
path.line_to(kurbo::Point::new(start2_x, start2_y));
830+
831+
let arc2 = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), start2, FRAC_PI_2, 0.0);
832+
arc2.to_cubic_beziers(0.1, |p1, p2, p| {
835833
path.curve_to(p1, p2, p);
836834
});
837835
path.close_path();

editor/src/messages/tool/tool_messages/select_tool.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ struct SelectToolData {
400400
selected_layers_changed: bool,
401401
snap_candidates: Vec<SnapCandidatePoint>,
402402
auto_panning: AutoPanning,
403+
drag_start_center: ViewportPosition,
403404
}
404405

405406
impl SelectToolData {
@@ -911,11 +912,10 @@ impl Fsm for SelectToolFsmState {
911912
let angle = -mouse_position.angle_to(DVec2::X);
912913
let snapped_angle = (angle / snap_resolution).round() * snap_resolution;
913914

914-
let extension = tool_data.drag_current - tool_data.drag_start;
915-
let origin = compass_center - extension;
915+
let origin = tool_data.drag_start_center;
916916
let viewport_diagonal = viewport.size().into_dvec2().length();
917917

918-
let edge = DVec2::from_angle(snapped_angle).normalize_or(DVec2::X) * viewport_diagonal;
918+
let edge = DVec2::from_angle(snapped_angle).normalize_or(DVec2::X);
919919
let perp = edge.perp();
920920

921921
let (edge_color, perp_color) = if edge.x.abs() > edge.y.abs() {
@@ -1032,6 +1032,8 @@ impl Fsm for SelectToolFsmState {
10321032
let position = tool_data.pivot_gizmo().position(document);
10331033
let (resize, rotate, skew) = transforming_transform_cage(document, &mut tool_data.bounding_box_manager, input, responses, &mut tool_data.layers_dragging, Some(position));
10341034

1035+
tool_data.drag_start_center = position;
1036+
10351037
// If the user is dragging the bounding box bounds, go into ResizingBounds mode.
10361038
// If the user is dragging the rotate trigger, go into RotatingBounds mode.
10371039
// If the user clicks on a layer that is in their current selection, go into the dragging mode.

0 commit comments

Comments
 (0)