bg_gps_menu_prp = Material("info_prp/bg.png")
top_gps_menu_prp = Material("info_prp/gps_unitop.png")
affiche_btn_prp = Material("info_prp/progress_gpsok.png")



function PLibs.BaseFramePaint(self,w,h)
	surface.SetDrawColor(color_white)
	surface.SetMaterial(bg_gps_menu_prp)
	surface.DrawTexturedRect(0,0,w,h)
	--
	surface.SetDrawColor(color_white)
	surface.SetMaterial(top_gps_menu_prp)
	surface.DrawTexturedRect(0,0,w,30)

	local _,y = PLibs.SizeToClient(_,30)
	surface.SetDrawColor(0,0,0)
	surface.DrawLine(0,y,w,y)
	--draw.RoundedBox(3,0,0,w,y,Color(61, 90, 254))
	local _,y1 = PLibs.SizeToClient(_,15)
	draw.SimpleText(self.Title,"PLibs:Size:22",w/2,y1,color_white,TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

function PLibs.drawCircle( x, y, radius, seg ) -- This is from garrys mod wiki
	local cir = {}

	table.insert( cir, { x = x, y = y, u = 0.5, v = 0.5 } )
	for i = 0, seg do
		local a = math.rad( ( i / seg ) * -360 )
		table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
	end

	local a = math.rad( 0 )
	table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )

	surface.DrawPoly( cir )
end

function PLibs.CreateFrame(x,y,w,h,center,title) -- I don't use vgui.Register for multiple reason -- This function is auto responsive
	local Frame = vgui.Create("DFrame")
	Frame:SetSize(PLibs.SizeToClient(w,h))
	if center then Frame:Center() else Frame:SetPos(PLibs.SizeToClient(x,y)) end
	Frame:ShowCloseButton(false)
	Frame:MakePopup()
	Frame:SetDraggable(false)
	Frame:SetTitle("")
	Frame.Title = title
	Frame.Paint = PLibs.BaseFramePaint

	local quit = vgui.Create( "DButton", Frame, "quit")
	quit:SetSize( PLibs.SizeToClient(20,20) )
	quit:SetPos( PLibs.SizeToClient(w-23,3) ) -- I use w than Frame:GetWide() because we can't resize a local sized value
	quit:SetText( "✘" )
	quit:SetTextColor( Color( 255, 255, 255 ) )
	quit.Paint = function( self, w, h )
		--[[if quit.Depressed or quit.m_bSelected then 
			draw.RoundedBox( 3, 0, 0, w, h, Color(48,48,48,250) )
		elseif quit.Hovered then
			draw.RoundedBox( 3, 0, 0, w, h, Color(255,0,0,255) )
		else
			draw.RoundedBox( 3, 0, 0, w, h, Color(48,48,48,255) )
		end]]
		surface.SetDrawColor(231, 76, 60)
		draw.NoTexture()
		PLibs.drawCircle( w/2,h/2, w/2, 10 )
	end
	quit.DoClick = function(self)
    	Frame:Close()
    end

    return Frame
end

function PLibs.CreateButtons(parent,x,y,w,h,txt,doClick) -- Function not auto responsive
	local but = vgui.Create("DButton",parent)
	but:SetSize(w,h)
	but:SetPos(x,y)
	but:SetText(txt)
	but:SetTextColor(color_white)
	but.Paint = function(self,w,h)
		draw.RoundedBox(1,0,0,w,h,Color(39, 174, 96))
	end
	but.DoClick = doClick

	return but
end