DScrollPanel/GetVBar

From Garry's Mod
Jump to: navigation, search
 DScrollPanel:GetVBar( )

Contents

DescriptionPanelFunc

Returns the vertical scroll bar of the panel.

Returns

Examples

Example

Example of styling a scrollbar

local DFrame = vgui.Create("DFrame")
DFrame:SetSize(500, 500)
DFrame:Center()
DFrame:MakePopup()
DFrame:SetTitle("Scrollbar Example")
function DFrame:Paint(w, h)
	draw.RoundedBox(0, 0, 0, w, h, Color(0, 100, 100))
end

local DScrollPanel = vgui.Create("DScrollPanel", DFrame)
DScrollPanel:SetSize(400, 250)
DScrollPanel:Center()

local sbar = DScrollPanel:GetVBar()
function sbar:Paint(w, h)
	draw.RoundedBox(0, 0, 0, w, h, Color(0, 0, 0, 100))
end
function sbar.btnUp:Paint(w, h)
	draw.RoundedBox(0, 0, 0, w, h, Color(200, 100, 0))
end
function sbar.btnDown:Paint(w, h)
	draw.RoundedBox(0, 0, 0, w, h, Color(200, 100, 0))
end
function sbar.btnGrip:Paint(w, h)
	draw.RoundedBox(0, 0, 0, w, h, Color(100, 200, 0))
end

local str = ""
for i = 1, 50 do str = str .. "more space!\n" end

local DLabel = vgui.Create("DLabel", DScrollPanel)
DLabel:SetText(str)
DLabel:Center()
DLabel:SizeToContents()

Output:


scrollbar style example.png
Personal tools
Navigation