Garry's Mod Wiki

DPropertySheet

Description

A tab oriented control where you can create multiple tabs with items within. Used mainly for organization.

View source

Parent

Derives methods, etc not listed on this page from Panel.

Events

DPropertySheet:OnActiveTabChanged( Panel old, Panel new )
Called when a player switches the tabs. Source code states that this is meant to be overridden.

Methods

table DPropertySheet:AddSheet( string name, Panel pnl, string icon = nil, boolean noStretchX = false, boolean noStretchY = false, string tooltip = nil )
Adds a new tab.
Panel DPropertySheet:CloseTab( Panel tab, boolean removePanel )
Removes tab and/or panel from the parent DPropertySheet.
DPropertySheet:CrossFade( table anim, number delta, table data )
This is used internally - although you're able to use it you probably shouldn't. Internal function that handles the cross fade animation when the player switches tabs.
Panel DPropertySheet:GetActiveTab()
Returns the active DTab of this DPropertySheet.
number DPropertySheet:GetFadeTime()
Returns the amount of time (in seconds) it takes to fade between tabs. Set by DPropertySheet:SetFadeTime
table DPropertySheet:GetItems()
Returns a list of all tabs of this DPropertySheet.
number DPropertySheet:GetPadding()
Gets the padding from the parent panel to child panels.
boolean DPropertySheet:GetShowIcons()
We advise against using this. It may be changed or removed in a future update. Returns whatever value was set by DPropertySheet:SetShowIcons.
DPropertySheet:SetActiveTab( Panel tab )
Sets the active tab of the DPropertySheet.
DPropertySheet:SetFadeTime( number time = 0.1 )
Sets the amount of time (in seconds) it takes to fade between tabs.
DPropertySheet:SetPadding( number padding = 8 )
Sets the padding from parent panel to children panel.
DPropertySheet:SetShowIcons( boolean show )
We advise against using this. It may be changed or removed in a future update. Does nothing.
DPropertySheet:SetupCloseButton( function func )
Creates a close button on the right side of the DPropertySheet that will run the given callback function when pressed.
DPropertySheet:SizeToContentWidth()
Sets the width of the DPropertySheet to fit the contents of all of the tabs.
DPropertySheet:SwitchToName( string name )
Switches the active tab to a tab with given name.

Example

Example of how you'd create and use this panel.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 300 ) frame:Center() frame:MakePopup() local sheet = vgui.Create( "DPropertySheet", frame ) sheet:Dock( FILL ) local panel1 = vgui.Create( "DPanel", sheet ) panel1.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255, self:GetAlpha() ) ) end sheet:AddSheet( "test", panel1, "icon16/cross.png" ) local panel2 = vgui.Create( "DPanel", sheet ) panel2.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 255, 128, 0, self:GetAlpha() ) ) end sheet:AddSheet( "test 2", panel2, "icon16/tick.png" )
Output: