Skip to content

Commit

Permalink
tables work, passing framerefs does not
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Nov 21, 2010
1 parent 868773a commit 6a8873e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 49 deletions.
65 changes: 33 additions & 32 deletions core/bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,6 @@ local function frame_Create(id)
self:GetFrameRef('dragFrame'):SetAttribute('state-destroy', newstate)
]])

-- load many state attributes
frame:SetAttribute('lodas', [[
local state = self:GetAttribute('state-main') or 'default'
for i = 1, select('#', ...) do
local id = select(i, ...)
self:RunAttribute('loda', id, state)
end
]])

frame:SetAttribute('loda', [[
local id, state = ...
state = state or 'default'
local oldVal = self:GetAttribute('state-' .. id)
local newVal = self:RunAttribute('geta', id, state)
if oldVal ~= newVal then
self:SetAttribute('state-' .. id, newVal)
end
]])

frame:SetAttribute('geta', [[
local id, state = ...
state = state or 'default'
local v = self:GetAttribute(id .. '-' .. state)
if v == nil then
return self:GetAttribute(id .. '-default')
end
return v
]])

frame:SetAttribute('_onstate-enable', [[
self:ChildUpdate('state-enable', newstate)
self:GetFrameRef('dragFrame'):SetAttribute('state-enable', newstate)
Expand Down Expand Up @@ -105,6 +73,39 @@ local function frame_Create(id)
self:GetFrameRef('dragFrame'):CallMethod('UpdateColor')
]])


-- load many state attributes
frame:SetAttribute('lodas', [[
local state = self:GetAttribute('state-main') or 'default'
for i = 1, select('#', ...) do
local id = select(i, ...)
self:RunAttribute('loda', id, state)
end
]])

frame:SetAttribute('loda', [[
local id, state = ...
state = state or 'default'
local oldVal = self:GetAttribute('state-' .. id)
local newVal = self:RunAttribute('geta', id, state)
if oldVal ~= newVal then
self:SetAttribute('state-' .. id, newVal)
end
]])

frame:SetAttribute('geta', [[
local id, state = ...
state = state or 'default'
local v = self:GetAttribute(id .. '-' .. state)
if v == nil then
return self:GetAttribute(id .. '-default')
end
return v
]])

frame:SetAttribute('reposition', [[
self:ClearAllPoints()
Expand Down
31 changes: 14 additions & 17 deletions core/majorTom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ controller:SetAttribute('_onstate-lock', [[

--adds the given frame to control by majorTom
controller:SetAttribute('addFrame', [[
local frameId = ...
local f = self:GetFrameRef('frame-' .. frameId)
local f = self:GetFrameRef('addFrame')
if not myFrames then
myFrames = table.new()
end
myFrames[f:GetAttribute('id')] = f
f:SetParent(self)
f:SetAttribute('state-main', self:GetAttribute('state-main'))
Expand All @@ -49,26 +54,19 @@ controller:SetAttribute('addFrame', [[

controller:SetAttribute('delFrame', [[
local f = self:GetFrameRef('delFrame')
if myFrames then
myFrames[f:GetAttribute('id')] = nil
end
f:SetAttribute('state-destroy', true)
f:SetParent(nil)
f:Hide()
]])

controller:SetAttribute('getFrame', [[
local frameId = ...
if frameId then
local f = self:GetFrameRef('frame-' .. frameId)
if not f:GetAttribute('destroy') then
return f
end
end
]])

controller:SetAttribute('placeFrame', [[
local frameId, point, relFrameId, relPoint, xOff, yOff = ...
local frame = self:GetFrameRef('frame-' .. frameId)
local relFrame = self:GetFrameRef('frame-' .. relFrameId)
local frame = myFrames[tonumber(frameId) or frameId]
local relFrame = myFrames[tonumber(relFrameId) or relFrameId]
if frame and relFrame then
frame:SetPoint(point, relFrame, relPoint, xOff, yOff)
Expand All @@ -81,9 +79,8 @@ local TCFB = select(2, ...)
TCFB.MajorTom = {
--add frame to state control
addFrame = function(self, frame)
local frameId = frame:GetAttribute('id')
controller:SetFrameRef('frame-' .. frameId, frame)
controller:Execute(string.format([[ self:RunAttribute('addFrame', '%s') ]], frameId))
controller:SetFrameRef('addFrame', frame)
controller:Execute([[ self:RunAttribute('addFrame') ]])
end,

--remove frame from state control
Expand Down

0 comments on commit 6a8873e

Please sign in to comment.