diff --git a/editor/src/messages/portfolio/document/overlays/utility_types_native.rs b/editor/src/messages/portfolio/document/overlays/utility_types_native.rs index 3a0b40ce..1e86778f 100644 --- a/editor/src/messages/portfolio/document/overlays/utility_types_native.rs +++ b/editor/src/messages/portfolio/document/overlays/utility_types_native.rs @@ -804,34 +804,32 @@ impl OverlayContextInternal { let transform = self.get_transform(); - // Draw the background circle with a white fill and colored outline let circle = kurbo::Circle::new((x, y), DOWEL_PIN_RADIUS); self.scene.fill(peniko::Fill::NonZero, transform, Self::parse_color(COLOR_OVERLAY_WHITE), None, &circle); self.scene.stroke(&kurbo::Stroke::new(1.), transform, Self::parse_color(color), None, &circle); - // Draw the two filled sectors using paths let mut path = BezPath::new(); - // Top-left sector + let start1 = FRAC_PI_2 + angle; + let start1_x = x + DOWEL_PIN_RADIUS * start1.cos(); + let start1_y = y + DOWEL_PIN_RADIUS * start1.sin(); path.move_to(kurbo::Point::new(x, y)); - let end_x = x + DOWEL_PIN_RADIUS * (FRAC_PI_2 + angle.cos()); - let end_y = y + DOWEL_PIN_RADIUS * (FRAC_PI_2 + angle.sin()); - path.line_to(kurbo::Point::new(end_x, end_y)); - // Draw arc manually - let arc = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), FRAC_PI_2 + angle, FRAC_PI_2, 0.0); - arc.to_cubic_beziers(0.1, |p1, p2, p| { + path.line_to(kurbo::Point::new(start1_x, start1_y)); + + let arc1 = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), start1, FRAC_PI_2, 0.0); + arc1.to_cubic_beziers(0.1, |p1, p2, p| { path.curve_to(p1, p2, p); }); path.close_path(); - // Bottom-right sector + let start2 = PI + FRAC_PI_2 + angle; + let start2_x = x + DOWEL_PIN_RADIUS * start2.cos(); + let start2_y = y + DOWEL_PIN_RADIUS * start2.sin(); path.move_to(kurbo::Point::new(x, y)); - let end_x = x + DOWEL_PIN_RADIUS * (PI + FRAC_PI_2 + angle.cos()); - let end_y = y + DOWEL_PIN_RADIUS * (PI + FRAC_PI_2 + angle.sin()); - path.line_to(kurbo::Point::new(end_x, end_y)); - // Draw arc manually - let arc = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), PI + FRAC_PI_2 + angle, FRAC_PI_2, 0.0); - arc.to_cubic_beziers(0.1, |p1, p2, p| { + path.line_to(kurbo::Point::new(start2_x, start2_y)); + + let arc2 = kurbo::Arc::new((x, y), (DOWEL_PIN_RADIUS, DOWEL_PIN_RADIUS), start2, FRAC_PI_2, 0.0); + arc2.to_cubic_beziers(0.1, |p1, p2, p| { path.curve_to(p1, p2, p); }); path.close_path(); diff --git a/editor/src/messages/tool/tool_messages/select_tool.rs b/editor/src/messages/tool/tool_messages/select_tool.rs index 3a19f4a3..97c42f86 100644 --- a/editor/src/messages/tool/tool_messages/select_tool.rs +++ b/editor/src/messages/tool/tool_messages/select_tool.rs @@ -400,6 +400,7 @@ struct SelectToolData { selected_layers_changed: bool, snap_candidates: Vec, auto_panning: AutoPanning, + drag_start_center: ViewportPosition, } impl SelectToolData { @@ -911,11 +912,10 @@ impl Fsm for SelectToolFsmState { let angle = -mouse_position.angle_to(DVec2::X); let snapped_angle = (angle / snap_resolution).round() * snap_resolution; - let extension = tool_data.drag_current - tool_data.drag_start; - let origin = compass_center - extension; + let origin = tool_data.drag_start_center; let viewport_diagonal = viewport.size().into_dvec2().length(); - let edge = DVec2::from_angle(snapped_angle).normalize_or(DVec2::X) * viewport_diagonal; + let edge = DVec2::from_angle(snapped_angle).normalize_or(DVec2::X); let perp = edge.perp(); let (edge_color, perp_color) = if edge.x.abs() > edge.y.abs() { @@ -1032,6 +1032,8 @@ impl Fsm for SelectToolFsmState { let position = tool_data.pivot_gizmo().position(document); let (resize, rotate, skew) = transforming_transform_cage(document, &mut tool_data.bounding_box_manager, input, responses, &mut tool_data.layers_dragging, Some(position)); + tool_data.drag_start_center = position; + // If the user is dragging the bounding box bounds, go into ResizingBounds mode. // If the user is dragging the rotate trigger, go into RotatingBounds mode. // If the user clicks on a layer that is in their current selection, go into the dragging mode.