Mercurial > wow > reaction
comparison classes/Bar.lua @ 213:8ba8ab8bf6dd
Demodularize LBF
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Thu, 18 Nov 2010 20:07:48 -0800 |
| parents | c24ac8ee1e45 |
| children | 0e20f65375d5 |
comparison
equal
deleted
inserted
replaced
| 212:e275a8663a16 | 213:8ba8ab8bf6dd |
|---|---|
| 244 | 244 |
| 245 self:ApplyAnchor() | 245 self:ApplyAnchor() |
| 246 self:SetConfigMode(ReAction:GetConfigMode()) | 246 self:SetConfigMode(ReAction:GetConfigMode()) |
| 247 self:SetKeybindMode(ReAction:GetKeybindMode()) | 247 self:SetKeybindMode(ReAction:GetKeybindMode()) |
| 248 | 248 |
| 249 if ReAction.LBF then | |
| 250 local g = ReAction.LBF:Group(L["ReAction"], self.name) | |
| 251 self.config.ButtonFacade = self.config.ButtonFacade or { | |
| 252 skinID = "Blizzard", | |
| 253 backdrop = true, | |
| 254 gloss = 0, | |
| 255 colors = {}, | |
| 256 } | |
| 257 local c = self.config.ButtonFacade | |
| 258 g:Skin(c.skinID, c.gloss, c.backdrop, c.colors) | |
| 259 self.LBFGroup = g | |
| 260 end | |
| 261 | |
| 249 ReAction.RegisterCallback(self, "OnConfigModeChanged") | 262 ReAction.RegisterCallback(self, "OnConfigModeChanged") |
| 250 | 263 |
| 251 return self | 264 return self |
| 252 end | 265 end |
| 253 | 266 |
| 255 local f = self:GetFrame() | 268 local f = self:GetFrame() |
| 256 f:UnregisterAllEvents() | 269 f:UnregisterAllEvents() |
| 257 self:ShowControls(false) | 270 self:ShowControls(false) |
| 258 ReAction.UnregisterAllCallbacks(self) | 271 ReAction.UnregisterAllCallbacks(self) |
| 259 LKB.UnregisterAllCallbacks(self) | 272 LKB.UnregisterAllCallbacks(self) |
| 273 if self.LBFGroup then | |
| 274 self.LBFGroup:Delete(true) | |
| 275 end | |
| 260 LSG:RemoveFrame(f) | 276 LSG:RemoveFrame(f) |
| 261 f:SetParent(UIParent) | 277 f:SetParent(UIParent) |
| 262 f:ClearAllPoints() | 278 f:ClearAllPoints() |
| 263 f:Hide() | 279 f:Hide() |
| 264 end | 280 end |
| 280 end | 296 end |
| 281 | 297 |
| 282 -- only ReAction:RenameBar() should call this function. Calling from any other | 298 -- only ReAction:RenameBar() should call this function. Calling from any other |
| 283 -- context will desync the bar list in the ReAction class. | 299 -- context will desync the bar list in the ReAction class. |
| 284 function Bar:SetName(name) | 300 function Bar:SetName(name) |
| 301 if self.LBFGroup then | |
| 302 -- LBF doesn't offer a method of renaming a group, so delete and remake the group. | |
| 303 local c = self.config.ButtonFacade | |
| 304 local g = ReAction.LBF:Group(L["ReAction"], name) | |
| 305 for b in self:IterateButtons() do | |
| 306 self.LBFGroup:RemoveButton(b:GetFrame(), true) | |
| 307 g:AddButton(b:GetFrame()) | |
| 308 end | |
| 309 self.LBFGroup:Delete(true) | |
| 310 self.LBFGroup = g | |
| 311 self.LBFGroup:Skin(c.skinID, c.gloss, c.backdrop, c.colors) | |
| 312 end | |
| 285 self.name = name | 313 self.name = name |
| 286 if self.overlay then | 314 if self.overlay then |
| 287 self.overlay:SetLabel(self.name) | 315 self.overlay:SetLabel(self.name) |
| 288 end | 316 end |
| 289 end | 317 end |
| 449 self.buttons[button] = idx | 477 self.buttons[button] = idx |
| 450 | 478 |
| 451 -- Store a properly wrapped reference to the child frame as an attribute | 479 -- Store a properly wrapped reference to the child frame as an attribute |
| 452 -- (accessible via "frameref-btn#") | 480 -- (accessible via "frameref-btn#") |
| 453 f:SetFrameRef(format("btn%d",idx), button:GetFrame()) | 481 f:SetFrameRef(format("btn%d",idx), button:GetFrame()) |
| 482 | |
| 483 -- button constructors are responsible for calling SkinButton | |
| 454 end | 484 end |
| 455 | 485 |
| 456 function Bar:RemoveButton(button) | 486 function Bar:RemoveButton(button) |
| 457 local idx = self.buttons[button] | 487 local idx = self.buttons[button] |
| 458 if idx then | 488 if idx then |
| 459 self:GetFrame():SetAttribute(format("frameref-btn%d",idx),nil) | 489 self:GetFrame():SetAttribute(format("frameref-btn%d",idx),nil) |
| 460 self.buttons[button] = nil | 490 self.buttons[button] = nil |
| 491 end | |
| 492 if self.LBFGroup then | |
| 493 self.LBFGroup:RemoveButton(button:GetFrame(),true) | |
| 461 end | 494 end |
| 462 end | 495 end |
| 463 | 496 |
| 464 function Bar:PlaceButton(button, baseW, baseH) | 497 function Bar:PlaceButton(button, baseW, baseH) |
| 465 local idx = self.buttons[button] | 498 local idx = self.buttons[button] |
| 475 b:SetPoint("TOPLEFT",x/scale,y/scale) | 508 b:SetPoint("TOPLEFT",x/scale,y/scale) |
| 476 b:SetScale(scale) | 509 b:SetScale(scale) |
| 477 end | 510 end |
| 478 end | 511 end |
| 479 | 512 |
| 480 function Bar:SkinButton() | 513 function Bar:SkinButton( button, data ) |
| 481 -- does nothing by default | 514 if self.LBFGroup then |
| 515 self.LBFGroup:AddButton(button:GetFrame(), data) | |
| 516 end | |
| 482 end | 517 end |
| 483 | 518 |
| 484 function Bar:UpdateShowGrid() | 519 function Bar:UpdateShowGrid() |
| 485 for button in self:IterateButtons() do | 520 for button in self:IterateButtons() do |
| 486 button:UpdateShowGrid() | 521 button:UpdateShowGrid() |
