cLib.DFrame
Styled frame window with header, close button, and optional blur effect.
Basic Usage
local frame = vgui.Create("cLib.DFrame")
frame:SetSize(cLib.Scale(500), cLib.Scale(400))
frame:SetTitle("My Window")
frame:Center()
frame:MakePopup()Methods
| Method | Description |
|---|---|
SetTitle(string) | Set window title |
SetColor(Color) | Set background color |
SetHeaderColor(Color) | Set header color |
SetRound(number) | Set corner roundness |
DrawHeader(bool) | Show/hide header |
EnableBlur(bool, layers, intensity) | Enable blur effect |
DrawSecondaryFrameBase(bool) | Enable secondary style |
Customization
local frame = vgui.Create("cLib.DFrame")
frame:SetSize(cLib.Scale(600), cLib.Scale(450))
frame:SetTitle("Settings")
frame:Center()
-- Custom colors
frame:SetColor(Color(40, 40, 45, 250))
frame:SetHeaderColor(Color(50, 50, 55, 250))
-- Corner roundness
frame:SetRound(8)
-- Enable blur background
frame:EnableBlur(true, 4, 3) -- enabled, layers, intensity
frame:MakePopup()Accessing Content Area
-- Add content to the main container
local container = frame.mainContainer
local label = vgui.Create("DLabel", container)
label:SetText("Content goes here")
label:Dock(TOP)
label:DockMargin(cLib.Scale(10), cLib.Scale(10), cLib.Scale(10), 0)Custom Close Behavior
-- Override close button
frame.newCloseBtn.DoClick = function()
-- Confirm before closing
cLib.Confirm("Close", "Are you sure?", function()
frame:Remove()
end)
endPostThink Hook
-- Custom think function (runs after default Think)
frame.PostThink = function(self)
-- Update something every frame
self.timeLabel:SetText(os.date("%H:%M:%S"))
endWithout Header
local frame = vgui.Create("cLib.DFrame")
frame:SetSize(cLib.Scale(300), cLib.Scale(200))
frame:DrawHeader(false) -- Hide header
frame:Center()
frame:MakePopup()