From a8c6765170f826059b301dd4757bc2f081c9ee20 Mon Sep 17 00:00:00 2001 From: Bkacjios Date: Fri, 26 May 2023 13:04:38 -0400 Subject: [PATCH] Fixed music probability screen erroring --- source/modules/gui/panels/musicprobability.lua | 8 ++++++++ source/modules/gui/panels/scrollpanel.lua | 15 +++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source/modules/gui/panels/musicprobability.lua b/source/modules/gui/panels/musicprobability.lua index 501857f..7015667 100644 --- a/source/modules/gui/panels/musicprobability.lua +++ b/source/modules/gui/panels/musicprobability.lua @@ -24,6 +24,14 @@ function PANEL:MusicFileSlider() self:SetTextFormat("%d%%") end +function PANEL:SetValue(value) + self.m_pSlider:SetValue(value) +end + +function PANEL:GetValue() + return self.m_pSlider:GetValue() +end + function PANEL:SetFileName(str) self.m_pFileName:SetText(str) end diff --git a/source/modules/gui/panels/scrollpanel.lua b/source/modules/gui/panels/scrollpanel.lua index 60f4eae..503d45e 100644 --- a/source/modules/gui/panels/scrollpanel.lua +++ b/source/modules/gui/panels/scrollpanel.lua @@ -3,9 +3,17 @@ local PANEL = class.create("ScrollPanel", "Panel") function PANEL:ScrollPanel() self:super() -- Initialize our baseclass self:DockPadding(0,0,0,0) + self:SetBGColor(color(215, 0, 0)) self.m_pCanvas = self:Add("Panel") self.m_pCanvas:SetBGColor(color(215, 215, 215)) + + self.m_pCanvas.PerformLayout = function(this) + this:SizeToChildren(false, true) + if self.m_bNoSizing and this:GetHeight() < self:GetHeight() then + this:SetPos(0, (self:GetHeight()-this:GetHeight()) * 0.5) + end + end -- Create the scroll bar self.m_pVBar = self:Add("ScrollBar") @@ -41,10 +49,6 @@ function PANEL:InnerWidth() end function PANEL:Rebuild() - self:GetCanvas():SizeToChildren(false, true) - if self.m_bNoSizing and self:GetCanvas():GetHeight() < self:GetHeight() then - self:GetCanvas():SetPos(0, (self:GetHeight()-self:GetCanvas():GetHeight()) * 0.5) - end end function PANEL:OnMouseWheeled(x, y) @@ -83,8 +87,7 @@ function PANEL:PerformLayout() self.m_pCanvas:SetPos(0, ypos) self.m_pCanvas:SetWidth(wide) - - self:Rebuild() + self.m_pCanvas:InvalidateLayout() end function PANEL:SetScroll(scroll)