Skip to content

Allow avoid merging layers with pen tool #4214

@0HyperCube

Description

@0HyperCube

Reproduction

When drawing with the pen tool, a user may wish to keep two layers separate. This could be useful for e.g. applying different fills or animations. However if the anchor shares a position with an anchor from another layer, it will always automatically merge.

don.t_merge.mp4

Fix

  • Indication when placing the anchor will automatically merge layers (e.g. in the tooltip). It is currently very hard to tell.
  • Option to avoid merging the layers even when they have the same anchor position.

Code

// Merge two layers if the point is connected to the end point of another path
// This might not be the correct solution to artboards being included as the other layer,
// which occurs due to the `compute_modified_vector` call in `should_extend` using the click targets for a layer instead of vector.
let layers = LayerNodeIdentifier::ROOT_PARENT
.descendants(document.metadata())
.filter(|layer| !document.network_interface.is_artboard(&layer.to_node(), &[]));
if let Some((other_layer, _, _)) = should_extend(document, viewport_vec, crate::consts::SNAP_POINT_TOLERANCE, layers) {
let selected_nodes = document.network_interface.selected_nodes();
let mut selected_layers = selected_nodes.selected_layers(document.metadata());
if let Some(current_layer) = selected_layers
.next()
.filter(|current_layer| selected_layers.next().is_none() && *current_layer != other_layer)
.or(tool_data.current_layer.filter(|layer| *layer != other_layer))
{
merge_layers(document, current_layer, other_layer, responses);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions