Wierd derma bug

http://a.pomf.se/kalmzk.webm

This happens when i press the panel for example. How do i fix this?

Your white panel is repainting over your top bar. Wouldn’t the best fix be setting the top bar elements as children to the white panel?

did that, didnt fix it.

Can you paste the code you’re using?

[lua] local x = ScrW()/3
local y = ScrH()/3
local Frame = vgui.Create( “DFrame” )
Frame:SetPos( ScrW()/3, ScrH()/5 )
Frame:SetSize( x, y*2 )
Frame:SetDraggable( true )
Frame:MakePopup()
Frame.Paint = function()
draw.RoundedBox( 8, 0, 0, Frame:GetWide(), Frame:GetTall(), Color( 236, 240, 241, 255 ) )
end

local Panel = vgui.Create( "DPanel",Frame )
Panel:SetPos( ScrW()/3, ScrH()/5 )
Panel:SetSize( x, y*2 )
Panel:MakePopup()
function Panel:Paint( w, h )
	draw.RoundedBox(0, 0, 0, w, h, Color( 255, 255, 255, 255 ) )
end

local Row = vgui.Create( "DPanel",Panel )
Row:SetPos( ScrW()/3, ScrH()/5 )
Row:SetSize( x, 25 )
Row:MakePopup()
function Row:Paint( w, h )
	draw.RoundedBox( 0, 0, 0, Row:GetWide(), Row:GetTall(), Color( 22, 160, 133, 255 ) )
end

local closebtn = vgui.Create( "DButton",Panel )
closebtn:SetPos( ScrW()/3-25+x, ScrH()/5 )
closebtn:SetSize( 25, 25 )
closebtn:SetText( "X" )
closebtn:SetTextColor( Color(255,255,255,255) )
function closebtn:Paint( w, h )
	draw.RoundedBox( 0, 0, 0, w, h, Color( 192, 57, 43, 255 ) )
end
closebtn.DoClick = function()
	Frame:Close()
end
closebtn:MakePopup( )

[/lua]

Thanks. Firstly, when you parent a panel to another, its position becomes relative to the parent. 0,0 is equivalent to the top-left corner. Secondly, assuming you want something to fill the frame, you can use Panel:Dock(FILL) instead. You’re also calling MakePopup() on each element which will break your parenting. You only need to call this on the top-level parent (i.e. your DFrame).

Given that you’re trying to redraw the DFrame, you’re better off drawing the titlebar in the paint function instead of creating elements for this. This removes the need for the two DPanels. Something like this would suffice:


local x = ScrW()/3
local y = ScrH()/3
local Frame = vgui.Create( "DFrame" )
Frame:SetPos( ScrW()/3, ScrH()/5 )
Frame:SetSize( x, y*2 )
Frame:SetDraggable( true )
Frame:MakePopup()
Frame:SetTitle("") -- This now works

local frameCol = Color( 236, 240, 241, 255 )
local titleCol = Color( 22, 160, 133, 255 )
local titleHeight = 25
function Frame:Paint( w, h )
	draw.RoundedBox( 8, 0, 0, w, h, frameCol )
	
	-- You can change this to use RoundedBoxEx if you want a rounded titlebar
	surface.SetDrawColor( titleCol )
	surface.DrawRect( 0, 0, w, titleHeight )
end

//Remove default buttons
Frame.btnMaxim:Hide()
Frame.btnMinim:Hide()
Frame.btnClose:Hide()

local closebtn = vgui.Create( "DButton",Frame )
closebtn:SetSize( titleHeight, titleHeight ) -- Note the use of the variable from above
closebtn:SetPos( Frame:GetWide() - titleHeight, 0 ) -- Same here, this will make it easier to change
closebtn:SetText( "X" )
closebtn:SetTextColor( color_white )
local closeCol = Color( 192, 57, 43, 255 )
function closebtn:Paint( w, h )
	draw.RoundedBox( 0, 0, 0, w, h, closeCol )
end
closebtn.DoClick = function()
	Frame:Close()
end

Note that if you wanted to make the panel sizable, you’d need to make sure the close button’s position was updated in PerformLayout.

Thank you very much. :slight_smile: