Relative size - WoWInterface
Thread Tools Display Modes
09-14-14, 08:08 AM   #1
A Theradrim Guardian
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
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?
  Reply With Quote
09-14-14, 08:20 AM   #2
This Space For Rent
Haleth's Avatar
Join Date: Sep 2008
Posts: 1,173
frame:SetWidth(floor((frame:GetParent():GetWidth() / 2) + 0.5))
Or, you can position the frame so that it is resized automatically.


For example:

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

WoWInterface » Developer Discussions » Lua/XML Help » Relative size

Thread Tools
Display Modes

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