-
Notifications
You must be signed in to change notification settings - Fork 30
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
Introduce an optional grid module to deal with a grid layout #343
Conversation
09243d5
to
0a6a3c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Martin! Amazing change, I'm a big fan of the debug extension. This will be really helpful for us and our adopters!
In general, the code looks good to me.
The only thing I'm note sure about is the GridBackground
service. I feel like rendering the grid background is something that should be handled by the root graph view instead.
I quickly tested this and something like
@injectable()
export class GridGraphView extends GGraphView {
override render(model: Readonly<GGraph>, context: RenderingContext): VNode {
const edgeRouting = this.edgeRouterRegistry.routeAllChildren(model);
const transform = `scale(${model.zoom}) translate(${-model.scroll.x},${-model.scroll.y})`;
return (
<svg class-sprotty-graph={true}>
<defs>
<pattern id='grid' width='10' height='10' patternUnits='userSpaceOnUse' patternTransform={transform}>
<path d='M 10 0 L 0 0 0 10' fill='none' stroke='gray' stroke-width='1' />
</pattern>
</defs>
<rect width='100%' height='100%' fill='url(#grid)' />
<g transform={transform}>{context.renderChildren(model, { edgeRouting })}</g>
</svg>
);
}
}
seems to do the trick.
packages/client/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts
Show resolved
Hide resolved
- Optional grid module defines a grid based on x/y coordinates -- Adds the grid as a background that properly zooms/resizes -- By default uses the GridSnapper for positioning elements -- Use grid for helper lines and movement tools - Optional debug module that shows the bounds of elements -- Useful for debugging but not meant for production - Render optional debug and grid toggles in tool palette if present - Add both optional modules to the workflow example Contributed on behalf of Axon Ivy AG Fixes eclipse-glsp/glsp#1336
- Restore usage of accessibility module - Bind grid using TYPES.Grid instead of using local symbol - Fix using grid in movement key tool - Re-work rendering of grid background directly in graph - Bonus: Add OriginViewportAction to reset to 0,0 on zoom-level 1 Contributed on behalf of Axon Ivy AG
0a6a3c6
to
8486c8b
Compare
@tortmayr Thank you for the quick turnaround! I pushed an additional commit that should fix all the issues that you mentioned. I also added an action to reset the viewport to 0,0 with zoom 1 as I think it is very convenient. It is basically a specialization of the more generic SetViewportCommand. I'd really appreciate it if you could have another look at it. |
- Do not create subclasses for graphs but optionally inject - Use half-grid snapping for routing handles for nicer UX - Avoid default grid background image that is never used - Improve styling of tool palette now that we have broken it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements Martin.
Apart from a few nitpicks the change looks good to me.
I really like the improved styling of the tool palette 😉
packages/client/src/features/accessibility/resize-key-tool/resize-key-handler.ts
Outdated
Show resolved
Hide resolved
@tortmayr Thanks, I fixed the remaining issues! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 Looks good to me.
What it does
Introduce an optional grid module to deal with a grid layout
Optional grid module defines a grid based on x/y coordinates
-- Adds the grid as a background that properly zooms/resizes
-- By default uses the GridSnapper for positioning elements
-- Use grid for helper lines and movement tools
Optional debug module that shows the bounds of elements
-- Useful for debugging but not meant for production
Render optional debug and grid toggles in tool palette if present
Add both optional modules to the workflow example
Fixes eclipse-glsp/glsp#1336
Please note this PR builds upon #342 and should only be merged afterwards!
How to test
Follow-ups
Changelog
If the optional accessibility module was used, the grid was derived through the
GridSnapper
, this needs to be replaced by a binding of theGrid
.