Thread Tools Display Modes
08/18/14, 09:26 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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.

  Reply With Quote
08/19/14, 04:04 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
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?
  Reply With Quote
08/19/14, 06:31 AM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
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?
The MenuBarBackground is a child of the menuBar & AnchorFill does not give any errors, but then you cant see the background.

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:
  1. -- This is what I want to do, anchor to an offset, in diagonal corners so I don't need to know --
  2. -- the size of the menu bar & so I can stretch it out larger than the menu bar, to be visible --
  3.  
  4. -- Stretches it out 75 left & 75 up from the TOPLEFT corner of the menu bar --
  5. menuBarBg:SetAnchor(TOPLEFT, _cMenuBar, TOPLEFT, -75, -75)
  6.  
  7. -- Stretches it out 75 right & 75 down from the BOTTOMRIGHT corner of the menu bar --
  8. menuBarBg:SetAnchor(BOTTOMRIGHT, _cMenuBar, BOTTOMRIGHT, 75, 75)
  Reply With Quote
08/19/14, 06:36 AM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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.
  Reply With Quote
08/19/14, 06:51 AM   #5
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
And two more:
- is bg excluded from resize? menuBarBg:SetExcludeFromResizeToFitExtents(true)
- how about making bg a sibling of button container instead of child
  Reply With Quote
08/19/14, 07:03 AM   #6
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Garkin View Post
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.
Here is the xml background code:
Warning: Spoiler


But I originally started doing this without xml. I made the background by hand:
Lua Code:
  1. -- There may be some errors here I deleted this code when I switched to using xml --
  2. -- trying to find a way around this problem, but to give you an idea I did try something like this:
  3.  
  4.     local menuBarBg = CreateControl("FilterItMenuBarsBg", menuBar, CT_TEXTURE)
  5.     menuBarBg:SetTexture("EsoUI/Art/Miscellaneous/centerscreen_left.dds")
  6.     menuBarBg:SetDimensions(iWidth, iHeight)
  7.  
  8.     .....
  9.  
  10. --- Later in code, after the menu bars were created & buttons were added --
  11. --- I DEFANITELY cleared the anchors --
  12.     menuBarBg:ClearAnchors()
  13.     menuBarBg:SetAnchor(TOPLEFT, _cMenuBar, TOPLEFT, -75, -75)
  14.     menuBarBg:SetAnchor(BOTTOMRIGHT, _cMenuBar, BOTTOMRIGHT, 75, 75)

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).
  • Comment out the button code so the buttons aren't created (they are Anchored to the TOPRIGHT of the menu bar...is that coincidence or does that have something to do with why I can ONLY anchor my background to the TOPRIGHT of the menu bar?)
  • Change the parent of my Bg window to anything other than the menuBar (however I want it to show & hide with the menu bar so I really dont want to do that).
  Reply With Quote
08/19/14, 07:09 AM   #7
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
And two more:
- is bg excluded from resize? menuBarBg:SetExcludeFromResizeToFitExtents(true)
- how about making bg a sibling of button container instead of child
GetExcludeFromResizeToFitExtents is false (but either way that wouldn't help, I dont think, because that still wouldn't make it BIGGER than the menu bar...so it can stick out around the edges from behind it)

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.
  Reply With Quote
08/19/14, 10:06 AM   #8
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by circonian View Post
GetExcludeFromResizeToFitExtents is false (but either way that wouldn't help, I dont think, because that still wouldn't make it BIGGER than the menu bar...so it can stick out around the edges from behind it)
Many BG, highlight, divider etc. controls in ZOS files have excludeFromResizeToFitExtents="true". If you want the menuBar resized to encompass it's children, and want BG anchored to the new size, then unless BG is excluded from the size computation, you have a chicken & egg problem.

Originally Posted by circonian View Post
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.
What I suggested was to reorganize it like this:
+ 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.
  Reply With Quote
08/19/14, 12:57 PM   #9
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
Many BG, highlight, divider etc. controls in ZOS files have excludeFromResizeToFitExtents="true". If you want the menuBar resized to encompass it's children, and want BG anchored to the new size, then unless BG is excluded from the size computation, you have a chicken & egg problem.
  • The menuBar already has SetResizeToFitDescendents = true and does resize to fit its children (the buttons).
  • I do not want the BG anchored to the new size of the Menu bar,I want it to be BIGGER. If the background is the same size as the menuBar (it is underneith it so) I would not be able to see it.


Originally Posted by merlight View Post
What I suggested was to reorganize it like this:
+ menuBar
++ menuBarButtonsContainer -- parent to buttons and only buttons, nothing else
++ menuBarBG -- anchor this to Container
So basically swap what is anchored to my container..anchor the background there instead of the menuBar.

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.
  Reply With Quote
08/19/14, 01:51 PM   #10
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by circonian View Post
  • The menuBar already has SetResizeToFitDescendents = true and does resize to fit its children (the buttons).
  • I do not want the BG anchored to the new size of the Menu bar,I want it to be BIGGER. If the background is the same size as the menuBar (it is underneith it so) I would not be able to see it.
We're misunderstanding each other. In the above code you wrote "This is what I WOULD LIKE TO DO" -- this is what I mean by "anchored to menuBar". It will be larger, but the anchors are relative to menuBar, so it's anchored to menuBar.

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.
  Reply With Quote
08/19/14, 04:33 PM   #11
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
We're misunderstanding each other.
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.
Yes, I misunderstood what the function did and so then misunderstood what you were saying....and you were absolutely right, SetExcludeFromResizeToFitExtents solved the anchor problem. I didn't even catch that problem about it trying to computer the size of the background, while also trying to computer the size of the parent....based on the size of the child (background).

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.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Too many Anchors


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