Mercurial > wow > reaction
changeset 239:2669f737d9d7
Fold Action page state options into state.lua
author | Flick |
---|---|
date | Fri, 25 Mar 2011 16:28:25 -0700 |
parents | 8bde290d300c |
children | 98d7ad4a1158 |
files | modules/Action.lua modules/State.lua modules/modules.xml |
diffstat | 3 files changed, 40 insertions(+), 82 deletions(-) [+] |
line wrap: on
line diff
--- a/modules/Action.lua Thu Mar 24 14:27:56 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -local addonName, addonTable = ... -local ReAction = addonTable.ReAction -local L = ReAction.L -local _G = _G -local format = string.format -local wipe = wipe - -local weak = { __mode="k" } - --- module declaration -local moduleID = "Action" -local module = ReAction:NewModule( moduleID ) - --- Class declarations -local PropHandler = { } - --- Event handlers -function module:OnInitialize() - self.handles = setmetatable({ }, weak) -end - -function module:OnEnable() - ReAction:GetModule("State"):RegisterStateProperty("page", nil, PropHandler.GetOptions(), PropHandler) -end - -function module:OnDisable() - ReAction:GetModule("State"):UnregisterStateProperty("page") -end - ------- State property options ------ -do - local pageOptions = { - page = { - name = L["Show Page #"], - order = 11, - type = "select", - width = "half", - disabled = "IsPageDisabled", - hidden = "IsPageHidden", - values = "GetPageValues", - set = "SetProp", - get = "GetPage", - }, - } - - function PropHandler.GetOptions() - return pageOptions - end - - function PropHandler:IsPageDisabled() - local c = self.bar:GetConfig() - local n = c and c.nPages or 1 - return not (n > 1) - end - - function PropHandler:IsPageHidden() - return not self.bar:GetConfig() - end - - function PropHandler:GetPageValues() - if not self._pagevalues then - self._pagevalues = { } - end - local c = self.bar:GetConfig() - if c then - local n = c.nPages - -- cache the results - if self._npages ~= n then - self._npages = n - wipe(self._pagevalues) - for i = 1, n do - self._pagevalues["page"..i] = i - end - end - end - return self._pagevalues - end - - function PropHandler:GetPage(info) - return self:GetProp(info) or 1 - end - -end -
--- a/modules/State.lua Thu Mar 24 14:27:56 2011 -0700 +++ b/modules/State.lua Fri Mar 25 16:28:25 2011 -0700 @@ -238,6 +238,17 @@ order = 1, type = "description" }, + page = { + name = L["Show Page #"], + order = 11, + type = "select", + width = "half", + disabled = "IsPageDisabled", + hidden = "IsPageHidden", + values = "GetPageValues", + set = "SetProp", + get = "GetPage", + }, hide = { name = L["Hide Bar"], order = 90, @@ -649,6 +660,35 @@ return not GetProperty(self.bar, self:GetName(), "anchorEnable") end + function StateHandler:IsPageDisabled() + local n = self.bar:GetConfig().nPages or 1 + return not (n > 1) + end + + function StateHandler:IsPageHidden() + return not self.bar:GetConfig().nPages + end + + function StateHandler:GetPageValues() + if not self._pagevalues then + self._pagevalues = { } + end + local n = self.bar:GetConfig().nPages + -- cache the results + if self._npages ~= n then + self._npages = n + wipe(self._pagevalues) + for i = 1, n do + self._pagevalues["page"..i] = i + end + end + return self._pagevalues + end + + function StateHandler:GetPage(info) + return self:GetProp(info) or 1 + end + function StateHandler:GetAnchorFrames(info) self._anchorframes = self._anchorframes or { } table.wipe(self._anchorframes)