|Go to Page...|
This small mod is a tool to help align frames. In theory it works with nearly any frame that users drag manually. Credit goes to Iriel for the original code to enable this and to JoshBorke for figuring out a workable method for 2.0.
__ New in 1.1 __
- 2.0-enabled thanks to fixes by JoshBorke
To set up: Create a key binding for SnapToGrid in the Interface Options->Key Bindings window.
To use: Hold the key binding down and a crosshair will appear. While you hold the key down, drag windows as you normally do and they will snap to an imaginary grid. Let go of the key to stop snapping to the grid.
When done: Hit the Reload button. In 2.0, SnapToGrid taints a lot of stuff. Reloading the UI will release the taints and hooks until you use it again.
How it works: When the key binding goes down it starts watching for StartMoving and StopMovingOrSizing methods and then displays a crosshair. This crosshair snaps to an imaginary grid on the screen. When a mod or the UI begins a StartMoving, it notes the frame being moved and then the crosshair moves to the corner of the frame. Periodically it will snap the frame to the crosshair.
Slash command (optional): /snap X : change the size of each grid cell to X (1 to 128, 16 is default)
__ FAQ __
Q: Reloading the UI every time I use this is a pain. Is it reeeally necessary?
A: If you want, open SnapToGrid.lua and comment out these two lines:
line 111: meta.__index = hookIdxCheckButton
line 124: StaticPopup_Show("SNAPTOGRIDRELOAD")
And it will remove ActionButtons from drag candidates and remove the reload popup.
Q: It's not letting me move a frame!
A: This mod doesn't move frames. This mod only adjusts the position of already-moving frames. Get DFM or MoveAnything or one of the frame moving mods to move frames. This mod was made to align frames that can already move.
Q: Why are the crosshairs like three feet away from the frame's corner?
A: Frames don't necessary begin where you can see them. Many times frames have an invisible border that extend way beyond the visible part. The crosshairs has less value in this case but the frames will still snap. (CTRA raid unit frames is a common example)
Q: I have two frames of different scale that don't want to line up exactly.
A: Scaling, especially if they have an invisible border, will affect the snap slightly. Frames of the same scale will align best.
Q: I only installed this mod to line up my CTRA/bars/etc. Can I get rid of it once its served its purpose?
A: Yep. You can disable or delete the mod if you want. However the mod is ~250 lines lua+xml combined with no events registered and no hooks until you hit the key binding, so it's safe to sit inert if you need it again.
Q: I don't get the crosshair sightings when dragging some frames like minimap buttons.
A: The likely reason is that the frame doesn't use StartMoving or StopMovingOrSizing. If a frame moves some other way (ie, an OnUpdate that clings a minimap button to the minimap edge), then this mod can't intercept the movement.
Q: I have a chat frame stuck on my cursor. It won't let me let go of it.
A: I'm still trying to track this down but: once in a while StopMovingOrSizing doesn't want to finish for the chat frames if you release a key and the mouse at the same time. You can drop it by reloading the UI: /script ReloadUI()
This still works - Miscellaneous