View Single Post
11-21-20, 07:02 AM   #8
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
The error is the usage about the ScrollFrame, you normally should use the FauxScrollFrameTemplate or take the logic part from that template to handle the scroll range changes.

Back to the code,

Stockpile_Grid.lua, line 62, comment or delete it :
Lua Code:
  1. --Merchant.UI.StockpileGridScrollFrameContent:SetHeight((32 + 10) * math.floor((Merchant.UI.StockpileStockCnt - 1) / Merchant.UI.StockpileGridMaxPerLine))

The size of the scroll child will changed based on the children on it(show /hide those children also affect the scroll range, there is no need to handle it by your own)

Stockpile.lua, line 149~167
Lua Code:
  1. Merchant.UI.StockpileGridScrollFrameSlider = CreateFrame("Slider", "$parentSlider", Merchant.UI.StockpileGridScrollFrame, "UIPanelScrollBarTemplate")
  2.   Merchant.UI.StockpileGridScrollFrameSlider:SetPoint("TOPLEFT", Merchant.UI.StockpileGridScrollFrame, "TOPRIGHT", -5, 0)
  3.   Merchant.UI.StockpileGridScrollFrameSlider:SetPoint("BOTTOMLEFT", Merchant.UI.StockpileGridScrollFrame, "BOTTOMRIGHT", 0, 0)
  4.   --Merchant.UI.StockpileGridScrollFrameSlider:SetMinMaxValues(0, 1000)
  5.   Merchant.UI.StockpileGridScrollFrameSlider:SetValueStep(1)
  6.   Merchant.UI.StockpileGridScrollFrameSlider:SetValue(0)
  7.   Merchant.UI.StockpileGridScrollFrameSlider:SetWidth(16)
  8.   Merchant.UI.StockpileGridScrollFrameSlider:SetScript("OnValueChanged", function(frame, value)
  9.     Merchant.UI.StockpileGridScrollRefresh(value)
  10.   end)
  11.   Merchant.UI.StockpileGridScrollFrameSliderBackground = Merchant.UI.StockpileGridScrollFrameSlider:CreateTexture(nil, "BACKGROUND")
  12.   Merchant.UI.StockpileGridScrollFrameSliderBackground:SetAllPoints(Merchant.UI.StockpileGridScrollFrameSlider)
  13.   Merchant.UI.StockpileGridScrollFrameSliderBackground:SetColorTexture(0, 0, 0, 0.4)
  14.   Merchant.UI.StockpileGridScrollFrameContent = CreateFrame("Frame", "$parentContent", Merchant.UI.StockpileGridScrollFrame)
  15.   Merchant.UI.StockpileGridScrollFrameContent:SetPoint("TOPLEFT")
  16.   --Merchant.UI.StockpileGridScrollFrameContent:SetPoint("TOPRIGHT")
  17.   --Merchant.UI.StockpileGridScrollFrameContent:SetHeight(0)
  18.   Merchant.UI.StockpileGridScrollFrameContent:SetSize(1, 1)
  19.   Merchant.UI.StockpileGridScrollFrame:SetScrollChild(Merchant.UI.StockpileGridScrollFrameContent)

Don't set the slider's range by your own, should be done by the scrollframe's OnScrollRangeChanged events.

Only need to set the scroll child to topleft, so the wow can handle it, and keep give it a init (1, 1) size to avoid some bugs.

The same file, line 242, you don't need to handle those by your own.
Lua Code:
  1. --Merchant.UI.StockpileGridScrollRefresh(0)

You'd better use the FauxScrollFrameTemplate, the scroll frame is a little complex widget.
Attached Files
File Type: zip merchant.zip (33.3 KB, 184 views)

Last edited by kurapica.igas : 11-21-20 at 07:05 AM.
  Reply With Quote