Skip to content

Commit 90be1f4

Browse files
mTvare6Keavon
andauthored
Fix 'Shallow Select' mode behavior for selection context transference (#2604)
* Fix ancestor always returning None during shallow select * Fixes * fix shift remove on both * cleanup * one more cleanup * final(?) fix * some cleanup * more stuff * make shallow the default * fixes * fix * fix * fix * Code review --------- Co-authored-by: Keavon Chambers <[email protected]>
1 parent 23b2c5b commit 90be1f4

File tree

7 files changed

+178
-70
lines changed

7 files changed

+178
-70
lines changed

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,10 @@ impl OverlayContext {
310310
}
311311

312312
pub fn draw_angle(&mut self, pivot: DVec2, radius: f64, arc_radius: f64, offset_angle: f64, angle: f64) {
313-
let color_line = COLOR_OVERLAY_BLUE;
314-
315313
let end_point1 = pivot + radius * DVec2::from_angle(angle + offset_angle);
316314
let end_point2 = pivot + radius * DVec2::from_angle(offset_angle);
317-
self.line(pivot, end_point1, Some(color_line), None);
318-
self.line(pivot, end_point2, Some(color_line), None);
319-
315+
self.line(pivot, end_point1, None, None);
316+
self.dashed_line(pivot, end_point2, None, None, Some(2.), Some(2.), Some(0.5));
320317
self.draw_arc(pivot, arc_radius, offset_angle, (angle) % TAU + offset_angle);
321318
}
322319

editor/src/messages/portfolio/document/utility_types/document_metadata.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,21 @@ impl LayerNodeIdentifier {
261261
metadata.get_relations(self).and_then(|relations| relations.last_child)
262262
}
263263

264-
/// Does the layer have children? If so, then it is a folder
264+
/// Does the layer have children? If so, then it is a folder.
265265
pub fn has_children(self, metadata: &DocumentMetadata) -> bool {
266266
self.first_child(metadata).is_some()
267267
}
268268

269+
/// Is the layer a child of the given layer?
270+
pub fn is_child_of(self, metadata: &DocumentMetadata, parent: &LayerNodeIdentifier) -> bool {
271+
parent.children(metadata).any(|child| child == self)
272+
}
273+
274+
/// Is the layer an ancestor of the given layer?
275+
pub fn is_ancestor_of(self, metadata: &DocumentMetadata, child: &LayerNodeIdentifier) -> bool {
276+
child.ancestors(metadata).any(|ancestor| ancestor == self)
277+
}
278+
269279
/// Iterator over all direct children (excluding self and recursive children)
270280
pub fn children(self, metadata: &DocumentMetadata) -> AxisIter {
271281
AxisIter {

editor/src/messages/tool/common_functionality/measure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fn draw_dashed_line(line_start: DVec2, line_end: DVec2, transform: DAffine2, ove
1010

1111
overlay_context.dashed_line(min_viewport, max_viewport, None, None, Some(2.), Some(2.), Some(0.5));
1212
}
13+
1314
/// Draws a solid line with a length annotation between two points transformed by the given affine transformations.
1415
fn draw_line_with_length(line_start: DVec2, line_end: DVec2, transform: DAffine2, document_to_viewport: DAffine2, overlay_context: &mut OverlayContext, label_alignment: LabelAlignment) {
1516
let transform_to_document = document_to_viewport.inverse() * transform;

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl Fsm for ArtboardToolFsmState {
267267
let constrain_square = input.keyboard.get(constrain_axis_or_aspect as usize);
268268
tool_data.resize_artboard(responses, document, input, from_center, constrain_square);
269269

270-
// AutoPanning
270+
// Auto-panning
271271
let messages = [
272272
ArtboardToolMessage::PointerOutsideViewport { constrain_axis_or_aspect, center }.into(),
273273
ArtboardToolMessage::PointerMove { constrain_axis_or_aspect, center }.into(),
@@ -306,7 +306,7 @@ impl Fsm for ArtboardToolFsmState {
306306
bounds.bounds[0] = position.round();
307307
bounds.bounds[1] = position.round() + size.round();
308308

309-
// AutoPanning
309+
// Auto-panning
310310
let messages = [
311311
ArtboardToolMessage::PointerOutsideViewport { constrain_axis_or_aspect, center }.into(),
312312
ArtboardToolMessage::PointerMove { constrain_axis_or_aspect, center }.into(),
@@ -345,7 +345,7 @@ impl Fsm for ArtboardToolFsmState {
345345
})
346346
}
347347

348-
// AutoPanning
348+
// Auto-panning
349349
let messages = [
350350
ArtboardToolMessage::PointerOutsideViewport { constrain_axis_or_aspect, center }.into(),
351351
ArtboardToolMessage::PointerMove { constrain_axis_or_aspect, center }.into(),
@@ -377,25 +377,25 @@ impl Fsm for ArtboardToolFsmState {
377377
ArtboardToolFsmState::Ready { hovered }
378378
}
379379
(ArtboardToolFsmState::ResizingBounds, ArtboardToolMessage::PointerOutsideViewport { .. }) => {
380-
// AutoPanning
380+
// Auto-panning
381381
let _ = tool_data.auto_panning.shift_viewport(input, responses);
382382

383383
ArtboardToolFsmState::ResizingBounds
384384
}
385385
(ArtboardToolFsmState::Dragging, ArtboardToolMessage::PointerOutsideViewport { .. }) => {
386-
// AutoPanning
386+
// Auto-panning
387387
tool_data.auto_panning.shift_viewport(input, responses);
388388

389389
ArtboardToolFsmState::Dragging
390390
}
391391
(ArtboardToolFsmState::Drawing, ArtboardToolMessage::PointerOutsideViewport { .. }) => {
392-
// AutoPanning
392+
// Auto-panning
393393
tool_data.auto_panning.shift_viewport(input, responses);
394394

395395
ArtboardToolFsmState::Drawing
396396
}
397397
(state, ArtboardToolMessage::PointerOutsideViewport { constrain_axis_or_aspect, center }) => {
398-
// AutoPanning
398+
// Auto-panning
399399
let messages = [
400400
ArtboardToolMessage::PointerOutsideViewport { constrain_axis_or_aspect, center }.into(),
401401
ArtboardToolMessage::PointerMove { constrain_axis_or_aspect, center }.into(),

0 commit comments

Comments
 (0)