View Single Post
05-27-11, 03:17 PM   #4
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
k, it is working now... I moved the grabbing of the buttons one layer higher:

lua Code:
  1. local lib = {}
  2.     lib.buttonFuncProxy = {}
  3.  
  4.     --[[ VOID noop()
  5.         This prevents the default UI from altering our stuff!
  6.     ]]
  7.     lib.noop = function() end
  8.  
  9.     --[[ VOID MoveButton(BUTTON button, INT sizeX, INT sizeY, ARRAY pos)
  10.         Moves a button (which is in use, meaning visible) to the correct position.
  11.         ARRAY pos is defined as an array which holds the position information as it is used in SetPoint()
  12.     ]]
  13.     lib.MoveButton = function(button, sizeX, sizeY, pos)
  14.  
  15.         button:ClearAllPoints()
  16.         -- button:SetSize(sizeX, sizeY)
  17.         lib.buttonFuncProxy[button:GetName()..'SetSize'](button, sizeX, sizeY)
  18.         -- button:SetPoint(unpack(pos))
  19.         lib.buttonFuncProxy[button:GetName()..'SetPoint'](button, unpack(pos))
  20.  
  21.     end
  22.  
  23.     --[[ VOID HandleButtonBar
  24.         FRAME parent
  25.         STRING key - the string to access settings in arrays
  26.         OTHER INPUT IS DOCUMENTED at lib.HandleButton !!!
  27.     ]]
  28.     lib.HandleButtonBar = function(parent, key, sizeX, sizeY)
  29.         -- lib.debugging('HandleButtonBar() '..key..', '..settings.static.NumButtons[key]..', '..PredatorButtonsSettings[key].buttons)
  30.         local i, button, bname
  31.         for i = 1, settings.static.NumButtons[key] do
  32.             button = _G[settings.static.ButtonPrefix[key]..i]
  33.             bname = button:GetName()
  34.             if ( not lib.buttonFuncProxy[bname..'SetSize'] ) then
  35.                 lib.buttonFuncProxy[bname..'SetSize'] = button.SetSize
  36.                 button.SetSize = lib.noop                                       -- don't do this anymore!
  37.             end
  38.             if ( not lib.buttonFuncProxy[bname..'SetPoint'] ) then
  39.                 lib.buttonFuncProxy[bname..'SetPoint'] = button.SetPoint
  40.                 button.SetPoint = lib.noop                                      -- don't do this anymore!
  41.             end
  42.             if ( i <= PredatorButtonsSettings[key].buttons ) then               -- magic happening here!
  43.                 if ( i == 1 ) then
  44.                     lib.MoveButton(button,
  45.                         sizeX, sizeY,
  46.                         {'TOPLEFT', parent, 'TOPLEFT',
  47.                             PredatorButtonsSettings[key].padding,
  48.                             -PredatorButtonsSettings[key].padding
  49.                         } )
  50.                 else
  51.                     lib.MoveButton(button,
  52.                         sizeX, sizeY,
  53.                         {'TOPLEFT', parent, 'TOPLEFT',
  54.                             ( ((i-1)%PredatorButtonsSettings[key].columns)*(PredatorButtonsSettings[key].buttonSize+2*PredatorButtonsSettings[key].padding)+PredatorButtonsSettings[key].padding ),
  55.                             -( (floor((i-1) / PredatorButtonsSettings[key].columns))*(PredatorButtonsSettings[key].buttonSize+(2*PredatorButtonsSettings[key].padding))+PredatorButtonsSettings[key].padding )
  56.                         } )
  57.                 end
  58.             else
  59.                 button:ClearAllPoints()
  60.                 -- button:SetPoint('BOTTOMRIGHT', UIParent, 'TOPLEFT', -5, 5)       -- out of sight, out of mind!
  61.                 lib.buttonFuncProxy[bname..'SetPoint'](button, 'BOTTOMRIGHT', UIParent, 'TOPLEFT', -5, 5)
  62.             end
  63.         end
  64.     end

Thx for your reply Saiket, your confirmation was necessary and I think you solved it by pointing out, that maybe I'm filling the array twice!
__________________
  Reply With Quote