Quantcast
Masque ButtonData - WoWInterface
Thread Tools Display Modes
11-10-15, 04:07 PM   #1
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
Masque ButtonData

I am trying to assign a skin to my addon buttons with Masque, but there are some trouble with the cooldown layer. In fact, it often happens that the size of the cooldown are greater than those of the button. I think this is due to the fact that Masque not skins the cooldown layer. Reading the documentation, I came across this page. Honestly is not very clear explanation, and from what little I understood I should "feed" Masque with this table, but there no mention of how it should be done. The buttons are created and skinned in this way:

Lua Code:
  1. local MSQ = LibStub("Masque", true)
  2.  
  3. local f = CreateFrame("Button", "myButton",)
  4. f.cooldown = CreateFrame("Cooldown", f:GetName().."Cooldown", f, "CooldownFrameTemplate")
  5.  
  6. if (MSQ) then
  7.     MSQ:Group("MyAddon", "MyAddon group"):AddButton(f:GetName())
  8. end

How should do to get the right skin?
  Reply With Quote
11-10-15, 06:10 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. Masque does "skin" the cooldown, by moving and resizing it according to the skin's definitions. If it's misplaced or incorrectly sized, either Masque isn't able to identify your button's cooldown object, or the skin you're using is broken. Compare to the same skin on other action buttons (eg. Bartender or Dominos) to see if it's a skin issue or not.

2. You only need to provide a button data table if your button (a) doesn't have all of the regions/children Masque expects, or (b) doesn't use the standard names/keys for its regions/children. It's not necessary for typical action buttons with the expected structure.

3. Please post your entire, actual button creation code. What you posted is just not enough to identify any issues, and is making my eye twitch with awful (hopefully fake example) globals like "myButton".
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
11-11-15, 05:44 AM   #3
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
Originally Posted by Phanx View Post

3. Please post your entire, actual button creation code. What you posted is just not enough to identify any issues, and is making my eye twitch with awful (hopefully fake example) globals like "myButton".
XML code: http://nopaste.linux-dev.org/?830226 (I know I'm a bad person 'cause I use XML )
Lua code: http://nopaste.linux-dev.org/?830227

I use nopaste service 'cause is a bit long code, and I did not want write a flood post

Last edited by Benalish : 11-11-15 at 05:47 AM.
  Reply With Quote
11-13-15, 02:57 PM   #4
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
MyAddon:iconLocation() is just an icon reposizioning function

Lua Code:
  1. function MyAddon:iconLocation(idx) -- how the icons will be arranged according to the number of rows and columns
  2.     local row = db.profile["Bars"][idx]["rows"]
  3.     local col = db.profile["Bars"][idx]["columns"]
  4.     local frm = "MyAddon_Frame"..idx
  5.     for r = 1, row do
  6.         local line = col * r
  7.         local first = line - (col - 1)
  8.         for i = first, line do
  9.             local icona = MyAddon:iconName(idx, i)
  10.             if (i == 1) then
  11.                 icona:SetPoint("TOPLEFT",0,0)
  12.             elseif (i == first) and (i ~= 1) then
  13.                 local up =  first - col
  14.                 icona:SetPoint("TOPLEFT", frm.."MyAddon_Icon"..up , "BOTTOMLEFT", 0, db.profile.Vspacing)
  15.             else
  16.                 icona:SetPoint("TOPLEFT", frm.."MyAddon_Icon"..i-1 ,"TOPRIGHT", db.profile.Hspacing, 0)
  17.             end
  18.         end
  19.     end
  20. end
  Reply With Quote
11-17-15, 01:18 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
XML, lines 13-15:
This does nothing, since you don't set any drag-related scripts on bars, only on buttons. Get rid of this.

XML, lines 63-75:
You probably don't actually want to create a separate dropdown frame for every button. Just create one dropdown for your whole addon, and pass the correct arguments to the toggle function to position it relative to the specific button that was clicked to open it.

XML, line 86:
Based on the Lua code you posted, this is the mouseover trigger for tooltips -- get rid of this, you don't need it, the whole button can (and should) trigger a tooltip.

Lua, line 37:
If you're going to create a dedicated function for concatenating values to form a button name, you should also use that same function to get the name you pass to CreateFrame.

Lua, line 39:
If you're going to use XML, you should actually use XML, and add a cooldown to your button template.

Also (and much more importantly) you are creating a new cooldown object every time you update the button, which is bad.

Lua, line 54:
You should really try to find a way to do this that doesn't require creating a new function every time you update the button. See your "MyAddon_wpnenchScan_Onupdate" function as an example. An easy way to do this would be to attach keys to the button whose values contain the appopriate values of "bar" and "i", eg "f.bar = <reference to the bar frame>" and "f.id = i", and then refer to those in the function, so it can be called on any button and still have the data it needs.

Also, while "0,005" may be correct for human language in your region, Lua requires "0.005" notation for decimal values; currently you're passing "0" and then "005" as separate arguments.

Lua, line 58:
Again, try to generalize this function and define it outside of this update function, so you don't need to create a new one every time you update a button.

Lua, line 64:
Same thing, except Blizzard has already defined a generic version of this function; just use SetScript("OnLeave", GameTooltip_Hide) to get this behavior.

Lua, line 68:
Your button doesn't have a "highlight" member. It has a highlight texture, but that's not automatically assigned to the "highlight" key. If you want to do that, you need to write "f.highlight = f:GetHighlightTexture()" somewhere (like in your button's OnLoad script) first.

Lua, line 90:
Now we finally get to Masque! Most like you don't need your individual bars to be skinned differently, so you should just use Group("MyAddon") to just create one entry in the Masque options UI for your whole addon.

Masque's AddButton function can just take a reference to the button -- "f" in this context -- so you don't need to look up its name -- though if you did need to, you should just do "f:GetName()" instead of this!

Your button's button data table should probably look like this:

Code:
{
    -- Things your button does have:
    Icon = f.texture,

    -- Textures your button doesn't have:
    AutoCastable = false,
    Backdrop = false,
    Border = false,
    Checked = false,
    Disabled = false,
    Flash = false,
    Normal = false,
    Pushed = false,

    -- Font strings your button doesn't have:
    Name = false,
    Count = false,
    Duration = false,
    HotKey = false,

    -- Frames your button doesn't have:
    AutoCast = false,
    SpellAlert = false,
}
Things that aren't included in the table:

Cooldown: Masque can find this on its own since your cooldown object is named <buttonName>Cooldown like "real" action buttons.

Highlight: Masque will just call button:GetHighlightTexture() to find this on its own.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
11-19-15, 02:28 PM   #6
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
This is my new attempt, and its results:

The XML skeleton: https://gist.github.com/anonymous/2eebedd2141d3106f108

And the lua code:

Lua Code:
  1. function MyAddon:iconUpdate(total, frm) -- Icons (where buffs displayed)
  2.     local bar = frm:GetID()
  3.    
  4.     for i = 1, total do
  5.         local f = MyAddon:iconName(bar, i) or CreateFrame("Button", frm:GetName().."MyAddon_Icon"..i, frm, "MyAddon_IconTemplate", i)
  6.         local ButtonData = {
  7.                 -- Things your button does have:
  8.                 Icon = f.texture,
  9.  
  10.                 -- Textures your button doesn't have:
  11.                 AutoCastable = false,
  12.                 Backdrop = false,
  13.                 Border = false,
  14.                 Checked = false,
  15.                 Disabled = false,
  16.                 Flash = false,
  17.                 Normal = false,
  18.                 Pushed = false,
  19.  
  20.                 -- Font strings your button doesn't have:
  21.                 Name = false,
  22.                 Count = false,
  23.                 Duration = false,
  24.                 HotKey = false,
  25.  
  26.                 -- Frames your button doesn't have:
  27.                 AutoCast = false,
  28.                 SpellAlert = false,
  29.             }  
  30.         --the rest of the stuff is the same, with your hints
  31.         if (MSQ) then
  32.             MSQ:Group("MyAddon", "Icon bar\32"..bar):AddButton(f, ButtonData)
  33.         end
  34.     end
  35. end

The result is different from what I expected: http://imgur.com/ggJhCQo. As one can see from the picture, the cooldown overflow from icon because Masque failed to skin it. You should see the border, according to Masque settings: http://imgur.com/tLSEuSk

The only thing I can add is that the buttons are created at the call of this function:

Lua Code:
  1. function MyAddon:OnInitialize()
  2.     -- Called when the addon is loaded
  3.     self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults)
  4.     db = self.db
  5.     MyAddon:RegisterEvent("PLAYER_ENTERING_WORLD", function()  
  6.         MyAddon:barUpdate()
  7.     end)
  8. end

Where did I go wrong?

Last edited by Benalish : 11-19-15 at 02:33 PM.
  Reply With Quote
11-19-15, 03:29 PM   #7
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,351
The button skin tells Masque the dimensions of the cooldown swipe.
Lua Code:
  1. Cooldown = {
  2.         Width = 32,
  3.         Height = 32,
  4.     },
From the "Death Knight" part of my Masque_CB-Elv.
I don't think you can change that with another addon, but I guess maybe you can if you have the dimensions to change. Anyway, if I'm wrong I'm sure someone will chime in here to tell me.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
11-19-15, 09:54 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
As I mentioned earlier:

Originally Posted by Phanx View Post
1. Masque does "skin" the cooldown, by moving and resizing it according to the skin's definitions. If it's misplaced or incorrectly sized, either Masque isn't able to identify your button's cooldown object, or the skin you're using is broken. Compare to the same skin on other action buttons (eg. Bartender or Dominos) to see if it's a skin issue or not.
Does the same skin show the same issue on other addons?

If not, then it's likely the problem actually stems from the fact that your buttons don't have most of the textures a "regular" buttons have, but the skin is constructed with "regular" buttons in mind, where the border and/or normal textures would be filling up that space around the icon texture where the cooldown appears to be sticking out. If this is what's happening, then you'll probably just have to (1) tell Masque not to touch your cooldown (by setting Cooldown = false) in the buttonData table, and (2) manage the size of the cooldown yourself by registering for a OnSkinChanged callback from Masque, checking the size of the icon, and sizing/placing your cooldown object appropriately.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
11-20-15, 08:12 AM   #9
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,351
Keep in mind: Masque DOES NOT skin default objects. IE default action bars or buffs, debuffs and there may be more objects that I'm missing (imagine that!).
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
11-22-15, 08:15 AM   #10
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
After several attempts, I found that the problem lies in the texture structure, but I don't know how to configure it properly so Masque is able to skin it correctly. Any advice is welcome
  Reply With Quote
11-22-15, 12:42 PM   #11
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,351
Try resizing the cool down in whatever skin you are using. That should resize the swipe.

Look for something like
Lua Code:
  1. Cooldown = {
  2.         Width = 36,
  3.         Height = 36,
  4.     },
in the skin's Lua file. Just change the numbers.

EDIT: You are using a Masque skin, right? /EDIT
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 11-22-15 at 12:49 PM.
  Reply With Quote
11-22-15, 01:11 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by jeffy162 View Post
Try resizing the cool down in whatever skin you are using. That should resize the swipe.
It will, but it will also resize the swipe for all addons that you apply the skin to (which probably won't result in a good appearance, since other addons have things like border textures on their buttons) and it won't solve the problem for anyone else if the addon is published for other people to use.

Originally Posted by Benalish View Post
After several attempts, I found that the problem lies in the texture structure, but I don't know how to configure it properly so Masque is able to skin it correctly. Any advice is welcome
Without more information, there's not much I can tell you, but I am going to repeat myself for a third time:

Originally Posted by Phanx View Post
Does the same skin show the same issue on other addons?
If yes, your skin is broken, try a different one.

If no, post screenshots of the same skin applied to both your addon (where it looks wrong) and another addon (where it looks correct) and post your entire addon (not just parts of it).
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Masque ButtonData

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