Quantcast Larger childframe not overflowing parentframe - WoWInterface
Thread Tools Display Modes
03-14-18, 01:02 AM   #1
bryde
A Defias Bandit
Join Date: Mar 2018
Posts: 3
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?
  Reply With Quote
03-14-18, 01:49 AM   #2
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
[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)
  Reply With Quote
03-14-18, 02:20 AM   #3
bryde
A Defias Bandit
Join Date: Mar 2018
Posts: 3
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.
  Reply With Quote
03-14-18, 03:10 AM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 427
Lua Code:
  1. parent:SetClipsChildren(true)
__________________
  Reply With Quote
03-14-18, 03:13 AM   #5
bryde
A Defias Bandit
Join Date: Mar 2018
Posts: 3
Originally Posted by MunkDev View Post
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?
  Reply With Quote
03-14-18, 09:53 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,727
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.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-14-18, 10:05 AM   #7
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 926
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.
__________________
Knowledge = Power; Be OP

  Reply With Quote
03-14-18, 11:17 AM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 427
Originally Posted by bryde View Post
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.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Larger childframe not overflowing parentframe

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