changeset 18:27aa0d9ffe43

allow hiding of the anchor
author Chris Mellon <arkanes@gmai.com>
date Fri, 15 Oct 2010 22:40:50 -0500
parents 233745d4774b
children a6f5a0f2d429
files KBF.lua
diffstat 1 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/KBF.lua	Fri Oct 15 21:41:55 2010 -0500
+++ b/KBF.lua	Fri Oct 15 22:40:50 2010 -0500
@@ -8,15 +8,18 @@
 function kbf:OnInitialize()
     self.debuffFrames = {}
     self.anchor = self:CreateAnchorFrame()
-    self.anchor:Show()
     self:RegisterEvent("UNIT_AURA")
     -- set up the countdown timer
     -- TODO: Fancy enable/disable based on whether you have any timed buffs.
     -- Not a big deal, how often do you care about that
     -- also TODO: Maybe should bucket OnUpdates somehow
-    self.anchor:SetScript("OnUpdate", function() self:OnUpdate() end)
+    -- AceTimer repeating events can only happen at 0.1 seconds, which is probably
+    -- fast enough for updating, but makes the animation look jerky
+    self.update = CreateFrame("FRAME")
+    self.update:SetScript("OnUpdate", function() self:OnUpdate() end)
     self.dirty = true -- force an immediate scan on login
     self:HideBlizzardBuffFrames()
+    self:RegisterChatCommand("kbf", "ToggleAnchor")
 end
 -- naming convention
 -- a "frame" is the top-level button (secure button from the header, or one I make myself)
@@ -34,7 +37,7 @@
     end
     HideBlizFrame(BuffFrame)
     HideBlizFrame(ConsolidatedBuffs)
-    --HideBlizFrame(TemporaryEnchantFrame)
+    HideBlizFrame(TemporaryEnchantFrame)
     
 end
 
@@ -310,7 +313,7 @@
     anchor:SetClampedToScreen(true)
     anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", 
                          edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 
-                         tile = true, tileSize = 16, edgeSize = 16,
+                         tile = true, tileSize = 16, edgeSize = 12,
                          insets = { left = 4, right = 4, top = 4, bottom = 4 },
                          })
     local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text
@@ -319,8 +322,8 @@
     text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0)
     text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0)
     text:SetText("KBF ANCHOR")
-    anchor:SetWidth(200 + 16 + 8)
-    anchor:SetHeight(16 + 8)
+    anchor:SetWidth(200 +16)
+    anchor:SetHeight(16)
     -- movability
     anchor:EnableMouse(true)
     anchor:SetMovable(true)
@@ -331,7 +334,7 @@
     anchor:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
     anchor:Hide()
     
-    local frame = CreateFrame("FRAME", "KBFBuffFrame", anchor, "SecureAuraHeaderTemplate")
+    local frame = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate")
     --local frame = anchor
     frame:SetAttribute("filter", "HELPFUL")
     frame:SetAttribute("template", "KBFSecureUnitAuraTemplate")
@@ -348,8 +351,28 @@
     -- TODO: SecureAuraHeader doesn't correcltly implement the temp enchants
     frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate")
     frame:SetAttribute("includeWeapons", 1)
-    frame:SetPoint("TOP", anchor, "BOTTOM", 0, 0)
+    frame:SetPoint("TOP", anchor, "TOP", 0, 0)
     frame:Show() -- has to be shown, otherwise the child frames don't show
     self.secureFrame = frame
     return anchor
 end
+
+function kbf:ShowAnchor()
+    self.secureFrame:ClearAllPoints()
+    self.secureFrame:SetPoint("TOP", self.anchor, "BOTTOM", 0, 0)
+    self.anchor:Show()
+end
+
+function kbf:HideAnchor()
+    self.secureFrame:ClearAllPoints()
+    self.secureFrame:SetPoint("TOP", self.anchor, "TOP", 0, 0)
+    self.anchor:Hide()
+end
+
+function kbf:ToggleAnchor()
+    if self.anchor:IsShown() then
+        self:HideAnchor()
+    else
+        self:ShowAnchor()
+    end
+end