changeset 98:a44173c7a82c

- added (Hidden) to label when bar is being shown temporarily for config - added snap-indicator (lock) icon. Displays when not dragging, if anchored, as well. - changed bar color when anchored
author Flick <flickerstreak@gmail.com>
date Fri, 24 Oct 2008 18:14:07 +0000
parents 5d3b7b025142
children f200bcb193d6
files Overlay.lua State.lua img/lock.tga locale/enUS.lua
diffstat 4 files changed, 89 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Overlay.lua	Thu Oct 23 00:01:00 2008 +0000
+++ b/Overlay.lua	Fri Oct 24 18:14:07 2008 +0000
@@ -24,6 +24,22 @@
 -- Bar config overlay
 --
 
+local function GetNormalTextColor()
+  return 1.0, 1.0, 1.0, 1.0
+end
+
+local function GetAnchoredTextColor()
+  return 1.0, 1.0, 1.0, 1.0
+end
+
+local function GetNormalBgColor()
+  return 0.7, 0.7, 1.0, 0.3
+end
+
+local function GetAnchoredBgColor()
+  return 0.9, 0.2, 0.7, 0.3
+end
+
 local function StoreSize(bar)
   local f = bar:GetFrame()
   SetSize( bar, f:GetWidth(), f:GetHeight() )
@@ -129,7 +145,7 @@
   TOP         = function(x, y) return 0, -y end,
   TOPLEFT     = function(x, y) return x, -y end,
   LEFT        = function(x, y) return x, 0 end,
-  CENTER      = function(x, y) return 0, 0 end,
+  CENTER      = function(x, y) return x, y end,
 }
 local pointCoordFuncs = {
   BOTTOMLEFT  = function(f) return f:GetLeft(),  f:GetBottom() end,
@@ -318,11 +334,11 @@
 local function CreateSnapIndicator()
   local si = CreateFrame("Frame",nil,UIParent)
   si:SetFrameStrata("HIGH")
-  si:SetHeight(8)
-  si:SetWidth(8)
+  si:SetHeight(16)
+  si:SetWidth(16)
   local tex = si:CreateTexture()
   tex:SetAllPoints()
-  tex:SetTexture(1.0, 0.82, 0, 0.8)
+  tex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock")
   tex:SetBlendMode("ADD")
   tex:SetDrawLayer("OVERLAY")
   return si
@@ -349,6 +365,7 @@
       si2:Hide()
     end
   end
+  return o, p
 end
 
 local function HideSnapIndicator()
@@ -358,6 +375,17 @@
   end
 end
 
+local function UpdateLabelString(bar)
+  local label = bar.controlLabelString
+  if label then
+    local name = bar.labelName
+    if name and bar.labelSubtext then
+      name = format("%s (%s)", name, bar.labelSubtext)
+    end
+    label:SetText(name or "")
+  end
+end
+
 local function CreateControls(bar)
   local f = bar:GetFrame()
 
@@ -387,18 +415,43 @@
   hTex:SetPoint("TOPLEFT",4,-4)
   hTex:SetPoint("BOTTOMRIGHT",-4,4)
   hTex:SetBlendMode("ADD")
+  local aTex = overlay:CreateTexture(nil,"ARTWORK")
+  aTex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock")
+  aTex:SetWidth(16)
+  aTex:SetHeight(16)
+  aTex:Hide()
 
   -- label
   local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
   label:SetAllPoints()
   label:SetJustifyH("CENTER")
   label:SetShadowColor(0,0,0,1)
-  label:SetShadowOffset(2,-2)
-  label:SetTextColor(1,1,1,1)
+  label:SetShadowOffset(3,-3)
+  label:SetTextColor(GetNormalTextColor())
   label:SetText(bar:GetName())
   label:Show()
   bar.controlLabelString = label  -- so that bar:SetLabel() can update it
 
+  local function UpdateAnchorDecoration()
+    local point, anchor, relPoint, x, y = f:GetPoint(1)
+    if point then
+      local ofsx, ofsy = insidePointOffsetFuncs[point](x,y)
+      if (anchor and anchor ~= UIParent) or (ofsx == 0 and ofsy == 0) then
+        bgTex:SetTexture( GetAnchoredBgColor() )
+        hTex:SetTexture( GetAnchoredBgColor() )
+        label:SetTextColor( GetAnchoredTextColor() )
+        aTex:ClearAllPoints()
+        aTex:SetPoint(point)
+        aTex:Show()
+        return
+      end
+    end
+    bgTex:SetTexture( GetNormalBgColor() )
+    hTex:SetTexture( GetNormalBgColor() )
+    label:SetTextColor( GetNormalTextColor() )
+    aTex:Hide()
+  end
+
   local function StopResize()
     f:StopMovingOrSizing()
     f.isMoving = false
@@ -466,7 +519,7 @@
     tex:SetBlendMode("ADD")
     tex:SetAllPoints()
     corner:RegisterForDrag("LeftButton","RightButton")
-    local function updateTooltip()
+    local function UpdateTooltip()
       local size, size2 = bar:GetButtonSize()
       local rows, cols, spacing = bar:GetButtonGrid()
       size = (size == size2) and tostring(size) or format("%dx%d",size,size2)
@@ -482,7 +535,7 @@
           f:SetScript("OnUpdate", 
             function()
               RecomputeButtonSize(bar)
-              updateTooltip()
+              UpdateTooltip()
             end
           )
         elseif btn == "RightButton" then -- spacing resize
@@ -490,7 +543,7 @@
           f:SetScript("OnUpdate", 
             function()
               RecomputeButtonSpacing(bar)
-              updateTooltip()
+              UpdateTooltip()
             end
           )
         end
@@ -530,9 +583,10 @@
       f.isMoving = true
       local w,h = bar:GetButtonSize()
       f:ClearAllPoints()
+      UpdateAnchorDecoration()
       f:SetScript("OnUpdate", function()
           if IsShiftKeyDown() then
-            DisplaySnapIndicator(f,w,h)
+            local f, p = DisplaySnapIndicator(f,w,h)
           else
             HideSnapIndicator()
           end
@@ -540,7 +594,7 @@
     end
   )
 
-  local function updateDragTooltip()
+  local function UpdateDragTooltip()
     GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT")
     GameTooltip:AddLine(bar.name)
     GameTooltip:AddLine(L["Drag to move"])
@@ -571,24 +625,14 @@
 
       StoreExtents(bar)
       ReAction:RefreshOptions()
-      updateDragTooltip()
+      UpdateDragTooltip()
+      UpdateAnchorDecoration()
     end
   )
 
   overlay:SetScript("OnEnter",
     function()
-      -- TODO: add bar type and status information to name
-      --[[
-      local name = bar.name
-      for _, m in ReAction:IterateModules() do
-        local suffix = safecall(m,"GetBarNameModifier",bar)
-        if suffix then
-          name = ("%s %s"):format(name,suffix)
-        end
-      end
-      ]]--
-
-      updateDragTooltip()
+      UpdateDragTooltip()
     end
   )
 
@@ -615,6 +659,10 @@
     overlay:SetFrameLevel(1)
   end
 
+  bar:SetLabel(bar:GetName())
+  UpdateLabelString(bar)
+  UpdateAnchorDecoration()
+
   return overlay
 end
 
@@ -635,8 +683,11 @@
 end
 
 function Bar:SetLabel(name)
-  local label = self.controlLabelString
-  if label then
-    label:SetText(self.name)
-  end
+  self.labelName = name
+  UpdateLabelString(self)
 end
+
+function Bar:SetLabelSubtext(text)
+  self.labelSubtext = text
+  UpdateLabelString(self)
+end
--- a/State.lua	Thu Oct 23 00:01:00 2008 +0000
+++ b/State.lua	Fri Oct 24 18:14:07 2008 +0000
@@ -73,6 +73,9 @@
           end
           hidden = h
         end
+        if showAll then
+          control:CallMethod("UpdateHiddenLabel",hide[state])
+        end
       ]],
 
     --keybindState  TODO: broken
@@ -206,6 +209,12 @@
     function SetStateDriver( bar, rule )
       local f = bar:GetFrame()
 
+      if not f.UpdateHiddenLabel then
+        function f:UpdateHiddenLabel(hide)
+          bar:SetLabelSubtext( hide and L["Hidden"] )
+        end
+      end
+
       local props = { }
       for p, h in pairs(properties) do
         if type(h) == "string" then
Binary file img/lock.tga has changed
--- a/locale/enUS.lua	Thu Oct 23 00:01:00 2008 +0000
+++ b/locale/enUS.lua	Fri Oct 24 18:14:07 2008 +0000
@@ -39,6 +39,7 @@
 "Are you sure you want to remove this bar?",
 
 -- State.lua
+"Hidden",
 "State named '%s' already exists",
 "Battle Stance",
 "Defensive Stance",