Mercurial > wow > reaction
comparison classes/Button.lua @ 128:729232aeeb5e
Action Button rewrite. (note: pet actions are probably slightly broken right now, they haven't been updated yet)
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Thu, 05 Mar 2009 01:28:48 +0000 |
parents | 6a4b4d3c5fad |
children | 28b430de5875 |
comparison
equal
deleted
inserted
replaced
127:29dacbecdb52 | 128:729232aeeb5e |
---|---|
28 -- Button class | 28 -- Button class |
29 local Button = { } | 29 local Button = { } |
30 | 30 |
31 ReAction.Button = Button -- export to ReAction | 31 ReAction.Button = Button -- export to ReAction |
32 | 32 |
33 function Button:New( name, config, bar, idx, inherits, buttonType ) | 33 function Button:New( name, barConfig, bar, idx, inherits, buttonType ) |
34 buttonType = buttonType or "CheckButton" | 34 buttonType = buttonType or "CheckButton" |
35 | 35 |
36 -- create new self | 36 -- create new self |
37 self = setmetatable( | 37 self = setmetatable( |
38 { | 38 { |
39 bar = bar, | 39 bar = bar, |
40 idx = idx, | 40 idx = idx, |
41 config = config, | 41 barConfig = barConfig, |
42 config = barConfig.buttons[idx], | |
42 name = name, | 43 name = name, |
43 }, | 44 }, |
44 { __index = self } ) | 45 { __index = self } ) |
45 | 46 |
46 -- have to recycle frames with the same name: CreateFrame() doesn't overwrite | 47 -- have to recycle frames with the same name: CreateFrame() doesn't overwrite |
82 f:SetParent(trash) | 83 f:SetParent(trash) |
83 f:ClearAllPoints() | 84 f:ClearAllPoints() |
84 end | 85 end |
85 end | 86 end |
86 | 87 |
88 function Button:GetBar() | |
89 return self.bar | |
90 end | |
91 | |
87 function Button:GetFrame() | 92 function Button:GetFrame() |
88 return self.frame | 93 return self.frame |
89 end | 94 end |
90 | 95 |
91 function Button:GetName() | 96 function Button:GetName() |
92 return self.name | 97 return self.name |
93 end | 98 end |
94 | 99 |
95 function Button:GetConfig() | 100 function Button:GetConfig() |
96 return self.config | 101 return self.config |
102 end | |
103 | |
104 function Button:GetBarConfig() | |
105 -- this is the per-bar Button config structure, | |
106 -- not the config structure of the bar itself | |
107 return self.barConfig | |
97 end | 108 end |
98 | 109 |
99 function Button:GetActionID() | 110 function Button:GetActionID() |
100 -- derived classes should override this | 111 -- derived classes should override this |
101 return nil | 112 return nil |
178 f:SetScript("OnEnter", kb_onEnter) | 189 f:SetScript("OnEnter", kb_onEnter) |
179 elseif self.oldOnEnter then | 190 elseif self.oldOnEnter then |
180 f:SetScript("OnEnter", self.oldOnEnter) | 191 f:SetScript("OnEnter", self.oldOnEnter) |
181 self.oldOnEnter = nil | 192 self.oldOnEnter = nil |
182 end | 193 end |
194 self:ShowGridTemp(mode) | |
183 self:UpdateKeybindModeDisplay( mode ) | 195 self:UpdateKeybindModeDisplay( mode ) |
184 end | 196 end |
185 | 197 |
186 function Button:UpdateKeybindModeDisplay( mode ) | 198 function Button:UpdateKeybindModeDisplay( mode ) |
187 self.border = self.border or _G[format("%sBorder",tostring(self:GetName()))] | 199 self.border = self.border or _G[format("%sBorder",tostring(self:GetName()))] |
254 else | 266 else |
255 return self.frame:GetNormalTexture():GetVertexColor() | 267 return self.frame:GetNormalTexture():GetVertexColor() |
256 end | 268 end |
257 end | 269 end |
258 | 270 |
259 function Button:ShowGrid( show ) | |
260 if not InCombatLockdown() then | |
261 local f = self.frame | |
262 local count = f:GetAttribute("showgrid") | |
263 if show then | |
264 count = count + 1 | |
265 else | |
266 count = count - 1 | |
267 end | |
268 if count < 0 then | |
269 count = 0 | |
270 end | |
271 f:SetAttribute("showgrid",count) | |
272 self:UpdateShowGrid() | |
273 end | |
274 end | |
275 | |
276 function Button:UpdateShowGrid() | 271 function Button:UpdateShowGrid() |
277 -- does nothing by default | 272 -- does nothing by default |
278 end | 273 end |
274 | |
275 function Button:ShowGridTemp(show) | |
276 -- does nothing by default | |
277 end | |
278 | |
279 function Button:ShowGrid(show) | |
280 -- does nothing by default | |
281 end |