Skip to content

Feat: Box selection of partially selected lines #3360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from

Conversation

jquery404
Copy link
Contributor

@jquery404 jquery404 commented Apr 6, 2025

Cross-references to related issues.

⚠️ Cytoscape only checks if both (start and end points) or all endpoints (in the case of haystacks) are inside the user selection box to consider it selected.

Example of the issue:

Associated issues:

Notes re. the content of the pull request. Give context to reviewers or serve as a general record of the changes made. Add a screenshot or video to demonstrate your new feature, if possible.

  • This PR introduces a new style parameter, box-select-lines: yes. When this attribute is included, line can be selected even if at least one (start or end point) is inside the user selection box.

📸 Demo:

Checklist

Author:

  • The proper base branch has been selected. New features go on unstable. Bug-fix patches can go on either unstable or master.
  • Automated tests have been included in this pull request, if possible, for the new feature(s) or bug fix. Check this box if tests are not pragmatically possible (e.g. rendering features could include screenshots or videos instead of automated tests).
  • The associated GitHub issues are included (above).
  • Notes have been included (above).
  • For new or updated API, the index.d.ts Typescript definition file has been appropriately updated.

Reviewers:

  • All automated checks are passing (green check next to latest commit).
  • At least one reviewer has signed off on the pull request.
  • For bug fixes: Just after this pull request is merged, it should be applied to both the master branch and the unstable branch. Normally, this just requires cherry-picking the corresponding merge commit from master to unstable -- or vice versa.

cc: @maxkfranz

@maxkfranz
Copy link
Member

@jquery404 #3359 (comment)

Copy link
Member

@maxkfranz maxkfranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We should address both contain and overlap for nodes. We should also make sure that the default stylesheet has overlap for nodes and contain for edges, to be consistent with existing behaviour (compatibility).

includeLabels: nodeBoxSelectMode && eventsEnabled,
});

if (math.boundingBoxesIntersect(boxBb, nodeBb)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logic for box-selection:overlap for nodes

What about box-selection:contain for nodes? Probably the bounds of the node body and rotated label box can just be checked for containment. These functions would be useful for this: https://github.com/cytoscape/cytoscape.js/blob/unstable/src/math.mjs#L363-L372

@maxkfranz
Copy link
Member

Also the index.d.ts file would need to be updated with the new prop

@@ -234,7 +235,7 @@ const styfn = {};
{ name: 'text-border-style', type: t.borderStyle, triggersBounds: diff.any },
{ name: 'text-background-shape', type: t.textBackgroundShape, triggersBounds: diff.any },
{ name: 'text-justification', type: t.justification },
{ name: 'box-select-labels', type: t.bool, triggersBounds: diff.any },
{ name: 'box-selection', type: t.boxSelection }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prop should only be specced out once. Not here since it doesn't affect the label visual style.

@@ -407,7 +408,8 @@ const styfn = {};
{ name: 'loop-direction', type: t.angle, triggersBounds: diff.any },
{ name: 'loop-sweep', type: t.angle, triggersBounds: diff.any },
{ name: 'source-distance-from-node', type: t.size, triggersBounds: diff.any },
{ name: 'target-distance-from-node', type: t.size, triggersBounds: diff.any }
{ name: 'target-distance-from-node', type: t.size, triggersBounds: diff.any },
{ name: 'box-selection', type: t.boxSelection }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be here either.

behaviour is a good place

@maxkfranz
Copy link
Member

@jquery404, do you think you could make the changes in the next few days? I'm releasing the next feature release soon, and I'll be away for over a month starting next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants