WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Relative size (https://www.wowinterface.com/forums/showthread.php?t=49889)

Benalish 09-14-14 08:08 AM

Relative size
 
You can do something similar to CSS, or resize a widget according to the space available in the parent in which it is hosted? For example, create a button with half widht (50%) of the frame in which it is contained?

Haleth 09-14-14 08:20 AM

Code:

frame:SetWidth(floor((frame:GetParent():GetWidth() / 2) + 0.5))
Or, you can position the frame so that it is resized automatically.

http://wowpedia.org/API_Region_SetPoint

For example:

Code:

local parent = frame:GetParent()
frame:SetPoint("TOPLEFT", parent)
frame:SetPoint("BOTTOMRIGHT", parent, "BOTTOM")

Now your frame fills up the left half of your parent's frame and resizes accordingly, because its top left corner is attached to the parent's top left corner, and the bottom right corner is attached to the bottom (centre) of the parent.

Of course, you don't need the GetParent() calls in these examples if you're creating the frame yourself.


All times are GMT -6. The time now is 02:38 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI