Garry's Mod Wiki

Panel:ChildrenSize

number, number Panel:ChildrenSize()

Description

Returns the width and height of the space between the position of the panel (upper-left corner) and the max bound of the children panels (farthest reaching lower-right corner).

Returns

1 number
The children size width.
2 number
The children size height.

Example

Creates a recursively generated box of panels where the size of each panel is determined by the parent panel's children size + 10x10 pixels.

Also they flash bluish colors, just for good measure.

-- Parent panel BGPanel = vgui.Create("DPanel") BGPanel:SetSize(200, 200) BGPanel:Center() local panel, child_size_w, child_size_h = nil, 0, 0 -- Create increasingly large blocks until children size exceeds the size of the panel while(BGPanel:ChildrenSize() < BGPanel:GetSize()) do child_w, child_h = BGPanel:ChildrenSize() panel = vgui.Create("DPanel", BGPanel) panel:SetPos(0, 0) -- Increase size based on the children size panel:SetSize(child_w+10, child_h+10) -- Random bluish color every frame function panel:PerformLayout() self:InvalidateLayout() -- Call this again next frame self:SetBackgroundColor(Color(math.random(0, 255), 255, math.random(0, 255))) end -- Move to back so we can see the effect panel:MoveToBack() end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 130ms

DB GetPage 43
Generate Html 9
SaveChanges (1) 64
Render Body 0
Render Sidebar 11