Mercurial > wow > reaction
comparison ReBar.lua @ 2:8e0ff8ae4c08
Version 0.2
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Tue, 20 Mar 2007 21:08:31 +0000 |
parents | c11ca1d8ed91 |
children |
comparison
equal
deleted
inserted
replaced
1:c11ca1d8ed91 | 2:8e0ff8ae4c08 |
---|---|
1 | 1 |
2 -- private constants | 2 -- private constants |
3 local insideFrame = 1 | 3 local insideFrame = 1 |
4 local outsideFrame = 2 | 4 local outsideFrame = 2 |
5 local _G = getfenv(0) -- global variable table | |
6 | 5 |
7 local pointFindTable = { | 6 local pointFindTable = { |
8 BOTTOMLEFT = function(f) return f:GetLeft(), f:GetBottom() end, | 7 BOTTOMLEFT = function(f) return f:GetLeft(), f:GetBottom() end, |
9 BOTTOM = function(f) return nil, f:GetBottom() end, | 8 BOTTOM = function(f) return nil, f:GetBottom() end, |
10 BOTTOMRIGHT = function(f) return f:GetRight(), f:GetBottom() end, | 9 BOTTOMRIGHT = function(f) return f:GetRight(), f:GetBottom() end, |
24 TOP = "BOTTOM", | 23 TOP = "BOTTOM", |
25 TOPLEFT = "BOTTOMRIGHT", | 24 TOPLEFT = "BOTTOMRIGHT", |
26 LEFT = "RIGHT" | 25 LEFT = "RIGHT" |
27 } | 26 } |
28 | 27 |
28 local anchoredLabelColor = { r =0.6, g = 0.2, b = 1.0 } | |
29 local nonAnchoredLabelColor = { r = 1.0, g = 0.82, b = 0.0 } | |
30 | |
29 -- private variables | 31 -- private variables |
30 local stickyTargets = { | 32 local stickyTargets = { |
31 [UIParent] = insideFrame, | 33 [UIParent] = insideFrame, |
32 [WorldFrame] = insideFrame | 34 [WorldFrame] = insideFrame |
33 } | 35 } |
38 local dewdrop = AceLibrary("Dewdrop-2.0") | 40 local dewdrop = AceLibrary("Dewdrop-2.0") |
39 | 41 |
40 function ReBar.prototype:init( config, id ) | 42 function ReBar.prototype:init( config, id ) |
41 ReBar.super.prototype.init(self) | 43 ReBar.super.prototype.init(self) |
42 | 44 |
43 local buttonClass = config and config.btnConfig and config.btnConfig.type and _G[config.btnConfig.type] | 45 local buttonClass = config and config.btnConfig and config.btnConfig.type and getglobal(config.btnConfig.type) |
44 self.config = config | 46 self.config = config |
45 self.barID = id | 47 self.barID = id |
46 self.class = { button = buttonClass } | 48 self.class = { button = buttonClass } |
47 self.buttons = { } | 49 self.buttons = { } |
48 | 50 |
49 -- create the bar and control widgets | 51 -- create the bar and control widgets |
50 self.barFrame = CreateFrame("Frame", "ReBar_"..self.barID, UIParent, "ReBarTemplate") | 52 self.barFrame = CreateFrame("Frame", "ReBar_"..self.barID, UIParent, "ReBarTemplate") |
51 self.controlFrame = _G[self.barFrame:GetName().."Controls"] | 53 self.controlFrame = getglobal(self.barFrame:GetName().."Controls") |
52 self.controlFrame.reBar = self | 54 self.controlFrame.reBar = self |
55 self.barFrame:SetClampedToScreen(true) | |
53 | 56 |
54 -- set the text label on the control widget | 57 -- set the text label on the control widget |
55 _G[self.controlFrame:GetName().."LabelString"]:SetText(id) | 58 self.labelString = getglobal(self.controlFrame:GetName().."LabelString") |
59 self.labelString:SetText(id) | |
56 | 60 |
57 -- initialize the bar layout | 61 -- initialize the bar layout |
58 self:ApplySize() | 62 self:ApplySize() |
59 self:ApplyAnchor() | 63 self:ApplyAnchor() |
60 self:LayoutButtons() | 64 self:LayoutButtons() |
66 -- initialize dewdrop menu | 70 -- initialize dewdrop menu |
67 dewdrop:Register(self.controlFrame, 'children', function() | 71 dewdrop:Register(self.controlFrame, 'children', function() |
68 dewdrop:FeedAceOptionsTable(ReActionGlobalMenuOptions) | 72 dewdrop:FeedAceOptionsTable(ReActionGlobalMenuOptions) |
69 dewdrop:FeedAceOptionsTable(GenerateReActionBarOptions(self)) | 73 dewdrop:FeedAceOptionsTable(GenerateReActionBarOptions(self)) |
70 dewdrop:FeedAceOptionsTable(GenerateReActionButtonOptions(self)) | 74 dewdrop:FeedAceOptionsTable(GenerateReActionButtonOptions(self)) |
71 dewdrop:FeedAceOptionsTable(ReActionProfileMenuOptions) | |
72 end, | 75 end, |
73 'cursorX', true, | 76 'cursorX', true, |
74 'cursorY', true | 77 'cursorY', true |
75 ) | 78 ) |
76 end | 79 end |
80 if self.barFrame == dewdrop:GetOpenedParent() then | 83 if self.barFrame == dewdrop:GetOpenedParent() then |
81 dewdrop:Close() | 84 dewdrop:Close() |
82 dewdrop:Unregister(self.barFrame) | 85 dewdrop:Unregister(self.barFrame) |
83 end | 86 end |
84 | 87 |
88 self:HideControls() | |
85 self.barFrame:Hide() | 89 self.barFrame:Hide() |
86 self.barFrame:ClearAllPoints() | 90 self.barFrame:ClearAllPoints() |
87 self.barFrame:SetParent(nil) | 91 self.barFrame:SetParent(nil) |
92 self.barFrame:SetPoint("BOTTOMRIGHT", UIParent, "TOPLEFT", 0, 0) | |
88 | 93 |
89 -- need to keep around self.config for dewdrop menus in the process of deleting self | 94 -- need to keep around self.config for dewdrop menus in the process of deleting self |
90 | 95 |
91 while #self.buttons > 0 do | 96 while #self.buttons > 0 do |
92 self.class.button:release(table.remove(self.buttons)) | 97 self.class.button:release(table.remove(self.buttons)) |
105 | 110 |
106 | 111 |
107 -- show/hide the control frame | 112 -- show/hide the control frame |
108 function ReBar.prototype:ShowControls() | 113 function ReBar.prototype:ShowControls() |
109 self.controlFrame:Show() | 114 self.controlFrame:Show() |
115 for _, b in ipairs(self.buttons) do | |
116 b:BarUnlocked() | |
117 end | |
110 end | 118 end |
111 | 119 |
112 function ReBar.prototype:HideControls() | 120 function ReBar.prototype:HideControls() |
113 local b = self.barFrame | 121 local b = self.barFrame |
114 if b.isMoving or b.resizing then | 122 if b.isMoving or b.resizing then |
116 b:SetScript("OnUpdate",nil) | 124 b:SetScript("OnUpdate",nil) |
117 end | 125 end |
118 -- close any dewdrop menu owned by us | 126 -- close any dewdrop menu owned by us |
119 if self.barFrame == dewdrop:GetOpenedParent() then | 127 if self.barFrame == dewdrop:GetOpenedParent() then |
120 dewdrop:Close() | 128 dewdrop:Close() |
129 end | |
130 for _, b in ipairs(self.buttons) do | |
131 b:BarLocked() | |
121 end | 132 end |
122 self.controlFrame:Hide() | 133 self.controlFrame:Hide() |
123 end | 134 end |
124 | 135 |
125 | 136 |
163 end | 174 end |
164 | 175 |
165 function ReBar.prototype:ApplyAnchor() | 176 function ReBar.prototype:ApplyAnchor() |
166 local a = self.config.anchor | 177 local a = self.config.anchor |
167 local f = self.barFrame | 178 local f = self.barFrame |
168 f:ClearAllPoints() | 179 if a then |
169 f:SetPoint(a.point,getglobal(a.to),a.relPoint,a.x,a.y) | 180 f:ClearAllPoints() |
181 f:SetPoint(a.point,getglobal(a.to),a.relPoint,a.x,a.y) | |
182 local color = anchoredLabelColor | |
183 if a.to == "UIParent" or a.to == "WorldFrame" then | |
184 color = nonAnchoredLabelColor | |
185 end | |
186 self.labelString:SetTextColor(color.r, color.g, color.b) | |
187 end | |
170 end | 188 end |
171 | 189 |
172 function ReBar.prototype:ApplyVisibility() | 190 function ReBar.prototype:ApplyVisibility() |
173 local v = self.config.visibility | 191 local v = self.config.visibility |
174 if type(v) == "table" then | 192 if type(v) == "table" then |