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 alignment buttons popover option for alignment relative to artboard #1724

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

nico-mayora
Copy link
Contributor

@nico-mayora nico-mayora commented Apr 5, 2024

Closes #1720.

This issue is still very much WIP--note the numerous debug! calls :^), but wanted to get this PR going as I have run into a small issue:

Note editor/src/messages/tool/tool_messages/select_tool.rs:173: I've made it so that if to_artboard is true, the alignment options are again enabled for just one selected object. In practise, this doesn't work--ticking the checkbox won't update the alignment buttons automatically. We need to reselect the object for the effect to take place. Is there a way this automatic refresh can be done?

Solved!

@nico-mayora nico-mayora changed the title [WIP] Feat: Add aligning relative to artboard Feat: Add aligning relative to artboard Apr 5, 2024
Copy link
Member

@0HyperCube 0HyperCube left a comment

Choose a reason for hiding this comment

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

Works well apart from the broken checkbox.

editor/src/messages/tool/tool_messages/select_tool.rs Outdated Show resolved Hide resolved
@Keavon Keavon changed the title Feat: Add aligning relative to artboard Add alignment buttons popover option for alignment relative to artboard Apr 6, 2024
@nico-mayora nico-mayora force-pushed the master branch 3 times, most recently from 8e48669 to 5596691 Compare April 13, 2024 15:24
@Keavon
Copy link
Member

Keavon commented Apr 13, 2024

!build

Copy link

📦 Build Complete for 5596691
https://a2b8aa9f.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented Apr 13, 2024

QA feedback:

  • A dash is shown in the dropdown menu until it is open. Only upon opening the menu is the dash replaced with the first item.
  • The list is not always populated with the current selection.
  • Let's use a three-way radio input to pick which alignment mode to use. "Selection" / "Layer" / "Artboard" can be the three choices.

@nico-mayora
Copy link
Contributor Author

@Keavon

QA feedback:

* [ ]  A dash is shown in the dropdown menu until it is open. Only upon opening the menu is the dash replaced with the first item.

* [ ]  The list is not always populated with the current selection.

* [ ]  Let's use a three-way radio input to pick which alignment mode to use. "Selection" / "Layer" / "Artboard" can be the three choices.

I've pushed fixes for points 1 and 3, but can't manage to reproduce 2. Would you mind elaborating a bit more?

@Keavon
Copy link
Member

Keavon commented Apr 18, 2024

  • I've decided it's better to have only two radio button modes: Layers and Artboard. Layers mode is a combined form of the current Selection and Layer modes. The dropdown menu should have a default (top) entry "Combined Bounds of Selection", with the selected layers available to choose if 2+ are selected currently. It should always switch back to "Combined Bounds of Selection" when the selected layer is lost. For example, if the user picks a layer from that menu, then closes the menu and deselects it, the menu should reset next time the user opens the alignment popover or clicks one of the alignment buttons. But it should try to memorize the layer chosen by the user while that menu is closed, allowing the user to deselect that layer then re-select it as long as the popover wasn't re-opened or the alignment buttons used because those activities will necessitate that it resets back to the default "Combined Bounds of Selection" option. If for some reason the popover is open while the chosen layer is deselected (perhaps by keyboard shortcut like CtrlShiftA to deselect), it should immediately switch back to "Combined Bounds of Selection" because the menu is actively open. Essentially, the chosen value should only be preserved in the event of deselection while the menu is closed and the user isn't doing alignment actions.
  • If there are no artboards (infinite canvas is in use), Artboard alignment mode should be disabled (and if that's currently the active mode, it should be reset back to Selection alignment mode using the same rules as above where it only resets once the popover is viewed or the alignment buttons are used, allowing the user to create an artboard again and not lose the state which would be frustrating).
  • Artboard alignment should be relative to the parent artboard of each layer, not the last-selected artboard
  • This PR breaks the options bar for the Select tool, making it empty upon loading the editor until a layer is selected
  • To reproduce the issue I mentioned above where the - or other incorrect layers shows in the layers dropdown, here is one of many ways you can perform some steps to run into these problems (but just select and deselect various layers, you'll immediately run into it since it's extremely easy to trigger):
    • Draw some shapes and refresh the web page
    • Select one layer
    • Switch to Layer alignment mode
    • Click in the canvas to deselect the layer
    • Use CtrlA to select all layers
    • View the alignment list again and it should be a dash now, despite having more than one layer selected
    • Keep clicking around (or multi-selecting in the Layers panel) to select and deselect various layers and you'll see that it starts showing a dash, or only one layer that isn't the selected layer, or other assortments of the wrong results

@nico-mayora
Copy link
Contributor Author

Artboard alignment should be relative to the parent artboard of each layer, not the last-selected artboard

What if the selection spans several artboards and "Preserve relative positions" is checked?

@Keavon
Copy link
Member

Keavon commented Apr 22, 2024

Good question. Let's say it preserves relative positions of each per-artboard group of layers.

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.

Alignment button options (align to artboard)
4 participants