WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Scroll child draw order (https://www.wowinterface.com/forums/showthread.php?t=44173)

nailertn 09-05-12 04:10 PM

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?

yssaril 09-05-12 06:28 PM

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

Phanx 09-05-12 08:23 PM

Quote:

Originally Posted by nailertn (Post 262511)
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.

Quote:

Originally Posted by yssaril (Post 262522)
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.

nailertn 09-05-12 09:44 PM

Quote:

Originally Posted by yssaril (Post 262522)
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.

Quote:

Originally Posted by Phanx (Post 262537)
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.


All times are GMT -6. The time now is 02:57 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI