AGLModule - Animated Grid Layout Module [V1.1.2]

Hello! This is my first time making a open source module. Correct me if i make any mistakes.

AGL allows you to easily animate Grid Layouts. They work exacly the same as a UiGridLayout, but with added functionality.


In this example, you can see there is a object to the left, which is still a child of the parent of the UiGridLayout, but, it does not count as a real cell and stays on its position. (it was blacklisted)

ezgif-2-c74eeea2f2


In this example, you can see me messing around with a UiGridLayout. You can do the same in the example in the module. You need to use the real uiGridLayout, sincei made a .Changed event, so that it will automatically also change the module’s Layout. the red Color is the real uiGridLayout.

AGLGif2


Features
  • It is exacly the same as a UiGridLayout Every property is coded by myself, to always produce the same effects as a real UiGridLayout.

  • Animations for moving a cell to their next location, in case they need to be moved.Look at the properties section at OnPositionChange.

  • Animations for inserting a cell to the GrildLayout. This allows you to control how they appear, like fade in, and so on. Look at the properties section at OnCellInsert.

  • Anchorpointscan be set to any value , and the grid will still behave like normal. This allows you to set the Anchorpoint to something like (0.5,0.5). Adding a size increase will make this guiobject scale in all directions. That is the main purpose of this feature.

  • Sizes don’t need to be the cellsize This allows you to create hovereffects, that scale up the cell. Read more about that in the "added Properties section, at the ForceSize property.

Just note that you can also make simular to UiListLayouts. As you can just set the FillDirectionMaxCells to 1, which will make the uigridlayout 1D. You can read a little bit more about that in UIGridLayout | Documentation - Roblox Creator Hub.

All the old properties can be found at UIGridLayout | Documentation - Roblox Creator Hub. This module has all the properties that a real UiGridLayout has too!


Functions

module.new(UiGridLayout : UIGridLayout?, OtherProperties : Properties?)

This creates a new custom UiGridLayout. If UiGridLayout is passed, it sets its parent to nil, and copies all of its properties.. If UiGridLayout is nil, then it will inherit all the base properties from a Normal UiGridLayout.

module:OrganizeGuiObjects()

This function recalculates all the new positions of the cells, and fires the OnPositionChange and, if there are new cells added, compared to the last time when organize was run, it will also run OnCellInsert.

module:Void()

This function wil basically destroy the module, and put the UiListLayout back to its original parent.

Added Properties

ForceSize: boolean?

ForceSize will make it, when you organize the grid, if it will also change the cells sizes to the cellsize. Automatically set to true.


OnPositionChange: (Object : GuiObject, Position : UDim2) -> ()?

OnPositionChangewill allow you to animate the clles, when the position changes.

Example:

OnPositionChange= function(Object : GuiObject, Position : UDim2)
	TweenService:Create(Object, TweenInfo.new(.4,Enum.EasingStyle.Quint, Enum.EasingDirection.Out),{
		Position = Position
	}):Play()
end

Normally, this is set toa function, that automatically sets the position instantly, without animating it.


OnCellInsert: (Onbject : GuiObject, Position : UDim2) -> ()?

This function is called, when a new cell is added to the gridlayout, and the OrganizeGuiObjects method is called. This allows you to make a transition for a frame to go into the grid.

Example:

OnCellInsert = function(Object : GuiObject, Position : UDim2)
	Object.Position = Position + UDim2.new(0,-100,0,00)
	TweenService:Create(Object, TweenInfo.new(1,Enum.EasingStyle.Quint, Enum.EasingDirection.Out),{
		Position = Position
	}):Play()
end

AffectedGuiObjectsType: Whitelist | BlackList | Auto ?

AffectedGuiObjectsType allows you to change which objects you want to move.
  • Whitelist: AffectedGuiObjects is a table, and only Guiobjects that are in this table will be part of the grid. WARNING: Please make sure that the objects parent is the same as the guidlaouts parent. Not following this may have some unexpected results.
  • BlackList: The same as Auto, but removes the objects that are in AffectedGuiObjects from the list of cells.
  • Auto: Will get all children, and put them in the cell, if the object is a guiobject.

AffectedGuiObjects : {[number] : GuiObject}?

if AffectedGuiObjectsType is either set to Whitelist or Blacklist, then this table is used as support for their respective effect. Please read the effects above.

self.__UiGridLayout : UiGridLayout

If a UiGridLayout was made, while a real gridlayout was passed, then you can always acces that instance using this value.

Notes that are good to know
  1. If parent is set to nil, then the script will trow an error telling you that there is no parent. Please make sure there always is a parent. Only required when not passing in a UiGridLayout.

Updates
  • VX.X.X is increases each time the module gets an entire new overhaul
  • VX.X.X is increases each time there is an update, where you need to edit some part of your code in order for it to work again.
  • VX.X.X is increased each time there are bugfixes or little update that require no manual change of your code to work. This means it can be updated to this version safely.

V1.1.0

24 nov '24
  1. Removed an etra if statement that was unnececary in module:OrganizeGuiObjects()
  2. PositionChange changed to “OnPositionChange” to match with its similar function: “OnCellInsert”
  3. In the model, updated and made the Exmaple (previously ReadMe) more cleaner and readable.

V1.1.1

24 nov '24
  1. Fixed a problem, where an custom error didn’t occur. (Parent is nil)

V1.1.2

25 nov '24
  1. Fixed a big where the properties get overwritten by the base settings, even tough those properties were already set.

Current Patch bugs
  • When VerticalAlignment or HorizontalAlignment are set to Center, then the Cells are shifted one pixel in their respective axis
  • Not 100% sure but i joust found out that if a guiobject is invisible, it is ignored

Planned Features
  • Add Suport for UiListLayouts
    • Custom Padding for each Axis. For some reason, Padding is a UDIm for the UiListLayout, but it still has 2 other properties that arent visibe on the wiki and as properties? They are called VerticalPadding and HorizontalPadding.

Here is the Roblox model: https://create.roblox.com/store/asset/126049853207104/AGLModule

Note: The Roblox Model contains an example of how you could use. There are 2 frames, one with a real UiGridLayout, and one that is made by the module. The real UiGridLayout’s color is red, and the custom one is white.


And at last:

  • This module might have bugs, and if you found one, please comment it in this post.
  • Please share your AGL creations with us here!
  • Credits are appreciated!
  • Extra ideas for features are also welcome!

Will you use this module?

  • I will use this recource!
  • I will not use this recource.

0 voters

17 Likes

The module seems very great, could you show a video of it?

5 Likes

Checked out the example and its very clever! You should also add support for ListLayouts as that would be super helpful.

2 Likes

Working on an inventory system, might use this for my hotbar.

1 Like

Showing a video of the features in action would be amazing.

A video and support for lists would be great.

As mentioned above, it might be better to showcase a GIF or a video.

i will make that later on after i am done with this, listlayouts should be simpler, since they are only 1d. And don’t forget you can make the FillDirectionMaxCells 1, and in that case, you alos have a uilistlayout! But remember the offset is always the same, so each object should be the same size.

Edit: UiListLayouts ARE NOT simpler

Look at this, i have to write each of these individually

1 Like

It will be worth it lol

Godspeed and good luck!

1 Like

Yeah i kinda realized that uilidtlayouts are really confusing, they are like littely almost the same as a gridlayout, the uilistlayout also has a property called wrap. That makes it act kinda like and uigridlayout. But even if i made this listlayout, the listlayout should only be used if the objects are not all thr same size (hover animations excluded). If they are the same size, just use the uiGridLayout one, since thr listlayout is unnececary. Also listlayouts have an invisible property called horizontal- and verticalpadding? Like the wiki does ot sah anhthjng about it, but you cnnot manualy change either of those. (But you will with my module). Also planning on mizing some properties from grid with list and the other way around mabytoo since these can be improved easily.

I just have to code them first i almost have the code writtin but it doesnt as expected, so it will hopefully be ready in like 3 to 4 days.

edit: i am sorry for this terrible writing, it was written on my phone.

1 Like

UiListLayout delayed and might be discontinued

There are a few problems i could not find the solutions for, so idecided to leave it as is for now, and release it later when i want to continue this.

Also from my experience, even if i released UiListLayout support, i do not recommend it to use unless:

  • The objects are all different sizes
  • you need the fill property

What the module needs for realease is still:

  • Add Uiflexitem support into it
  • Add support for strech and align preoperties (i have no clue how they work)
  • fix some bugs

I would want to make this module, but i feel like i don’t get enough out of it. Probably nobody will use this, including me. It was fun foor thinking logically, but i will not add uilistlayout support unless someone wants to do it themselves (i can send you the code that i made, currently around 800 lines).

The main module will still be supported and could get occasionally updated

Thank you for reading.

Hey, you should make a repository of this resource on your github so we can fork it and help improve your module and fix some bugs. We could also directly create issues…

good idea but if i am honest i am not really planning to update this anymore its more like a fun thing i made in like 2 days or so.

I might say its discontinued so people know.

Update: nevermind i will work on this later but i have to delay it for a while. I am also immediately going to look into this: New UIListLayout Flex Features [Beta]

I’ll also add a github repository then. I’ll also rewrite this devforum post and use a custom website to host the docs via github if thats free.