changeset 51:c964fb84560c

added anchor controls
author Flick <flickerstreak@gmail.com>
date Tue, 22 Apr 2008 21:33:37 +0000
parents c3c64e2def50
children c9df7866ff31
files Bar.lua locale/enUS.lua modules/ReAction_ConfigUI/ReAction_ConfigUI.lua
diffstat 3 files changed, 118 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Bar.lua	Tue Apr 22 20:37:44 2008 +0000
+++ b/Bar.lua	Tue Apr 22 21:33:37 2008 +0000
@@ -60,6 +60,7 @@
   f:SetWidth(config.width)
   f:SetHeight(config.height)
   local anchor = config.anchor
+  f:ClearAllPoints()
   if anchor then
     local anchorTo
     if config.anchorTo then
@@ -71,6 +72,21 @@
   end
 end
 
+function Bar:SetAnchor(point, frame, relativePoint, x, y)
+  local c = self.config
+  c.anchor = point or c.anchor
+  c.anchorTo = frame and frame:GetName() or c.anchorTo
+  c.relativePoint = relativePoint or c.relativePoint
+  c.x = x or c.x
+  c.y = y or c.y
+  self:ApplyAnchor()
+end
+
+function Bar:GetAnchor()
+  local c = self.config
+  return (c.anchor or "CENTER"), (c.anchorTo or self.frame:GetParent():GetName()), (c.relativePoint or c.anchor or "CENTER"), (c.x or 0), (c.y or 0)
+end
+
 function Bar:GetFrame()
   return self.frame
 end
@@ -234,6 +250,7 @@
     -- via frame nesting, hence good old foo's appearance here.
     local foo = CreateFrame("Frame",nil,f)
     foo:SetAllPoints()
+    foo:SetClampedToScreen(true)
 
     local control = CreateFrame("Button", nil, foo)
     control:EnableMouse(true)
--- a/locale/enUS.lua	Tue Apr 22 20:37:44 2008 +0000
+++ b/locale/enUS.lua	Tue Apr 22 21:33:37 2008 +0000
@@ -37,6 +37,15 @@
 "Hide Empty Buttons",
 
 -- modules/ReAction_ConfigUI
+"Center",
+"Left",
+"Right",
+"Top",
+"Bottom",
+"Top Left",  
+"Top Right",
+"Bottom Left",
+"Bottom Right",
 "Customizable replacement for Blizzard's Action Bars",
 "Global Settings",
 "Global configuration settings",
@@ -61,6 +70,15 @@
 "General",
 "Rename Bar",
 "Delete Bar",
+"Anchor",
+"Frame",
+"The frame that the bar is anchored to",
+"Point",
+"Anchor point on the bar frame",
+"Relative Point",
+"Anchor point on the target frame",
+"X offset",
+"Y offset",
 "Button Grid",
 "Rows",
 "Columns",
--- a/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua	Tue Apr 22 20:37:44 2008 +0000
+++ b/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua	Tue Apr 22 21:33:37 2008 +0000
@@ -7,9 +7,23 @@
 -- local imports
 local ReAction = ReAction
 local L = ReAction.L
+local _G = _G
 local AceConfigReg = LibStub("AceConfigRegistry-3.0")
 local AceConfigDialog = LibStub("AceConfigDialog-3.0")
 
+-- some constants
+local pointTable = {
+  CENTER      = L["Center"], 
+  LEFT        = L["Left"],
+  RIGHT       = L["Right"],
+  TOP         = L["Top"],
+  BOTTOM      = L["Bottom"],
+  TOPLEFT     = L["Top Left"],
+  TOPRIGHT    = L["Top Right"],
+  BOTTOMLEFT  = L["Bottom Left"],
+  BOTTOMRIGHT = L["Bottom Right"],
+}
+
 -- module declaration
 local moduleID = "ConfigUI"
 local module = ReAction:NewModule( moduleID,
@@ -85,10 +99,76 @@
             desc = function() return bar:GetName() end,
             confirm = true,
             func = function() ReAction:EraseBar(bar) end,
-            order = -1
+            order = 2
           },
-
-        }
+          anchor = {
+            type = "group",
+            name = L["Anchor"],
+            inline = true,
+            args = {
+              frame = {
+                type = "input",
+                name = L["Frame"],
+                desc = L["The frame that the bar is anchored to"],
+                get  = function() local _, f = bar:GetAnchor(); return f end,
+                set  = function(info, val) bar:SetAnchor(nil,val) end,
+                validate = function(info, name) 
+                    if name then
+                      local f = ReAction:GetBar(name)
+                      if f then
+                        return true
+                      else
+                        f = _G[name]
+                        if f and type(f) == "table" and f.IsObjectType and f:IsObjectType("Frame") then
+                          return true
+                        end
+                      end
+                    end
+                    return false
+                  end,
+                width = "double",
+                order = 1
+              },
+              point = {
+                type = "select",
+                name = L["Point"],
+                desc = L["Anchor point on the bar frame"],
+                style = "dropdown",
+                get  = function() return bar:GetAnchor() end,
+                set  = function(info, val) bar:SetAnchor(val) end,
+                values = pointTable,
+                order = 2,
+              },
+              relativePoint = {
+                type = "select",
+                name = L["Relative Point"],
+                desc = L["Anchor point on the target frame"],
+                style = "dropdown",
+                get  = function() local p,f,r = bar:GetAnchor(); return r end,
+                set  = function(info, val) bar:SetAnchor(nil,nil,val) end,
+                values = pointTable,
+                order = 3,
+              },
+              x = {
+                type = "input",
+                pattern = "\-?%d+",
+                name = L["X offset"],
+                get = function() local p,f,r,x = bar:GetAnchor(); return x end,
+                set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
+                order = 4
+              },
+              y = {
+                type = "input",
+                pattern = "\-?%d+",
+                name = L["Y offset"],
+                get = function() local p,f,r,x,y = bar:GetAnchor(); return y end,
+                set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
+                order = 5
+              },
+            },
+            order = 3
+          },
+        },
       },
     },