Hi,
I'm trying to use DockPadding() on a DScrollPanel because my last element is too close to the bottom, it looks ugly as hell !
self.MainPanel.LeftPanel.PseudoContainer = vgui.Create("DPanel", self.MainPanel.LeftPanel)
self.MainPanel.LeftPanel.PseudoContainer:Dock(FILL)
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel = vgui.Create("DLabel", self.MainPanel.LeftPanel.PseudoContainer)
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel:Dock(TOP)
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel:SetHeight(mainPanelH * 1/30)
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel:SetText("PLAYERS LIST")
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel:SetColor(Color(255,255,255))
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel:SetContentAlignment(5)
self.MainPanel.LeftPanel.PseudoContainer.PlayersLabel.Paint = function(pnl,w,h)
draw.RoundedBox(0,0,0,w,h,Color(50,49,49))
end
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector = vgui.Create("DScrollPanel", self.MainPanel.LeftPanel.PseudoContainer)
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector:Dock(FILL)
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector:DockPadding(0,0,0,10)
-- scroll bar
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar.Paint = function() end
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar.btnUp.Paint = function() end
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar.btnDown.Paint = function() end
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar.btnGrip.Paint = function() end
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar.SetUp = function (self, barSize, canvasSize)
self.BarSize = barSize
self.CanvasSize = math.max(canvasSize - barSize, 1)
self:SetEnabled(true)
self:InvalidateLayout()
end
-- scroll bar
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.Paint = function(pnl,w,h)
draw.RoundedBox(0,0,0,w,h,Color(50,49,49))
draw.RoundedBox(0,math.floor(w*1/80),0,w - math.floor(w*1/80) * 2,h - math.floor(w*1/80),Color(150,146,146))
end
for _,ply in ipairs(player.GetAll()) do
-----------
local currentPly = vgui.Create("DButton", self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector)
currentPly:Dock(TOP)
currentPly:SetHeight(self.MainPanel.LeftPanel:GetWide() * 1/15)
currentPly:DockMargin(self.MainPanel.LeftPanel:GetWide() * 1/30 + self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector.VBar:GetWide(),self.MainPanel.LeftPanel:GetWide() * 1/60,self.MainPanel.LeftPanel:GetWide() * 1/30,self.MainPanel.LeftPanel:GetWide() * 1/60)
currentPly.Paint = function(pnl,w,h)
draw.RoundedBox(0,0,0,w,h,Color(50,49,49))
end
currentPly:SetText(ply:Name())
currentPly:SetColor(Color(255,255,255))
currentPly.DoClick = function()
self.MainPanel.LeftPanel.PseudoLabel:SetText(ply:Name())
self.MainPanel.LeftPanel.ModelViewerPanel.ModelViewer:SetModel(ply:GetModel())
end
end
Here is a snippet of my code,
and here is the output if i scroll to the bottom :
https://files.facepunch.com/forum/upload/113807/b62078ba-1ba0-411f-a562-db4cfac9d34e/Sans titre.png
How should I use the padding to make it work ?
I even tried to use like SetPadding(1000,1000,1000,1000) and nothing changed. :/
If SetPadding is not appropriate in my case, what should I use then ?
Thanks in advance !
Try using DockMargin on the child elements.
I used DockMargin on the child element as you can see but margin is the space between too element, because of that it will not affect the last element. And no using DockMargin on the scrollpanel will not do what i want. I want spacing after last element :/
try using DockPadding on your self.MainPanel.LeftPanel.PseudoContainer instead
self.MainPanel.LeftPanel.PseudoContainer:DockPadding(0,0,0,10)
It should be equivalent to using DockMargin on the scrollpanel like Bobblehead said.
self.MainPanel.LeftPanel.PseudoContainer.PseudoSelector:DockMargin(0,0,0,10)
Worked fine, I had to moove the .Paint function override from PseudoSelector.PseudoSelector to PseudoSelector
Sorry, you need to Log In to post a reply to this thread.