tercio@0
|
1
|
tercio@0
|
2 LibHotCorners = LibStub ("AceAddon-3.0"):NewAddon ("HotCorners", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
tercio@0
|
3 local LibHotCorners = LibHotCorners
|
tercio@0
|
4
|
tercio@0
|
5 local LBD = LibStub ("LibDataBroker-1.1")
|
tercio@0
|
6
|
tercio@0
|
7 local debug = false
|
tercio@0
|
8 local tinsert = tinsert
|
tercio@0
|
9
|
tercio@0
|
10 local default_db = {
|
tercio@0
|
11 profile = {
|
tercio@0
|
12 is_enabled = true,
|
tercio@0
|
13 topleft_enabled = true,
|
tercio@0
|
14 quickfunc = false,
|
tercio@0
|
15 clicks = {},
|
tercio@0
|
16 disabled = {}
|
tercio@0
|
17 },
|
tercio@0
|
18 }
|
tercio@0
|
19
|
tercio@0
|
20 function LibHotCorners:OnEnable()
|
tercio@0
|
21
|
tercio@0
|
22 end
|
tercio@0
|
23
|
tercio@0
|
24 function LibHotCorners:OnDisable()
|
tercio@0
|
25
|
tercio@0
|
26 end
|
tercio@0
|
27
|
tercio@0
|
28 local refresh_topleft = function()
|
tercio@0
|
29 LibHotCorners ["topleft"].is_enabled = LibHotCorners.db.profile.topleft_enabled
|
tercio@0
|
30 end
|
tercio@0
|
31
|
tercio@0
|
32 local OptionsTable = {
|
tercio@0
|
33 name = "HotCorners",
|
tercio@0
|
34 type = "group",
|
tercio@0
|
35 args = {
|
tercio@0
|
36 Enabled = {
|
tercio@0
|
37 type = "toggle",
|
tercio@0
|
38 name = "Enabled",
|
tercio@0
|
39 desc = "Enable or Disable this addon.",
|
tercio@0
|
40 order = 1,
|
tercio@0
|
41 get = function() return LibHotCorners.db.profile.is_enabled end,
|
tercio@0
|
42 set = function (self, val) LibHotCorners.db.profile.is_enabled = not LibHotCorners.db.profile.is_enabled; --[[ do something]] end,
|
tercio@0
|
43 },
|
tercio@0
|
44 TopLeftEnabled = {
|
tercio@0
|
45 type = "toggle",
|
tercio@0
|
46 name = "Top Left",
|
tercio@0
|
47 desc = "Enable or Disable the Top Left bar.",
|
tercio@0
|
48 order = 2,
|
tercio@0
|
49 get = function() return LibHotCorners.db.profile.topleft_enabled end,
|
tercio@0
|
50 set = function (self, val) LibHotCorners.db.profile.topleft_enabled = not LibHotCorners.db.profile.topleft_enabled; refresh_topleft() end,
|
tercio@0
|
51 },
|
tercio@0
|
52 }
|
tercio@0
|
53 }
|
tercio@0
|
54
|
tercio@0
|
55 function LibHotCorners:OnInitialize()
|
tercio@0
|
56
|
tercio@0
|
57 --declarar primeiro o db usando a global que é declarada no toc.
|
tercio@0
|
58 self.db = LibStub ("AceDB-3.0"):New ("HotCornersDB", default_db, true)
|
tercio@0
|
59
|
tercio@0
|
60 --declara agora as opções da tab raiz
|
tercio@0
|
61 LibStub("AceConfig-3.0"):RegisterOptionsTable ("HotCorners", OptionsTable)
|
tercio@0
|
62 LibHotCorners.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners", "HotCorners")
|
tercio@0
|
63 --sub tab
|
tercio@0
|
64 LibStub ("AceConfig-3.0"):RegisterOptionsTable ("HotCorners-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
|
tercio@0
|
65 LibHotCorners.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners-Profiles", "Profiles", "HotCorners")
|
tercio@0
|
66
|
tercio@0
|
67 LibHotCorners ["topleft"].is_enabled = self.db.topleft_enabled
|
tercio@0
|
68 refresh_topleft()
|
tercio@0
|
69
|
tercio@0
|
70 SLASH_HOTCORNER1, SLASH_HOTCORNER2 = "/hotcorners", "/hotcorner"
|
tercio@0
|
71 function SlashCmdList.HOTCORNER (msg, editbox)
|
tercio@0
|
72 HotCornersOpenOptions (self);
|
tercio@0
|
73 end
|
tercio@0
|
74
|
tercio@0
|
75 for name, dataobj in LBD:DataObjectIterator() do
|
tercio@0
|
76 if (dataobj.type and dataobj.icon and dataobj.OnClick) then
|
tercio@0
|
77 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
|
tercio@0
|
78 end
|
tercio@0
|
79 end
|
tercio@0
|
80 for k, v in pairs (LBD.attributestorage) do
|
tercio@0
|
81 --print (k, v)
|
tercio@0
|
82 --print ("----------------")
|
tercio@0
|
83 --vardump (v)
|
tercio@0
|
84 end
|
tercio@0
|
85
|
tercio@0
|
86 end
|
tercio@0
|
87
|
tercio@0
|
88 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
89 --> main function
|
tercio@0
|
90
|
tercio@0
|
91 LibHotCorners.embeds = LibHotCorners.embeds or {}
|
tercio@0
|
92 local embed_functions = {
|
tercio@0
|
93 "RegisterHotCornerButton",
|
tercio@0
|
94 "HideHotCornerButton",
|
tercio@0
|
95 "QuickHotCornerEnable"
|
tercio@0
|
96 }
|
tercio@0
|
97
|
tercio@0
|
98 function LibHotCorners:Embed (target)
|
tercio@0
|
99 for k, v in pairs (embed_functions) do
|
tercio@0
|
100 target[v] = self[v]
|
tercio@0
|
101 end
|
tercio@0
|
102 self.embeds [target] = true
|
tercio@0
|
103 return target
|
tercio@0
|
104 end
|
tercio@0
|
105
|
tercio@0
|
106 local CallbackHandler = LibStub:GetLibrary ("CallbackHandler-1.0")
|
tercio@0
|
107 LibHotCorners.callbacks = LibHotCorners.callbacks or CallbackHandler:New (LibHotCorners)
|
tercio@0
|
108
|
tercio@0
|
109 LibHotCorners.topleft = LibHotCorners.topleft or {widgets = {}, quickclick = false, is_enabled = false, map = {}}
|
tercio@0
|
110 LibHotCorners.bottomleft = {}
|
tercio@0
|
111 LibHotCorners.topright = {}
|
tercio@0
|
112 LibHotCorners.bottomright = {}
|
tercio@0
|
113
|
tercio@0
|
114 local function test (corner)
|
tercio@0
|
115 assert (corner == "topleft" or corner == "bottomleft" or corner == "topright" or corner == "bottomright", "LibHotCorners:RegisterAddon expects a corner on #1 argument.")
|
tercio@0
|
116 end
|
tercio@0
|
117
|
tercio@0
|
118 function LibHotCorners:RegisterHotCornerButton (name, corner, savedtable, fname, icon, tooltip, clickfunc, menus, quickfunc, onenter, onleave, is_install)
|
tercio@0
|
119 corner = string.lower (corner)
|
tercio@0
|
120 test (corner)
|
tercio@0
|
121
|
tercio@0
|
122 if (is_install) then
|
tercio@0
|
123 --> overwrite if already exists a widget
|
tercio@0
|
124 for i, widget in ipairs (LibHotCorners [corner]) do
|
tercio@0
|
125 if (widget.name == name) then
|
tercio@0
|
126 table.remove (LibHotCorners [corner], i)
|
tercio@0
|
127 table.insert (LibHotCorners [corner], i, {name = name, fname = fname, savedtable = savedtable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave, is_install = true})
|
tercio@0
|
128 return LibHotCorners [corner].map [name]
|
tercio@0
|
129 end
|
tercio@0
|
130 end
|
tercio@0
|
131
|
tercio@0
|
132 table.insert (LibHotCorners [corner], {name = name, fname = fname, savedtable = savedtable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave, is_install = true})
|
tercio@0
|
133 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
|
tercio@0
|
134 return LibHotCorners [corner].map [name]
|
tercio@0
|
135 else
|
tercio@0
|
136 tinsert (LibHotCorners [corner], {name = name, fname = fname, savedtable = savedtable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave})
|
tercio@0
|
137 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
|
tercio@0
|
138 return LibHotCorners [corner].map [name]
|
tercio@0
|
139 end
|
tercio@0
|
140 end
|
tercio@0
|
141
|
tercio@0
|
142 function LibHotCorners:QuickHotCornerEnable (name, corner, value)
|
tercio@0
|
143
|
tercio@0
|
144 corner = string.lower (corner)
|
tercio@0
|
145 test (corner)
|
tercio@0
|
146
|
tercio@0
|
147 local corner_table = LibHotCorners [corner]
|
tercio@0
|
148 local addon_table = corner_table [corner_table.map [name]]
|
tercio@0
|
149
|
tercio@0
|
150 addon_table.savedtable [corner .. "_quickclick"] = value
|
tercio@0
|
151
|
tercio@0
|
152 if (value and addon_table.quickfunc) then
|
tercio@0
|
153 corner_table.quickfunc = addon_table.quickfunc
|
tercio@0
|
154 else
|
tercio@0
|
155 local got = false
|
tercio@0
|
156 for index, button_table in ipairs (corner_table) do
|
tercio@0
|
157 if (button_table.savedtable.quickclick) then
|
tercio@0
|
158 corner_table.quickfunc = button_table.quickfunc
|
tercio@0
|
159 got = true
|
tercio@0
|
160 break
|
tercio@0
|
161 end
|
tercio@0
|
162 end
|
tercio@0
|
163
|
tercio@0
|
164 if (not got) then
|
tercio@0
|
165 corner_table.quickfunc = nil
|
tercio@0
|
166 end
|
tercio@0
|
167 end
|
tercio@0
|
168 end
|
tercio@0
|
169
|
tercio@0
|
170 function LibHotCorners:HideHotCornerButton (name, corner, value)
|
tercio@0
|
171
|
tercio@0
|
172 corner = string.lower (corner)
|
tercio@0
|
173 test (corner)
|
tercio@0
|
174
|
tercio@0
|
175 local corner_table = LibHotCorners [corner]
|
tercio@0
|
176 local addon_table = corner_table [corner_table.map [name]]
|
tercio@0
|
177
|
tercio@0
|
178 addon_table.savedtable.hide = value
|
tercio@0
|
179
|
tercio@0
|
180 --print (LibHotCorners, corner)
|
tercio@0
|
181 LibHotCorners [corner].is_enabled = false
|
tercio@0
|
182
|
tercio@0
|
183 for index, button_table in ipairs (corner_table) do
|
tercio@0
|
184 if (not button_table.savedtable.hide) then
|
tercio@0
|
185 LibHotCorners [corner].is_enabled = true
|
tercio@0
|
186 break
|
tercio@0
|
187 end
|
tercio@0
|
188 end
|
tercio@0
|
189
|
tercio@0
|
190 return true
|
tercio@0
|
191 end
|
tercio@0
|
192
|
tercio@0
|
193 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
194 --> data broker stuff
|
tercio@0
|
195 function LibHotCorners:DataBrokerCallback (event, name, dataobj)
|
tercio@0
|
196 if (not name or not dataobj or not dataobj.type) then
|
tercio@0
|
197 return
|
tercio@0
|
198 end
|
tercio@0
|
199 if (dataobj.icon and dataobj.OnClick) then
|
tercio@0
|
200 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
|
tercio@0
|
201 end
|
tercio@0
|
202 end
|
tercio@0
|
203 LBD.RegisterCallback (LibHotCorners, "DataBrokerCallback")
|
tercio@0
|
204
|
tercio@0
|
205 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
206 --> scripts
|
tercio@0
|
207
|
tercio@0
|
208 --> background (window mode fix)
|
tercio@0
|
209 function HotCornersBackgroundOnEnter (self)
|
tercio@0
|
210 if (LibHotCornersTopLeft and LibHotCornersTopLeft:IsShown()) then
|
tercio@0
|
211 if (LibHotCornersTopLeft:GetWidth() > 2) then
|
tercio@0
|
212 HotCornersOnLeave (LibHotCornersTopLeft)
|
tercio@0
|
213 end
|
tercio@0
|
214 end
|
tercio@0
|
215 self:EnableMouse (false)
|
tercio@0
|
216 end
|
tercio@0
|
217
|
tercio@0
|
218 --> set size
|
tercio@0
|
219 local function set_size (self)
|
tercio@0
|
220 if (self.position == "topleft" or self.position == "topright") then
|
tercio@0
|
221 self:SetSize (40, GetScreenHeight())
|
tercio@0
|
222 else
|
tercio@0
|
223 self:SetSize (GetScreenWidth(), 40)
|
tercio@0
|
224 end
|
tercio@0
|
225 end
|
tercio@0
|
226
|
tercio@0
|
227 --> show tooltip
|
tercio@0
|
228 local show_tooltip = function (self)
|
tercio@0
|
229 if (self.table.tooltip) then
|
tercio@0
|
230 if (type (self.table.tooltip) == "function") then
|
tercio@0
|
231 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
|
tercio@0
|
232 self.table.tooltip (GameTooltip)
|
tercio@0
|
233 GameTooltip:Show()
|
tercio@0
|
234 elseif (type (self.table.tooltip) == "string") then
|
tercio@0
|
235 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
|
tercio@0
|
236 GameTooltip:AddLine (self.table.tooltip)
|
tercio@0
|
237 GameTooltip:Show()
|
tercio@0
|
238 end
|
tercio@0
|
239 elseif (self.table.onenter) then
|
tercio@0
|
240 self.table.onenter (self)
|
tercio@0
|
241 end
|
tercio@0
|
242 end
|
tercio@0
|
243
|
tercio@0
|
244 --> corner frame on enter
|
tercio@0
|
245 local more_clicked = function (t1, t2)
|
tercio@0
|
246 return t1[1] > t2[1]
|
tercio@0
|
247 end
|
tercio@0
|
248
|
tercio@0
|
249 function HotCornersOnEnter (self)
|
tercio@0
|
250
|
tercio@0
|
251 if (not LibHotCorners.db.profile.is_enabled) then
|
tercio@0
|
252 return
|
tercio@0
|
253 end
|
tercio@0
|
254
|
tercio@0
|
255 if (not LibHotCorners.db.profile [self.position .. "_enabled"]) then
|
tercio@0
|
256 return
|
tercio@0
|
257 end
|
tercio@0
|
258
|
tercio@0
|
259 set_size (self)
|
tercio@0
|
260
|
tercio@0
|
261 HotCornersBackgroundFrame:EnableMouse (true)
|
tercio@0
|
262
|
tercio@0
|
263 local i = 1
|
tercio@0
|
264
|
tercio@0
|
265 local sort = {}
|
tercio@0
|
266 local clicks = LibHotCorners.db.profile.clicks
|
tercio@0
|
267 for index, button_table in ipairs (LibHotCorners [self.position]) do
|
tercio@0
|
268 tinsert (sort, {clicks [button_table.name] or 0, button_table})
|
tercio@0
|
269 end
|
tercio@0
|
270 table.sort (sort, more_clicked)
|
tercio@0
|
271
|
tercio@0
|
272 local last_button
|
tercio@0
|
273
|
tercio@0
|
274 local disabled = LibHotCorners.db.profile.disabled
|
tercio@0
|
275
|
tercio@0
|
276 for index, button_table in ipairs (sort) do
|
tercio@0
|
277 button_table = button_table [2]
|
tercio@0
|
278 if (not button_table.widget) then
|
tercio@0
|
279 LibHotCorners:CreateAddonWidget (self, button_table, index, self.position)
|
tercio@0
|
280 end
|
tercio@0
|
281
|
tercio@0
|
282 button_table.widget:ClearAllPoints()
|
tercio@0
|
283
|
tercio@0
|
284 if (not disabled [button_table.name]) then
|
tercio@0
|
285 if (self.position == "topleft" or self.position == "topright") then
|
tercio@0
|
286 local y = i * 35 * -1
|
tercio@0
|
287 button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
|
tercio@0
|
288 button_table.widget.y = y
|
tercio@0
|
289 else
|
tercio@0
|
290 local x = i * 35
|
tercio@0
|
291 button_table.widget:SetPoint ("topleft", self, "topleft", x, -4)
|
tercio@0
|
292 button_table.widget.x = x
|
tercio@0
|
293 end
|
tercio@0
|
294
|
tercio@0
|
295 button_table.widget:Show()
|
tercio@0
|
296 last_button = button_table.widget
|
tercio@0
|
297
|
tercio@0
|
298 i = i + 1
|
tercio@0
|
299 else
|
tercio@0
|
300 button_table.widget:Hide()
|
tercio@0
|
301 end
|
tercio@0
|
302 end
|
tercio@0
|
303
|
tercio@0
|
304 local OptionsButton = LibHotCorners [self.position].optionsbutton
|
tercio@0
|
305 local y = i * 35 * -1
|
tercio@0
|
306 OptionsButton:SetPoint ("top", self, "top", 0, y)
|
tercio@0
|
307 OptionsButton:Show()
|
tercio@0
|
308
|
tercio@0
|
309 end
|
tercio@0
|
310
|
tercio@0
|
311 --> corner frame on leave
|
tercio@0
|
312 function HotCornersOnLeave (self)
|
tercio@0
|
313 self:SetSize (1, 1)
|
tercio@0
|
314 for index, button_table in ipairs (LibHotCorners [self.position]) do
|
tercio@0
|
315 button_table.widget:Hide()
|
tercio@0
|
316 end
|
tercio@0
|
317 local OptionsButton = LibHotCorners [self.position].optionsbutton
|
tercio@0
|
318 OptionsButton:Hide()
|
tercio@0
|
319 end
|
tercio@0
|
320
|
tercio@0
|
321 --> quick corner on click
|
tercio@0
|
322 function HotCornersOnQuickClick (self, button)
|
tercio@0
|
323 local parent_position = self:GetParent().position
|
tercio@0
|
324 if (LibHotCorners [parent_position].quickfunc) then
|
tercio@0
|
325 LibHotCorners [parent_position].quickfunc (self, button)
|
tercio@0
|
326 end
|
tercio@0
|
327 end
|
tercio@0
|
328
|
tercio@0
|
329 --> options button onenter
|
tercio@0
|
330 function HotCornersOptionsButtonOnEnter (self)
|
tercio@0
|
331 set_size (self:GetParent())
|
tercio@0
|
332 for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
|
tercio@0
|
333 if (not LibHotCorners.db.profile.disabled [button_table.name]) then
|
tercio@0
|
334 button_table.widget:Show()
|
tercio@0
|
335 end
|
tercio@0
|
336 end
|
tercio@0
|
337 self:Show()
|
tercio@0
|
338 end
|
tercio@0
|
339
|
tercio@0
|
340 function HotCornersOpenOptions (self)
|
tercio@0
|
341 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
|
tercio@0
|
342 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
|
tercio@0
|
343 end
|
tercio@0
|
344
|
tercio@0
|
345 function HotCornersSetEnabled (state)
|
tercio@0
|
346 LibHotCorners.db.profile.is_enabled = state
|
tercio@0
|
347 end
|
tercio@0
|
348
|
tercio@0
|
349 --> options button onleave
|
tercio@0
|
350 function HotCornersOptionsButtonOnLeave (self)
|
tercio@0
|
351 self:GetParent():GetScript("OnLeave")(self:GetParent())
|
tercio@0
|
352 end
|
tercio@0
|
353
|
tercio@0
|
354 --> button onenter
|
tercio@0
|
355 function HotCornersButtonOnEnter (self)
|
tercio@0
|
356 set_size (self:GetParent())
|
tercio@0
|
357 for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
|
tercio@0
|
358 if (not LibHotCorners.db.profile.disabled [button_table.name]) then
|
tercio@0
|
359 button_table.widget:Show()
|
tercio@0
|
360 end
|
tercio@0
|
361 end
|
tercio@0
|
362 show_tooltip (self)
|
tercio@0
|
363 local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
|
tercio@0
|
364 OptionsButton:Show()
|
tercio@0
|
365 end
|
tercio@0
|
366
|
tercio@0
|
367 --> button onleave
|
tercio@0
|
368 function HotCornersButtonOnLeave (self)
|
tercio@0
|
369 GameTooltip:Hide()
|
tercio@0
|
370 if (self.table.onleave) then
|
tercio@0
|
371 self.table.onleave (self)
|
tercio@0
|
372 end
|
tercio@0
|
373 self:GetParent():GetScript("OnLeave")(self:GetParent())
|
tercio@0
|
374 local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
|
tercio@0
|
375 OptionsButton:Hide()
|
tercio@0
|
376 end
|
tercio@0
|
377
|
tercio@0
|
378 --> button onmousedown
|
tercio@0
|
379 function HotCornersButtonOnMouseDown (self, button)
|
tercio@0
|
380 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
|
tercio@0
|
381 self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
|
tercio@0
|
382 else
|
tercio@0
|
383 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
|
tercio@0
|
384 end
|
tercio@0
|
385 end
|
tercio@0
|
386
|
tercio@0
|
387 --> button onmouseup
|
tercio@0
|
388 function HotCornersButtonOnMouseUp (self, button)
|
tercio@0
|
389 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
|
tercio@0
|
390 self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
|
tercio@0
|
391 else
|
tercio@0
|
392 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
|
tercio@0
|
393 end
|
tercio@0
|
394 if (self.table.click) then
|
tercio@0
|
395 local clicks = LibHotCorners.db.profile.clicks
|
tercio@0
|
396 clicks [self.table.name] = clicks [self.table.name] or 0
|
tercio@0
|
397 clicks [self.table.name] = clicks [self.table.name] + 1
|
tercio@0
|
398 self.table.click (self, button)
|
tercio@0
|
399 end
|
tercio@0
|
400 end
|
tercio@0
|
401
|
tercio@0
|
402 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
403 --> create top left corner
|
tercio@0
|
404
|
tercio@0
|
405 local TopLeftCorner = CreateFrame ("Frame", "LibHotCornersTopLeft", nil, "HotCornersFrameCornerTemplate")
|
tercio@0
|
406 TopLeftCorner:SetPoint ("topleft", UIParent, "topleft", 0, 0)
|
tercio@0
|
407 TopLeftCorner.position = "topleft"
|
tercio@0
|
408
|
tercio@0
|
409 --fast corner button
|
tercio@0
|
410 local QuickClickButton = CreateFrame ("button", "LibHotCornersTopLeftFastButton", TopLeftCorner, "HotCornersQuickCornerButtonTemplate")
|
tercio@0
|
411
|
tercio@0
|
412 --options button
|
tercio@0
|
413 local OptionsButton = CreateFrame ("button", "LibHotCornersTopLeftOptionsButton", TopLeftCorner, "HotCornersOptionsButtonTemplate")
|
tercio@0
|
414
|
tercio@0
|
415 if (debug) then
|
tercio@0
|
416 QuickClickButton:SetSize (20, 20)
|
tercio@0
|
417 QuickClickButton:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]], tile = true, tileSize = 40})
|
tercio@0
|
418 QuickClickButton:SetBackdropColor (1, 0, 0, 1)
|
tercio@0
|
419 end
|
tercio@0
|
420
|
tercio@0
|
421 LibHotCorners.topleft.quickbutton = QuickClickButton
|
tercio@0
|
422 LibHotCorners.topleft.optionsbutton = OptionsButton
|
tercio@0
|
423
|
tercio@0
|
424 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
425 --> buttons
|
tercio@0
|
426
|
tercio@0
|
427 function LibHotCorners:CreateAddonWidget (frame, button_table, index, side)
|
tercio@0
|
428
|
tercio@0
|
429 --> create the button
|
tercio@0
|
430 local button = CreateFrame ("button", "LibHotCorners" .. side .. button_table.fname, frame, "HotCornersButtonTemplate")
|
tercio@0
|
431
|
tercio@0
|
432 --> write some attributes
|
tercio@0
|
433 button.index = index
|
tercio@0
|
434 button.table = button_table
|
tercio@0
|
435 button.parent = frame
|
tercio@0
|
436 button_table.widget = button
|
tercio@0
|
437
|
tercio@0
|
438 --> set the icon
|
tercio@0
|
439 button:SetNormalTexture (button_table.icon)
|
tercio@0
|
440 button:SetHighlightTexture (button_table.icon)
|
tercio@0
|
441
|
tercio@0
|
442 if (string.lower (button_table.icon):find ([[\icons\]])) then
|
tercio@0
|
443 button:GetNormalTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
|
tercio@0
|
444 button:GetHighlightTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
|
tercio@0
|
445 end
|
tercio@0
|
446
|
tercio@0
|
447 return button
|
tercio@0
|
448 end |