Thread Tools Display Modes
10-22-16, 09:53 AM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
ScrollFrame within a ScrollFrame issue.

I've known about this issue for a while but no clue what the best approach is for dealing with it.

If you have a ScrollFrame widget inside another ScrollFrame and the inner ScrollFrame is scrolled out of view using the outer/parent ScrollFrame, then weird graphical glitches occur:

https://s21.postimg.org/gszw7xurr/img1.png

https://s21.postimg.org/d7zfaz8k7/img2.jpg

The effect is even more noticeable if the items inside the inner ScrollFrame have backgrounds but mine don't.

I guess the reason is because it breaks the masking of what should be visible and WoW doesn't know how to handle it. Not sure though.

I don't think it has anything to do with the rest of my code because this ScrollFrame inception problem always occurs despite the rest of the code. However, if you really want to view the code for any reason you can do from GitHub but the project is very confusing and large and both ScrollFrames are created in separate files

The outer ScrollFrame is created using "CreateDynamicFrame" found here:
https://github.com/Mayron/MayronUI-G....lua#L730-L736

and the inner one is created here:
https://github.com/Mayron/MayronUI-G...config.lua#L88

The "gui:CreateScrollFrame" function can be found here:
https://github.com/Mayron/MayronUI-G...ilder.lua#L165

Last edited by Mayron : 10-22-16 at 11:12 AM.
  Reply With Quote
10-22-16, 12:56 PM   #2
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
I've created an example to isolate the problem into a single AddOn:

toc Code:
  1. ## Interface: 70000
  2. ## Title: SCROLL FRAME TEST
  3. main.lua

Lua Code:
  1. -- main.lua
  2. local function OnMouseWheel(self, step)
  3.     local value = self:GetVerticalScroll() - (step * 20);
  4.     if (value < 0) then
  5.         value = 0;
  6.     elseif (value > self:GetVerticalScrollRange()) then
  7.         value = self:GetVerticalScrollRange();
  8.     end
  9.     self:SetVerticalScroll(value);
  10. end
  11.  
  12. local outer = CreateFrame("ScrollFrame", "SCROLL_FRAME_TEST", UIParent);
  13. outer:SetPoint("CENTER");
  14. outer:SetSize(200, 400);
  15. outer:SetScript("OnMouseWheel", OnMouseWheel);
  16.  
  17. outer.child = CreateFrame("Frame", nil, outer);
  18. outer.child:SetSize(200, 800);
  19. outer:SetScrollChild(outer.child);
  20.  
  21. outer.child.bg = outer.child:CreateTexture(nil, "BACKGROUND");
  22. outer.child.bg:SetAllPoints(true);
  23. outer.child.bg:SetColorTexture(math.random(), math.random(), math.random());
  24.  
  25. local inner = CreateFrame("ScrollFrame", nil, outer.child);
  26. inner:SetPoint("TOPLEFT", 20, -50);
  27. inner:SetSize(150, 200);
  28. inner:SetScript("OnMouseWheel", OnMouseWheel);
  29.  
  30. inner.child = CreateFrame("Frame", nil, inner);
  31. inner.child:SetSize(150, 800);
  32. inner:SetScrollChild(inner.child);
  33.  
  34. inner.child.bg = inner.child:CreateTexture(nil, "BACKGROUND");
  35. inner.child.bg:SetAllPoints(true);
  36. inner.child.bg:SetColorTexture(math.random(), math.random(), math.random());
  37.  
  38. inner.child.content = inner.child:CreateFontString(nil, "OVERLAY", "GameFontNormal");
  39. inner.child.content:SetText("CENTER");
  40. inner.child.content:SetPoint("CENTER");

The child comes out of the ScrollFrame mask once the inner ScrollFrame cannot be seen.

Last edited by Mayron : 10-22-16 at 03:42 PM.
  Reply With Quote
10-22-16, 01:24 PM   #3
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
I understand why this would happen. I think the masking area for what is visible becomes flipped so that the top of the mask is lower than the bottom of the mask and causes a graphical glitch. I wanted to fix this by determining the top and bottom points of this mask region but the API doesn't seem to have a way of doing this. I guess it's hidden from us and there doesn't seem to be a way of accessing this data.

I did try adding this to the outer ScrollFrame's OnMouseWheel handler as a manual fix but it still seems buggy:

Lua Code:
  1. outer:SetScript("OnMouseWheel", function(self, step)
  2.     -- test code: --------------------
  3.     local bottom = inner:GetBottom();
  4.     local top = self:GetTop();
  5.     print(top - bottom)
  6.     if (top - bottom <= 0) then
  7.         inner:Hide();
  8.     else       
  9.         inner:Show();
  10.     end
  11.     -----------------------------------

Last edited by Mayron : 10-22-16 at 01:40 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ScrollFrame within a ScrollFrame issue.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off