Giter Site home page Giter Site logo

better-derma-grid's Introduction

Better Derma Grid

Replacement for Gmod's DIconLayout that isn't buggy and hard to use

Example

local frame = vgui.Create("DFrame")
frame:SetSize(800, 500)
frame:Center()
frame:MakePopup()

local grid = vgui.Create("ThreeGrid", frame)
grid:Dock(FILL)
grid:DockMargin(4, 4, 4, 4)
grid:InvalidateParent(true)

grid:SetColumns(3)
grid:SetHorizontalMargin(2)
grid:SetVerticalMargin(2)

for i=1, 10 do
	local pnl = vgui.Create("DPanel")
	pnl:SetTall(100)
	grid:AddCell(pnl)
end

Installation

Put it in clientside autorun

Usage

Initialize the panel, and set its columns - the amount of columns will dictate how many items are on each row.

local grid = vgui.Create("ThreeGrid")
grid:SetColumns(3)

Add cells to the grid, all you need to do is set the panel's height, every panel in a row will take the height of its tallest child

local pnl = vgui.Create("DPanel")
pnl:SetTall(100)
grid:AddCell(pnl)

If you need to position child panels based on the cell's size, note that GetWide will return the correct width of the panel right after you call AddCell.

Spacing

Want spacing between your grid cells?

grid:SetHorizontalMargin(5) //5 pixels of space between each item on a row, horizontally
grid:SetVerticalMargin(10) //10 pixels of space between each row, vertically

This is the equivalent of DIconLayout's SetSpaceX and SetSpaceY

Clearing

You can get rid of everything in a grid by using:

grid:Clear()

Misc

Normally, adding cells to the table goes on a left to right, top to down basis, so if you want to add a completely empty cell for spacing reasons or whatever, you can use:

grid:Skip()

better-derma-grid's People

Contributors

threebow avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.