Move refresh logic out of the generic frame factory
This commit is contained in:
parent
1809a8e116
commit
4accb650c6
|
@ -95,7 +95,6 @@ function ns.NewScrollBar(parent, offset, step)
|
||||||
local value = self:GetValue()
|
local value = self:GetValue()
|
||||||
if value == min then up:Disable() else up:Enable() end
|
if value == min then up:Disable() else up:Enable() end
|
||||||
if value == max then down:Disable() else down:Enable() end
|
if value == max then down:Disable() else down:Enable() end
|
||||||
if self.Refresh then self:Refresh() end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
f:HookScript("OnMinMaxChanged", UpdateUpDown)
|
f:HookScript("OnMinMaxChanged", UpdateUpDown)
|
||||||
|
|
|
@ -12,7 +12,7 @@ local NUMROWS = 14
|
||||||
function ns.NewMainFrame()
|
function ns.NewMainFrame()
|
||||||
local GVS = CreateFrame("frame", nil, MerchantFrame)
|
local GVS = CreateFrame("frame", nil, MerchantFrame)
|
||||||
|
|
||||||
local search = ns.MakeSearchField(GVS, scrollbar.Refresh)
|
local search = ns.MakeSearchField(GVS)
|
||||||
|
|
||||||
local rows = {}
|
local rows = {}
|
||||||
for i=1,NUMROWS do
|
for i=1,NUMROWS do
|
||||||
|
@ -30,7 +30,7 @@ function ns.NewMainFrame()
|
||||||
end
|
end
|
||||||
|
|
||||||
local scrollbar = ns.NewScrollBar(GVS, 0, 5)
|
local scrollbar = ns.NewScrollBar(GVS, 0, 5)
|
||||||
function scrollbar:Refresh()
|
local function Refresh()
|
||||||
local offset = scrollbar:GetValue()
|
local offset = scrollbar:GetValue()
|
||||||
local searchstring = search:GetText()
|
local searchstring = search:GetText()
|
||||||
local n = GetMerchantNumItems()
|
local n = GetMerchantNumItems()
|
||||||
|
@ -48,6 +48,8 @@ function ns.NewMainFrame()
|
||||||
scrollbar:SetMinMaxValues(0, math.max(0, n_searchmatch - NUMROWS))
|
scrollbar:SetMinMaxValues(0, math.max(0, n_searchmatch - NUMROWS))
|
||||||
for i=row,NUMROWS do rows[i]:Hide() end
|
for i=row,NUMROWS do rows[i]:Hide() end
|
||||||
end
|
end
|
||||||
|
scrollbar:SetScript("OnValueChanged", Refresh)
|
||||||
|
|
||||||
|
|
||||||
search:SetScript("OnTextChanged", Refresh)
|
search:SetScript("OnTextChanged", Refresh)
|
||||||
|
|
||||||
|
@ -59,12 +61,12 @@ function ns.NewMainFrame()
|
||||||
scrollbar:Increment()
|
scrollbar:Increment()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
GVS:SetScript("OnEvent", scrollbar.Refresh)
|
GVS:SetScript("OnEvent", Refresh)
|
||||||
GVS:SetScript("OnShow", function(self, noreset)
|
GVS:SetScript("OnShow", function(self, noreset)
|
||||||
local max = math.max(0, GetMerchantNumItems() - NUMROWS)
|
local max = math.max(0, GetMerchantNumItems() - NUMROWS)
|
||||||
scrollbar:SetMinMaxValues(0, max)
|
scrollbar:SetMinMaxValues(0, max)
|
||||||
scrollbar:SetValue(noreset and math.min(scrollbar:GetValue(), max) or 0)
|
scrollbar:SetValue(noreset and math.min(scrollbar:GetValue(), max) or 0)
|
||||||
scrollbar.Refresh()
|
Refresh()
|
||||||
|
|
||||||
GVS:RegisterEvent("BAG_UPDATE")
|
GVS:RegisterEvent("BAG_UPDATE")
|
||||||
GVS:RegisterEvent("MERCHANT_UPDATE")
|
GVS:RegisterEvent("MERCHANT_UPDATE")
|
||||||
|
|
Loading…
Reference in New Issue