annotate HotCorners.lua @ 1:018fc9f0c471

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