Revision Difference
DFrame#528821
<panel>
<parent>EditablePanel</parent>
<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 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
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>Create an advanced customized DFrame.</description>
<code>
surface.CreateFont("Font", {font = "Arial",extended = false,size = 20,}) -- Then font named 'Font' compacted on one line⤶
local faded_black = Color(0, 0, 0, 200) -- The color black but with 200 Alpha⤶
local DermaPanel = vgui.Create("DFrame") -- The name DermaPanel to store the value DFrame⤶
DermaPanel:SetSize(500, 300) -- Sets the size to 500x by 300y⤶
DermaPanel:Center() -- Centers the panel⤶
DermaPanel:SetTitle("") -- Set the title to nothing⤶
DermaPanel:SetDraggable(false) -- Makes it so you carnt drag it⤶
DermaPanel:MakePopup() -- Makes it so you can move your mouse on it⤶
DermaPanel.Paint = function(self, w, h) -- Paint function w, h = how wide and tall it is⤶
draw.RoundedBox(2, 0, 0, w, h, faded_black) -- Draws a rounded box with the color faded_black stored abouve⤶
draw.SimpleText("Derma Frame", "Font", 250, 0, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) -- Draws text in the color white
-- Then font named "Font" compacted on one line.⤶
surface.CreateFont( "Font", { font = "Arial", extended = true, size = 20 } )⤶
⤶
local faded_black = Color( 0, 0, 0, 200 ) -- The color black but with 200 Alpha⤶
⤶
local DermaPanel = vgui.Create( "DFrame" ) -- The name DermaPanel to store the value DFrame.⤶
DermaPanel:SetSize( 500, 300 ) -- Sets the size to 500x by 300y.⤶
DermaPanel:Center() -- Centers the panel.⤶
DermaPanel:SetTitle( "" ) -- Set the title to nothing.⤶
DermaPanel:SetDraggable( false ) -- Makes it so you carnt drag it.⤶
DermaPanel:MakePopup() -- Makes it so you can move your mouse on it.⤶
DermaPanel.Paint = function( self, w, h ) -- Paint function w, h = how wide and tall it is.⤶
-- Draws a rounded box with the color faded_black stored above.
draw.RoundedBox( 2, 0, 0, w, h, faded_black )⤶
-- Draws text in the color white.⤶
draw.SimpleText( "Derma Frame", "Font", 250, 0, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )⤶
end
</code>
</example>