Garry's Mod Wiki

Revision Difference

DFrame#526840

<panel> <parent>EditablePanel</parent> <description>The DFrame control is the foundation for any Derma menu. It holds all of your controls.</description> <hooks></hooks> <file>lua/vgui/dframe.lua</file> </panel> <example> <description>Creates a DFrame.</description> <code> local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:SetTitle( "My new Derma frame" ) DermaPanel:SetDraggable( true ) DermaPanel:MakePopup() </code> </example> <example> <description>Creates a DFrame with only close button.</description> <code> local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:SetTitle( "My new Derma frame" ) DermaPanel:SetDraggable( true ) DermaPanel:MakePopup() DermaPanel.btnMinim:SetVisible(false) DermaPanel.btnMaxim:SetVisible(false) </code> </example> <example> <description>Create an advanced DFrame.</description> <code> surface.CreateFont( "HudFont", { font = "Arial", extended = false, size = 20, }) local DermaPanel = vgui.Create("DFrame")⤶ -- Never create colors inside paint environments, cache them instead⤶ local white = Color(255, 255, 255)⤶ local black_trans = Color(0, 0, 0, 200)⤶ ⤶ local DermaPanel = vgui.Create("DFrame")⤶ DermaPanel:SetSize(500, 300) DermaPanel:Center() DermaPanel:SetTitle("") DermaPanel:SetDraggable(false) DermaPanel:MakePopup() DermaPanel.Paint = function(self, w, h) draw.RoundedBox(2, 0, 0, w, h, Color(0, 0, 0, 200)) draw.SimpleText("Derma Frame", "HudFont", 250, 0, Color(255, 255, 255)) draw.RoundedBox(2, 0, 0, w, h, black_trans) draw.SimpleText("Derma Frame", "HudFont", 250, 0, white) end </code> </example> <example> <description>Creates a DFrame with custom title color.</description> <code> local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:SetTitle( "My new Derma frame" ) DermaPanel:SetDraggable( true ) DermaPanel:MakePopup() DermaPanel.lblTitle.UpdateColours = function( label ) label:SetTextStyleColor( color_green ) end </code> </example>