API : Controls and Offset
Hello,
I am currently writting my own extension, i have done a small code part ^^ but i am blocked with the UI style :( I am trying to add some controls headers and controls lines one above the other on a constant background but without knowing the exact offset (or height) of each element, and each element can have one or more lignes and never the same height. so is it possible please ? if it's possible can you help me to know how ? I have actualy something like that : Lua Code:
this code work fine, but i'm looking for a way to automatically place the object Thanks in advance ^^ |
What's wrong with GetDimensions() and GetAnchor() ?
|
Quote:
But thanks for info, i will try ^^ |
I'd love to know if you manage to figure out SetResizeToFitDescendents(bool resize). I have only managed to get it to work with SetDimensionConstraints(number minWidth, number minHeight, number maxWidth, number maxHeight) and SetResizeToFitPadding(number width, number height).
Also, depending on what you want to achieve at the end, you could also use SetAnchor instead of SetSimple so you can have control over the objects alignment. I find it much easier to use the alignment with parenting windows to control how and where they show up in relation to other frames. Instead of trying to find specific offsets to use. For a descending order for example, TOP alignment for the windows self alignment and BOTTOM for the windows target alignment would ensure that no matter how long (wide) a label's text is, it will always be centered underneath its parent frame. |
Hi ^^ thanks for your answers ^^
I tryed with GetDimension() and GetHeight() but nothing, the return give me a '0' value. I will try today what Nogaruk said... The problem is i have no examples... Nogaruk can you give me an short example please, for placing automaticaly several child one above the other ? (I have only one parent, it's the background...) ? Otherwise, i use SetResizeToFitDescendents() without argument and it auto resize width and height from is content -> set on my background (the background is the parent of all content) I am looking for a way to use a constraint on the width value, to permit players to specify width in the menu settings ... but i don't know if it's possible to keep the 2 possibilities .. i need to do some tries ^^ |
Something you can do, that I have working nicely in my main addon is to chain components together on the screen with anchor points.
Say you have two labels: LABELA & LABELB. You set the position of LABELA as normal, within your top-level container. You can then use SetAnchor to anchor the TOP of LABELB to the BOTTOM of LABELA. If you change the height of LABELA, then the position of LABELB on the screen will automatically adjust without you having to do any additional scripting to move it. Code:
<GuiXml> Code:
MyAddonLabelB:SetAnchor(TOP, MyAddonLabelA, BOTTOM, 0, 0) Now when you change the size or position of LabelA, you'll see LabelB adjusts as well. |
I'll try to give a short example. Since storm gave you one with xml, I'll give you one with just lua.
Code:
-- Variable to hold the window manager object There are chain functions examples on here for creating things or you could make your own functions to simplify, lower code reuse, or even automate the window creations. Ok I'm going to bed. I'll double check this tomorrow to see if it was useful for ya and in case I typed something wrong. Can't think...clowns will eat me...night. |
Great !!
I thinks your examples are very helpful ^^ and very nicely commented ^^ thanks a lot :) I'm sure with that, it can do ^^ Good job ! |
Hi ^^
Definitivly helpful ^^ find a way to do what i want thx a lot ^^ -> notice that you have some errors ^^ like "Anchor" not "Anchors" and some variables was incorrect in the example but it's was awesome :) |
Glad it helped. Fixed some of the typos in case someone else comes across it later. I did write it when I was about to pass out, some typos were bound to happen. :)
|
All times are GMT -6. The time now is 05:17 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI