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

Improve handling of change bounds in several areas #344

Merged
merged 3 commits into from
May 16, 2024
Merged

Conversation

martin-fleck-at
Copy link
Contributor

What it does

Improve handling of change bounds

  • Introduce change bounds manager to centralize bounds-related services
    -- Bounds changes through position snapping and movement restriction
    -- Validation for size and position of an element
    -- Customizable methods for when to use move and resize options

  • Introduce change bounds tracker for moves and resizes
    -- Tracker calculates move on diagram and calculates move and resizes
    -- Tracker supports options on which parts of the process are applied

  • Provide moveable wrappers for resize and routing handles

Fixes eclipse-glsp/glsp#1337

  • Extend current resize capabilities
    -- Introduce mode for symmetric resize
    -- Introduce one-dimensional resize on top, right, bottom and left side

Fixes eclipse-glsp/glsp#1338
Fixes eclipse-glsp/glsp#1339

  • Fix elements moving during resizing when hitting minimum bounds
    -- Store calculated minimum size from layouter in element
    -- Adapt resize so we do not produce invalid sized bounds

Fixes eclipse-glsp/glsp#1340

Minor:

  • Ensure we get proper cursor feedback when hovering over resize handle
  • Add additional convenience functions
  • Add origin viewport command for convenience

Please note this PR builds upon #343 and should only be merged afterwards!

How to test

  • Double check that everything behaves as before (minus the bugs)
  • Symmetric resize can be tested using the Ctrl Key
  • Additional resize handles can be tested by adding the locations to the ChangeBoundsManager. The corners are kept for backwards-compatibilty.
  • General sizing can be tested more easily with the debug bounds module from Introduce an optional grid module to deal with a grid layout #343

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

As soon as we agree on the PR, I'll write a paragraph about the changes ;-)

Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

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

Thanks a lot Martin.
I really like the centralized approach of handling bound changes.
I have retested everything and can confirm that all mentioned bugs are fixed and (almost) everything works as expected.

There seems to be a bug when resizing elements close to the diagram border when projetion bars are visible:

resize-bug.mp4

On master the resize works as expected in this case.

Other than that i also noticed that the a11y keyboard resize tool currently does not respect grid size i.e. resizing with +/- does not snap the size to the grid. But we can handle that in a follow-up PR if necessary.

packages/client/css/change-bounds.css Outdated Show resolved Hide resolved
packages/client/src/utils/gmodel-util.ts Outdated Show resolved Hide resolved
packages/client/src/utils/gmodel-util.ts Outdated Show resolved Hide resolved
packages/protocol/src/utils/type-util.ts Show resolved Hide resolved
- Introduce change bounds manager to centralize bounds-related services
-- Bounds changes through position snapping and movement restriction
-- Validation for size and position of an element
-- Customizable methods for when to use move and resize options

- Introduce change bounds tracker for moves and resizes
-- Tracker calculates move on diagram and calculates move and resizes
-- Tracker supports options on which parts of the process are applied

- Provide moveable wrappers for resize and routing handles

Fixes eclipse-glsp/glsp#1337

- Extend current resize capabilities
-- Introduce mode for symmetric resize
-- Introduce one-dimensional resize on top, right, bottom and left side

Fixes eclipse-glsp/glsp#1338
Fixes eclipse-glsp/glsp#1339

- Fix elements moving during resizing when hitting minimum bounds
-- Store calculated minimum size from layouter in element
-- Adapt resize so we do not produce invalid sized bounds

Fixes eclipse-glsp/glsp#1340

Minor:
- Ensure we get proper cursor feedback when hovering over resize handle
- Add additional convenience functions
- Add origin viewport command for convenience

Contributed on behalf of Axon Ivy AG
- Fix issue with wrong coordinates on project bars during move/resize
- Fix move during resize for constrained, symmetric resize
- Ensure symmetric resize does not trigger deselect of element

- Remove !important from CSS rules
- Allow undefined unsnap modifier for adopters
- Use isSizeable for debug decoration to avoid wrong edge decoration
- Remove non-generic getAbsoluteEdgeBounds
- Better unify the helper functions for CSS classes
- Fix deprecation warnings
- Minor cleanup

Contributed on behalf of Axon Ivy AG
@martin-fleck-at
Copy link
Contributor Author

@tortmayr I think I managed to address all the issues, I'd really appreciate it if you could have another, more detailed look at this. Thank you very much!

Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

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

Thanks Martin. All issues have been addressed and everything seems to work as expected now. Nice job!

I encountered one issue with the recently introduced debug module. It also decorates validation markers (and potentially other decorations) which looks a bit confusing. We should probably not decorate decorations at all:

image

@@ -16,8 +16,8 @@

.helper-line {
pointer-events: none;
stroke: red;
stroke-width: 1px;
stroke: #f7086c;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe use a less aggressive color than red for the helper lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you maybe have a suggestion? I tried to choose a softer red, more pink-ish color to make it less look like an error. However, I couldn't quickly find a color that has a good contrast to most other colors and still look very visible on the blue-ish background.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed an update where I set the stroke width back to 1 and use the blue that we also use for the resize handles, please have a look at that.

@@ -49,7 +49,7 @@ declare module 'sprotty-protocol/lib/utils/geometry' {
* @param right right bounds
* @returns true if the two bounds are equal
*/
function equals(left: Bounds, right: Bounds): boolean;
function equals(left: Bounds, right: Bounds, eps?: number): boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing @param for the eps param

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

- Add missing @param doc
- Do not debug decoratable elements
- Adapt color of helper line
@martin-fleck-at
Copy link
Contributor Author

@tortmayr Thank you, I pushed an update that should address the remaining issues. Now we just need to agree on a color ;-)

@tortmayr tortmayr self-requested a review May 16, 2024 12:30
Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

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

Thanks Martin.
Everything now works as expected.
I'm happy with the new color of the helper lines 😛

@tortmayr tortmayr merged commit a0e5612 into master May 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants