PANEL/Paint

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 9: Line 9:
 
|Realm=Client
 
|Realm=Client
 
|Predicted=No
 
|Predicted=No
 +
}}
 +
{{Arg
 +
|type=Panel
 +
|name=panel
 +
|desc=The panel itself.
 
}}
 
}}
 
{{Arg
 
{{Arg

Revision as of 16:31, 24 November 2019

 PANEL:Paint( )

Contents

Description

Called whenever the panel should be drawn.

You can create panels with a customized appearance by overriding their Paint() function, which will prevent the default appearance from being drawn.

NOTE

Render operations from the surface library (and consequentially the draw library) are always offset by the global position of this panel, as seen in the example below

NOTE

This hook will not run if the panel is completely off the screen. The hook will still run however if any parts of the panel are still on screen.

Arguments

Panel panel

The panel itself.

Arguments

number width

The panel's width.

Arguments

number height

The panel's height.

Returns

boolean

Returning true prevents the background from being drawn.

Examples

Example

Creates a DPanel and overrides its Paint() function to draw a 100x100 pixel black rounded box in the center of the screen.

local panel = vgui.Create( "DPanel" )
panel:SetSize( 100, 100 )
panel:SetPos( ScrW() / 2 - 50, ScrH() / 2 - 50 )

function panel:Paint( w, h )
    draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 0, 0 ) )
end


Personal tools
Navigation