How can I actually center a vgui object on screen?

I was just about to post this in a different thread, but it got closed moments before I could. Is there a way to actually center an object, not set it’s top left corner to the center? I can’t seem to figure it out.



local test_frame = vgui.Create("DFrame")
test_frame:SetSize(100, 100)
test_frame:SetTitle("Test")
test_frame:Center() -- Use this for the frame/element you want to center
test_frame:MakePopup()


I feel extremely stupid for not knowing this beforehand. Thanks!