Garry's Mod Wiki

DFrame

Description

The DFrame is the moma of basically all VGUI elements. 98% of the time you will parent your element to this.

Parent

Derives from EditablePanel.

Methods

DFrame:Center()
Centers the frame relative to the whole screen and invalidates its layout. This overrides Panel:Center.
DFrame:Close()
Hides or removes the DFrame, and calls DFrame:OnClose. To set whether the frame is hidden or removed, use DFrame:SetDeleteOnClose.
boolean DFrame:GetBackgroundBlur()
Gets whether the background behind the frame is being blurred.
boolean DFrame:GetDeleteOnClose()
Determines whether or not the DFrame will be removed when it is closed. This is set with DFrame:SetDeleteOnClose.
boolean DFrame:GetDraggable()
Gets whether or not the frame is draggable by the user.
boolean DFrame:GetIsMenu()
Gets whether or not the frame is part of a derma menu. This is set with DFrame:SetIsMenu.
number DFrame:GetMinHeight()
Gets the minimum height the DFrame can be resized to by the user. You must call DFrame:SetSizable before the user can resize the frame.
number DFrame:GetMinWidth()
Gets the minimum width the DFrame can be resized to by the user. You must call DFrame:SetSizable before the user can resize the frame.
boolean DFrame:GetPaintShadow()
Gets whether or not the shadow effect bordering the DFrame is being drawn.
boolean DFrame:GetScreenLock()
Gets whether or not the DFrame is restricted to the boundaries of the screen resolution.
boolean DFrame:GetSizable()
Gets whether or not the DFrame can be resized by the user. This is achieved by clicking and dragging in the bottom right corner of the frame.
string DFrame:GetTitle()
Returns the title of the frame.
boolean DFrame:IsActive()
Determines if the frame or one of its children has the screen focus.
DFrame:OnClose()
Called when the DFrame is closed with DFrame:Close. This applies when the close button in the DFrame's control box is clicked. This is not called when the DFrame is removed with Panel:Remove.
DFrame:SetBackgroundBlur( boolean blur )
Blurs background behind the frame.
DFrame:SetDeleteOnClose( boolean shouldDelete )
Determines whether or not the DFrame is removed when it is closed with DFrame:Close.
DFrame:SetDraggable( boolean draggable )
Sets whether the frame should be draggable by the user. The DFrame can only be dragged from its title bar.
DFrame:SetIcon( string path )
Adds or removes an icon on the left of the DFrame's title.
DFrame:SetIsMenu( boolean isMenu )
Sets whether the frame is part of a derma menu or not. If this is set to true, CloseDermaMenus will not be called when the frame is clicked, and thus any open menus will remain open.
DFrame:SetMinHeight( number minH )
Sets the minimum height the DFrame can be resized to by the user. This only applies to users attempting to resize the frame; Panel:SetTall and similar methods will not be affected. You must call DFrame:SetSizable before the user can resize the frame.
DFrame:SetMinWidth( number minW )
Sets the minimum width the DFrame can be resized to by the user. This only applies to users attempting to resize the frame; Panel:SetWide and similar methods will not be affected. You must call DFrame:SetSizable before the user can resize the frame.
DFrame:SetPaintShadow( boolean shouldPaint )
Sets whether or not the shadow effect bordering the DFrame should be drawn.
DFrame:SetScreenLock( boolean lock )
Sets whether the DFrame is restricted to the boundaries of the screen resolution.
DFrame:SetSizable( boolean sizeable )
Sets whether or not the DFrame can be resized by the user. This is achieved by clicking and dragging in the bottom right corner of the frame. You can set the minimum size using DFrame:SetMinWidth and DFrame:SetMinHeight.
DFrame:SetTitle( string title )
Sets the title of the frame.
DFrame:ShowCloseButton( boolean show )
Determines whether the DFrame's control box (close, minimise and maximise buttons) is displayed.

Example

Creates a basic DFrame.

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

Example

Create an advanced customized DFrame.

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 end

Page Links


Special Pages


Wikis

?

Render Time: 40ms

DB GetPage 4
Generate Html 7
SaveChanges (1) 14
Render Body 0
Render Sidebar 13