View Single Post
07-11-16, 02:13 PM   #1
Infus
A Deviate Faerie Dragon
Join Date: Jul 2016
Posts: 13
Scrollframes:SetPoint and clipping

In this code a scrollframe is moved to a different position. Doing that naively, results in the clipping not correctly updating. Hiding the scrollframe before setting the new position and then reshowing updates the clipping.

That is, I would expect spinner1 and spinner2 to behave identically.

Code:
local function createFrame()
  local spinner = CreateFrame('Frame', nil, parent)
  spinner:SetSize(64, 64)

  -- ScrollFrame is the top right quadrant of spinner
  local scrollframe = CreateFrame('ScrollFrame', nil, spinner)
  scrollframe:SetPoint('BOTTOMLEFT', spinner, 'CENTER')
  scrollframe:SetPoint('TOPRIGHT')
  spinner.scrollframe = scrollframe

  local scrollchild = CreateFrame('frame', nil, scrollframe)
  scrollframe:SetScrollChild(scrollchild)
  scrollchild:SetAllPoints(scrollframe)

  -- Clipped by scrollframe
  local wedge = scrollchild:CreateTexture()
  wedge:SetAllPoints(spinner)
  spinner.wedge = wedge;

  return spinner;
end


local spinner1 = createFrame();
spinner1:SetPoint('BOTTOMRIGHT', UIParent, 'CENTER', -2, 2);
spinner1.wedge:SetTexture('interface/icons/inv_mushroom_11')

local spinner2 = createFrame();
spinner2:SetPoint('BOTTOMLEFT', UIParent, 'CENTER', 2, 2);
spinner2.wedge:SetTexture(236595)

C_Timer.After(3, function()
  -- Move the scroll frames to the top left quadrant
  spinner1.scrollframe:ClearAllPoints();
  spinner1.scrollframe:SetPoint('BOTTOMRIGHT', spinner1, 'CENTER');
  spinner1.scrollframe:SetPoint('TOPLEFT');

  spinner2.scrollframe:Hide();
  spinner2.scrollframe:ClearAllPoints();
  spinner2.scrollframe:SetPoint('BOTTOMRIGHT', spinner2, 'CENTER');
  spinner2.scrollframe:SetPoint('TOPLEFT');
  spinner2.scrollframe:Show();
end)