flickerstreak@25
|
1 --[[
|
flickerstreak@25
|
2 ReAction Configuration UI module
|
flickerstreak@25
|
3
|
flickerstreak@25
|
4 This modules creates and manages ReAction configuration
|
flickerstreak@25
|
5 elements, including:
|
flickerstreak@25
|
6
|
flickerstreak@30
|
7 - Interface Options panel
|
flickerstreak@25
|
8 - bar dragging and resizing control overlays
|
flickerstreak@25
|
9 - contextual menus
|
flickerstreak@25
|
10
|
flickerstreak@25
|
11 Individual modules are responsible for populating these
|
flickerstreak@30
|
12 configuration elements via ReAction:RegisterOptions(). The
|
flickerstreak@30
|
13 valid values of 'context' are:
|
flickerstreak@30
|
14
|
flickerstreak@30
|
15 - 'global' : added to the Global Settings tab
|
flickerstreak@30
|
16 - 'module' : added to the Module Settings tab
|
flickerstreak@30
|
17 - 'bar' : added to the Bar Settings tab
|
flickerstreak@30
|
18 - 'barMenu' : shown on the bar contextual menu
|
flickerstreak@25
|
19
|
flickerstreak@25
|
20 --]]
|
flickerstreak@25
|
21
|
flickerstreak@25
|
22 -- local imports
|
flickerstreak@25
|
23 local ReAction = ReAction
|
flickerstreak@25
|
24 local L = ReAction.L
|
flickerstreak@25
|
25 local _G = _G
|
flickerstreak@30
|
26 local InCombatLockdown = InCombatLockdown
|
flickerstreak@30
|
27
|
flickerstreak@25
|
28 local Dewdrop = AceLibrary("Dewdrop-2.0")
|
flickerstreak@25
|
29
|
flickerstreak@25
|
30 -- module declaration
|
flickerstreak@25
|
31 local moduleID = "ConfigUI"
|
flickerstreak@25
|
32 local module = ReAction:NewModule( moduleID,
|
flickerstreak@28
|
33 "AceEvent-3.0"
|
flickerstreak@25
|
34 )
|
flickerstreak@25
|
35
|
flickerstreak@25
|
36 module.configOptions = {
|
flickerstreak@25
|
37 type = "group",
|
flickerstreak@30
|
38 childGroups = "tab",
|
flickerstreak@25
|
39 args = {
|
flickerstreak@30
|
40 desc = {
|
flickerstreak@30
|
41 type = "description",
|
flickerstreak@30
|
42 name = L["Customizable replacement for Blizzard's Action Bars"],
|
flickerstreak@30
|
43 },
|
flickerstreak@25
|
44 global = {
|
flickerstreak@25
|
45 type = "group",
|
flickerstreak@25
|
46 name = L["Global Settings"],
|
flickerstreak@25
|
47 desc = L["Global configuration settings"],
|
flickerstreak@30
|
48 args = {
|
flickerstreak@30
|
49 unlock = {
|
flickerstreak@30
|
50 type = "toggle",
|
flickerstreak@30
|
51 handler = module,
|
flickerstreak@30
|
52 name = L["Unlock Bars"],
|
flickerstreak@30
|
53 desc = L["Unlock bars for dragging and resizing with the mouse"],
|
flickerstreak@30
|
54 get = function() return module.configMode end,
|
flickerstreak@30
|
55 set = function(info, value) module:SetConfigMode(value) end,
|
flickerstreak@30
|
56 disabled = InCombatLockdown,
|
flickerstreak@30
|
57 order = 1
|
flickerstreak@30
|
58 },
|
flickerstreak@30
|
59 },
|
flickerstreak@25
|
60 order = 1,
|
flickerstreak@25
|
61 },
|
flickerstreak@25
|
62 module = {
|
flickerstreak@25
|
63 type = "group",
|
flickerstreak@30
|
64 childGroups = "select",
|
flickerstreak@25
|
65 name = L["Module Settings"],
|
flickerstreak@25
|
66 desc = L["Configuration settings for each module"],
|
flickerstreak@30
|
67 args = {
|
flickerstreak@30
|
68 configUI = {
|
flickerstreak@30
|
69 type = "group",
|
flickerstreak@30
|
70 name = "Config UI",
|
flickerstreak@30
|
71 desc = "description",
|
flickerstreak@30
|
72 args = {
|
flickerstreak@30
|
73 foo = {
|
flickerstreak@30
|
74 type = "toggle",
|
flickerstreak@30
|
75 handler = module,
|
flickerstreak@30
|
76 name = "foo",
|
flickerstreak@30
|
77 desc = "description",
|
flickerstreak@30
|
78 get = function() return true end,
|
flickerstreak@30
|
79 set = function() end,
|
flickerstreak@30
|
80 }
|
flickerstreak@30
|
81 }
|
flickerstreak@30
|
82 },
|
flickerstreak@30
|
83 },
|
flickerstreak@30
|
84 order = -1,
|
flickerstreak@25
|
85 },
|
flickerstreak@30
|
86 },
|
flickerstreak@30
|
87 plugins = { }
|
flickerstreak@25
|
88 }
|
flickerstreak@25
|
89
|
flickerstreak@25
|
90 -- module methods
|
flickerstreak@25
|
91 function module:OnInitialize()
|
flickerstreak@28
|
92 self.db = ReAction.db:RegisterNamespace( moduleID,
|
flickerstreak@25
|
93 {
|
flickerstreak@28
|
94 profile = { }
|
flickerstreak@25
|
95 }
|
flickerstreak@25
|
96 )
|
flickerstreak@30
|
97 self:InitializeOptions()
|
flickerstreak@30
|
98 LibStub("AceConfig-3.0"):RegisterOptionsTable("ReAction",self.configOptions)
|
flickerstreak@30
|
99 LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ReAction", "ReAction")
|
flickerstreak@30
|
100 self:RegisterEvent("PLAYER_REGEN_DISABLED")
|
flickerstreak@25
|
101 end
|
flickerstreak@25
|
102
|
flickerstreak@30
|
103 function module:InitializeOptions()
|
flickerstreak@30
|
104 for _, m in pairs(ReAction:GetOptions("global")) do
|
flickerstreak@30
|
105 for k, v in pairs(m) do
|
flickerstreak@30
|
106 self.configOptions.args.global.args[k] = v
|
flickerstreak@30
|
107 end
|
flickerstreak@30
|
108 end
|
flickerstreak@30
|
109 ReAction.RegisterCallback(self,"OnOptionsRegistered")
|
flickerstreak@25
|
110 end
|
flickerstreak@25
|
111
|
flickerstreak@30
|
112 function module:OnOptionsRegistered(evt, context, module, opts)
|
flickerstreak@30
|
113 if context == "global" then
|
flickerstreak@30
|
114 for k, v in pairs(opts) do
|
flickerstreak@30
|
115 self.configOptions.args.global.args[k] = v
|
flickerstreak@30
|
116 end
|
flickerstreak@30
|
117 elseif context == "module" then
|
flickerstreak@30
|
118 for k, v in pairs(opts) do
|
flickerstreak@30
|
119 self.configOptions.args.module.args[k] = v
|
flickerstreak@30
|
120 end
|
flickerstreak@30
|
121 elseif context == "bar" then
|
flickerstreak@30
|
122
|
flickerstreak@30
|
123 elseif context == "barMenu" then
|
flickerstreak@30
|
124
|
flickerstreak@30
|
125 end
|
flickerstreak@25
|
126 end
|
flickerstreak@25
|
127
|
flickerstreak@25
|
128 function module:PLAYER_REGEN_DISABLED()
|
flickerstreak@25
|
129 if self.configMode == true then
|
flickerstreak@25
|
130 UIErrorsFrame:AddMessage(L["ReAction config mode disabled during combat."])
|
flickerstreak@25
|
131 self:SetConfigMode(false)
|
flickerstreak@25
|
132 end
|
flickerstreak@25
|
133 end
|
flickerstreak@25
|
134
|
flickerstreak@25
|
135 function module:SetConfigMode( mode )
|
flickerstreak@28
|
136 ReAction:CallMethodOnAllBars("ShowControls",mode)
|
flickerstreak@28
|
137 ReAction:CallMethodOnAllModules("ApplyConfigMode",mode,ReAction.bars)
|
flickerstreak@25
|
138 self.configMode = mode
|
flickerstreak@25
|
139 end
|
flickerstreak@25
|
140
|
flickerstreak@25
|
141 function module:ApplyConfigMode( mode, bars )
|
flickerstreak@25
|
142 if not(mode) then
|
flickerstreak@25
|
143 -- close open dewdrop menu
|
flickerstreak@25
|
144 local p = Dewdrop:GetOpenedParent()
|
flickerstreak@25
|
145 if p then
|
flickerstreak@25
|
146 for _, bar in pairs(bars) do
|
flickerstreak@25
|
147 if bar then
|
flickerstreak@25
|
148 if p == bar.controlFrame then
|
flickerstreak@25
|
149 Dewdrop:Close()
|
flickerstreak@25
|
150 end
|
flickerstreak@25
|
151 end
|
flickerstreak@25
|
152 end
|
flickerstreak@25
|
153 end
|
flickerstreak@25
|
154 end
|
flickerstreak@25
|
155 end
|
flickerstreak@25
|
156
|
flickerstreak@30
|
157 local function safecall(module, method, ...)
|
flickerstreak@28
|
158 if module and type(module[method]) == "function" then
|
flickerstreak@30
|
159 return module[method](method, ...)
|
flickerstreak@25
|
160 end
|
flickerstreak@25
|
161 end
|
flickerstreak@25
|
162
|
flickerstreak@25
|
163 function module:OpenConfig(bar)
|
flickerstreak@25
|
164 Dewdrop:Close()
|
flickerstreak@30
|
165 InterfaceOptionsFrame_OpenToFrame("ReAction")
|
flickerstreak@25
|
166 end
|
flickerstreak@25
|
167
|
flickerstreak@25
|
168 function module:ApplyToBar(bar)
|
flickerstreak@25
|
169 if self.configMode then
|
flickerstreak@30
|
170 bar:ShowControls(self.configMode)
|
flickerstreak@25
|
171 end
|
flickerstreak@25
|
172 end
|
flickerstreak@25
|
173
|
flickerstreak@25
|
174 function module:RemoveFromBar(bar)
|
flickerstreak@25
|
175 if bar.controlFrame then
|
flickerstreak@25
|
176 bar.controlFrame:SetParent(UIParent)
|
flickerstreak@25
|
177 bar.controlFrame:ClearAllPoints()
|
flickerstreak@25
|
178 bar.controlFrame:Hide()
|
flickerstreak@25
|
179 bar.controlFrame = nil
|
flickerstreak@25
|
180 end
|
flickerstreak@25
|
181 end
|
flickerstreak@25
|
182
|
flickerstreak@25
|
183
|
flickerstreak@25
|
184
|
flickerstreak@25
|
185
|
flickerstreak@25
|
186
|
flickerstreak@25
|
187 --
|
flickerstreak@25
|
188 -- Bar config overlay
|
flickerstreak@25
|
189 --
|
flickerstreak@25
|
190 -- import some of these for small OnUpdate performance boost
|
flickerstreak@28
|
191 local Bar = ReAction.Bar.prototype
|
flickerstreak@25
|
192 local GetSize = Bar.GetSize
|
flickerstreak@25
|
193 local GetButtonSize = Bar.GetButtonSize
|
flickerstreak@25
|
194 local GetButtonGrid = Bar.GetButtonGrid
|
flickerstreak@25
|
195 local SetSize = Bar.SetSize
|
flickerstreak@25
|
196 local SetButtonSize = Bar.SetButtonSize
|
flickerstreak@25
|
197 local SetButtonGrid = Bar.SetButtonGrid
|
flickerstreak@25
|
198 local ApplyAnchor = Bar.ApplyAnchor
|
flickerstreak@25
|
199 local floor = math.floor
|
flickerstreak@25
|
200 local min = math.min
|
flickerstreak@25
|
201 local format = string.format
|
flickerstreak@25
|
202 local GameTooltip = GameTooltip
|
flickerstreak@25
|
203
|
flickerstreak@25
|
204 local function StoreExtents(bar)
|
flickerstreak@25
|
205 local f = bar.frame
|
flickerstreak@25
|
206 local point, relativeTo, relativePoint, x, y = f:GetPoint(1)
|
flickerstreak@25
|
207 relativeTo = relativeTo or f:GetParent()
|
flickerstreak@25
|
208 local anchorTo
|
flickerstreak@28
|
209 for name, b in pairs(ReAction.bars) do
|
flickerstreak@25
|
210 if b then
|
flickerstreak@25
|
211 if b:GetFrame() == relativeTo then
|
flickerstreak@25
|
212 anchorTo = name
|
flickerstreak@25
|
213 break
|
flickerstreak@25
|
214 end
|
flickerstreak@25
|
215 end
|
flickerstreak@25
|
216 end
|
flickerstreak@25
|
217 anchorTo = anchorTo or relativeTo:GetName()
|
flickerstreak@25
|
218 local c = bar.config
|
flickerstreak@25
|
219 c.anchor = point
|
flickerstreak@25
|
220 c.anchorTo = anchorTo
|
flickerstreak@25
|
221 c.relativePoint = relativePoint
|
flickerstreak@25
|
222 c.x = x
|
flickerstreak@25
|
223 c.y = y
|
flickerstreak@25
|
224 c.width, c.height = f:GetWidth(), f:GetHeight()
|
flickerstreak@25
|
225 end
|
flickerstreak@25
|
226
|
flickerstreak@25
|
227 local function RecomputeButtonSize(bar)
|
flickerstreak@25
|
228 local w, h = GetSize(bar)
|
flickerstreak@25
|
229 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
230 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
231
|
flickerstreak@25
|
232 local scaleW = (floor(w/c) - s) / bw
|
flickerstreak@25
|
233 local scaleH = (floor(h/r) - s) / bh
|
flickerstreak@25
|
234 local scale = min(scaleW, scaleH)
|
flickerstreak@25
|
235
|
flickerstreak@25
|
236 SetButtonSize(bar, scale * bw, scale * bh, s)
|
flickerstreak@25
|
237 end
|
flickerstreak@25
|
238
|
flickerstreak@25
|
239 local function RecomputeButtonSpacing(bar)
|
flickerstreak@25
|
240 local w, h = GetSize(bar)
|
flickerstreak@25
|
241 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
242 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
243
|
flickerstreak@25
|
244 SetButtonGrid(bar,r,c,min(floor(w/c) - bw, floor(h/r) - bh))
|
flickerstreak@25
|
245 end
|
flickerstreak@25
|
246
|
flickerstreak@25
|
247 local function RecomputeGrid(bar)
|
flickerstreak@25
|
248 local w, h = GetSize(bar)
|
flickerstreak@25
|
249 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
250 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
251
|
flickerstreak@25
|
252 SetButtonGrid(bar, floor(h/(bh+s)), floor(w/(bw+s)), s)
|
flickerstreak@25
|
253 end
|
flickerstreak@25
|
254
|
flickerstreak@25
|
255 local function ClampToButtons(bar)
|
flickerstreak@25
|
256 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
257 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
258 SetSize(bar, (bw+s)*c, (bh+s)*r )
|
flickerstreak@25
|
259 end
|
flickerstreak@25
|
260
|
flickerstreak@25
|
261 local function HideGameTooltip()
|
flickerstreak@25
|
262 GameTooltip:Hide()
|
flickerstreak@25
|
263 end
|
flickerstreak@25
|
264
|
flickerstreak@25
|
265 local function CreateControls(bar)
|
flickerstreak@25
|
266 local f = bar.frame
|
flickerstreak@25
|
267
|
flickerstreak@25
|
268 f:SetMovable(true)
|
flickerstreak@25
|
269 f:SetResizable(true)
|
flickerstreak@25
|
270 f:SetClampedToScreen(true)
|
flickerstreak@25
|
271
|
flickerstreak@25
|
272 -- buttons on the bar should be direct children of the bar frame.
|
flickerstreak@25
|
273 -- The control elements need to float on top of this, which we could
|
flickerstreak@25
|
274 -- do with SetFrameLevel() or Raise(), but it's more reliable to do it
|
flickerstreak@25
|
275 -- via frame nesting, hence good old foo's appearance here.
|
flickerstreak@25
|
276 local foo = CreateFrame("Frame",nil,f)
|
flickerstreak@25
|
277 foo:SetAllPoints()
|
flickerstreak@25
|
278
|
flickerstreak@25
|
279 local control = CreateFrame("Button", nil, foo)
|
flickerstreak@25
|
280 control:EnableMouse(true)
|
flickerstreak@25
|
281 control:SetToplevel(true)
|
flickerstreak@25
|
282 control:SetPoint("TOPLEFT", -4, 4)
|
flickerstreak@25
|
283 control:SetPoint("BOTTOMRIGHT", 4, -4)
|
flickerstreak@25
|
284 control:SetBackdrop({
|
flickerstreak@25
|
285 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
flickerstreak@25
|
286 tile = true,
|
flickerstreak@25
|
287 tileSize = 16,
|
flickerstreak@25
|
288 edgeSize = 16,
|
flickerstreak@25
|
289 insets = { left = 0, right = 0, top = 0, bottom = 0 },
|
flickerstreak@25
|
290 })
|
flickerstreak@25
|
291
|
flickerstreak@25
|
292 -- textures
|
flickerstreak@25
|
293 local bgTex = control:CreateTexture(nil,"BACKGROUND")
|
flickerstreak@25
|
294 bgTex:SetTexture(0.7,0.7,1.0,0.2)
|
flickerstreak@25
|
295 bgTex:SetPoint("TOPLEFT",4,-4)
|
flickerstreak@25
|
296 bgTex:SetPoint("BOTTOMRIGHT",-4,4)
|
flickerstreak@25
|
297 local hTex = control:CreateTexture(nil,"HIGHLIGHT")
|
flickerstreak@25
|
298 hTex:SetTexture(0.7,0.7,1.0,0.2)
|
flickerstreak@25
|
299 hTex:SetPoint("TOPLEFT",4,-4)
|
flickerstreak@25
|
300 hTex:SetPoint("BOTTOMRIGHT",-4,4)
|
flickerstreak@25
|
301 hTex:SetBlendMode("ADD")
|
flickerstreak@25
|
302
|
flickerstreak@25
|
303 -- label
|
flickerstreak@25
|
304 local label = control:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
|
flickerstreak@25
|
305 label:SetAllPoints()
|
flickerstreak@25
|
306 label:SetJustifyH("CENTER")
|
flickerstreak@25
|
307 label:SetShadowColor(0,0,0,1)
|
flickerstreak@25
|
308 label:SetShadowOffset(2,-2)
|
flickerstreak@25
|
309 label:SetTextColor(1,1,1,1)
|
flickerstreak@25
|
310 label:SetText(bar:GetName())
|
flickerstreak@25
|
311 label:Show()
|
flickerstreak@25
|
312 bar.controlLabelString = label -- so that bar:SetName() can update it
|
flickerstreak@25
|
313
|
flickerstreak@25
|
314 local StopResize = function()
|
flickerstreak@25
|
315 f:StopMovingOrSizing()
|
flickerstreak@25
|
316 f.isMoving = false
|
flickerstreak@25
|
317 f:SetScript("OnUpdate",nil)
|
flickerstreak@25
|
318 StoreExtents(bar)
|
flickerstreak@25
|
319 ClampToButtons(bar)
|
flickerstreak@25
|
320 ApplyAnchor(bar)
|
flickerstreak@25
|
321 end
|
flickerstreak@25
|
322
|
flickerstreak@25
|
323 -- edge drag handles
|
flickerstreak@25
|
324 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do
|
flickerstreak@25
|
325 local edge = CreateFrame("Frame",nil,control)
|
flickerstreak@25
|
326 edge:EnableMouse(true)
|
flickerstreak@25
|
327 edge:SetWidth(8)
|
flickerstreak@25
|
328 edge:SetHeight(8)
|
flickerstreak@25
|
329 if point == "TOP" or point == "BOTTOM" then
|
flickerstreak@25
|
330 edge:SetPoint(point.."LEFT")
|
flickerstreak@25
|
331 edge:SetPoint(point.."RIGHT")
|
flickerstreak@25
|
332 else
|
flickerstreak@25
|
333 edge:SetPoint("TOP"..point)
|
flickerstreak@25
|
334 edge:SetPoint("BOTTOM"..point)
|
flickerstreak@25
|
335 end
|
flickerstreak@25
|
336 local tex = edge:CreateTexture(nil,"HIGHLIGHT")
|
flickerstreak@25
|
337 tex:SetTexture(1.0,0.82,0,0.7)
|
flickerstreak@25
|
338 tex:SetBlendMode("ADD")
|
flickerstreak@25
|
339 tex:SetAllPoints()
|
flickerstreak@25
|
340 edge:RegisterForDrag("LeftButton")
|
flickerstreak@25
|
341 edge:SetScript("OnMouseDown",
|
flickerstreak@25
|
342 function()
|
flickerstreak@25
|
343 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
344 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
345 f:SetMinResize( bw+s+1, bh+s+1 )
|
flickerstreak@25
|
346 f:StartSizing(point)
|
flickerstreak@25
|
347 f:SetScript("OnUpdate",
|
flickerstreak@25
|
348 function()
|
flickerstreak@25
|
349 RecomputeGrid(bar)
|
flickerstreak@25
|
350 bar:RefreshLayout()
|
flickerstreak@25
|
351 end
|
flickerstreak@25
|
352 )
|
flickerstreak@25
|
353 end
|
flickerstreak@25
|
354 )
|
flickerstreak@25
|
355 edge:SetScript("OnMouseUp", StopResize)
|
flickerstreak@25
|
356 edge:SetScript("OnEnter",
|
flickerstreak@25
|
357 function()
|
flickerstreak@25
|
358 GameTooltip:SetOwner(f, "ANCHOR_"..point)
|
flickerstreak@25
|
359 GameTooltip:AddLine(L["Drag to add/remove buttons"])
|
flickerstreak@25
|
360 GameTooltip:Show()
|
flickerstreak@25
|
361 end
|
flickerstreak@25
|
362 )
|
flickerstreak@25
|
363 edge:SetScript("OnLeave", HideGameTooltip)
|
flickerstreak@25
|
364 edge:Show()
|
flickerstreak@25
|
365 end
|
flickerstreak@25
|
366
|
flickerstreak@25
|
367 -- corner drag handles, again nested in an anonymous frame so that they are on top
|
flickerstreak@25
|
368 local foo2 = CreateFrame("Frame",nil,control)
|
flickerstreak@25
|
369 foo2:SetAllPoints(true)
|
flickerstreak@25
|
370 for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do
|
flickerstreak@25
|
371 local corner = CreateFrame("Frame",nil,foo2)
|
flickerstreak@25
|
372 corner:EnableMouse(true)
|
flickerstreak@25
|
373 corner:SetWidth(12)
|
flickerstreak@25
|
374 corner:SetHeight(12)
|
flickerstreak@25
|
375 corner:SetPoint(point)
|
flickerstreak@25
|
376 local tex = corner:CreateTexture(nil,"HIGHLIGHT")
|
flickerstreak@25
|
377 tex:SetTexture(1.0,0.82,0,0.7)
|
flickerstreak@25
|
378 tex:SetBlendMode("ADD")
|
flickerstreak@25
|
379 tex:SetAllPoints()
|
flickerstreak@25
|
380 corner:RegisterForDrag("LeftButton","RightButton")
|
flickerstreak@25
|
381 local updateTooltip = function()
|
flickerstreak@25
|
382 local size, size2 = bar:GetButtonSize()
|
flickerstreak@25
|
383 local rows, cols, spacing = bar:GetButtonGrid()
|
flickerstreak@25
|
384 size = (size == size2) and tostring(size) or format("%dx%d",size,size2)
|
flickerstreak@25
|
385 GameTooltipTextRight4:SetText(size)
|
flickerstreak@25
|
386 GameTooltipTextRight5:SetText(tostring(spacing))
|
flickerstreak@25
|
387 end
|
flickerstreak@25
|
388 corner:SetScript("OnMouseDown",
|
flickerstreak@25
|
389 function(_,btn)
|
flickerstreak@25
|
390 local bw, bh = GetButtonSize(bar)
|
flickerstreak@25
|
391 local r, c, s = GetButtonGrid(bar)
|
flickerstreak@25
|
392 if btn == "LeftButton" then -- button resize
|
flickerstreak@25
|
393 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 )
|
flickerstreak@25
|
394 f:SetScript("OnUpdate",
|
flickerstreak@25
|
395 function()
|
flickerstreak@25
|
396 RecomputeButtonSize(bar)
|
flickerstreak@25
|
397 bar:RefreshLayout()
|
flickerstreak@25
|
398 updateTooltip()
|
flickerstreak@25
|
399 end
|
flickerstreak@25
|
400 )
|
flickerstreak@25
|
401 elseif btn == "RightButton" then -- spacing resize
|
flickerstreak@25
|
402 f:SetMinResize( bw*c, bh*r )
|
flickerstreak@25
|
403 f:SetScript("OnUpdate",
|
flickerstreak@25
|
404 function()
|
flickerstreak@25
|
405 RecomputeButtonSpacing(bar)
|
flickerstreak@25
|
406 bar:RefreshLayout()
|
flickerstreak@25
|
407 updateTooltip()
|
flickerstreak@25
|
408 end
|
flickerstreak@25
|
409 )
|
flickerstreak@25
|
410 end
|
flickerstreak@25
|
411 f:StartSizing(point)
|
flickerstreak@25
|
412 end
|
flickerstreak@25
|
413 )
|
flickerstreak@25
|
414 corner:SetScript("OnMouseUp",StopResize)
|
flickerstreak@25
|
415 corner:SetScript("OnEnter",
|
flickerstreak@25
|
416 function()
|
flickerstreak@25
|
417 GameTooltip:SetOwner(f, "ANCHOR_"..point)
|
flickerstreak@25
|
418 GameTooltip:AddLine(L["Drag to resize buttons"])
|
flickerstreak@25
|
419 GameTooltip:AddLine(L["Right-click-drag"])
|
flickerstreak@25
|
420 GameTooltip:AddLine(L["to change spacing"])
|
flickerstreak@25
|
421 local size, size2 = bar:GetButtonSize()
|
flickerstreak@25
|
422 local rows, cols, spacing = bar:GetButtonGrid()
|
flickerstreak@25
|
423 size = (size == size2) and tostring(size) or format("%dx%d",size,size2)
|
flickerstreak@25
|
424 GameTooltip:AddDoubleLine(L["Size:"], size)
|
flickerstreak@25
|
425 GameTooltip:AddDoubleLine(L["Spacing:"], tostring(spacing))
|
flickerstreak@25
|
426 GameTooltip:Show()
|
flickerstreak@25
|
427 end
|
flickerstreak@25
|
428 )
|
flickerstreak@25
|
429 corner:SetScript("OnLeave",
|
flickerstreak@25
|
430 function()
|
flickerstreak@25
|
431 GameTooltip:Hide()
|
flickerstreak@25
|
432 f:SetScript("OnUpdate",nil)
|
flickerstreak@25
|
433 end
|
flickerstreak@25
|
434 )
|
flickerstreak@25
|
435
|
flickerstreak@25
|
436 end
|
flickerstreak@25
|
437
|
flickerstreak@25
|
438 control:RegisterForDrag("LeftButton")
|
flickerstreak@25
|
439 control:RegisterForClicks("RightButtonDown")
|
flickerstreak@25
|
440
|
flickerstreak@25
|
441 control:SetScript("OnDragStart",
|
flickerstreak@25
|
442 function()
|
flickerstreak@25
|
443 f:StartMoving()
|
flickerstreak@25
|
444 f.isMoving = true
|
flickerstreak@25
|
445 -- TODO: snap indicator update install
|
flickerstreak@25
|
446 end
|
flickerstreak@25
|
447 )
|
flickerstreak@25
|
448
|
flickerstreak@25
|
449 control:SetScript("OnDragStop",
|
flickerstreak@25
|
450 function()
|
flickerstreak@25
|
451 f:StopMovingOrSizing()
|
flickerstreak@25
|
452 f.isMoving = false
|
flickerstreak@25
|
453 f:SetScript("OnUpdate",nil)
|
flickerstreak@25
|
454 -- TODO: snap frame here
|
flickerstreak@25
|
455 StoreExtents(bar)
|
flickerstreak@25
|
456 end
|
flickerstreak@25
|
457 )
|
flickerstreak@25
|
458
|
flickerstreak@25
|
459 control:SetScript("OnEnter",
|
flickerstreak@25
|
460 function()
|
flickerstreak@25
|
461 -- add bar type and status information to name
|
flickerstreak@25
|
462 local name = bar.name
|
flickerstreak@28
|
463 for _, m in ReAction:IterateModules() do
|
flickerstreak@30
|
464 local suffix = safecall(m,"GetBarNameModifier",bar)
|
flickerstreak@25
|
465 if suffix then
|
flickerstreak@30
|
466 name = ("%s %s"):format(name,suffix)
|
flickerstreak@25
|
467 end
|
flickerstreak@25
|
468 end
|
flickerstreak@25
|
469
|
flickerstreak@25
|
470 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT")
|
flickerstreak@25
|
471 GameTooltip:AddLine(name)
|
flickerstreak@25
|
472 GameTooltip:AddLine(L["Drag to move"])
|
flickerstreak@25
|
473 --GameTooltip:AddLine(L["Shift-drag for sticky mode"])
|
flickerstreak@25
|
474 GameTooltip:AddLine(L["Right-click for options"])
|
flickerstreak@25
|
475 GameTooltip:Show()
|
flickerstreak@25
|
476 end
|
flickerstreak@25
|
477 )
|
flickerstreak@25
|
478
|
flickerstreak@25
|
479 control:SetScript("OnLeave", HideGameTooltip)
|
flickerstreak@25
|
480
|
flickerstreak@25
|
481 control:SetScript("OnClick",
|
flickerstreak@25
|
482 function()
|
flickerstreak@25
|
483 bar:ShowMenu()
|
flickerstreak@25
|
484 end
|
flickerstreak@25
|
485 )
|
flickerstreak@25
|
486
|
flickerstreak@25
|
487 return control
|
flickerstreak@25
|
488 end
|
flickerstreak@25
|
489
|
flickerstreak@25
|
490 function Bar:ShowControls(show)
|
flickerstreak@25
|
491 if show then
|
flickerstreak@25
|
492 if not self.controlFrame then
|
flickerstreak@25
|
493 self.controlFrame = CreateControls(self)
|
flickerstreak@25
|
494 end
|
flickerstreak@25
|
495 self.controlFrame:Show()
|
flickerstreak@25
|
496 elseif self.controlFrame then
|
flickerstreak@25
|
497 self.controlFrame:Hide()
|
flickerstreak@25
|
498 end
|
flickerstreak@25
|
499 end
|
flickerstreak@25
|
500
|
flickerstreak@25
|
501 function Bar:ShowMenu()
|
flickerstreak@25
|
502 if not self.menuOpts then
|
flickerstreak@25
|
503 self.menuOpts = {
|
flickerstreak@25
|
504 type = "group",
|
flickerstreak@25
|
505 args = {
|
flickerstreak@25
|
506 openConfig = {
|
flickerstreak@25
|
507 type = "execute",
|
flickerstreak@25
|
508 name = L["Configure..."],
|
flickerstreak@25
|
509 desc = L["Open the configuration dialogue for this bar"],
|
flickerstreak@25
|
510 func = function() module:OpenConfig(self) end,
|
flickerstreak@25
|
511 disabled = InCombatLockdown,
|
flickerstreak@25
|
512 order = 1
|
flickerstreak@28
|
513 },
|
flickerstreak@28
|
514 delete = {
|
flickerstreak@28
|
515 type = "execute",
|
flickerstreak@28
|
516 name = L["Delete Bar"],
|
flickerstreak@28
|
517 desc = L["Remove the bar from the current profile"],
|
flickerstreak@28
|
518 func = function() ReAction:EraseBar(self) end,
|
flickerstreak@28
|
519 order = 2
|
flickerstreak@28
|
520 },
|
flickerstreak@25
|
521 }
|
flickerstreak@25
|
522 }
|
flickerstreak@25
|
523 end
|
flickerstreak@25
|
524 if self.modMenuOpts == nil then
|
flickerstreak@25
|
525 self.modMenuOpts = { }
|
flickerstreak@25
|
526 end
|
flickerstreak@28
|
527 for _, m in ReAction:IterateModules() do
|
flickerstreak@30
|
528 local opts = safecall(m,"GetBarMenuOptions",self,module)
|
flickerstreak@28
|
529 if opts then
|
flickerstreak@28
|
530 for k, v in pairs(opts) do
|
flickerstreak@28
|
531 self.menuOpts.args[k] = v
|
flickerstreak@28
|
532 end
|
flickerstreak@25
|
533 end
|
flickerstreak@25
|
534 end
|
flickerstreak@25
|
535 Dewdrop:Open(self.controlFrame, "children", self.menuOpts, "cursorX", true, "cursorY", true)
|
flickerstreak@25
|
536 end
|
flickerstreak@25
|
537
|
flickerstreak@25
|
538 local Bar_SuperSetName = Bar.SetName
|
flickerstreak@25
|
539 function Bar:SetName(name)
|
flickerstreak@25
|
540 Bar_SuperSetName(self,name)
|
flickerstreak@25
|
541 if self.controlLabelString then
|
flickerstreak@25
|
542 self.controlLabelString:SetText(self.name)
|
flickerstreak@25
|
543 end
|
flickerstreak@25
|
544 end
|