WoWInterface (
-   Lua/XML Help (
-   -   Snapping Frames vertically horizontally (

Walkerbo 05-11-21 07:00 PM

Snapping Frames vertically horizontally
Hi all

I am trying to find a way to snap multiple frames to each other.
I would like to snap these bars to any point; top to bottom, right to left and any combination thereof.
I have not been able to find any tutorials that help.

If someone here could direct me to a tutorial that would be fantastic.

Xrystal 05-11-21 09:08 PM

It sounds like you are talking about what we have as anchoring functionality. You anchor the "TOP" of a frame to the "BOTTOM" of another frame to get them connected vertically. Similarly "LEFT" to "RIGHT" for horizontal connections. "CENTER" to "CENTER" will anchor the center of frame1 to the center of frame2.

Hopefully those above will help you see whats possible.

Also, has the latest Blizzard code you can look at to see how some of the frames do it that you want to emulate.

But, based on your addon list I suspect it is more than what can be done via this that you are talking about. Maybe a visual example or a more verbal example of what you are looking for. But, you should be able to use a multiple of simple connections but you will need to have some sort of hierarchy to the frames for it to work well together.

Seerah 05-12-21 01:51 PM

Have a look at Tuller's LibFlyPaper. This is what is used in Dominos, for example.

Walkerbo 05-13-21 07:15 PM

Hi all

Sorry for the delayed response.

I have 4 separate frames A, B, C and D.

I want to have each frame to be able to move freely, however, when a frame touches another frame I want them to snap together either top to bottom or left to right.

I want to be able to snap in any combination, eg.

I still do not know how to use libraries but will use the link to see if I can nut it out.


Seerah 05-14-21 11:19 AM

Using a library will likely be your best bet, as what you are attempting can get quite complicated.

Besides looking at how Dominos uses LibFlyPaper, you can also look at StatBlock - it uses the library, too.

Walkerbo 05-18-21 07:05 PM

Hi Seerah

Wow, I have been really bad at replying within a reasonable time frame of late, sorry for that.

I am still unsure how to use libraries or even two or more .lua files in one project.

I have not yet been able to nut out namespaces, I will just join the discord as I will have many many noob questions that would flood this post.

Once again thanks for the help, you guys are always so helpful. :)

Xrystal 05-19-21 12:53 AM

I use minimal libraries myself but I do have multiple files in my addons.

If you put this line ( or similar ) at the top of each file they will have access to your addon wide table or namespace.

local addonName, addonTable = ...
This fills the variable addonName with the name of the addon in question and fills the variable addonTable with the data currently available to the addon.

For example: If I were to have an addon called Portals I could use the following:
local Portals, PortalsNS = ...

And then use local for variables and functions only used in that file, public for variables and functions you want other addons to access and PortalsNS[key] = function(...) end and PortalsNS[key] = value and PortalsNS[key] = { .. } and PortalsNS.variableName = value etc for data you want the rest of your addon to have access to.

Just make sure that the files are processed in the right order so that the relevant data is available when needed.

Walkerbo 05-25-21 09:17 PM

Heya Xrystal

Thanks for the advice, I will be playing with namespaces and will absolutely be using your example.

Thanks for the help.

All times are GMT -6. The time now is 08:53 PM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI