Mercurial > wow > reaction
comparison classes/Bar.lua @ 242:b56cff349bd6
Move non-option stuff out of State.lua
Remove unused callbacks
author | Flick |
---|---|
date | Fri, 25 Mar 2011 17:06:56 -0700 |
parents | 09c8e9baa35a |
children |
comparison
equal
deleted
inserted
replaced
241:09c8e9baa35a | 242:b56cff349bd6 |
---|---|
6 local CreateFrame = CreateFrame | 6 local CreateFrame = CreateFrame |
7 local floor = math.floor | 7 local floor = math.floor |
8 local fmod = math.fmod | 8 local fmod = math.fmod |
9 local format = string.format | 9 local format = string.format |
10 local tfetch = addonTable.tfetch | 10 local tfetch = addonTable.tfetch |
11 local tbuild = addonTable.tbuild | |
11 local fieldsort = addonTable.fieldsort | 12 local fieldsort = addonTable.fieldsort |
12 | 13 |
13 local LSG = LibStub("ReAction-LibShowActionGrid-1.0") | 14 local LSG = LibStub("ReAction-LibShowActionGrid-1.0") |
14 | 15 |
15 ---- Secure snippets ---- | 16 ---- Secure snippets ---- |
226 end | 227 end |
227 | 228 |
228 ReAction.RegisterCallback(self, "OnConfigModeChanged") | 229 ReAction.RegisterCallback(self, "OnConfigModeChanged") |
229 | 230 |
230 buttonClass:SetupBar(self) | 231 buttonClass:SetupBar(self) |
232 self:ApplyStates() | |
231 | 233 |
232 return self | 234 return self |
233 end | 235 end |
234 | 236 |
235 function Bar:Destroy() | 237 function Bar:Destroy() |
236 local f = self:GetFrame() | 238 local f = self:GetFrame() |
239 self:CleanupStates() | |
237 for idx, b in self:IterateButtons() do | 240 for idx, b in self:IterateButtons() do |
238 b:Destroy() | 241 b:Destroy() |
239 end | 242 end |
240 f:UnregisterAllEvents() | 243 f:UnregisterAllEvents() |
241 self:ShowControls(false) | 244 self:ShowControls(false) |
320 c.anchor = frame or c.anchor | 323 c.anchor = frame or c.anchor |
321 c.relpoint = relativePoint or c.relpoint | 324 c.relpoint = relativePoint or c.relpoint |
322 c.x = x or c.x | 325 c.x = x or c.x |
323 c.y = y or c.y | 326 c.y = y or c.y |
324 self:ApplyAnchor() | 327 self:ApplyAnchor() |
325 ReAction:RefreshBar(self) | |
326 end | 328 end |
327 | 329 |
328 function Bar:GetSize() | 330 function Bar:GetSize() |
329 local f = self:GetFrame() | 331 local f = self:GetFrame() |
330 return f:GetWidth(), f:GetHeight() | 332 return f:GetWidth(), f:GetHeight() |
348 function Bar:SetButtonSize(w,h) | 350 function Bar:SetButtonSize(w,h) |
349 if w > 0 and h > 0 then | 351 if w > 0 and h > 0 then |
350 self.config.btnWidth = w | 352 self.config.btnWidth = w |
351 self.config.btnHeight = h | 353 self.config.btnHeight = h |
352 end | 354 end |
353 ReAction:RefreshBar(self) | |
354 end | 355 end |
355 | 356 |
356 function Bar:GetNumButtons() | 357 function Bar:GetNumButtons() |
357 local r,c = self:GetButtonGrid() | 358 local r,c = self:GetButtonGrid() |
358 return r*c | 359 return r*c |
372 cfg.btnRows = r | 373 cfg.btnRows = r |
373 cfg.btnColumns = c | 374 cfg.btnColumns = c |
374 cfg.spacing = s | 375 cfg.spacing = s |
375 end | 376 end |
376 self.buttonClass:SetupBar(self) | 377 self.buttonClass:SetupBar(self) |
377 ReAction:RefreshBar(self) | |
378 end | 378 end |
379 | 379 |
380 function Bar:GetAlpha() | 380 function Bar:GetAlpha() |
381 return self.config.alpha or 1.0 | 381 return self.config.alpha or 1.0 |
382 end | 382 end |
383 | 383 |
384 function Bar:SetAlpha(value) | 384 function Bar:SetAlpha(value) |
385 self.config.alpha = value | 385 self.config.alpha = value |
386 self:GetFrame():SetAlpha(value or 1.0) | 386 self:GetFrame():SetAlpha(value or 1.0) |
387 self:UpdateDefaultStateAlpha() | 387 self:UpdateDefaultStateAlpha() |
388 ReAction:RefreshBar(self) | |
389 end | 388 end |
390 | 389 |
391 function Bar:IterateButtons() | 390 function Bar:IterateButtons() |
392 -- iterator returns idx, button, but does NOT iterate in index order | 391 -- iterator returns idx, button, but does NOT iterate in index order |
393 return pairs(self.buttons) | 392 return pairs(self.buttons) |
533 local env = GetManagedEnvironment(self:GetFrame()) | 532 local env = GetManagedEnvironment(self:GetFrame()) |
534 return env and env.state | 533 return env and env.state |
535 end | 534 end |
536 | 535 |
537 function Bar:GetStateProperty(state, propname) | 536 function Bar:GetStateProperty(state, propname) |
538 -- override in modules/State.lua for now | 537 return tfetch(self:GetConfig(), "states", state, propname) |
539 end | 538 end |
540 | 539 |
541 function Bar:SetStateProperty(state, propname, value) | 540 function Bar:SetStateProperty(state, propname, value) |
542 -- override in modules/State.lua for now | 541 local s = tbuild(self:GetConfig(), "states", state) |
542 s[propname] = value | |
543 self:SetSecureStateData(state, propname, value) | |
544 end | |
545 | |
546 function Bar:ApplyStates() | |
547 local states = tfetch(self:GetConfig(), "states") | |
548 if states then | |
549 self:SetStateDriver(states) | |
550 end | |
551 end | |
552 | |
553 function Bar:CleanupStates() | |
554 self:SetStateDriver(nil) | |
543 end | 555 end |
544 | 556 |
545 function Bar:RefreshSecureState() | 557 function Bar:RefreshSecureState() |
546 self:GetFrame():Execute(_reaction_refresh) | 558 self:GetFrame():Execute(_reaction_refresh) |
547 end | 559 end |