Quantcast
All my frames are transparent in Retail/BCC - WoWInterface
Thread Tools Display Modes
05-24-21, 04:26 PM   #1
fullmoon_sulfuras
A Murloc Raider
Join Date: Dec 2019
Posts: 8
All my frames are transparent in Retail/BCC

I'm updating an addon to BCC and I managed to make it work with the Backdrop System Changes by inheriting from `BackdropTemplate`. But now all my frame are transparent, they have no background.

I'm creating the frames like so:

Lua Code:
  1. tempObject = CreateFrame("Frame", "LSButtonDialog", "Button Settings", "LunarWindow");
  2. tempObject:SetBackdropColor(0, 1, 0, 1.0);
  3. tempObject:SetFrameStrata("HIGH");
  4. tempObject:EnableKeyboard(false);
  5. tempObject:SetScript("OnKeyDown", Lunar.Settings.Keybind_OnKeyDown);
  6. tempObject:SetScript("OnKeyUp", Lunar.Settings.Keybind_OnKeyUp);

The `LunarWindow` template is defined as

Code:
<Frame name="LunarWindow" movable="true" toplevel="true" enableMouse="true" hidden="true" parent="UIParent" virtual="true" inherits="BackdropTemplate">
	<Size>
		<AbsDimension x="352" y="32"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER" />
	</Anchors>
	<Backdrop bgFile="Interface\AddOns\LunarSphere\art\Window-Background" edgeFile="Interface\Addons\LunarSphere\art\Window-Border" tile="true">
		<BackgroundInsets>
			<AbsInset left="5" right="5" top="5" bottom="5"/>
		</BackgroundInsets>
		<TileSize>
			<AbsValue val="128"/>
		</TileSize>
		<EdgeSize>
			<AbsValue val="16"/>
		</EdgeSize>
	</Backdrop>
The resulting frame is
https://imgur.com/pWBjlG3

But for the Classic client it works!


The Classic `LunarWindow` template just differs by not inheriting from `BackdropTemplate`:

Code:
<Frame name="LunarWindow" movable="true" toplevel="true" enableMouse="true" hidden="true" parent="UIParent" virtual="true">
The frame does have a nice background.

https://imgur.com/yuiNdm8

What am I doing wrong here? Do I need to inherit from something different than `BackdropTemplate`?

Thanks!!
  Reply With Quote
05-24-21, 04:47 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
Will allow you use the same xml frame in either Classic (era) or BCC or Retail by using the OnLoad script to check is the mixin exists or not.

If the mixin doesn't exist then frames automatically have a Backdrop.

You would also move the <Backdrop...> </Backdrop> into a SetBackdrop call in the OnLoad function after checking for the mixin.

The new xml would look something like (no backdrop inherited):
Code:
<Frame name="LunarWindow" movable="true" toplevel="true" enableMouse="true" hidden="true" parent="UIParent" virtual="true">
	<Size>
		<AbsDimension x="352" y="32"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER" />
	</Anchors>
	<Scripts>	
		<OnLoad inherit="prepend">
			OnLoadFunc(self)
		</OnLoad>
	</Scripts>
</Frame>
The OnLoad function would look solmething like:
Code:
function OnLoadFunc(self)
	if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
		Mixin(self, BackdropTemplateMixin)
	end
	-- setup the backdrop that was in the xml.
	self:Setbackdrop( {
		bgFile = "Interface\\AddOns\\LunarSphere\\art\\Window-Background",
		edgeFile = "Interface\\Addons\\LunarSphere\\art\\Window-Border",
		tile = true,
		tileEdge = false,
		tileSize = 128,
		edgeSize = 16,
		insets = { left = 5, right = 5, top = 5, bottom = 5 }
	} )
end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-24-21 at 05:13 PM.
  Reply With Quote
05-24-21, 06:41 PM   #3
fullmoon_sulfuras
A Murloc Raider
Join Date: Dec 2019
Posts: 8
Thanks for the reply!

I've tried your suggestion and now I'm getting an `attempt to call method 'SetBackdropColor' (a nil value)` error when trying to create the frame. Where should the `OnLoadFunc` function be placed? Does it need to be somewhere special?

But regardless of that, my understanding is that by using an `OnLoad` method you can avoid having separate XML files for Classic and Retail/BCC, which is nice. Will this solve the problem of transparent backgrounds?

The frame already had a <Script> section:

Code:
<Scripts>
	<OnLoad>
		self:SetBackdropColor(1.0,1.0,1.0,1);
	</OnLoad>
	<OnMouseDown>
		if ( button == "LeftButton" ) then
			self:StartMoving();
		end
	</OnMouseDown>
	<OnMouseUp>
		self:StopMovingOrSizing();
	</OnMouseUp>
</Scripts>
So I've changed it to:

Code:
<Scripts>
	<OnLoad inherit="prepend">
		if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
			Mixin(self, BackdropTemplateMixin)
		end
		self:SetBackdropColor(1.0,1.0,1.0,1);
	</OnLoad>
	<OnMouseDown>
		if ( button == "LeftButton" ) then
			self:StartMoving();
		end
	</OnMouseDown>
	<OnMouseUp>
		self:StopMovingOrSizing();
	</OnMouseUp>
</Scripts>
That fixed the `attempt to call method 'SetBackdropColor' (a nil value)` error, but I'm still getting a transparent background.


Thanks!

Last edited by fullmoon_sulfuras : 05-24-21 at 06:56 PM.
  Reply With Quote
05-24-21, 06:59 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
attempt to call method 'SetBackdropColor'
This would mean you are calling frame:SetBackdropColor(...) on a frame that doesn't the mixin set. Maybe a frame created using CreateFrame() with a template that doesn't set a backdrop by default?

Or possibly inheriting a custom xml template that is still using the <Backdrop> </Backdrop> tags and not checking the mixin.

You could
Code:
if not frame.SetBackdropColor then
   Mixin(frame, BackdropTemplateMixin)
end
Prikor to the call, but it seems you would be better figuring our where the backdrop is actually set in the first place and fixing that. Setting the colour of a non-existant backdrop doesn't seem very usefull .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-24-21 at 07:04 PM.
  Reply With Quote
05-24-21, 08:06 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
Code:
<Scripts>
	<OnLoad inherit="prepend">
		if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
			Mixin(self, BackdropTemplateMixin)
		end
		self:SetBackdropColor(1.0,1.0,1.0,1);
	</OnLoad>
	<OnMouseDown>
		if ( button == "LeftButton" ) then
			self:StartMoving();
		end
	</OnMouseDown>
	<OnMouseUp>
		self:StopMovingOrSizing();
	</OnMouseUp>
</Scripts>
I missed your OnLoad code.

Lua Code:
  1. if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
  2.     Mixin(self, BackdropTemplateMixin)
  3. end
  4. self:SetBackdropColor(1.0,1.0,1.0,1);
Adding the mixin just configures the frame to use a backdrop. Once that is done, you've then have to actually add the backdrop to colour.

Lua Code:
  1. if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
  2.     Mixin(self, BackdropTemplateMixin)
  3. end
  4. self:SetBackdrop( {... you have to find the actual backdrop information to put here } );
  5. self:SetBackdropColor(1.0,1.0,1.0,1); -- and set the colour
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-24-21, 08:17 PM   #6
fullmoon_sulfuras
A Murloc Raider
Join Date: Dec 2019
Posts: 8
Originally Posted by Fizzlemizz View Post
This would mean you are calling frame:SetBackdropColor(...) on a frame that doesn't the mixin set. Maybe a frame created using CreateFrame() with a template that doesn't set a backdrop by default?
The problem goes away if I explicitly inherit from BackdropTemplate. So I'm guessing that
Code:
Mixin(self, BackdropTemplateMixin)
Would fix that. To be clear: the error is thrown in the line

Lua Code:
  1. tempObject = CreateFrame("Frame", objectName, objectParent, "LunarWindow");

So it's not another frame, it's the frame template that I just changed in the XML file.

Originally Posted by Fizzlemizz View Post
Or possibly inheriting a custom xml template that is still using the <Backdrop> </Backdrop> tags and not checking the mixin.

You could
Code:
if not frame.SetBackdropColor then
   Mixin(frame, BackdropTemplateMixin)
end
Sorry, not following here. This works:

Lua Code:
  1. <OnLoad inherit="prepend">
  2.     if BackdropTemplateMixin then
  3.         Mixin(self, BackdropTemplateMixin)
  4.     end
  5.     self:SetBackdropColor(0.2,0.2,0.2,1.0);
  6. </OnLoad>

This does not work (`attempt to call method 'Setbackdrop' (a nil value)` is thrown).

Lua Code:
  1. <OnLoad inherit="prepend">
  2.     if BackdropTemplateMixin then
  3.         Mixin(self, BackdropTemplateMixin)
  4.     end
  5.     self:Setbackdrop( {
  6.         bgFile = "Interface\\AddOns\\LunarSphere\\art\\Window-Background",
  7.         edgeFile = "Interface\\Addons\\LunarSphere\\art\\Window-Border",
  8.         tile = true,
  9.         tileEdge = false,
  10.         tileSize = 128,
  11.         edgeSize = 16,
  12.         insets = { left = 5, right = 5, top = 5, bottom = 5 }
  13.     } )
  14.     self:SetBackdropColor(1.0,1.0,1.0,1);
  15. </OnLoad>

Originally Posted by Fizzlemizz View Post
Prikor to the call, but it seems you would be better figuring our where the backdrop is actually set in the first place and fixing that. Setting the colour of a non-existant backdrop doesn't seem very usefull .
The backdrop is being set in the XML, as per the original post. With the Backdrop System Changes it doesn't work anymore.

A question:

According to the backdrop changes page:

Code:
<KeyValue key="backdropInfo" value="BACKDROP_TOOLTIP_16_16_5555" type="global"/>
Where exactly I need to define the backdropInfo value? I've tried creating a frame with

Code:
<Frame name="TestFrame" parent="UIParent" inherits="BackdropTemplate">
    <KeyValues>
        <KeyValue key="backdropInfo" value="BACKDROP_TOOLTIP_16_16_5555" type="global"/>
        <KeyValue key="backdropBorderColor" value="LEGENDARY_ORANGE_COLOR" type="global"/>
        <KeyValue key="backdropBorderColorAlpha" value="0.25" type="number"/>
    </KeyValues>
    <Size x="300" y="300"/>
    <Anchors>
        <Anchor point="CENTER"/>
    </Anchors>
    <Scripts>
        <OnLoad inherit="prepend">
            print("Loaded!");
        </OnLoad>
    </Scripts>
</Frame>
And it of course works. Now, if I change the backdropInfo line to

Code:
        <KeyValue key="backdropInfo" value="my_backdrop_value" type="global"/>
And define my_backdrop_value in a .lua file:

Lua Code:
  1. my_backdrop_value= {
  2.     bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
  3.     edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  4.     tile = true,
  5.     tileEdge = true,
  6.     tileSize = 16,
  7.     edgeSize = 16,
  8.     insets = { left = 5, right = 5, top = 5, bottom = 5 },
  9. };

It just doesn't work. Do I need to place it somewhere special?

Thanks!
  Reply With Quote
05-24-21, 08:26 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
Lua Code:
  1. <Frame name="TestFrame" parent="UIParent">
  2.     <Size x="300" y="300"/>
  3.     <Anchors>
  4.         <Anchor point="CENTER"/>
  5.     </Anchors>
  6.     <Scripts>
  7.         <OnLoad inherit="prepend">
  8.             if BackdropTemplateMixin then
  9.                 Mixin(self, BackdropTemplateMixin)
  10.             end
  11.             self:SetBackdrop( BACKDROP_TOOLTIP_16_16_5555 )
  12.             self:SetBackdropColor(unpack(LEGENDARY_ORANGE_COLOR))
  13.             self:SetBackdropColor(0.25)
  14.  
  15.         </OnLoad>
  16.     </Scripts>
  17. </Frame>

Because the frame doesn't have the backdrop code when it is created, the xml attributes for backdrops are ignored (or error?) so they have to be set after the frame is configured to use a backdrop via the mixin.

This should work in all versions of the client.

You could replace:
Code:
self:SetBackdrop( BACKDROP_TOOLTIP_16_16_5555 )
with:
Code:
self:SetBackdrop(
    {
        bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
        edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true,
        tileEdge = true,
        tileSize = 16,
        edgeSize = 16,
        insets = { left = 5, right = 5, top = 5, bottom = 5 },
    }
)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-24-21 at 08:36 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » All my frames are transparent in Retail/BCC

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