diff Overlay.lua @ 92:5f1d7a81317c

- Various bugfixes - Switched action bar paging/mc fully to the _childupdate method
author Flick <flickerstreak@gmail.com>
date Fri, 17 Oct 2008 22:43:57 +0000
parents 7cabc8ac6c16
children 567a885cdfad
line wrap: on
line diff
--- a/Overlay.lua	Fri Oct 17 03:59:55 2008 +0000
+++ b/Overlay.lua	Fri Oct 17 22:43:57 2008 +0000
@@ -16,6 +16,8 @@
 local SetButtonGrid    = Bar.SetButtonGrid
 local ApplyAnchor      = Bar.ApplyAnchor
 
+local KB = LibStub("LibKeyBound-1.0")
+
 ReAction:UpdateRevision("$Revision$")
 
 --
@@ -29,7 +31,9 @@
 
 local function StoreExtents(bar)
   local f = bar:GetFrame()
-  SetAnchor( bar, f:GetPoint(1) )
+  local p, fr, rp, x, y = f:GetPoint(1)
+  fr = fr or UIParent
+  SetAnchor( bar, p, fr, rp, x, y )
   SetSize( bar, f:GetWidth(), f:GetHeight() )
 end
 
@@ -267,6 +271,12 @@
 local function GetClosestPointSnapped(f1, rx, ry, xOff, yOff)
   local o, p, rp, x, y = GetClosestVisiblePoint(f1)
   local s = false
+
+  local insideOffsetFunc = p and insidePointOffsetFuncs[p]
+  local coordFunc = p and pointCoordFuncs[p]
+  if not insideOffsetFunc or not coordFunc then
+    return
+  end
   
   local sx, sy = insidePointOffsetFuncs[p](xOff or 0, yOff or 0)
   local xx, yy = pointCoordFuncs[p](f1)
@@ -353,35 +363,33 @@
 
   f:SetMovable(true)
   f:SetResizable(true)
-  f:SetClampedToScreen(true)
 
-  local control = CreateFrame("Button", nil, f)
-  control:EnableMouse(true)
-  control:SetToplevel(true)
-  control:SetPoint("TOPLEFT", -4, 4)
-  control:SetPoint("BOTTOMRIGHT", 4, -4)
-  control:SetBackdrop({
+  local overlay = CreateFrame("Button", nil, f)
+  overlay:EnableMouse(true)
+  overlay:SetFrameLevel(3) -- set it above the buttons
+  overlay:SetPoint("TOPLEFT", -4, 4)
+  overlay:SetPoint("BOTTOMRIGHT", 4, -4)
+  overlay:SetBackdrop({
     edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
     tile = true,
     tileSize = 16,
     edgeSize = 16,
     insets = { left = 0, right = 0, top = 0, bottom = 0 },
   })
-  control:SetClampedToScreen(true)
 
   -- textures
-  local bgTex = control:CreateTexture(nil,"BACKGROUND")
+  local bgTex = overlay:CreateTexture(nil,"BACKGROUND")
   bgTex:SetTexture(0.7,0.7,1.0,0.2)
   bgTex:SetPoint("TOPLEFT",4,-4)
   bgTex:SetPoint("BOTTOMRIGHT",-4,4)
-  local hTex = control:CreateTexture(nil,"HIGHLIGHT")
+  local hTex = overlay:CreateTexture(nil,"HIGHLIGHT")
   hTex:SetTexture(0.7,0.7,1.0,0.2)
   hTex:SetPoint("TOPLEFT",4,-4)
   hTex:SetPoint("BOTTOMRIGHT",-4,4)
   hTex:SetBlendMode("ADD")
 
   -- label
-  local label = control:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
+  local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
   label:SetAllPoints()
   label:SetJustifyH("CENTER")
   label:SetShadowColor(0,0,0,1)
@@ -403,7 +411,7 @@
 
   -- edge drag handles
   for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do
-    local edge = CreateFrame("Frame",nil,control)
+    local edge = CreateFrame("Frame",nil,overlay)
     edge:EnableMouse(true)
     edge:SetWidth(8)
     edge:SetHeight(8)
@@ -445,7 +453,7 @@
   end
 
   -- corner drag handles, nested in an anonymous frame so that they are on top
-  local foo = CreateFrame("Frame",nil,control)
+  local foo = CreateFrame("Frame",nil,overlay)
   foo:SetAllPoints(true)
   for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do
     local corner = CreateFrame("Frame",nil,foo)
@@ -513,10 +521,10 @@
 
   end
 
-  control:RegisterForDrag("LeftButton")
-  control:RegisterForClicks("RightButtonUp")
+  overlay:RegisterForDrag("LeftButton")
+  overlay:RegisterForClicks("RightButtonUp")
   
-  control:SetScript("OnDragStart",
+  overlay:SetScript("OnDragStart",
     function()
       f:StartMoving()
       f.isMoving = true
@@ -545,7 +553,7 @@
     GameTooltip:Show()
   end
 
-  control:SetScript("OnDragStop",
+  overlay:SetScript("OnDragStop",
     function()
       f:StopMovingOrSizing()
       f.isMoving = false
@@ -567,7 +575,7 @@
     end
   )
 
-  control:SetScript("OnEnter",
+  overlay:SetScript("OnEnter",
     function()
       -- TODO: add bar type and status information to name
       --[[
@@ -584,36 +592,51 @@
     end
   )
 
-  control:SetScript("OnLeave", HideGameTooltip)
+  overlay:SetScript("OnLeave", HideGameTooltip)
 
-  control:SetScript("OnClick",
+  overlay:SetScript("OnClick",
     function()
       ReAction:ShowEditor(bar)
     end
   )
 
-  control:Raise()
+  function overlay:LIBKEYBOUND_ENABLED(evt)
+    self:SetFrameLevel(1)
+  end
 
-  return control
+  function overlay:LIBKEYBOUND_DISABLED(evt)
+    self:SetFrameLevel(3)
+  end
+
+  KB.RegisterCallback(overlay,"LIBKEYBOUND_ENABLED")
+  KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED")
+
+  if ReAction:GetKeybindMode() then
+    self:SetFrameLevel(1)
+  end
+
+  return overlay
 end
 
 
 -- export methods to the Bar prototype
 
 function Bar:ShowControls(show)
+  local f = self.controlFrame
   if show then
-    if not self.controlFrame then
-      self.controlFrame = CreateControls(self)
+    if not f then
+      f = CreateControls(self)
+      self.controlFrame = f
     end
-    self.controlFrame:Show()
-    self.controlFrame:Raise()
-  elseif self.controlFrame then
-    self.controlFrame:Hide()
+    f:Show()
+  elseif f then
+    f:Hide()
   end
 end
 
 function Bar:SetLabel(name)
-  if self.controlLabelString then
-    self.controlLabelString:SetText(self.name)
+  local label = self.controlLabelString
+  if label then
+    label:SetText(self.name)
   end
 end