Mercurial > wow > reaction
comparison Bar.lua @ 51:c964fb84560c
added anchor controls
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Tue, 22 Apr 2008 21:33:37 +0000 |
| parents | c3c64e2def50 |
| children | c9df7866ff31 |
comparison
equal
deleted
inserted
replaced
| 50:c3c64e2def50 | 51:c964fb84560c |
|---|---|
| 58 function Bar:ApplyAnchor() | 58 function Bar:ApplyAnchor() |
| 59 local f, config = self.frame, self.config | 59 local f, config = self.frame, self.config |
| 60 f:SetWidth(config.width) | 60 f:SetWidth(config.width) |
| 61 f:SetHeight(config.height) | 61 f:SetHeight(config.height) |
| 62 local anchor = config.anchor | 62 local anchor = config.anchor |
| 63 f:ClearAllPoints() | |
| 63 if anchor then | 64 if anchor then |
| 64 local anchorTo | 65 local anchorTo |
| 65 if config.anchorTo then | 66 if config.anchorTo then |
| 66 anchorTo = ReAction:GetBar(config.anchorTo) or _G[config.anchorTo] | 67 anchorTo = ReAction:GetBar(config.anchorTo) or _G[config.anchorTo] |
| 67 end | 68 end |
| 68 f:SetPoint(anchor, anchorTo, config.relativePoint, config.x or 0, config.y or 0) | 69 f:SetPoint(anchor, anchorTo, config.relativePoint, config.x or 0, config.y or 0) |
| 69 else | 70 else |
| 70 f:SetPoint("CENTER") | 71 f:SetPoint("CENTER") |
| 71 end | 72 end |
| 73 end | |
| 74 | |
| 75 function Bar:SetAnchor(point, frame, relativePoint, x, y) | |
| 76 local c = self.config | |
| 77 c.anchor = point or c.anchor | |
| 78 c.anchorTo = frame and frame:GetName() or c.anchorTo | |
| 79 c.relativePoint = relativePoint or c.relativePoint | |
| 80 c.x = x or c.x | |
| 81 c.y = y or c.y | |
| 82 self:ApplyAnchor() | |
| 83 end | |
| 84 | |
| 85 function Bar:GetAnchor() | |
| 86 local c = self.config | |
| 87 return (c.anchor or "CENTER"), (c.anchorTo or self.frame:GetParent():GetName()), (c.relativePoint or c.anchor or "CENTER"), (c.x or 0), (c.y or 0) | |
| 72 end | 88 end |
| 73 | 89 |
| 74 function Bar:GetFrame() | 90 function Bar:GetFrame() |
| 75 return self.frame | 91 return self.frame |
| 76 end | 92 end |
| 232 -- The control elements need to float on top of this, which we could | 248 -- The control elements need to float on top of this, which we could |
| 233 -- do with SetFrameLevel() or Raise(), but it's more reliable to do it | 249 -- do with SetFrameLevel() or Raise(), but it's more reliable to do it |
| 234 -- via frame nesting, hence good old foo's appearance here. | 250 -- via frame nesting, hence good old foo's appearance here. |
| 235 local foo = CreateFrame("Frame",nil,f) | 251 local foo = CreateFrame("Frame",nil,f) |
| 236 foo:SetAllPoints() | 252 foo:SetAllPoints() |
| 253 foo:SetClampedToScreen(true) | |
| 237 | 254 |
| 238 local control = CreateFrame("Button", nil, foo) | 255 local control = CreateFrame("Button", nil, foo) |
| 239 control:EnableMouse(true) | 256 control:EnableMouse(true) |
| 240 control:SetToplevel(true) | 257 control:SetToplevel(true) |
| 241 control:SetPoint("TOPLEFT", -4, 4) | 258 control:SetPoint("TOPLEFT", -4, 4) |
