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

Properly handle grid layout with Tree::move_tile_to_container() #45

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Jan 25, 2024

Follow-up to:

The grid layout needs a special treatment because it can have holes, contrary to other containers.

When dragging a tile away from a grid, it leaves behind it a hole. As a result, if the tile is dropped in the same grid, it there is no need to account for an insertion index shift. However, if the tiles are reordered in a separate, linear representation of the grid (such as the Rerun blueprint tree), the expectation is that the grid is reordered and thus the insertion index must be shifted in case the tile is moved inside the same grid. This PR introduce a flag in move_tile_to_container() to select between these behaviors.

In general:

  • when drag-and-dropping from a 2D representation of the grid, set reflow_grid = false
  • when drag-and-dropping from a 1D representation of the grid, set reflow_grid = true

The grid layout needs a special treatment because it can have holes. When dragging a tile away from a grid, it leaves behind it a hole. As a result, if the tile is dropped in the same grid, it there is no need to account for an insertion index shift. However, if the tiles are reorder in a separate, linear representation of the grid (such as the Rerun blueprint tree), the expectation is that the grid is reordered and thus the insertion index must be shifted in case the tile is moved inside the same grid.
TL;DR:
when drag-and-dropping from a 2D representation of the grid, set reflow_grid = false
when drag-and-dropping from a 1D representation of the grid, set reflow_grid = true
@abey79 abey79 added the enhancement New feature or request label Jan 25, 2024
@abey79 abey79 merged commit 35e7112 into main Jan 26, 2024
8 of 9 checks passed
@abey79 abey79 deleted the antoine/grid-reflow-opt branch January 26, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants