comparison classes/Bar.lua @ 154:df67685b340e

Fixed some bar/overlay encapsulation
author Flick <flickerstreak@gmail.com>
date Fri, 08 May 2009 17:30:22 +0000
parents d5e11e924053
children 806a61b331a0
comparison
equal deleted inserted replaced
153:d5e11e924053 154:df67685b340e
120 120
121 -- only ReAction:RenameBar() should call this function. Calling from any other 121 -- only ReAction:RenameBar() should call this function. Calling from any other
122 -- context will desync the bar list in the ReAction class. 122 -- context will desync the bar list in the ReAction class.
123 function Bar:SetName(name) 123 function Bar:SetName(name)
124 self.name = name 124 self.name = name
125 self:SetLabel(self.name) -- Bar:SetLabel() defined in Overlay.lua 125 if self.overlay then
126 self.overlay:SetLabel(self.name)
127 end
126 end 128 end
127 129
128 function Bar:GetFrame() 130 function Bar:GetFrame()
129 -- this method is included for documentation purposes. It is overridden 131 -- this method is included for documentation purposes. It is overridden
130 -- for each object in the :New() method. 132 -- for each object in the :New() method.
327 329
328 function Bar:SkinButton() 330 function Bar:SkinButton()
329 -- does nothing by default 331 -- does nothing by default
330 end 332 end
331 333
334 function Bar:ShowControls(show)
335 local f = self.overlay
336 if show then
337 if not f then
338 f = Bar.Overlay:New(self) -- see Overlay.lua
339 self.overlay = f
340 end
341 f:Show()
342 elseif f then
343 f:Hide()
344 end
345 end
346
347 function Bar:RefreshControls()
348 if self.overlay and self.overlay:IsShown() then
349 self.overlay:RefreshControls()
350 end
351 end
352
353 function Bar:SetLabelSubtext(text)
354 if self.overlay then
355 self.overlay:SetLabelSubtext(text)
356 end
357 end
358
359 --
360 -- Secure state functions
361 --
362
332 -- pass unit=nil to set up the unit elsewhere, if you want something more complex 363 -- pass unit=nil to set up the unit elsewhere, if you want something more complex
333 function Bar:RegisterUnitWatch( unit, enable ) 364 function Bar:RegisterUnitWatch( unit, enable )
334 local f = self:GetFrame() 365 local f = self:GetFrame()
335 if unit then 366 if unit then
336 f:SetAttribute("unit",unit) 367 f:SetAttribute("unit",unit)