DModelPanel help

So i am including a DModelPanel into a menu i am making for a gamemode, and it is a child to a DScrollPanel. My problem is that when i scroll, the model panels does his -

how can I get it to slide 'underneath" where the light grey and dark grey areas meet (like the right-side text and buttons do)?

You’ll need to call render.SetScissorRect for the area you want it to display in, then reset it after you’re done.

Here’s a recent thread that shows how to solve it with code!
http://forum.facepunch.com/showthread.php?t=1285791

so use this (but rename the funcs/vars with what I named the DModelPanels)?

[lua]
local oldpaint = mdl.Paint
function mdl:Paint()

	local pnl = self:GetParent():GetParent()
	local x2, y2 = pnl:LocalToScreen( 0, 0 )
	local w2, h2 = pnl:GetSize()
	render.SetScissorRect( x2, y2, x2 + w2, y2 + h2, true )

	oldpaint( self )
	
	render.SetScissorRect( 0, 0, 0, 0, false )

[/lua]

(sorry, Just started working with vgui yesterday, I manages to avoid it for a few years, not anymore, lol)

Pretty much. It’s essentially setting the rendering bounds of that panel from startx, starty, to endx, endy for that call then reset so it doesn’t cut off other rendering features. oldpaint is what they did so it could be easily wrapped. Otherwise you set the scissor inside your old paint function and reset at the end.

ok, thanks, i’ll apply it tomorrow

[editline]26th July 2013[/editline]

I got bored and did this (tested, and it works), plus a real time saver.

for anyone that wants it -

[lua]
local modelFix = {}
modelFix[1] = lambopic – this is a table of all DModelPanels that need fixing
modelFix[2] = skylinepic
modelFix[3] = escaladepic
modelFix[4] = gt500pic
modelFix[5] = bmwpic
modelFix[6] = volksBug
modelFix[7] = impala

– then a loop that applies the patch to everything in the table above, instead of having to retype the whole function for every DModelPanel

for k, v in pairs( modelFix ) do
local oldpaint = v.Paint
function v:Paint()
local pnl = self:GetParent():GetParent()
local x2, y2 = pnl:LocalToScreen( 0, 0 )
local w2, h2 = pnl:GetSize()
render.SetScissorRect( x2, y2, x2 + w2, y2 + h2, true )

		oldpaint( self )
	
		render.SetScissorRect( 0, 0, 0, 0, false )
	end
end

[/lua]