From d2c072193d4407f43fbda265cc6db5cb664b3018 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sat, 3 Oct 2009 13:20:28 -0500 Subject: [PATCH] made scrollBarUpdate generic --- WeightsWatcher.xml | 2 +- config.lua | 37 ++++++++++++++----------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/WeightsWatcher.xml b/WeightsWatcher.xml index 16e115c..ceb7677 100644 --- a/WeightsWatcher.xml +++ b/WeightsWatcher.xml @@ -116,7 +116,7 @@ - scrollBarUpdate() + scrollBarUpdate(self, ww_editWeight.scrollContainer, ww_statFrameTable, 20, -30, 28) FauxScrollFrame_OnVerticalScroll(self, offset, 20, self:GetScript("OnShow")) diff --git a/config.lua b/config.lua index f0e32fa..b9fd8cb 100644 --- a/config.lua +++ b/config.lua @@ -25,35 +25,26 @@ function open_config() end end -function scrollBarUpdate() - --since all buttons are relative to the first we need to adjust the position of the first to have the rest display within our frame - local numShown, i = 28 - --scroll bar position - local offset = FauxScrollFrame_GetOffset(ww_editWeight.scrollFrame) - --let the scroll bar position update - FauxScrollFrame_Update(ww_editWeight.scrollFrame, #(ww_statFrameTable), numShown, 100) +function scrollBarUpdate(scrollFrame, scrolledFrame, buttonTable, buttonHeight, initialOffset, numShown) + local i + local offset = FauxScrollFrame_GetOffset(scrollFrame) offset = offset / 5 - if numShown > #(ww_statFrameTable) then - numShown = #(ww_statFrameTable) + if numShown > #(buttonTable) then + numShown = #(buttonTable) end - if offset > #(ww_statFrameTable) - numShown then - offset = #(ww_statFrameTable) - numShown + if offset > #(buttonTable) - numShown then + offset = #(buttonTable) - numShown end - - --change the position of the stats frame based on the offset - ww_editWeight.scrollContainer:SetPoint("TOPLEFT", 0, -30 + 20 * offset) - - --hide the stats that appear before the first button shown + FauxScrollFrame_Update(scrollFrame, #(buttonTable), numShown, buttonHeight * 5) + scrolledFrame:SetPoint("TOPLEFT", 0, initialOffset + buttonHeight * offset) for i = 1, offset do - ww_statFrameTable[i]:Hide() + buttonTable[i]:Hide() end - --display those that fit in the window for i = offset + 1, offset + numShown do - ww_statFrameTable[i]:Show() + buttonTable[i]:Show() end - --hide the stats after the window - for i = offset + numShown + 1, #(ww_statFrameTable) do - ww_statFrameTable[i]:Hide() + for i = offset + numShown + 1, #(buttonTable) do + buttonTable[i]:Hide() end end @@ -177,7 +168,7 @@ function toggleCollapse(categoryFrame) categoryFrame.collapsed = true categoryFrame:SetHeight(20) end - scrollBarUpdate() + scrollBarUpdate(ww_editWeight.scrollFrame, ww_editWeight.scrollContainer, ww_statFrameTable, 20, -30, 28) end trackedStats = { -- 1.7.9.5