• DIconLayout Panels Don't Fit Snug HELP PLEASE?
    5 replies, posted
So I want to create a specific number of dpanels and make them fit the panel accurately But using this: [CODE] local test = vgui.Create( "DFrame" ) test:SetSize( 250, 500 ) test:Center() test:MakePopup() // Make the scroll panel local test2 = vgui.Create( "DScrollPanel", test ) test2:SetPos( 0, 50 ) test2:SetSize( test:GetWide(), test:GetTall() ) // Make the IconLayout local test3 = vgui.Create( "DIconLayout", test2 ) test3:SetSize( test:GetWide(), test:GetTall() ) // Store Width local w = test3:GetWide() // Define Squares local amt = 12 // Go through each and create based on math ratio for i = 1, amt do local pnl = test3:Add( "DPanel" ) pnl:SetSize( w/amt, 50 ) end [/CODE] It results in: [url]http://gyazo.com/06d62a0b58adc6e53d05f6c1ca49a381[/url] I suspected maybe the Scroll Panel had some strange offset so I removed it: [CODE] //local test = vgui.Create( "Inventory" ) local test = vgui.Create( "DFrame" ) test:SetSize( 250, 500 ) test:Center() test:MakePopup() // Make the scroll panel //local test2 = vgui.Create( "DScrollPanel", test ) //test2:SetPos( 0, 50 ) //test2:SetSize( test:GetWide(), test:GetTall() ) // Make the IconLayout local test3 = vgui.Create( "DIconLayout", test ) test3:SetSize( test:GetWide(), test:GetTall() ) // Store Width local w = test3:GetWide() // Define Squares local amt = 12 // Go through each and create based on math ratio for i = 1, amt do local pnl = test3:Add( "DPanel" ) pnl:SetSize( w/amt, 50 ) end [/CODE] but same results: [url]http://gyazo.com/82370ee9d9731392a5985c06fc7a0009[/url]
[lua] test3:SetSpaceY( 5 ) //Sets the space in between the panels on the X Axis by 5 test3:SetSpaceX( 5 ) //Sets the space in between the panels on the Y Axis by 5 [/lua]
[QUOTE=James xX;47689690][lua] test3:SetSpaceY( 5 ) //Sets the space in between the panels on the X Axis by 5 test3:SetSpaceX( 5 ) //Sets the space in between the panels on the Y Axis by 5 [/lua][/QUOTE] Thanks for the reply, but I am looking to make it fit in one line not space them out. As you can see the math should make it so they all stay on the one line fitting it completely but it doesn't, it just has that stupid gap.
Ok then use DPanelList, I know it's outdated, well you can say thanks to Garry who made this vgui outdated by the way it's the only way to make a list of panels, the DIconLayout is working only when you need multiple panels per lines, when you want 1 panel per line, use DPanelList.
[QUOTE=16 bytes;47689769]Thanks for the reply, but I am looking to make it fit in one line not space them out. As you can see the math should make it so they all stay on the one line fitting it completely but it doesn't, it just has that stupid gap.[/QUOTE] I would use [url]http://wiki.garrysmod.com/page/Category:DGrid[/url] if you want them all on one line then.
Wow that was super useful, much appreciated sir you are truly a great help.
Sorry, you need to Log In to post a reply to this thread.