Garry's Mod Wiki

Revision Difference

DFrame#526887

<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>⤶ <description>The DFrame is the moma of basically all VGUI elements. 98% of the time you will parent your element to this. </description></panel>⤶ ⤶ <example>⤶ <description>Creates a basic 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()⤶ local DFrame = vgui.Create( "DFrame" ) -- The name of the panel we don't have to parent it⤶ DFrame:SetPos(100, 100) -- Set the position to 100x by 100y DFrame:SetSize(300, 200) -- Set the size to 300x by 200y⤶ DFrame:SetTitle("Derma Frame") -- Set the title in the top left to 'Derma Frame'⤶ DFrame:MakePopup() -- Makes your mouse be able to move around </code> ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>Creates a DFrame with only close button.</description>⤶ </example>⤶ ⤶ <example>⤶ <description>Create an advanced customized 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()⤶ 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,⤶ })⤶ -- Never create colors inside paint environments, cache them instead⤶ local black_trans = Color(0, 0, 0, 200)⤶ ⤶ local DermaPanel = vgui.Create("DFrame")⤶ surface.CreateFont("Font", {font = "Arial",extended = false,size = 20,}) -- The font named 'Font'⤶ local faded_black = 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, black_trans) -- color_white is a Color that is pre-defined in Garry's mod for us! draw.SimpleText("Derma Frame", "HudFont", 250, 0, color_white)⤶ draw.RoundedBox(2, 0, 0, w, h, faded_black) draw.SimpleText("Derma Frame", Font", 250, 0, color_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>⤶ ⤶ </example>