Thread Tools Display Modes
01-27-12, 04:02 PM   #1
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Parenting to BT4 issues...

I'm working on an addon that only adds some artwork to my UI. I know I could use KGPanels or LitePanels but I wanted to try it as a standalone addon. The problem I'm having is that when I parent a frame to BT4Bar1 (which I have set to fade out out of combat) the frame does not fade with the bar.

Here's the code I have now:
LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",UIParent);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", UIParent, "CENTER", 0, -200);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     a:SetScript("OnEnter", function()
  11.     a:SetAlpha(.85) end)
  12.     a:SetScript("OnLeave", function()
  13.     a:SetAlpha(0) end)
  14.     else return
  15. end

Like this the frame changes alpha when moused over perfectly. When I tried to parent it to BT4Bar1 like this:

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",BT4Bar1);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", BT4Bar1, "CENTER", 0, 0);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     a:SetScript("OnEnter", function()
  11.     a:SetAlpha(.85) end)
  12.     a:SetScript("OnLeave", function()
  13.     a:SetAlpha(0) end)
  14.     else return
  15. end

it still changed alpha when moused over, and when I eliminated the mouseover script there was no change in the alpha

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",BT4Bar1);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", BT4Bar1, "CENTER", 0, 0);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     --a:SetScript("OnEnter", function()
  11.     --a:SetAlpha(.85) end)
  12.     --a:SetScript("OnLeave", function()
  13.     --a:SetAlpha(0) end)
  14.     else return
  15. end

I know I have to be missing something dumb here. All I want it to do is to inherit the alpha of BT4Bar1 (it's parent).
__________________


  Reply With Quote
01-27-12, 06:17 PM   #2
Canities
A Wyrmkin Dreamwalker
Join Date: Oct 2007
Posts: 54
Try parenting your frame to: BT4Button1, if i rememebr correctly bartender doesnt use frame names for the diffrent bars only names on the buttons.

Also you might want to make a macro with /framestack and use that for finding what element names are.

Cani.
  Reply With Quote
01-27-12, 06:30 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Othgar View Post
I'm working on an addon that only adds some artwork to my UI. I know I could use KGPanels or LitePanels but I wanted to try it as a standalone addon. The problem I'm having is that when I parent a frame to BT4Bar1 (which I have set to fade out out of combat) the frame does not fade with the bar.

Here's the code I have now:
LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",UIParent);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", UIParent, "CENTER", 0, -200);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     a:SetScript("OnEnter", function()
  11.     a:SetAlpha(.85) end)
  12.     a:SetScript("OnLeave", function()
  13.     a:SetAlpha(0) end)
  14.     else return
  15. end

Like this the frame changes alpha when moused over perfectly. When I tried to parent it to BT4Bar1 like this:

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",BT4Bar1);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", BT4Bar1, "CENTER", 0, 0);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     a:SetScript("OnEnter", function()
  11.     a:SetAlpha(.85) end)
  12.     a:SetScript("OnLeave", function()
  13.     a:SetAlpha(0) end)
  14.     else return
  15. end

it still changed alpha when moused over, and when I eliminated the mouseover script there was no change in the alpha

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",BT4Bar1);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", BT4Bar1, "CENTER", 0, 0);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     --a:SetScript("OnEnter", function()
  11.     --a:SetAlpha(.85) end)
  12.     --a:SetScript("OnLeave", function()
  13.     --a:SetAlpha(0) end)
  14.     else return
  15. end

I know I have to be missing something dumb here. All I want it to do is to inherit the alpha of BT4Bar1 (it's parent).
What you can do, is open ButtonBar.lua

then find this;

LUA Code:
  1. if not LBF then
  2.         for i = 1, #buttons do
  3.             local button = buttons[i]
  4.             if button.icon and self.config.skin.Zoom then
  5.                 button.icon:SetTexCoord(0.07,0.93,0.07,0.93)
  6.             elseif button.icon then
  7.                 button.icon:SetTexCoord(0,1,0,1)
  8.                 -- Insert stuff here.
  9.             end
  10.         end
  11.     end
  Reply With Quote
01-27-12, 09:43 PM   #4
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Originally Posted by Canities View Post
Try parenting your frame to: BT4Button1, if i rememebr correctly bartender doesnt use frame names for the diffrent bars only names on the buttons.

Also you might want to make a macro with /framestack and use that for finding what element names are.

Cani.
Tried parenting to BT4Button1 and got the same results, my frame is there but doesn't inherit the alpha settings of the button.

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",BT4Button1);
  3.     a:SetWidth(512);
  4.     a:SetHeight(64);
  5.     a:SetPoint("CENTER", UIParent, "CENTER", 0, -200);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetBackdropColor(0,0,0);
  10.     --a:SetScript("OnEnter", function()
  11.     --a:SetAlpha(.85) end)
  12.     --a:SetScript("OnLeave", function()
  13.     --a:SetAlpha(0) end)
  14.     else return
  15. end

Originally Posted by Game92 View Post
What you can do, is open ButtonBar.lua

then find this;

LUA Code:
  1. if not LBF then
  2.         for i = 1, #buttons do
  3.             local button = buttons[i]
  4.             if button.icon and self.config.skin.Zoom then
  5.                 button.icon:SetTexCoord(0.07,0.93,0.07,0.93)
  6.             elseif button.icon then
  7.                 button.icon:SetTexCoord(0,1,0,1)
  8.                 -- Insert stuff here.
  9.             end
  10.         end
  11.     end
I was hoping to stay away from inserting code into Bartender just so I don't have to keep doing it every time Bartender updates.

I know this can be done with KGPanels, I've done it before with other frames.... there has to be something I'm missing here. Unless maybe it won't inherit the alpha because it's set with conditionals? At this point if I could just get it to only show in combat and fade out when I leave combat I'd be happy with it since that's the way Bartender is setup right now. I tried PLAYER_REGEN_DISABLED but I didn't go too far with it since that's not ideally what I want, maybe I'll have to go back to that.
__________________


  Reply With Quote
01-29-12, 02:53 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
First you need to figure out which object BT4 actually changes the alpha value on (it's probably not the individual button). Then, if for some reason parenting your frame to that object doesn't work, you can always just forcibly copy the alpha every time it changes:

Code:
hooksecurefunc(BT4Object, "SetAlpha", function(self, alpha)
	MyObject:SetAlpha(alpha)
end)
  Reply With Quote
01-29-12, 08:09 AM   #6
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Originally Posted by Phanx View Post
First you need to figure out which object BT4 actually changes the alpha value on (it's probably not the individual button). Then, if for some reason parenting your frame to that object doesn't work, you can always just forcibly copy the alpha every time it changes:

Code:
hooksecurefunc(BT4Object, "SetAlpha", function(self, alpha)
	MyObject:SetAlpha(alpha)
end)
Awesome, thanks Phanx. I'll give that a try as soon as I'm actually awake enough to function.

edit: Ok I've tried everything I can find for what the object might be. /fstack only gives me the buttons, unless they're unlocked in which case I get BT4BarXOverlay. Which also didn't work, and it doesn't work with BT4BarX. I'm thinking that somewhere there has to be a "helper" frame or something that the buttons anchor to, but I can't find it in Bartenders Code anywhere.

Also when I tried any of those objects with your code Phanx I got this:
Code:
Date: 2012-01-29 10:29:16
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\Lust Panels\panels.lua line 31:
   Usage: hooksecurefunc([table,] "function", hookfunc)
Debug:
   [C]: ?
   [C]: hooksecurefunc()
   Lust Panels\panels.lua:31: in main chunk
AddOns:
Which I'm sure is just me doing something since I'm not at all familiar with hooksecurefunc
__________________



Last edited by Othgar : 01-29-12 at 09:58 AM. Reason: update
  Reply With Quote
01-29-12, 10:02 PM   #7
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Well since I couldn't get my frame to parent to Bartender and inherit it's alpha, I ended up just adding an onUpdate script in to handle it.

LUA Code:
  1. if IsAddOnLoaded("Bartender4") then
  2.     local a = CreateFrame("frame","apanel",UIParent);
  3.     a:SetWidth(575);
  4.     a:SetHeight(100);
  5.     a:SetPoint("CENTER", UIParent, "TOP", 0, -80);
  6.     a:SetFrameStrata("MEDIUM");
  7.     a:SetClampedToScreen(1);
  8.     a:SetBackdrop({bgFile="Interface\\Addons\\Lust Panels\\media\\bpanel"});
  9.     a:SetScript("OnUpdate", function(self, elapsed)
  10.         if UnitAffectingCombat(1) then
  11.             a:SetAlpha(.95)
  12.         elseif UnitExists("target") then
  13.             a:SetAlpha(.95)
  14.         else
  15.             a:SetAlpha(.1)
  16.            
  17.         end
  18.     end)

Probably not the most efficient thing in the world but my frame now changes alpha right along with my Bartender bars.
__________________


  Reply With Quote
01-30-12, 07:17 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Try searching in BT4's files for any instance of "SetAlpha".

It could also be using a state driver; search for "SecureHandlerStateTemplate" and/or "RegisterStateDriver".

In either case, look for the name of the frame being acted on.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Parenting to BT4 issues...

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