Skip to content

[IMP] renderer: add animations on cell change #6448

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 4 commits into
base: master
Choose a base branch
from

Conversation

hokolomopo
Copy link
Contributor

@hokolomopo hokolomopo commented May 21, 2025

Description:

This commit adds animations in the grid's canvas when a cell is changed.
The animations are defined in the cell_animation_registry.ts and
includes:

  • fade in the cell when it gets a new content.
  • fate out the cell when its content is removed.
  • text sliding animation when the text is changed.
  • color gradient animation when the cell colors is changed
  • and more

The feature is designed to not impact the current grid drawing logic.
We still have a first step yo create Box from the model content,
and a second step to draw the Box in the canvas. The animations
are a step in between, where we change the Box depending on the
animation progress, and possibly add some additional Box to be drawn.

Task: 4805149

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented May 21, 2025

Pull request status dashboard

@hokolomopo hokolomopo force-pushed the master-cell-animation-adrm branch 8 times, most recently from 2dd49ef to 9b7ce81 Compare May 22, 2025 12:37
icons: { left?: GridIcon; right?: GridIcon; center?: GridIcon };
overlayColor?: Color;
icons: { left?: GridIconWithOpacity; right?: GridIconWithOpacity; center?: GridIconWithOpacity };
textOpacity?: number;
Copy link
Contributor Author

@hokolomopo hokolomopo May 22, 2025

Choose a reason for hiding this comment

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

could also add textOpacity to property style of Box

for (const { zone, rect } of this.getters.getAllActiveViewportsZonesAndRect()) {
const { ctx } = renderingContext;
ctx.save();
ctx.beginPath();
ctx.rect(rect.x, rect.y, rect.width, rect.height);
ctx.clip();
const boxes = this.getGridBoxes(zone);
const boxesWithoutAnimations = this.getGridBoxes(zone);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could optimize the code a bit there; computing a new Box is useless if we're in an animation frame that isn't caused by a model update. We could re-use the boxes of last render. A bit annoying (because of multiple viewports), but entirely possible.

We'd save 2-3ms at each animation frame.

@hokolomopo hokolomopo force-pushed the master-cell-animation-adrm branch 2 times, most recently from 066c5b0 to 2216143 Compare May 26, 2025 13:51
hokolomopo added a commit that referenced this pull request May 27, 2025
This commit replaces the HTML-based rendering of grid icons with a
canvas-based approach. This have the advantages of:

- improved performance, especially when there are a lot of icons (no
  DOM + OWL manipulation overhead)
- no parallax effect on mobile devices
- is compatible with cell animations of #6448

Task: 4674384
hokolomopo added a commit that referenced this pull request Jun 2, 2025
This commit replaces the HTML-based rendering of grid icons with a
canvas-based approach. This have the advantages of:

- improved performance, especially when there are a lot of icons (no
  DOM + OWL manipulation overhead)
- no parallax effect on mobile devices
- is compatible with cell animations of #6448

Task: 4674384
robodoo pushed a commit that referenced this pull request Jun 2, 2025
This commit replaces the HTML-based rendering of grid icons with a
canvas-based approach. This have the advantages of:

- improved performance, especially when there are a lot of icons (no
  DOM + OWL manipulation overhead)
- no parallax effect on mobile devices
- is compatible with cell animations of #6448

Task: 4674384
Part-of: #6111
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
@hokolomopo hokolomopo force-pushed the master-cell-animation-adrm branch from 2216143 to 4a2f2f9 Compare June 4, 2025 08:54
In the rendering process, the `verticalAlign` property is duplicated:
inside a `Box` there is both a `verticalAlign` and a
`style.verticalAlign` property.

This commit removes the `verticalAlign` property from the `Box`.

Task: 4805149
The function `computeTextWidth` uses a cache to store the width of
a text, but we would make canvas operations `ctx.save()/restore()`
even if the width is already in the cache.

For an animation on 350 cells, we went from spending 25ms in
`computeTextWidth` to 4ms.

Task: 4805149
This commit adds animations in the grid's canvas when a cell is changed.
The animations are defined in the `cell_animation_registry.ts` and
includes:

- fade in the cell when it gets a new content.
- fate out the cell when its content is removed.
- text sliding animation when the text is changed.
- color gradient animation when the cell colors is changed
- and more

The feature is designed to not impact the current grid drawing logic.
We still have a first step yo create `Box` from the model content,
and a second step to draw the `Box` in the canvas. The animations
are a step in between, where we change the `Box` depending on the
animation progress, and possibly add some additional `Box` to be drawn.

Task: 4805149
@hokolomopo hokolomopo force-pushed the master-cell-animation-adrm branch from 4a2f2f9 to 62c9513 Compare June 4, 2025 12:03
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