Thread Tools Display Modes
09-05-12, 04:10 PM   #1
nailertn
An Aku'mai Servant
Join Date: Oct 2008
Posts: 33
Scroll child draw order

Whenever I parent frames to a scroll child, it seems the rendering order of those frames are not governed by frame stratas / frame levels / draw layers but by the order in which they are added to the scroll child. For example:

Code:
local foreground = CreateFrame("Frame", "my_foreground", QuestLogScrollFrameScrollChild)
foreground:SetSize(100, 100)
foreground:SetPoint"center"

local texture = foreground:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(0,1,0)

local background = CreateFrame("Frame", "my_background", QuestLogScrollFrameScrollChild)
background:SetSize(100,100)
background:SetPoint"center"
background:SetFrameLevel(foreground:GetFrameLevel() - 1)

local texture = background:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(1,0,0)
Since foreground (or green box) is one frame level above background (red box), it should be the one rendered on screen. Instead I get this:



Notice the framestack tooltip. Manipulating frame levels, frame stratas or draw layers changes nothing, the order of parenting does. If the frames are created with UIParent as their initial parent, the one that calls :SetParent(scrollchild) last gets to be rendered on screen. Am I overlooking something or is this how it is supposed to work?
  Reply With Quote
09-05-12, 06:28 PM   #2
yssaril
A Warpwood Thunder Caller
 
yssaril's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 96
change the level of the texture not frame

also it is a bad habbit to call both textures "textures" give them unique names such as foreground_texture and background_texture

edit: also why create 2 frames when one will do just fine?


edit2: hmmm something screwy on my end disregard the above for now

Last edited by yssaril : 09-05-12 at 06:53 PM. Reason: hmmm
  Reply With Quote
09-05-12, 08:23 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by nailertn View Post
Whenever I parent frames to a scroll child, it seems the rendering order of those frames are not governed by frame stratas / frame levels / draw layers but by the order in which they are added to the scroll child.
That's generally how it works -- if multiple objects are parented to the same object, the first one created gets parent level + 1, the second one gets parent level + 2, and so on.

However, :SetFrameLevel should work as expected. I don't have access to WoW right now (at work) but I'll try your code later if I remember.

Originally Posted by yssaril View Post
also it is a bad habbit to call both textures "textures" give them unique names such as foreground_texture and background_texture
It's fine for debugging code like the above, or code where the texture is not intended to be changed after creation and you don't need a reference to it. Also, giving textures global names should generally be avoided; you can add them as frame members if you need to access them later.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-05-12, 09:44 PM   #4
nailertn
An Aku'mai Servant
Join Date: Oct 2008
Posts: 33
Originally Posted by yssaril View Post
change the level of the texture not frame

also it is a bad habbit to call both textures "textures" give them unique names such as foreground_texture and background_texture

edit: also why create 2 frames when one will do just fine?


edit2: hmmm something screwy on my end disregard the above for now
"Manipulating frame levels, frame stratas or draw layers changes nothing." Even if it did, it still doesn't explain why a frame with leve 0 and strata "BACKGROUND" gets rendered on top of a frame with level 100 and strata "HIGH". The above code is just a demonstration, please treat it as such. All it has in common with what I am currently working is the problem it describes. There are ways to circumvent it, it's not even a big deal, but I would like to actually understand what's going on.

Originally Posted by Phanx View Post
That's generally how it works -- if multiple objects are parented to the same object, the first one created gets parent level + 1, the second one gets parent level + 2, and so on.

However, :SetFrameLevel should work as expected. I don't have access to WoW right now (at work) but I'll try your code later if I remember.
Don't child frames simply get parent frame level + 1 after CreateFrame or SetParent, regardless of how many children their parent already has? Or do you mean compound parenting as in child is +1, child's child is +2? Frankly I didn't even consider Set / GetFrameLevel being the culprit because according to the screenshot the frames are ordered correctly and the rendering ignores not just levels but stratas too. I'll check for any metatable shenanigans though just to make sure.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scroll child draw order

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