Thread Tools Display Modes
08-11-16, 05:14 PM   #1
MilleXIV
A Deviate Faerie Dragon
 
MilleXIV's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2016
Posts: 16
Frame Positioning Question

So I've been trying to figure this out and I can't quite get it. Let's say I do something like this:

Lua Code:
  1. local f1 = CreateFrame("FRAME", "XIV_FooFrame", UIParent)
  2. f1:SetPoint("LEFT", UIParent, "LEFT")
  3. f1:SetSize(100, 20)
  4. local t1 = f1:CreateTexture(nil, "BACKGROUND")
  5. t1:SetColorTexture(1,0,0,1)
  6. t1:SetAllPoints()
  7.  
  8. local f2 = CreateFrame("FRAME", "XIV_BarFrame", UIParent)
  9. f2:SetPoint("LEFT", f1, "RIGHT")
  10. f2:SetSize(20, 20)
  11. local t2 = f2:CreateTexture(nil, "BACKGROUND")
  12. t2:SetColorTexture(0,0,1,1)
  13. t2:SetAllPoints()

Is there any way to hide f1 and have f2 move all the way over? Other than reattaching f2 to UIParent instead of f1?
  Reply With Quote
08-11-16, 05:20 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,905
Whatever you do you're going to have to do:

f2:ClearAllPoints()

After that, it doesn't really matter wether you attach it LEFT/LEFT to UIParent or f1 unless you want f2 to subsequently move with f1 automatically.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-11-16 at 05:24 PM.
  Reply With Quote
08-11-16, 05:49 PM   #3
MilleXIV
A Deviate Faerie Dragon
 
MilleXIV's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2016
Posts: 16
Originally Posted by Fizzlemizz View Post
Whatever you do you're going to have to do:

f2:ClearAllPoints()

After that, it doesn't really matter wether you attach it LEFT/LEFT to UIParent or f1 unless you want f2 to subsequently move with f1 automatically.
So my intention is that f1 can have it's visibility toggled, with f2 moving into the space that it was taking up. I don't know much about how the layout system works in WoW, but what I want the end result to be is something like this: http://codepen.io/anon/pen/Lkrqrk. I managed to do it by doing f2:SetPoint("LEFT", UIParent), but I'd like to avoid that.

As best I can tell my options are reposition f2 to the shared parent frame at full left (if f1 disbaled) or with a gap equal to the width of f1 (if f1 enabled).
  Reply With Quote
08-11-16, 05:55 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,905
Lua Code:
  1. f1:SetScript("OnHide", function(self)
  2.     f2:ClearAllPoints()
  3.     f2:SetPoint("LEFT", self, "LEFT")
  4. end)
  5.  
  6. f1:SetScript("OnShow", function(self)
  7.     f2:ClearAllPoints()
  8.     f2:SetPoint("LEFT", self, "RIGHT")
  9. end)

This will toggle the movement on showing/hiding f1. Just because a frame is hidden doesn't mean it can't still be used for anchoring.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-11-16, 08:25 PM   #5
MilleXIV
A Deviate Faerie Dragon
 
MilleXIV's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2016
Posts: 16
Originally Posted by Fizzlemizz View Post
Lua Code:
  1. f1:SetScript("OnHide", function(self)
  2.     f2:ClearAllPoints()
  3.     f2:SetPoint("LEFT", self, "LEFT")
  4. end)
Hmm, it seems that's what my problem was. I was still setting it as left/right instead of left/left. Thanks for that.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Frame Positioning Question


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