Auto-resize frame
If I have a frame that composed of other frames is it possible to have the outer frame adjust based upon the size of the inner frames?
Let's say I have 1 outer frame with three inner frames A, B, C. A sets relative to the parent, B relative to A, and C relative to B. Is there a way to set the parent's bottom right to the bottom right of C? Such that if A, B, or C grow then the parent will grow? Also, what happens in the event that one (or more) of the inner frames gets hidden? -g |
You can call as many :SetPoint()s as you want. You can anchor topleft and bottomright for example. This is the main reason why it's very important to call :ClearAllPoints() before :SetPoint().
As for when a frame gets hidden, that entirely depends on how you code the placement of your frames in the event that something is not shown. ;) |
Parent
A - topleft to topleft of parentParent - bottomleft to bottomleft of C ?? I want A to track with the Parent, but I want the size of parent to track with bottomleft of C. Once I've set all the points, if I then change the size of "B" then does the parent frame adjust size? Upon hiding the "B" frame, does that break the chain or does it count as a zero size? Is it as if its topleft = its bottomleft? (That would be great) -g |
Quote:
If so, then what you have will work. Note also that you will have to manually set the heights of all three frames, since there's nothing in the chain that tells them how big to be. Changing the height of B will change the height of the parent (it will move the bottom edge of B, which will move the bottom edge of C). Hiding B will not have good results. I'm not 100% sure, but I believe C will disappear because it's no longer anchored to anything. You will need to manually re-anchor the topleft of C to the bottomleft of A. Now, if you want A and B to resize as well when the parent resizes, then you start with the same basic setup, give all three child frames fixed heights, and then in your resize function you include instructions to set the height of each child frame to some multiple of the height of the parent frame. |
Actually I was hoping resizing any of them will cause the parent to resize.
However if having something get hidden will break the works then means that I have to have a resize function so I can just calc the size based upon that (and reset parents and whatnot). I was just hoping I could be lazy... Thanks for the comments -g |
Quote:
Code:
A:ClearAllPoints() Note that you will get undesired/undefined behavior if you set the height of F to less than the height of A + the height of B + 0, since that would define the height of C as less than 0. If you want all three children to split the height equally, then you would have to specify them all explicitly. You could easily automate this by hooking the :SetHeight method on F: Code:
A:ClearAllPoints() Quote:
Quote:
|
Quote:
Alternatively, if C is positioned relative to B, and B is positioned relative to A, then you could position A relative to the UIParent, and then position the parent frame relative to the TOPLEFT of A and the BOTTOMRIGHT of C. Quote:
Honestly, though, all of this vague "A, B, and C" stuff makes it really hard to give you good suggestions and code. Why don't you just describe what you actually want to do? |
Thanks
Phanx, thanks for being so patient and clear with your answers.
Yes, A, B, C, are all children of F. My appologies if I said or implied anything to the contrary. No automatic sizing of A, B, or C - Their sizing will be manual. I was only interested in F resizing. I did not mention horizontal sizing as they will all be the same width. If hiding B causes a gap to appear unless I reset the points, then I need to reset the points. Needing to reset the points means I need code to do that and that is not a problem - just didn't want to write code that may have been superfluous. Thank you again for your help, I've got a pretty good idea what to do now. -g |
All times are GMT -6. The time now is 01:04 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI