Skip to content

Commit ce94e4e

Browse files
committed
Add consts for magic numbers
1 parent 2683b7f commit ce94e4e

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,8 @@ fn import_usvg_path(
593593
/// Set correct positions for all imported layers in a single top-down O(n) pass.
594594
///
595595
/// For each group's child stack:
596-
/// - The top-of-stack child (last SVG child) gets an Absolute position at (parent_x - LAYER_INDENT_OFFSET, parent_y + STACK_VERTICAL_GAP)
597-
/// - All other children get Stack(y_offset) where y_offset accounts for the subtree extent of
598-
/// the sibling above them in the stack, ensuring no overlap.
596+
/// - The top-of-stack child (last SVG child) gets an `Absolute` position at `(parent_x - LAYER_INDENT_OFFSET, parent_y + STACK_VERTICAL_GAP)`
597+
/// - All other children get `Stack(y_offset)` where `y_offset` accounts for the subtree extent of the sibling above them in the stack, ensuring no overlap.
599598
fn set_import_child_positions(
600599
network_interface: &mut NodeNetworkInterface,
601600
group: LayerNodeIdentifier,
@@ -613,8 +612,8 @@ fn set_import_child_positions(
613612
}
614613

615614
// Children in the layer tree are in stack order (top to bottom), which is the REVERSE of SVG order.
616-
// SVG order: [s_0, s_1, ..., s_{n-1}] with extents [e_0, e_1, ..., e_{n-1}]
617-
// Stack order: [s_{n-1}, s_{n-2}, ..., s_0] (top to bottom)
615+
// SVG order: [s_0, s_1, ..., s_{n-1}] with extents [e_0, e_1, ..., e_{n-1}]
616+
// Stack order: [s_{n-1}, s_{n-2}, ..., s_0 ] (top to bottom)
618617
//
619618
// For stack child at index i:
620619
// - SVG index = n - 1 - i
@@ -628,12 +627,12 @@ fn set_import_child_positions(
628627
let child_pos = IVec2::new(child_x, current_y);
629628

630629
if i == 0 {
631-
// Top of stack — set to Absolute position
630+
// Top of stack — set to `Absolute` position
632631
network_interface.set_layer_position_for_import(&child_layer.to_node(), LayerPosition::Absolute(child_pos), &[]);
633632
} else {
634-
// Below top — set Stack y_offset based on previous sibling's subtree extent
635-
let prev_sibling_svg_idx = n - i;
636-
let y_offset = child_extents_svg_order[prev_sibling_svg_idx] + STACK_VERTICAL_GAP as u32;
633+
// Below top — set `Stack` with `y_offset` based on previous sibling's subtree extent
634+
let prev_sibling_svg_index = n - i;
635+
let y_offset = child_extents_svg_order[prev_sibling_svg_index] + STACK_VERTICAL_GAP as u32;
637636
network_interface.set_layer_position_for_import(&child_layer.to_node(), LayerPosition::Stack(y_offset), &[]);
638637
}
639638

@@ -642,9 +641,9 @@ fn set_import_child_positions(
642641
set_import_child_positions(network_interface, *child_layer, child_pos, grandchild_extents, group_extents_map);
643642
}
644643

645-
// Advance current_y for the next child: node height (STACK_VERTICAL_GAP) + gap (STACK_VERTICAL_GAP) + subtree extent
646-
let child_svg_idx = n - 1 - i;
647-
let child_extent = child_extents_svg_order[child_svg_idx];
644+
// Advance `current_y` for the next child: node height (STACK_VERTICAL_GAP) + gap (STACK_VERTICAL_GAP) + subtree extent
645+
let child_svg_index = n - 1 - i;
646+
let child_extent = child_extents_svg_order[child_svg_index];
648647
current_y += 2 * STACK_VERTICAL_GAP + child_extent as i32;
649648
}
650649
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ pub struct ModifyInputsContext<'a> {
3333
pub responses: &'a mut VecDeque<Message>,
3434
// Cannot be LayerNodeIdentifier::ROOT_PARENT
3535
pub layer_node: Option<LayerNodeIdentifier>,
36-
/// When true, chain node wiring uses the lightweight import path that skips expensive
37-
/// `is_acyclic` checks and per-node cache invalidation.
36+
/// When true, chain node wiring uses the lightweight import path that skips expensive `is_acyclic` checks and per-node cache invalidation.
3837
pub import_mode: bool,
3938
}
4039

0 commit comments

Comments
 (0)