Skip to content

Commit ba5aa04

Browse files
committed
Added more overlay checks on anchors and handles
1 parent 3beb5cf commit ba5aa04

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub fn path_overlays(document: &DocumentMessageHandler, draw_handles: DrawHandle
174174
}
175175

176176
pub fn path_endpoint_overlays(document: &DocumentMessageHandler, shape_editor: &mut ShapeState, overlay_context: &mut OverlayContext, preferences: &PreferencesMessageHandler) {
177-
if !overlay_context.overlays_visibility_settings.path {
177+
if !overlay_context.overlays_visibility_settings.anchors {
178178
return;
179179
}
180180

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ impl Fsm for GradientToolFsmState {
252252
(_, GradientToolMessage::Overlays(mut overlay_context)) => {
253253
let selected = tool_data.selected_gradient.as_ref();
254254

255+
let display_handles = overlay_context.overlays_visibility_settings.handles;
256+
255257
for layer in document.network_interface.selected_nodes().selected_visible_layers(&document.network_interface) {
256258
let Some(gradient) = get_gradient(layer, &document.network_interface) else { continue };
257259
let transform = gradient_space_transform(layer, document);
@@ -263,15 +265,18 @@ impl Fsm for GradientToolFsmState {
263265
let (start, end) = (transform.transform_point2(start), transform.transform_point2(end));
264266

265267
overlay_context.line(start, end, None, None);
266-
overlay_context.manipulator_handle(start, dragging == Some(GradientDragTarget::Start), None);
267-
overlay_context.manipulator_handle(end, dragging == Some(GradientDragTarget::End), None);
268-
268+
if display_handles {
269+
overlay_context.manipulator_handle(start, dragging == Some(GradientDragTarget::Start), None);
270+
overlay_context.manipulator_handle(end, dragging == Some(GradientDragTarget::End), None);
271+
}
269272
for (index, (position, _)) in stops.into_iter().enumerate() {
270273
if position.abs() < f64::EPSILON * 1000. || (1. - position).abs() < f64::EPSILON * 1000. {
271274
continue;
272275
}
273276

274-
overlay_context.manipulator_handle(start.lerp(end, position), dragging == Some(GradientDragTarget::Step(index)), None);
277+
if display_handles {
278+
overlay_context.manipulator_handle(start.lerp(end, position), dragging == Some(GradientDragTarget::Step(index)), None);
279+
}
275280
}
276281
}
277282

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,13 +983,20 @@ impl Fsm for PathToolFsmState {
983983
Self::InsertPoint => {
984984
let state = tool_data.update_insertion(shape_editor, document, responses, input);
985985

986+
let display_anchors = overlay_context.overlays_visibility_settings.anchors;
987+
let display_handles = overlay_context.overlays_visibility_settings.handles;
988+
986989
if let Some(closest_segment) = &tool_data.segment {
987-
overlay_context.manipulator_anchor(closest_segment.closest_point_to_viewport(), false, Some(COLOR_OVERLAY_BLUE));
990+
if display_anchors {
991+
overlay_context.manipulator_anchor(closest_segment.closest_point_to_viewport(), false, Some(COLOR_OVERLAY_BLUE));
992+
}
988993
if let (Some(handle1), Some(handle2)) = closest_segment.handle_positions(document.metadata()) {
989994
overlay_context.line(closest_segment.closest_point_to_viewport(), handle1, Some(COLOR_OVERLAY_BLUE), None);
990995
overlay_context.line(closest_segment.closest_point_to_viewport(), handle2, Some(COLOR_OVERLAY_BLUE), None);
991-
overlay_context.manipulator_handle(handle1, false, Some(COLOR_OVERLAY_BLUE));
992-
overlay_context.manipulator_handle(handle2, false, Some(COLOR_OVERLAY_BLUE));
996+
if display_handles {
997+
overlay_context.manipulator_handle(handle1, false, Some(COLOR_OVERLAY_BLUE));
998+
overlay_context.manipulator_handle(handle2, false, Some(COLOR_OVERLAY_BLUE));
999+
}
9931000
}
9941001
}
9951002

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,9 @@ impl Fsm for PenToolFsmState {
15211521
self
15221522
}
15231523
(_, PenToolMessage::Overlays(mut overlay_context)) => {
1524+
let display_anchors = overlay_context.overlays_visibility_settings.anchors;
1525+
let display_handles = overlay_context.overlays_visibility_settings.handles;
1526+
15241527
let valid = |point: DVec2, handle: DVec2| point.distance_squared(handle) >= HIDE_HANDLE_DISTANCE * HIDE_HANDLE_DISTANCE;
15251528

15261529
let transform = document.metadata().document_to_viewport * transform;
@@ -1580,13 +1583,13 @@ impl Fsm for PenToolFsmState {
15801583
overlay_context.dashed_line(anchor_start, next_anchor, None, None, Some(4.), Some(4.), Some(0.5));
15811584
}
15821585

1583-
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) && valid(next_anchor, handle_end) {
1586+
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) && valid(next_anchor, handle_end) && display_handles {
15841587
// Draw the handle circle for the currently-being-dragged-out incoming handle (opposite the one currently being dragged out)
15851588
let selected = tool_data.handle_type == TargetHandle::PreviewInHandle;
15861589
overlay_context.manipulator_handle(handle_end, selected, None);
15871590
}
15881591

1589-
if valid(anchor_start, handle_start) {
1592+
if valid(anchor_start, handle_start) && display_handles {
15901593
// Draw the handle circle for the most recently placed anchor's outgoing handle (which is currently influencing the currently-being-placed segment)
15911594
overlay_context.manipulator_handle(handle_start, false, None);
15921595
}
@@ -1602,13 +1605,13 @@ impl Fsm for PenToolFsmState {
16021605
}
16031606
}
16041607

1605-
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) && valid(next_anchor, next_handle_start) {
1608+
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) && valid(next_anchor, next_handle_start) && display_handles {
16061609
// Draw the handle circle for the currently-being-dragged-out outgoing handle (the one currently being dragged out, under the user's cursor)
16071610
let selected = tool_data.handle_type == TargetHandle::FuturePreviewOutHandle;
16081611
overlay_context.manipulator_handle(next_handle_start, selected, None);
16091612
}
16101613

1611-
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) {
1614+
if self == PenToolFsmState::DraggingHandle(tool_data.handle_mode) && display_anchors {
16121615
// Draw the anchor square for the most recently placed anchor
16131616
overlay_context.manipulator_anchor(next_anchor, false, None);
16141617
}

0 commit comments

Comments
 (0)