Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move masque support to its own module (buttonThemer)
- Loading branch information
Showing
7 changed files
with
94 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
local AddonName = ... | ||
local ButtonThemer = LibStub('AceAddon-3.0'):GetAddon(AddonName):NewModule('ButtonThemer') | ||
|
||
local _NormalButtonWidth = _G['ActionButton1']:GetWidth() | ||
|
||
function ButtonThemer:OnInitialize() | ||
local Masque = LibStub('Masque', true) | ||
|
||
if Masque then | ||
Masque:Register(AddonName, function(...) | ||
local addon, group, skinId, gloss, backdrop, colors, disabled = ... | ||
|
||
if disabled then | ||
for button in pairs(Masque:Group(AddonName, group).Buttons) do | ||
self:ApplyDefaultTheme(button) | ||
end | ||
end | ||
end) | ||
|
||
self.Register = function(self, button, groupName, ...) | ||
local group = Masque:Group(AddonName, groupName) | ||
|
||
group:AddButton(button, ...) | ||
|
||
if group.Disable then | ||
self:ApplyDefaultTheme(button) | ||
end | ||
end | ||
else | ||
self.Register = self.ApplyDefaultTheme | ||
end | ||
end | ||
|
||
function ButtonThemer:ApplyDefaultTheme(button) | ||
button.icon:SetTexCoord(0.06, 0.94, 0.06, 0.94) | ||
|
||
local r = button:GetWidth() / _NormalButtonWidth | ||
|
||
local nt = button:GetNormalTexture() | ||
nt:ClearAllPoints() | ||
nt:SetPoint('TOPLEFT', -15 * r, 15 * r) | ||
nt:SetPoint('BOTTOMRIGHT', 15 * r, -15 * r) | ||
nt:SetVertexColor(1, 1, 1, 0.5) | ||
|
||
local floatingBG = _G[('%sFloatingBG'):format(button:GetName())] | ||
if floatingBG then | ||
floatingBG:Hide() | ||
end | ||
end |