08/18/14, 09:26 PM | #1 |
|
Too many Anchors
Is there some rule/limit/something on how you are allowed to set anchors? I know you can't have circular anchors, like: object A anchored to object B..and then object B anchored to object A, but I don't have that here.
I need to anchor my background to my menu bar (which is rectangular & the size of all the buttons), but it will only let me anchor to the TOPRIGHT of my menubar or it gives me the "too many anchors processed" error. Some things I've tried & other problems I had trying to do it a different way: It sounds easy enough to just set the TOPRIGHT anchor and then set the width/height, but I have a menuBar for each inventory tab and they are different sizes and for some reason GetDimensions() & GetWidth() on my MenuBar both return 0 width even after it is created & the menu buttons are added. I think it has something to do with the fact that the menuBar automatically resizes to fit descendents and even though I call GetDimensions & GetWidth AFTER the buttons are added I don't think its enough time & it hasn't finished resizing yet (but I cant turn that off because then it stays 0 width and I need to know the size of the area that the buttons take up) I haven't been able to get the correct width with them until I get into the game & use /zgoo or /znb, then it shows the correct dimensions for the menu bar. I could just put code in to resize when the window is shown, but then it would resize everytime & that seems like a waste. Thats the only way I've been able to get it to work so far. I'de much rather just figure out what the anchor problem is...or if anyone has a better idea on how to handle this. ************************************************************** If it helps any this is what everything looks like. I can post the code if you need, but its a lot. I thought the picture might be easier. The small red lines show how each button/control is anchored to another control. |
08/19/14, 04:04 AM | #2 |
|
Just thinking: <AnchorFill /> on the background woudln't work? If it's a child of the menubar, and the menubar has correct size, it should, no?
|
08/19/14, 06:31 AM | #3 | |
|
Anchor fill would make the MenuBarBackground the same size as the menu bar, which is the same size as the buttons (their total area)....and the buttons are on top, so they would completely cover the MenuBarBackground and you'd never see it. This is why I wanted to anchor in opposite corners of the menu bar (since I don't know the menu bars dimensions) I want to anchor in opposite corners and use the offset to stretch it out a little further to make it visible around the edges. This is what I WOULD LIKE TO DO: Lua Code:
|
|
08/19/14, 06:36 AM | #4 |
Another thought:
How did you create your background? It's possible that it inherits anchors from template, so you need to call menuBarBg:ClearAnchors() first to clear existing anchors and then set you own anchors. |
|
08/19/14, 06:51 AM | #5 |
|
And two more:
- is bg excluded from resize? menuBarBg:SetExcludeFromResizeToFitExtents(true) - how about making bg a sibling of button container instead of child |
08/19/14, 07:03 AM | #6 | |
|
Warning: Spoiler
xml Code:
But I originally started doing this without xml. I made the background by hand: Lua Code:
I can tell you that it does allow me to set the anchors (the way I want, to more than just the TOPRIGHT) if I do EITHER ONE of the following (I don't have to do both, either one will work).
|
|
08/19/14, 07:09 AM | #7 | |
|
This is a menuBarBg, it is all ready a child of the MenuBar...so are the buttons, So it is all ready a sibling of the buttons, not a child of the buttons. |
|
08/19/14, 10:06 AM | #8 | ||
|
+ menuBar ++ menuBarButtonsContainer -- parent to buttons and only buttons, nothing else ++ menuBarBG -- anchor this to Container Last edited by merlight : 08/19/14 at 10:08 AM. |
||
08/19/14, 12:57 PM | #9 | ||
|
But I don't see how that would my size problem. I have no way to know how big the menuBar is, which is why I wanted to anchor it to the menuBar, in opposite corners, (so I don't need to know) If I swapped what is anchored to the container I still would not know what size to make the BG and the ResizeToFitExtents would not help (unless I'm missunderstanding what that function does, I dont recall using it before), I need the BG to be bigger than the menu bar, not the same size as the menu bar. Sorry for being a pain :P I will post some code later when I get home if you would care to look at it, maybe it might make things more clear....and thanks for all the help. |
||
08/19/14, 01:51 PM | #10 | |
|
I have not tested it, but I can only see one way ResizeToFitDescendents can work: it has to process anchors of all children, and then take width = rightmost - leftmost, height = bottomost - topmost. But how can it deal with a child (background) that is anchored to the corners of the parent whose size is being computed? It can't, that's the chicken & egg. You have to exclude the background from the list of children used to compute size. That's how I understand excludeFromResizeToFitExtents. |
|
08/19/14, 04:33 PM | #11 | |
|
Argg so simple now that I see it. It was getting very frustrating that I managed to figured out how to do everything else to make this addon, but couldn't figure out that one simple anchor problem. Well it seems simple now! You have made my day...thank you VERY MUCH (both of you) for your help. |
|
ESOUI » Developer Discussions » Lua/XML Help » Too many Anchors |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|