Skip to content
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

Add support for box selection #332

Merged
merged 16 commits into from
May 6, 2024
Merged

Conversation

matthiaslehnertum
Copy link
Collaborator

@matthiaslehnertum matthiaslehnertum commented Dec 7, 2023

This PR is a port of the legacy PR #290 to support our new editor state format and zooming the editor canvas.

Checklist

  • I added multiple screenshots/screencasts of my UI changes

Motivation and Context

This PR provides the implementation of a selection box using the cursor in order to select multiple elements without the use of the keyboard.

Description

Every time the user clicks OUTSIDE an element, the selection box is created. In order for it to become visible, the user needs to drag the cursor. An element needs to be contained FULLY within the selection box for it to be selected when the selection box is released (i.e. the click/drag action is over). This feature also works when pressing the SHIFT key without deselecting the already selected items.

If the user's cursor goes outside the scope of the canvas while the selection box is active, the selection box will "freeze", but it will continue when the cursor comes back to the canvas. If the user releases the click while the cursor is outside the canvas and they return to the canvas, the selection box will remain active; clicking again will "resume" the selection box and the user can continue to drag the cursor in order to change the already active selection box before releasing it.

Adjustments:

  • hovering is disabled when the selection box is active
  • the cursor shape normally changes to sizeall (pointer: 'move') when hovering over the inside of an element - disabled while selection box is active
  • the cursor shape normally changes to sizenesw/sizenwse when hovering over the edges of an element - disabled while selection box is active

Steps for Testing

  1. Open Apollon in Chrome
  2. Add a few UML Elements to the canvas
  3. Click somewhere on the canvas where there are no elements and drag the mouse to see the selection box
  4. Drag the mouse to include the elements that you want to select
  5. Release the click and all the elements in the selection box should be selected while the others should remain deselected

Screenshots

grafik

grafik

@matthiaslehnertum matthiaslehnertum changed the title Bring over box selection changes Add support for box selection Dec 7, 2023
@matthiaslehnertum matthiaslehnertum marked this pull request as ready for review December 7, 2023 19:58
Copy link
Contributor

@loreanvictor loreanvictor left a comment

Choose a reason for hiding this comment

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

The change works as intended, though I feel it lacks test coverage? Besides that at least one of the changes (about unmounting) can potentially lead to memory leaks in future (listeners not being cleaned up). The rest are UX improvements that I think are important but also could be done iteratively in subsequent PRs.

src/main/components/canvas/mouse-eventlistener.tsx Outdated Show resolved Hide resolved
src/main/components/canvas/mouse-eventlistener.tsx Outdated Show resolved Hide resolved
@matthiaslehnertum matthiaslehnertum merged commit 8c64112 into develop May 6, 2024
3 of 4 checks passed
@matthiaslehnertum matthiaslehnertum deleted the feature/box-selection branch May 6, 2024 10:53
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