Skip to content

Conversation

MutatingFunc
Copy link
Contributor

@MutatingFunc MutatingFunc commented Feb 18, 2024

For more information about the thought behind this approach:
https://mutatingfunc.github.io/blog/2023-11-03-macos-amethyst-window-snapping/

Short version - iPad-style grid alignment.

Longer version - Floating layout, but windows are snapped to a grid to make it easier to align them.

Demo build download (updated 2025.03.21)

@MutatingFunc MutatingFunc changed the title Floating Grid Add Floating Grid Layout Feb 18, 2024
@ianyh
Copy link
Owner

ianyh commented May 27, 2024

Sorry I haven't had a chance to look at this! It seems neat, I just need to think about it a bit more.

@MutatingFunc
Copy link
Contributor Author

MutatingFunc commented Mar 20, 2025

@MutatingFunc
Copy link
Contributor Author

MutatingFunc commented Mar 21, 2025

Made a few changes following the rebase, as the approach I was using to detect window position & size changes stopped working. This build integrates directly with the window resizing and repositioning handlers to trigger the grid snapping, so it should be much more robust.

https://github.com/MutatingFunc/Amethyst/releases/tag/floating-grid-demo-2

Copy link
Owner

@ianyh ianyh left a comment

Choose a reason for hiding this comment

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

Overall seems like a cool change. I think some of this could be extended to support custom layouts, but I am okay with this being a native layout. It seems pretty easy to maintain.

DEAD_CODE_STRIPPING = YES;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = VKFDYMU9HJ;
Copy link
Owner

Choose a reason for hiding this comment

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

Can you revert these?


guard layout is PanedLayout else {
if layout is FloatingGridLayout, case .doneDragging = mouseStateKeeper.state {
screenManager.setNeedsReflow(withWindowChange: .layoutChange)
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think .layoutChange is right. That is for when the currently selected layout changes. We may need a different one for specifically window resizes.

@MutatingFunc
Copy link
Contributor Author

Hey, thanks for the feedback, makes sense! I think this came through day 1 of my 4 week holiday abroad though so I’ll get back to this when I’m at my laptop properly again in May!

@MutatingFunc
Copy link
Contributor Author

Hey, I'm back! I've removed my team ID from the Git history for security/privacy, and generalised the window resize event. However, the resize event is still only triggered for the Floating Grid layout, for efficiency. Potentially it could be worth looking at generalising this down the road to a protocol if it makes sense for other layout types to observe the event.

@MutatingFunc
Copy link
Contributor Author

Does this now look good to merge?

@rwjack
Copy link

rwjack commented Jun 30, 2025

This looks very cool!

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.

3 participants