View Single Post
04-11-16, 10:04 AM   #6
Folji
A Flamescale Wyrmkin
 
Folji's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 136
Alright, sweet, think I'm starting to get it now!

But essentially, in my actionbars.lua file I'm creating a holder frame for the action bars.
Lua Code:
  1. ns.MultiBarHolder = CreateFrame("Frame","MultiBarHolder",MainMenuBar,"SecureHandlerStateTemplate")
  2. ns.MultiBarHolder:SetPoint("BOTTOM",MainMenuBar,"BOTTOM",0,29)

And this frame essentially contains two more frames, MultiBarLeft and MultiBarRight, both of which are filled with the MultiBarBottomLeft/Right action buttons. And this part is perfectly fine, they're static frames anchored inside of the holder frame, and there's nothing happening to them.

Then there's this function, located inside bottomframe.lua, that works as a visibility handler for the bottom chunk of the UI. It scales the bottom frame based on what's in it, like it shows in the GIF at the top, and it runs on events updating experience and reputation, upon login, OnHide and OnShow for the game's default MultiBarBottom frames, so pretty much anything that affects the visibility of its contents.

Lua Code:
  1. local function BottomElementsHandler()
  2.  
  3.         -- Checking button visibility on their original container frames
  4.         local VisibleLeft = MultiBarBottomLeft:IsVisible()
  5.         local VisibleRight = MultiBarBottomRight:IsVisible()
  6.         local RepVisible = ns.Reputation:IsShown()
  7.         local ExpVisible = ns.Experience:IsShown()
  8.         local BarWidth = 483
  9.         local BarHeight = 11
  10.  
  11.         -- Visibility handling for the MultiBars
  12.             if VisibleLeft and VisibleRight then
  13.                 ns.MultiBarHolder:SetHeight(40)
  14.                 ns.MultiBarHolder:SetWidth((458*2))
  15.             elseif VisibleLeft or VisibleRight then
  16.                 ns.MultiBarHolder:SetHeight(40)
  17.                 ns.MultiBarHolder:SetWidth(460)
  18.             else
  19.                 ns.MultiBarHolder:SetHeight(1)
  20.                 ns.MultiBarHolder:SetWidth(460)
  21.             end
  22.  
  23.         -- Visibility for the MultiBar art
  24.         if VisibleLeft or VisibleRight then
  25.             ns.MultiBarRightArt:Show()
  26.             ns.MultiBarLeftArt:Show()
  27.         else
  28.             ns.MultiBarRightArt:Hide()
  29.             ns.MultiBarLeftArt:Hide()
  30.         end
  31.  
  32.         -- Set width for the statusbars
  33.         if (ns.MultiBarHolder:GetWidth() > 500) then
  34.             BarWidth = ns.MultiBarHolder:GetWidth()+4
  35.         else
  36.             BarWidth = 464
  37.         end
  38.  
  39.         -- Set the anchor points of the Exp and Rep bars
  40.         if RepVisible and ExpVisible then
  41.             ns.ExpRepHolder:SetHeight(BarHeight)
  42.             ns.Reputation:SetPoint("RIGHT",ns.ExpRepHolder,"RIGHT")
  43.             ns.Reputation:SetPoint("LEFT",ns.ExpRepHolder,"CENTER")
  44.             ns.Experience:SetPoint("LEFT",ns.ExpRepHolder,"LEFT")
  45.             ns.Experience:SetPoint("RIGHT",ns.ExpRepHolder,"CENTER")
  46.         elseif RepVisible or ExpVisible then
  47.             ns.ExpRepHolder:SetHeight(BarHeight)
  48.             ns.Reputation:SetPoint("LEFT",ns.ExpRepHolder,"LEFT")
  49.             ns.Reputation:SetPoint("RIGHT",ns.ExpRepHolder,"RIGHT")
  50.             ns.Experience:SetPoint("LEFT",ns.ExpRepHolder,"LEFT")
  51.             ns.Experience:SetPoint("RIGHT",ns.ExpRepHolder,"RIGHT")
  52.         else
  53.             ns.ExpRepHolder:SetHeight(1)
  54.         end
  55.  
  56.         ns.ExpRepHolder:SetWidth(BarWidth)
  57.  
  58.         MicroBarTexture:SetWidth(ns.MultiBarHolder:GetWidth()+4)
  59.  
  60.         LeftEdgeArt:SetPoint("TOPRIGHT",ns.ExpRepHolder,"TOPLEFT",83,28)
  61.         RightEdgeArt:SetPoint("TOPLEFT",ns.ExpRepHolder,"TOPRIGHT",-83,28)
  62.  
  63.  
  64.     end

And it's really just the visibility for the MultiBarHolder, on line 12 - 21, that screws up. It should be doing exactly the same thing, set its own width and height based on the visibility of its two child frames, and that is pretty much the extent of it.
  Reply With Quote