WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Larger childframe not overflowing parentframe (https://www.wowinterface.com/forums/showthread.php?t=56097)

bryde 03-14-18 01:02 AM

Larger childframe not overflowing parentframe
 
Hello everybody,
I'd like to know if it's possible to force a childframe to be "fully there" (in size) but it's texture not overflowing the boundaries of it's parentframe.
I don't have a project that requires this as of right now, but basically let's assume something like

Code:

parent = CreateFrame("Frame", nil, UIParent)
parent:SetSize(400,400)
parent:SetPoint("center")

child = CreateFrame("Frame", nil, parent)
child:SetSize(800,800)
child:SetPoint("Center")

if I set a texture for the background of the child, it'll draw the whole texture, but I'd like it to only paint within the parents boundries. I know I could work around the issue with the rectangle function and stuff, but that doesn't seem feasible in some cases. For example zoomed-in maps where you want to change the view with WASD or something, you'd have to reload the whole texture every time rather than just loading it once and manipulating it's x/y coordinates. Is there any way to do that?

Aftermathhqt 03-14-18 01:49 AM

[quote=bryde;327220]snip/QUOTE]

this should work, although i would not name your frames parent or child if they are global, they will most likey interfere with some other stuff.

Lua Code:
  1. local MyFrame = CreateFrame("Frame", nil, UIParent)
  2. MyFrame:SetSize(400, 400)
  3. MyFrame:SetPoint("CENTER", UIParent)
  4.  
  5. local MyFrameChild = CreateFrame("Frame", nil, MyFrame)
  6. MyFrameChild:SetSize(800, 800)
  7. MyFrameChild:SetPoint("CENTER", MyFrame)

bryde 03-14-18 02:20 AM

Thanks for the quick answer. Like I said, I'm not actively working on a project so the variable names were just chosen for easy identification.
Sadly however it's still doing what I don't want it to do :(

I adjusted your code to create a colortexture in the child frame and the texture is still overflowing, using all the 800x800 instead of the 400x400 window created by it's parent:

Lua Code:
  1. local MyFrame = CreateFrame("Frame", nil, UIParent)
  2. MyFrame:SetSize(400, 400)
  3. MyFrame:SetPoint("CENTER", UIParent)
  4.  
  5. local MyFrameChild = CreateFrame("Frame", nil, MyFrame)
  6. MyFrameChild:SetSize(800, 800)
  7. MyFrameChild:SetPoint("CENTER", MyFrame)
  8.  
  9. MyFrameChild.Texture = MyFrameChild:CreateTexture()
  10. MyFrameChild.Texture:SetAllPoints()
  11. MyFrameChild.Texture:SetColorTexture(1,1,1)

As mentioned, fills the 800x800 (and that's perfect), but I only want it to render the 400x400px of the parent. The idea being that the full 800x800 texture is loaded into cache but only the 400x400 part is visible/rendered.

MunkDev 03-14-18 03:10 AM

Lua Code:
  1. parent:SetClipsChildren(true)

bryde 03-14-18 03:13 AM

Quote:

Originally Posted by MunkDev (Post 327225)
Lua Code:
  1. parent:SetClipsChildren(true)

Aaaaah... just what I was looking for. May I ask where you found it? I've looked through the old wowprogramming reference, the wowwikia reference and so on and there's no mentioning of it anywhere?

Seerah 03-14-18 09:53 AM

I believe that method is relatively recent.

Before it was added, you would need a scrollframe container if you did not want to clip the texture manually.

Gethe 03-14-18 10:05 AM

Both of those resources are very outdated. Wowpedia is where most of the updated info is. Even this site isn't exhaustively updated, but it's better than the sites you've been using.

Blizzard has recently started documenting the API themselves via the Blizzard_APIDocumentation addon. Foxlit has made an online browser for it.

MunkDev 03-14-18 11:17 AM

Quote:

Originally Posted by bryde (Post 327226)
Aaaaah... just what I was looking for. May I ask where you found it? I've looked through the old wowprogramming reference, the wowwikia reference and so on and there's no mentioning of it anywhere?

I found this by examining the __index entry of a frame metatable. I rarely use the websites anymore because they're either outdated or lack the very specific information I'm looking for. I think Blizzard are trying to remedy this with their seemingly large focus on API documentation for the beta.

You can also do frame:SetTopLevel(true) to make it behave like a scroll frame.
SetClipsChildren will clip the children at the boundaries of the parent, but I think they're still clickable.


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

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