changeset 25:bf997ea151ca

yet another attempt to add missing files
author Flick <flickerstreak@gmail.com>
date Fri, 07 Mar 2008 22:19:03 +0000
parents 9e1984088124
children 261f0f6bd68a
files ReAction.lua ReAction_Bar.lua modules/ReAction_ConfigUI/ReAction_ConfigUI.lua modules/ReAction_ConfigUI/ReAction_ConfigUI.toc modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua modules/ReAction_HideBlizzard/ReAction_HideBlizzard.toc modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua modules/ReAction_ModuleTemplate/ReAction_ModuleName.toc modules/ReAction_State/ReAction_State.lua modules/ReAction_State/ReAction_State.toc
diffstat 10 files changed, 1507 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ReAction.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,164 @@
+--[[
+
+  ReAction Add-On main file. 
+  
+  Performs add-on and library initialization and setup.
+
+--]]
+
+
+-- 'ReAction' is exported as a global.
+ReAction = AceLibrary("AceAddon-2.0"):new(
+  "AceModuleCore-2.0",
+  "AceEvent-2.0",
+  "AceDB-2.0"
+)
+
+local ReAction = ReAction
+local L = AceLibrary("AceLocale-2.2"):new("ReAction")
+local AceOO = AceLibrary("AceOO-2.0")
+
+
+ReAction.revision = tonumber(("$Revision: 1 $"):match("%d+"))
+ReAction.L = L
+
+-- global variable strings for integration with WoW keybindings dialog (see bindings.xml)
+BINDING_HEADER_REACTION             = L["ReAction"]
+BINDING_NAME_REACTION_TOGGLELOCK    = L["Toggle ReAction Bar Lock"]
+BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"]
+
+-- from AceAddon-2.0
+function ReAction:OnInitialize()
+  self:RegisterDB("ReActionDB")
+end
+
+-- from AceAddon-2.0
+function ReAction:OnEnable()
+
+end
+
+-- from AceAddon-2.0
+function ReAction:OnDisable()
+
+end
+
+-- from AceDB-2.0
+function ReAction:OnProfileEnable()
+
+end
+
+-- from AceDB-2.0
+function ReAction:OnProfileDisable()
+
+end
+
+-- from AceModuleCore-2.0
+function ReAction:OnModuleEnable(module)
+  -- this handles initialization ordering issues with ReAction_Bar
+  local barMod = self:GetModule("Bar")
+  if barMod and module.ApplyToBar then
+    for _, b in pairs(barMod.bars) do
+      if b then
+        module:ApplyToBar(b)
+      end
+    end
+  end
+end
+
+-- from AceModuleCore-2.0
+function ReAction:OnModuleDisable(module)
+  local barMod = self:GetModule("Bar")
+  if barMod and module.RemoveFromBar then
+    for _, b in pairs(barMod.bars) do
+      if b then
+        module:RemoveFromBar(b)
+      end
+    end
+  end
+end
+
+--[[
+  Module API (see bar.lua for usage)
+
+  module:ApplyToBar(bar)
+  module:RemoveFromBar(bar)
+  module:RefreshBar(bar)
+  module:ApplyConfigMode(mode,listOfBars)
+  module:GetBarNameModifier(bar)
+  module:EraseBarConfig(barName)
+]]--
+
+
+-- debugging
+ReAction.debug = true
+if ReAction.debug then
+  ReAction.print = function(msg)
+    DEFAULT_CHAT_FRAME:AddMessage(msg)
+  end
+  --seterrorhandler(ReAction.print)
+else
+  ReAction.print = function() end
+end
+
+
+-- utility
+local newTable, recycle, deepCopy, deepDelete, varName
+do
+  local pool = setmetatable( { }, {__mode="kv"} )
+
+  function newTable(...)
+    local t = table.remove(pool) or { }
+    for i = 1, select('#',...), 2 do
+      local k = select(i,...)
+      local v = select(i+1,...)
+      if k and v then
+        t[k] = v
+      end
+    end
+    return t
+  end
+
+  function recycle(t)
+    if type(t) == "table" then
+      table.insert(pool,t)
+    end
+  end
+
+  function deepCopy( x )
+    if type(x) ~= "table" then
+      return x
+    end
+    local r = newTable()
+    for k,v in pairs(x) do
+      r[k] = deepCopy(v)
+    end
+    return r
+  end
+
+  function deepDelete( x )
+    if type(x) == "table" and x.IsObjectType == nil and not(AceOO.inherits(x,AceOO.Object)) then -- don't want to delete WoW or AceOO objects!
+      for k,v in pairs(x) do
+        x[k] = deepDelete(v)
+      end
+      recycle(x)
+    end
+  end
+
+  function varName(s)
+    return tostring(s):gsub("[^a-zA-Z0-9_]","_")
+  end
+
+  local u = setmetatable( { }, {__newindex = function(self,k,v) rawset(self,#self+1,v) ; rawset(self,k,v) end} )
+  u.deepCopy = deepCopy
+  u.deepDelete = deepDelete
+  u.newTable = newTable
+  u.recycle = recycle
+  u.varName = varName
+
+  ReAction.util = u
+end
+
+function ReAction:GetUtilFuncs()
+  return unpack(self.util)
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ReAction_Bar.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,380 @@
+--[[
+  ReAction bar module.
+
+  This is the heart of ReAction, the bar management module. Many of its
+  functions turn around and iterate all modules registered to the ReAction
+  parent core.
+
+  Also defined in this file is the Bar class implementation, which can be
+  used by other modules to manipulate the action bars. Many of the module
+  iterated calls pass a bar or list of bars as an argument.
+
+  Module methods called by the Bar module:
+    module:ApplyToBar(bar)
+    module:RemoveFromBar(bar)
+    module:RefreshBar(bar)
+    module:ApplyConfigMode(mode,listOfBars)
+    module:GetBarNameModifier(bar)
+    module:EraseBarConfig(barName)
+
+
+  useful Bar object API (partial list):
+    f     = bar:GetFrame()      -- f is derived from SecureStateDriver
+            bar:RefreshLayout()
+    w,h   = bar:GetSize()
+    r,c,s = bar:GetButtonGrid() -- #rows, #columns, inter-button spacing
+    name  = bar:GetName()
+            bar:PlaceButton(frame, idx, baseSizeX, baseSizeY) -- idx is 1-based
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+local AceOO = AceLibrary("AceOO-2.0")
+local CreateFrame = CreateFrame
+local geterrorhandler = geterrorhandler
+local pcall = pcall
+local print = ReAction.print
+
+-- update ReAction revision if this file is newer
+local revision = tonumber(("$Revision: 1 $"):match("%d+"))
+if revision > ReAction.revision then
+  Reaction.revision = revision
+end
+
+local moduleID = "Bar"
+
+--
+-- Bar module declaration
+--
+local module = ReAction:NewModule( moduleID )
+
+--
+-- Bar class declaration
+--
+local BarClass = AceOO.Class()
+local Bar = BarClass.prototype
+module.BarClass = BarClass
+
+
+--
+-- Bar module implementation
+--
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    { 
+      bars = { },
+      defaultBar = { }
+    }
+  )
+  self.bars = {}
+end
+
+function module:OnEnable()
+  self:InitializeBars()
+end
+
+function module:OnDisable()
+  self:TearDownBars()
+end
+
+function module:OnProfileEnable()
+  self:InitializeBars()
+end
+
+function module:OnProfileDisable()
+  self:TearDownBars()
+end
+
+function module:InitializeBars()
+  if not(self.inited) then
+    for name, config in pairs(self.db.profile.bars) do
+      if config then
+        self:CreateBar(name, config)
+      end
+    end
+    self:CallMethodOnAllBars("ApplyAnchor") -- re-anchor in the case of oddball ordering
+    self.inited = true
+  end
+end
+
+function module:TearDownBars()
+  for name, bar in pairs(self.bars) do
+    if bar then
+      self.bars[name] = self:DeleteBar(bar)
+    end
+  end
+  self.inited = false
+end
+
+-- Gets config from existing DB name or default if not supplied
+-- Saves to DB if name not known
+function module:CreateBar(name, config)
+  local profile = self.db.profile
+  if not name then
+    i = 1
+    repeat
+      name = L["Bar "]..i
+      i = i + 1
+    until self.bars[name] == nil
+  end
+  config = config or profile.bars[name] or deepCopy(profile.defaultBar)
+  if not profile.bars[name] then
+    profile.bars[name] = config
+  end
+  local bar = self.BarClass:new( name, config )
+  ReAction:CallMethodOnAllModules("ApplyToBar", bar)
+  self.bars[name] = bar
+  return bar
+end
+
+
+local SelectBar
+do
+  SelectBar = function(x)
+    local bar, name
+    if type(x) == "string" then
+      name = x
+      bar = module:GetBar(name)
+    elseif AceOO.inherits(x,BarClass) then
+      bar = x
+      for k,v in pairs(module.bars) do
+        if v == bar then
+          name = k
+        end
+      end
+    else
+      error("bad argument to SelectBar")
+    end
+    return bar, name
+  end
+end
+
+-- Takes either a bar name string or a bar object.
+-- Does NOT destroy the DB entry, this function is only used for 
+-- enable/disable and profile switching. To remove a bar permanently,
+-- use EraseBar() instead.
+function module:DeleteBar(x)
+  local bar, name = SelectBar(x)
+  if name and bar then
+    self.bars[name] = nil
+    ReAction:CallMethodOnAllModules("RemoveFromBar", bar)
+    bar:Destroy()
+  end
+end
+
+function module:EraseBar(x)
+  local bar, name = SelectBar(x)
+  if name and bar then
+    self:DeleteBar(bar)
+    self.db.profile.bars[name] = nil
+    ReAction:CallMethodOnAllModules("EraseBarConfig", name)
+  end
+end
+
+function module:GetBar(name)
+  return self.bars[name]
+end
+
+function module:RenameBar(x, newname)
+  local bar, name = SelectBar(x)
+  if bar and name and newname then
+    if self.bars[newname] then
+      error(L["ReAction: name already in use"])
+    end
+    self.bars[newname] = self.bars[name]
+    self.bars[name] = nil
+    bar:SetName(newname)
+    local cfg = self.db.profile.bars
+    cfg[newname], cfg[name] = cfg[name], nil
+  end
+end
+
+function module:CallMethodOnAllBars(method,...)
+  local m
+  if type(method) == "function" then
+    m = method
+  elseif type(method) ~= "string" then
+    error("Invalid method passed to ReAction_Bar:CallMethodOnAllBars()")
+  end
+  for _, bar in pairs(self.bars) do
+    if bar then
+      local m = m or bar[method]
+      if m then
+        local success,err = pcall(m,bar,...)
+        if not success then
+          geterrorhandler()(err)
+        end
+      end
+    end
+  end
+end
+
+
+
+function module:GetBarMenuOptions(bar)
+  if not(bar.modMenuOpts[moduleID]) then
+    bar.modMenuOpts[moduleID] = {
+      delete = {
+        type = "execute",
+        name = L["Delete Bar"],
+        desc = L["Remove the bar from the current profile"],
+        func = function() self:EraseBar(bar) end,
+        order = 1
+      },
+    }
+  end
+  return bar.modMenuOpts[moduleID]
+end
+
+function module:GetBarConfigOptions(bar, cfgModule)
+  if not(bar.modConfigOpts[moduleID]) then
+    bar.modConfigOpts[moduleID] = {
+      delete = {
+        type = "execute",
+        name = L["Delete Bar"],
+        desc = L["Remove the bar from the current profile"],
+        func = function() self:EraseBar(bar); cfgModule:RefreshConfig() end
+      },
+      rename = {
+        type = "text",
+        name = L["Rename Bar"],
+        desc = L["Set a name for the bar"],
+        get  = "GetName",
+        set  = function(name) self:RenameBar(bar,name); cfgModule:RefreshConfig() end
+      }
+    }
+  end
+  return bar.modConfigOpts[moduleID]
+end
+
+
+
+--
+-- Bar class implementation
+--
+function Bar:init( name, config )
+  BarClass.super.prototype.init(self)
+  self.name, self.config = name, config
+
+  if type(config) ~= "table" then
+    error("ReAction:Bar: config table required")
+  end
+
+  local f = CreateFrame("Frame",nil,config.parent or UIParent,"SecureStateDriverTemplate")
+  f:SetFrameStrata("MEDIUM")
+  config.width = config.width or 400
+  config.height = config.height or 80
+  f:SetWidth(config.width)
+  f:SetWidth(config.height)
+
+  self.frame = f
+  self:RefreshLayout()
+  self:ApplyAnchor()
+  f:Show()
+end
+
+function Bar:Destroy()
+  local f = self.frame
+  f:UnregisterAllEvents()
+  f:Hide()
+  f:SetParent(UIParent)
+  f:ClearAllPoints()
+  self.labelString = nil
+  self.controlFrame = nil
+  self.frame = nil
+  self.config = nil
+end
+
+function Bar:RefreshLayout()
+  ReAction:CallMethodOnAllModules("RefreshBar", self)
+end
+
+function Bar:ApplyAnchor()
+  local f, config = self.frame, self.config
+  f:SetWidth(config.width)
+  f:SetHeight(config.height)
+  local anchor = config.anchor
+  if anchor then
+    local anchorTo
+    if config.anchorTo then
+      anchorTo = module:GetBar(config.anchorTo) or _G[config.anchorTo]
+    end
+    f:SetPoint(anchor, anchorTo, config.relativePoint, config.x or 0, config.y or 0)
+  else
+    f:SetPoint("CENTER")
+  end
+end
+
+function Bar:GetFrame()
+  return self.frame
+end
+
+function Bar:GetSize()
+  return self.frame:GetWidth() or 200, self.frame:GetHeight() or 200
+end
+
+function Bar:SetSize(w,h)
+  self.config.width = w
+  self.config.height = h
+end
+
+function Bar:GetButtonSize()
+  local w = self.config.btnWidth or 32
+  local h = self.config.btnHeight or 32
+  -- TODO: get from modules?
+  return w,h
+end
+
+function Bar:SetButtonSize(w,h)
+  if w > 0 and h > 0 then
+    self.config.btnWidth = w
+    self.config.btnHeight = h
+  end
+end
+
+function Bar:GetButtonGrid()
+  local cfg = self.config
+  local r = cfg.btnRows or 1
+  local c = cfg.btnColumns or 1
+  local s = cfg.spacing or 4
+  return r,c,s
+end
+
+function Bar:SetButtonGrid(r,c,s)
+  if r > 0 and c > 0 and s > 0 then
+    local cfg = self.config
+    cfg.btnRows = r
+    cfg.btnColumns = c
+    cfg.spacing = s
+  end
+end
+
+-- This should only be called from module:RenameBar(), otherwise
+-- the bar's internal name and the module's list of bars by name
+-- can get out of sync.
+function Bar:SetName( name )
+  name = name or ""
+  self.name = name
+end
+
+function Bar:GetName()
+  return self.name
+end
+
+function Bar:PlaceButton(f, idx, baseW, baseH)
+  local r, c, s = self:GetButtonGrid()
+  local bh, bw = self:GetButtonSize()
+  local row, col = floor((idx-1)/c), mod((idx-1),c) -- zero-based
+  local x, y = col*bw + (col+0.5)*s, row*bh + (row+0.5)*s
+  local scale = bw/baseW
+
+  f:ClearAllPoints()
+  f:SetPoint("TOPLEFT",x/scale,-y/scale)
+  f:SetScale(scale)
+--  f:Show()
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,608 @@
+--[[
+  ReAction Configuration UI module
+
+  This modules creates and manages ReAction configuration
+  elements, including:
+
+   - waterfall config menu system
+   - bar dragging and resizing control overlays
+   - contextual menus
+
+  Individual modules are responsible for populating these
+  configuration elements via the following functions:
+
+  module:GetGlobalOptions( configModule )
+  module:GetGlobalBarOptions( configModule )
+  module:GetModuleOptions( configModule )
+  module:GetBarConfigOptions( bar, configModule )
+  module:GetBarMenuOptions( bar, configModule )
+
+  the ReAction_ConfigUI module is passed in as a parameter so that
+  option handlers can refresh the config UI.
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+local Waterfall = AceLibrary("Waterfall-1.0")
+local Dewdrop = AceLibrary("Dewdrop-2.0")
+local print = ReAction.print
+local InCombatLockdown = InCombatLockdown
+local BarModule = ReAction:GetModule("Bar")
+
+-- module declaration
+local moduleID = "ConfigUI"
+local module = ReAction:NewModule( moduleID,
+  "AceConsole-2.0",  -- temp
+  "AceEvent-2.0"
+  -- mixins go here
+)
+
+module.globalOptions = {
+  type = "group",
+  args = {
+    unlock = {
+      type     = "toggle",
+      handler  = module,
+      name     = L["unlock"],
+      guiName  = L["Unlock Bars"],
+      desc     = L["Unlock bars for dragging and resizing with the mouse"],
+      get      = function() return module.configMode end,
+      set      = "SetConfigMode",
+      disabled = InCombatLockdown,
+      order    = 1
+    },
+    config = {
+      type     = "execute",
+      handler  = module,
+      name     = L["config"],
+      guiName  = L["Configure..."],
+      desc     = L["Open the configuration dialogue"],
+      func     = "OpenConfig",
+      disabled = InCombatLockdown,
+      wfHidden = true, -- don't show this in the waterfall config
+      order    = 2
+    },
+  }
+}
+
+module.configOptions = {
+  type = "group",
+  args = {
+    global = {
+      type = "group",
+      name = L["Global Settings"],
+      desc = L["Global configuration settings"],
+      args = { },
+      order = 1,
+    },
+    module = {
+      type = "group",
+      name = L["Module Settings"],
+      desc = L["Configuration settings for each module"],
+      args = { },
+      order = 2,
+    },
+    bar = {
+      type = "group",
+      name = L["Bars"],
+      desc = L["Configuration settings for bars"],
+      args = { },
+      order = 3,
+    },
+  }
+}
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    {
+
+    }
+  )
+
+  -- temp: this will be moved to main ReAction.lua later in a more efficient AceConsole-less implementation
+  -- that can load the ConfigUI module on demand
+  -- NOTE: this inserts an 'about' command that we don't want
+  self:RegisterChatCommand( {L["/reaction"], L["/rxn"]}, self.globalOptions, "REACTION" )
+end
+
+function module:OnEnable()
+  self:RegisterEvent("PLAYER_REGEN_DISABLED")
+ 	Waterfall:Register("ReAction",
+    "aceOptions", self.configOptions,
+    "treeLevels", nil, -- infinite
+    "colorR", 0.8,
+    "colorG", 0.65,
+    "colorB", 0,
+    "defaultPane", "global" )
+end
+
+function module:OnDisable()
+  self:UnregisterEvent("PLAYER_REGEN_DISABLED")
+  self:SetConfigMode(false)
+  Waterfall:UnRegister("ReAction")
+end
+
+function module:PLAYER_REGEN_DISABLED()
+  if self.configMode == true then
+    UIErrorsFrame:AddMessage(L["ReAction config mode disabled during combat."])
+    self:SetConfigMode(false)
+    Waterfall:Close("ReAction")
+  end
+end
+
+function module:SetConfigMode( mode )
+  BarModule:CallMethodOnAllBars("ShowControls",mode)
+  ReAction:CallMethodOnAllModules("ApplyConfigMode",mode,BarModule.bars)
+  self.configMode = mode
+end
+
+function module:ApplyConfigMode( mode, bars )
+  if not(mode) then
+    -- close open dewdrop menu
+    local p = Dewdrop:GetOpenedParent()
+    if p then
+      for _, bar in pairs(bars) do
+        if bar then
+          if p == bar.controlFrame then
+            Dewdrop:Close()
+          end
+        end
+      end
+    end
+  end
+end
+
+local function refreshWaterfall()
+  module:RefreshConfig()
+end
+
+function module:RefreshOptions()
+  local opts = self.configOptions.args
+  
+  for _, m in ReAction:IterateModulesWithMethod("GetGlobalOptions") do
+    local o = m:GetGlobalOptions(self)
+    if o then
+      for k, v in pairs(o) do
+        opts.global.args[k] = v
+      end
+    end
+  end
+
+  for _, m in ReAction:IterateModulesWithMethod("GetGlobalBarOptions") do
+    local o = m:GetGlobalBarOptions(self)
+    if o then
+      for k, v in pairs(o) do
+        opts.bar.args[k] = v
+      end
+    end
+  end
+
+  for _, m in ReAction:IterateModulesWithMethod("GetModuleOptions") do
+    local o = m:GetModuleOptions(self)
+    if o then
+      for k, v in pairs(o) do
+        opts.module.args[k] = v
+      end
+    end
+  end
+
+  local barOpts = opts.bar.args
+  for name, bar in pairs(BarModule.bars) do
+    if bar then
+      if barOpts[name] == nil then
+        barOpts[name] = {
+          type = "group",
+          name = name,
+          desc = name,
+          handler = bar,
+          args = { }
+        }
+      end
+      if bar.modConfigOpts == nil then 
+        bar.modConfigOpts = { }
+      end
+      for _, m in ReAction:IterateModulesWithMethod("GetBarConfigOptions") do
+        local o = m:GetBarConfigOptions(bar,self)
+        if o then
+          for k, v in pairs(o) do
+            barOpts[name].args[k] = v
+          end
+        end
+      end
+    end
+  end
+  -- remove obsolete bar tables
+  for name, opt in pairs(barOpts) do
+    if opt.type == "group" and BarModule.bars[name] == nil then
+      barOpts[name] = nil
+    end
+  end
+end
+
+function module:OpenConfig(bar)
+  self:RefreshOptions()
+  Dewdrop:Close()
+  Waterfall:Open("ReAction",bar and "bar."..bar:GetName())
+end
+
+function module:RefreshConfig()
+  self:RefreshOptions()
+  Waterfall:Refresh("ReAction")
+end
+
+function module:ApplyToBar(bar)
+  if self.configMode then
+    bar:ShowControls(true)
+  end
+end
+
+function module:RemoveFromBar(bar)
+  if bar.controlFrame then
+    bar.controlFrame:SetParent(UIParent)
+    bar.controlFrame:ClearAllPoints()
+    bar.controlFrame:Hide()
+    bar.controlFrame = nil
+  end
+end
+
+function module:GetGlobalOptions()
+  return self.globalOptions.args
+end
+
+
+
+
+
+--
+-- Bar config overlay
+--
+-- import some of these for small OnUpdate performance boost
+local Bar           = BarModule.BarClass.prototype
+local GetSize       = Bar.GetSize
+local GetButtonSize = Bar.GetButtonSize
+local GetButtonGrid = Bar.GetButtonGrid
+local SetSize       = Bar.SetSize
+local SetButtonSize = Bar.SetButtonSize
+local SetButtonGrid = Bar.SetButtonGrid
+local ApplyAnchor   = Bar.ApplyAnchor
+local floor         = math.floor
+local min           = math.min
+local format        = string.format
+local GameTooltip   = GameTooltip
+
+local function StoreExtents(bar)
+  local f = bar.frame
+  local point, relativeTo, relativePoint, x, y = f:GetPoint(1)
+  relativeTo = relativeTo or f:GetParent()
+  local anchorTo
+  for name, b in pairs(BarModule.bars) do
+    if b then
+      if b:GetFrame() == relativeTo then
+        anchorTo = name
+        break
+      end
+    end
+  end
+  anchorTo = anchorTo or relativeTo:GetName()
+  local c = bar.config
+  c.anchor = point
+  c.anchorTo = anchorTo
+  c.relativePoint = relativePoint
+  c.x = x
+  c.y = y
+  c.width, c.height = f:GetWidth(), f:GetHeight()
+end
+
+local function RecomputeButtonSize(bar)
+  local w, h = GetSize(bar)
+  local bw, bh = GetButtonSize(bar)
+  local r, c, s = GetButtonGrid(bar)
+
+  local scaleW = (floor(w/c) - s) / bw
+  local scaleH = (floor(h/r) - s) / bh
+  local scale = min(scaleW, scaleH)
+
+  SetButtonSize(bar, scale * bw, scale * bh, s)
+end
+
+local function RecomputeButtonSpacing(bar)
+  local w, h = GetSize(bar)
+  local bw, bh = GetButtonSize(bar)
+  local r, c, s = GetButtonGrid(bar)
+
+  SetButtonGrid(bar,r,c,min(floor(w/c) - bw, floor(h/r) - bh))
+end
+
+local function RecomputeGrid(bar)
+  local w, h = GetSize(bar)
+  local bw, bh = GetButtonSize(bar)
+  local r, c, s = GetButtonGrid(bar)
+
+  SetButtonGrid(bar, floor(h/(bh+s)), floor(w/(bw+s)), s)
+end
+
+local function ClampToButtons(bar)
+  local bw, bh = GetButtonSize(bar)
+  local r, c, s = GetButtonGrid(bar)
+  SetSize(bar, (bw+s)*c, (bh+s)*r )
+end
+
+local function HideGameTooltip()
+  GameTooltip:Hide()
+end
+
+local function CreateControls(bar)
+  local f = bar.frame
+
+  f:SetMovable(true)
+  f:SetResizable(true)
+  f:SetClampedToScreen(true)
+
+  -- buttons on the bar should be direct children of the bar frame.
+  -- The control elements need to float on top of this, which we could
+  -- do with SetFrameLevel() or Raise(), but it's more reliable to do it
+  -- via frame nesting, hence good old foo's appearance here.
+  local foo = CreateFrame("Frame",nil,f)
+  foo:SetAllPoints()
+
+  local control = CreateFrame("Button", nil, foo)
+  control:EnableMouse(true)
+  control:SetToplevel(true)
+  control:SetPoint("TOPLEFT", -4, 4)
+  control:SetPoint("BOTTOMRIGHT", 4, -4)
+  control:SetBackdrop({
+    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+    tile = true,
+    tileSize = 16,
+    edgeSize = 16,
+    insets = { left = 0, right = 0, top = 0, bottom = 0 },
+  })
+
+  -- textures
+  local bgTex = control: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")
+  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")
+  label:SetAllPoints()
+  label:SetJustifyH("CENTER")
+  label:SetShadowColor(0,0,0,1)
+  label:SetShadowOffset(2,-2)
+  label:SetTextColor(1,1,1,1)
+  label:SetText(bar:GetName())
+  label:Show()
+  bar.controlLabelString = label  -- so that bar:SetName() can update it
+
+  local StopResize = function()
+    f:StopMovingOrSizing()
+    f.isMoving = false
+    f:SetScript("OnUpdate",nil)
+    StoreExtents(bar)
+    ClampToButtons(bar)
+    ApplyAnchor(bar)
+  end
+
+  -- edge drag handles
+  for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do
+    local edge = CreateFrame("Frame",nil,control)
+    edge:EnableMouse(true)
+    edge:SetWidth(8)
+    edge:SetHeight(8)
+    if point == "TOP" or point == "BOTTOM" then
+      edge:SetPoint(point.."LEFT")
+      edge:SetPoint(point.."RIGHT")
+    else
+      edge:SetPoint("TOP"..point)
+      edge:SetPoint("BOTTOM"..point)
+    end
+    local tex = edge:CreateTexture(nil,"HIGHLIGHT")
+    tex:SetTexture(1.0,0.82,0,0.7)
+    tex:SetBlendMode("ADD")
+    tex:SetAllPoints()
+    edge:RegisterForDrag("LeftButton")
+    edge:SetScript("OnMouseDown",
+      function()
+        local bw, bh = GetButtonSize(bar)
+        local r, c, s = GetButtonGrid(bar)
+        f:SetMinResize( bw+s+1, bh+s+1 )
+        f:StartSizing(point)
+        f:SetScript("OnUpdate", 
+          function()
+            RecomputeGrid(bar)
+            bar:RefreshLayout()
+          end
+        )
+      end
+    )
+    edge:SetScript("OnMouseUp", StopResize)
+    edge:SetScript("OnEnter",
+      function()
+        GameTooltip:SetOwner(f, "ANCHOR_"..point)
+        GameTooltip:AddLine(L["Drag to add/remove buttons"])
+        GameTooltip:Show()
+      end
+    )
+    edge:SetScript("OnLeave", HideGameTooltip)
+    edge:Show()
+  end
+
+  -- corner drag handles, again nested in an anonymous frame so that they are on top
+  local foo2 = CreateFrame("Frame",nil,control)
+  foo2:SetAllPoints(true)
+  for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do
+    local corner = CreateFrame("Frame",nil,foo2)
+    corner:EnableMouse(true)
+    corner:SetWidth(12)
+    corner:SetHeight(12)
+    corner:SetPoint(point)
+    local tex = corner:CreateTexture(nil,"HIGHLIGHT")
+    tex:SetTexture(1.0,0.82,0,0.7)
+    tex:SetBlendMode("ADD")
+    tex:SetAllPoints()
+    corner:RegisterForDrag("LeftButton","RightButton")
+    local updateTooltip = function()
+      local size, size2 = bar:GetButtonSize()
+      local rows, cols, spacing = bar:GetButtonGrid()
+      size = (size == size2) and tostring(size) or format("%dx%d",size,size2)
+      GameTooltipTextRight4:SetText(size)
+      GameTooltipTextRight5:SetText(tostring(spacing))
+    end
+    corner:SetScript("OnMouseDown",
+      function(_,btn)
+        local bw, bh = GetButtonSize(bar)
+        local r, c, s = GetButtonGrid(bar)
+        if btn == "LeftButton" then -- button resize
+          f:SetMinResize( (s+12)*c+1, (s+12)*r+1 )
+          f:SetScript("OnUpdate", 
+            function()
+              RecomputeButtonSize(bar)
+              bar:RefreshLayout()
+              updateTooltip()
+            end
+          )
+        elseif btn == "RightButton" then -- spacing resize
+          f:SetMinResize( bw*c, bh*r )
+          f:SetScript("OnUpdate", 
+            function()
+              RecomputeButtonSpacing(bar)
+              bar:RefreshLayout()
+              updateTooltip()
+            end
+          )
+        end
+        f:StartSizing(point)
+      end
+    )
+    corner:SetScript("OnMouseUp",StopResize)
+    corner:SetScript("OnEnter",
+      function()
+        GameTooltip:SetOwner(f, "ANCHOR_"..point)
+        GameTooltip:AddLine(L["Drag to resize buttons"])
+        GameTooltip:AddLine(L["Right-click-drag"])
+        GameTooltip:AddLine(L["to change spacing"])
+        local size, size2 = bar:GetButtonSize()
+        local rows, cols, spacing = bar:GetButtonGrid()
+        size = (size == size2) and tostring(size) or format("%dx%d",size,size2)
+        GameTooltip:AddDoubleLine(L["Size:"], size)
+        GameTooltip:AddDoubleLine(L["Spacing:"], tostring(spacing))
+        GameTooltip:Show()
+      end
+    )
+    corner:SetScript("OnLeave", 
+      function()
+        GameTooltip:Hide()
+        f:SetScript("OnUpdate",nil)
+      end
+    )
+
+  end
+
+  control:RegisterForDrag("LeftButton")
+  control:RegisterForClicks("RightButtonDown")
+  
+  control:SetScript("OnDragStart",
+    function()
+      f:StartMoving()
+      f.isMoving = true
+      -- TODO: snap indicator update install
+    end
+  )
+
+  control:SetScript("OnDragStop",
+    function()
+      f:StopMovingOrSizing()
+      f.isMoving = false
+      f:SetScript("OnUpdate",nil)
+      -- TODO: snap frame here
+      StoreExtents(bar)
+    end
+  )
+
+  control:SetScript("OnEnter",
+    function()
+      -- add bar type and status information to name
+      local name = bar.name
+      for _, m in ReAction:IterateModulesWithMethod("GetBarNameModifier") do
+        local suffix = m:GetBarNameModifier(bar)
+        if suffix then
+          name = format("%s %s",name,suffix)
+        end
+      end
+      
+      GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT")
+      GameTooltip:AddLine(name)
+      GameTooltip:AddLine(L["Drag to move"])
+      --GameTooltip:AddLine(L["Shift-drag for sticky mode"])
+      GameTooltip:AddLine(L["Right-click for options"])
+      GameTooltip:Show()
+    end
+  )
+
+  control:SetScript("OnLeave", HideGameTooltip)
+
+  control:SetScript("OnClick",
+    function()
+      bar:ShowMenu()
+    end
+  )
+
+  return control
+end
+
+function Bar:ShowControls(show)
+  if show then
+    if not self.controlFrame then
+      self.controlFrame = CreateControls(self)
+    end
+    self.controlFrame:Show()
+  elseif self.controlFrame then
+    self.controlFrame:Hide()
+  end
+end
+
+function Bar:ShowMenu()
+  if not self.menuOpts then
+    self.menuOpts = {
+      type = "group",
+      args = {
+        openConfig = {
+          type = "execute",
+          name = L["Configure..."],
+          desc = L["Open the configuration dialogue for this bar"],
+          func = function() module:OpenConfig(self) end,
+          disabled = InCombatLockdown,
+          order = 1
+        }
+      }
+    }
+  end
+  if self.modMenuOpts == nil then
+    self.modMenuOpts = { }
+  end
+  for _, m in ReAction:IterateModulesWithMethod("GetBarMenuOptions") do
+    for k, v in pairs(m:GetBarMenuOptions(self, module)) do
+      self.menuOpts.args[k] = v
+    end
+  end
+  Dewdrop:Open(self.controlFrame, "children", self.menuOpts, "cursorX", true, "cursorY", true)
+end
+
+local Bar_SuperSetName = Bar.SetName
+function Bar:SetName(name)
+  Bar_SuperSetName(self,name)  
+  if self.controlLabelString then
+    self.controlLabelString:SetText(self.name)
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ConfigUI/ReAction_ConfigUI.toc	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,14 @@
+## Interface: 20300
+## Title: ReAction: Config UI
+## Notes: Configuration UI for ReAction
+## DefaultState: enabled
+## LoadOnDemand: 1
+## Author: Flick
+## Version: 1.0
+## X-Category: Action Bars
+## Dependencies: ReAction
+## OptionalDeps: Waterfall-1.0, DewdropLib
+
+lib\Waterfall-1.0\Waterfall-1.0.lua
+
+ReAction_ConfigUI.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,160 @@
+--[[
+  ReAction 'Hide Blizzard' module
+
+  Hides Blizzard action bars. This hides the extra action bars, stance bar, pet bar, and 
+  main menu bar, which in turn hides the experience bar, bag bar, micro menu bar, and lag meter.
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+
+-- module declaration
+local moduleID = "HideBlizzard"
+local module = ReAction:NewModule( moduleID )
+
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    { 
+      hide = false
+    }
+  )
+
+  self.hiddenFrame = CreateFrame("Frame")
+  self.hiddenFrame:Hide()
+
+  -- disable the buttons to hide/show the blizzard multiaction bars
+  -- see UIOptionsFrame.lua and .xml
+  -- This is called every time the options panel is shown, after it is set up
+  local disabledOptionsButtons = {
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR1_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR2_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR3_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR4_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["ALWAYS_SHOW_MULTIBARS_TEXT"].index],
+  }
+  hooksecurefunc("UIOptionsFrame_Load",
+    function()
+      if self.db.profile.hide then
+        for _, f in pairs(disabledOptionsButtons) do
+          f.disabled = true
+          OptionsFrame_DisableCheckBox(f)
+        end
+      end
+    end
+  )
+end
+
+function module:OnEnable()
+  if self.db.profile.hide then
+    self:HideAll(true)
+  end
+end
+
+function module:OnDisable()
+  self:ShowAll(true)
+end
+
+function module:OnProfileEnable()
+  if self.db.profile.hide then
+    self:HideAll(true)
+  else
+    self:ShowAll(true)
+  end
+end
+
+
+local frames = {
+  MainMenuBar,
+  PetActionButton1,
+  PetActionButton2,
+  PetActionButton3,
+  PetActionButton4,
+  PetActionButton5,
+  PetActionButton6,
+  PetActionButton7,
+  PetActionButton8,
+  PetActionButton9,
+  PetActionButton10,
+  BonusActionBarFrame,
+  ShapeshiftBarFrame,
+  MultiBarLeft,
+  MultiBarRight,
+  MultiBarBottomLeft,
+  MultiBarBottomRight,
+  SlidingActionBarTexture0,
+  SlidingActionBarTexture1,
+}
+
+local hidden = { }
+
+function module:HideAll( force )
+  if not(self.db.profile.hide) or force then
+    self.db.profile.hide = true
+    -- the pet bar is a child of MainMenuBar, but can't be permanently hidden because it will
+    -- break automatic pet bar show/hide. Need to reparent it instead.
+    PetActionBarFrame:SetParent(UIParent)
+    -- for some odd reason PetActionBarFrame has mouse input enabled even though it has no mouse
+    -- input handlers. Because of this it can potentially trap mouse clicks from getting through
+    -- to things behind it. It's not feasible to move it, either, since UIParent_ManageFramePositions()
+    -- will move it back to its original position whenever it's called.
+    PetActionBarFrame:EnableMouse(false)
+
+    for _, f in pairs(frames) do
+      hidden[f] = hidden[f] or { parent = f:GetParent(), wasShown = f:IsShown() }
+      f:SetParent(self.hiddenFrame)
+      f:Hide()
+    end
+  end
+end
+
+function module:ShowAll( force )
+  if self.db.profile.hide or force then
+    self.db.profile.hide = false
+
+    PetActionBarFrame:SetParent(MainMenuBar)
+    for _, f in pairs(frames) do
+      local h = hidden[f]
+      if h then
+        f:SetParent(h.parent)
+        if h.wasShown then
+          f:Show()
+        end
+      end
+    end
+  end
+end
+
+function module:IsHidden()
+  return self.db.profile.hide
+end
+
+function module:SetHidden(h)
+  if h then
+    self:HideAll()
+  else
+    self:ShowAll()
+  end
+end
+
+function module:GetGlobalOptions()
+  if self.globalOptions == nil then
+    self.globalOptions = {
+      hideBlizzard = {
+        type = "toggle",
+        handler = self,
+        name = L["Hide Default Action Bars"],
+        desc = L["Hide the default main bar and extra action bars"],
+        get  = "IsHidden",
+        set  = "SetHidden",
+        disabled = function() return InCombatLockdown() end
+      }
+    }
+  end
+  return self.globalOptions
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_HideBlizzard/ReAction_HideBlizzard.toc	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,11 @@
+## Interface: 20300
+## Title: ReAction: Hide Blizzard Frames
+## Notes: Hides blizzard action bars
+## DefaultState: enabled
+## LoadOnDemand: 1
+## Author: Flick
+## Version: 1.0
+## X-Category: Action Bars
+## Dependencies: ReAction
+
+ReAction_HideBlizzard.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,42 @@
+--[[
+  ReAction module template
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+
+-- module declaration
+local moduleID = "MyModuleName"
+local module = ReAction:NewModule( moduleID,
+  -- mixins go here
+)
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    {
+
+    }
+  )
+end
+
+function module:OnEnable()
+
+end
+
+function module:OnDisable()
+
+end
+
+function module:OnProfileEnable()
+
+end
+
+function module:OnProfileDisable()
+
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_ModuleTemplate/ReAction_ModuleName.toc	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,11 @@
+## Interface: 20300
+## Title: ReAction: <ModuleName>
+## Notes: <description here>
+## DefaultState: enabled
+## LoadOnDemand: 1
+## Author: Flick
+## Version: 1.0
+## X-Category: Action Bars
+## Dependencies: ReAction
+
+ReAction_<ModuleName>.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_State/ReAction_State.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,106 @@
+--[[
+  ReAction bar state machine
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+local _G = _G
+local InCombatLockdown = InCombatLockdown
+
+-- module declaration
+local moduleID = "State"
+local module = ReAction:NewModule( moduleID )
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    {
+
+    }
+  )
+end
+
+function module:OnEnable()
+
+end
+
+function module:OnDisable()
+
+end
+
+function module:OnProfileEnable()
+
+end
+
+function module:OnProfileDisable()
+
+end
+
+function module:GetGlobalOptions( configModule )
+
+end
+
+function module:GetGlobalBarOptions( configModule )
+
+end
+
+function module:GetModuleOptions( configModule )
+
+end
+
+function module:GetBarConfigOptions( bar, configModule )
+  if not bar.modConfigOpts[moduleID] then
+    local IsEnabled = function() 
+      return false
+    end
+
+    bar.modConfigOpts[moduleID] = {
+      state = {
+        type = "group",
+        name = L["Dynamic Behavior"],
+        desc = L["Dynamic Behavior"],
+        args = {
+          enable = {
+            type = "toggle",
+            name = L["Enable dynamic behavior"],
+            desc = L["Toggles dynamic behavior for this bar"],
+            get  = function() return false end,
+            set  = function(x) end,
+            disabled = InCombatLockdown,
+            order = 1
+          },
+
+          default = {
+            type = "text",
+            name = L["Default State"],
+            desc = L["State when no conditions apply"],
+            get  = function() return false end,
+            set  = function(x) end,
+            disabled = IsEnabled,
+            order = 2
+          },
+
+          stealth = {
+            type = "text",
+            name = L["Behavior when Stealthed"],
+            desc = L["Change bar state when stealthed"],
+            get  = function() return false end,
+            set  = function(x) end,
+            disabled = IsEnabled,
+            validate = { },
+          },
+
+        }
+      }
+    }
+  end
+  return bar.modConfigOpts[moduleID]
+end
+
+function module:GetBarMenuOptions( bar, configModule )
+
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_State/ReAction_State.toc	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,11 @@
+## Interface: 20300
+## Title: ReAction: State
+## Notes: Dynamic bar states for ReAction
+## DefaultState: enabled
+## LoadOnDemand: 1
+## Author: Flick
+## Version: 1.0
+## X-Category: Action Bars
+## Dependencies: ReAction
+
+ReAction_State.lua