annotate Veneer.lua @ 109:26938ae258b7

- Re-use the basic addon table for core mixin - add /rl command
author Nick@Zahhak
date Mon, 06 Mar 2017 02:30:22 -0500
parents a41f6b74709a
children 7c77fde36287
rev   line source
Nenue@88 1 -- Veneer Custom Interface Framework
Nenue@88 2 -- 1. vn OnLoad
Nenue@88 3 -- 2. OnEvent where IsLoggedIn() == true
Nenue@88 4 -- 3. Setup() where (not self.initialized)
Nenue@88 5 -- 4. Update()
Nenue@88 6 -- 5. Reanchor()
Nick@109 7 local ADDON, Veneer = ...
Nenue@90 8 local VENEER_VERSION = 703
Nenue@103 9 local LE_FREE_FRAMES_GROUP = 1
Nenue@93 10 local type, strrep, ipairs, tinsert, tostring, select = type, string.rep, ipairs, tinsert, tostring, select
Nenue@93 11 local pairs, tremove = pairs, tremove
Nick@109 12 local print = DEVIAN_WORKSPACE and function(...) _G.print('Veneer', ...) end or nop
Nick@109 13 local wipe = table.wipe
Nenue@84 14
Nick@109 15 SLASH_VENEER1 = "/veneer"
Nick@109 16 SLASH_VENEER2 = "/vn"
Nenue@84 17 SlashCmdList.VENEER = function(cmd)
Nenue@90 18 if Veneer.ConfigMode then
Nenue@90 19 Veneer.ConfigMode = false
Nenue@90 20 else
Nenue@90 21 Veneer.ConfigMode = true
Nenue@90 22 end
Nenue@90 23 Veneer:UpdateConfigLayers()
Nenue@84 24 end
Nenue@88 25
Nick@109 26 Veneer.Frames = {}
Nick@109 27 Veneer.ConfigLayers = {}
Nick@109 28 Veneer.FrameClusters = {
Nick@109 29 [LE_FREE_FRAMES_GROUP] = {}
Nick@109 30 }
Nick@109 31 Veneer.parserDepth = 0
Nick@109 32 Veneer.pendingCalls = {}
Nick@109 33 Veneer.AddOnCheck = {}
Nenue@0 34
Nenue@59 35 local defaults = {
Nenue@59 36 enableAll = true,
Nenue@90 37 ConfigMode = true
Nenue@59 38 }
Nenue@84 39
Nenue@71 40 local configMode
Nenue@79 41 local anonID = 0
Nenue@79 42 local IsFrameHandle = IsFrameHandle
Nenue@79 43 local GetAnonymousName = function(key)
Nenue@79 44 if not key then
Nenue@71 45 anonID = anonID + 1
Nenue@79 46 key = anonID
Nenue@71 47 end
Nenue@79 48 return 'VN' .. key
Nenue@71 49 end
Nenue@79 50 local GetTableName = function(table)
Nenue@79 51 return (IsFrameHandle(table) and table:GetName()) or tostring(table)
Nenue@79 52 end
Nenue@79 53
Nenue@87 54 local OFFSET_PARALLELS = {
Nenue@87 55 TOP = {'LEFT', 'RIGHT', 'SetHeight'},
Nenue@87 56 BOTTOM = {'LEFT', 'RIGHT', 'SetHeight'},
Nenue@87 57 LEFT = {'TOP', 'BOTTOM', 'SetWidth'},
Nenue@87 58 RIGHT = {'TOP', 'BOTTOM', 'SetWidth'},
Nenue@87 59 }
Nenue@87 60 local ANCHOR_OFFSET_POINT = {
Nenue@87 61 TOP = 'BOTTOM',
Nenue@87 62 TOPLEFT = 'BOTTOMRIGHT',
Nenue@87 63 TOPRIGHT = 'BOTTOMLEFT',
Nenue@87 64 LEFT = 'RIGHT',
Nenue@87 65 RIGHT = 'LEFT',
Nenue@87 66 CENTER = 'CENTER',
Nenue@87 67 BOTTOM = 'TOP',
Nenue@87 68 BOTTOMRIGHT = 'TOPLEFT',
Nenue@87 69 BOTTOMLEFT = 'TOPRIGHT',
Nenue@87 70 }
Nenue@87 71 local ANCHOR_INSET_DELTA = {
Nenue@87 72 TOP = {0, -1},
Nenue@87 73 TOPLEFT = {1, -1},
Nenue@87 74 TOPRIGHT = {-1,-1},
Nenue@87 75 LEFT = {1, 0},
Nenue@87 76 BOTTOMLEFT = {1, 1},
Nenue@87 77 BOTTOM = {0, 1},
Nenue@87 78 BOTTOMRIGHT = {-1, 1},
Nenue@87 79 RIGHT = {-1, 0},
Nenue@87 80 CENTER = {0, 0},
Nenue@72 81 }
Nenue@72 82
Nick@109 83 function Veneer:print(...)
Nenue@84 84 local txt = '|cFFFFFF00Veneer|r:'
Nenue@84 85 for i = 1, select('#', ...) do
Nenue@84 86 txt = txt .. ' '.. tostring(select(i, ...))
Nenue@84 87 end
Nenue@84 88
Nenue@84 89 DEFAULT_CHAT_FRAME:AddMessage(txt)
Nenue@84 90 end
Nenue@84 91
Nick@109 92 function Veneer:OnLoad()
Nenue@84 93 print('|cFFFFFF00Veneer!|r')
Nenue@84 94 self:RegisterEvent('ADDON_LOADED')
Nenue@84 95 self:RegisterEvent('PLAYER_LOGIN')
Nenue@84 96
Nenue@84 97 self.DEVIAN_PNAME = 'Veneer'
Nenue@84 98 self:RegisterForDrag('LeftButton')
Nenue@88 99
Nenue@88 100
Nenue@84 101 end
Nenue@84 102
Nenue@90 103 local select, IsAddOnLoaded, IsLoggedIn = select, IsAddOnLoaded, IsLoggedIn
Nenue@90 104
Nick@109 105 function Veneer:OnEvent(event, ...)
Nenue@97 106 print('|cFFFF0088OnEvent()|r',event, ...)
Nenue@98 107 if (event == 'PLAYER_LOGIN') or (event == 'ADDON_LOADED') then
Nenue@90 108 print(IsLoggedIn(), self.initialized)
Nenue@84 109 if IsLoggedIn() and not self.intialized then
Nenue@84 110 self:Setup()
Nenue@90 111 self.intialized = true
Nenue@90 112 print('popping init sequence', self.intialized)
Nenue@90 113 end
Nenue@90 114
Nenue@90 115
Nenue@90 116 if self.intialized then
Nenue@90 117 local addon = ...
Nenue@90 118 if self.AddOnCheck[addon] then
Nenue@90 119 print(' - setting up '..addon..' dependent modules:')
Nenue@90 120 local keepChecking = false
Nenue@90 121 for index, handler in ipairs(self.AddOnCheck[addon]) do
Nenue@90 122 print(' -', handler:GetName(), (not handler.initialized) and (handler.addonFrame and not _G[handler.addonFrame]))
Nenue@90 123 if not handler.initialized then
Nenue@90 124 print(' '..handler:GetName()..':Setup()')
Nenue@90 125 handler:Setup()
Nenue@90 126 handler.initialized = true
Nenue@90 127 end
Nenue@90 128 end
Nenue@90 129 if not keepChecking then
Nenue@90 130 self.AddOnCheck[addon] = nil
Nenue@90 131 end
Nenue@90 132 end
Nenue@84 133 end
Nenue@84 134 end
Nenue@84 135 end
Nenue@84 136
Nick@109 137 function Veneer:OnDragStart()
Nenue@84 138 self:StartMoving()
Nenue@84 139 end
Nenue@84 140
Nick@109 141 function Veneer:OnDragStop()
Nenue@84 142 self:StopMovingOrSizing()
Nenue@84 143 end
Nenue@84 144
Nenue@93 145 local VeneerModule_Setup = function(frame)
Nenue@97 146 if not frame.initialized then
Nenue@97 147 local doSetup = (not frame.addonTrigger) or select(2, IsAddOnLoaded(frame.addonTrigger))
Nenue@97 148 print(' '..frame:GetName()..'.doSetup =', doSetup)
Nenue@97 149 if doSetup then
Nenue@93 150 frame:Setup()
Nenue@93 151 frame.initialized = true
Nenue@98 152 else
Nick@109 153 frame:RegisterEvent('ADDON_LOADED')
Nenue@93 154 end
Nenue@97 155
Nenue@93 156 end
Nenue@93 157 end
Nenue@93 158
Nick@109 159 function Veneer:Setup ()
Nenue@97 160 print('|cFFFF0088Setup()|r')
Nenue@90 161 local resetConfig = (not VeneerData)
Nenue@90 162 if (not VeneerData) then
Nenue@84 163 VeneerData = defaults
Nenue@90 164 VeneerData.version = VENEER_VERSION
Nenue@84 165 end
Nenue@84 166 self.data = VeneerData
Nenue@93 167 self:ExecuteOnClusters(nil, VeneerModule_Setup)
Nenue@90 168
Nenue@90 169 self.ConfigMode = VeneerData.ConfigMode
Nenue@90 170 self:UpdateConfigLayers()
Nenue@90 171 self:Reanchor()
Nenue@90 172 self:Update()
Nenue@87 173 end
Nenue@84 174
Nick@109 175 function Veneer:UpdateConfigLayers()
Nenue@90 176 if VeneerData then
Nenue@90 177
Nenue@90 178 VeneerData.ConfigMode = self.ConfigMode
Nenue@90 179 end
Nenue@90 180
Nenue@90 181 self:print('Config mode '..(self.ConfigMode and '|cFF00FF00ON|r' or '|cFFFF0000OFF|r')..'.')
Nenue@90 182 self:ExecuteOnClusters(nil, function(frame)
Nenue@90 183 if frame.UpdateConfigLayers then
Nenue@90 184 frame:UpdateConfigLayers(self.ConfigMode)
Nenue@90 185 end
Nenue@90 186
Nenue@90 187
Nenue@90 188 if type(frame.ConfigLayer) == 'table' then
Nenue@90 189 for index, region in ipairs(frame.ConfigLayer) do
Nenue@90 190 print('setting', frame:GetName() .. '['.. index..']', 'to', self.ConfigMode)
Nenue@90 191
Nenue@90 192 region:SetShown(self.ConfigMode)
Nenue@90 193 end
Nenue@90 194 end
Nenue@90 195
Nenue@90 196 self.ConfigLayers[frame] = frame:IsShown()
Nenue@90 197 if self.ConfigMode then
Nenue@90 198 print(frame:GetName(), self.ConfigLayers[frame])
Nenue@90 199 frame:SetShown(self.ConfigMode)
Nenue@90 200 else
Nenue@90 201 frame:SetShown(self.ConfigLayers[frame])
Nenue@90 202 end
Nenue@90 203 end)
Nenue@90 204 end
Nenue@84 205
Nenue@93 206
Nick@109 207 function Veneer:GetClusterFromArgs (...)
Nenue@87 208 local primaryAnchor
Nenue@87 209 local insertPosition
Nick@108 210 local insertPriority
Nenue@90 211
Nenue@90 212
Nenue@87 213 local clusterTable = self.FrameClusters
Nenue@87 214 for i = 1, select('#', ...) do
Nenue@87 215 local arg = select(i, ...)
Nenue@87 216 local argType = type(arg)
Nenue@87 217 if argType == 'string' then
Nenue@87 218 if not primaryAnchor then
Nenue@87 219 primaryAnchor = arg
Nenue@87 220 end
Nenue@87 221 clusterTable[arg] = clusterTable[arg] or {}
Nenue@87 222 clusterTable = clusterTable[arg]
Nenue@93 223 print(strrep(' ', i)..'anchor cluster', i, arg)
Nenue@87 224 elseif argType == 'boolean' then
Nick@108 225 if arg == true then
Nick@108 226 print('force top position')
Nick@108 227 insertPosition = 1
Nick@108 228 insertPriority = nil
Nick@108 229 end
Nick@108 230 elseif argType == 'number' then
Nick@108 231 insertPriority = arg
Nenue@87 232 end
Nenue@87 233 end
Nick@108 234
Nick@108 235 if insertPriority then
Nick@108 236 for i = 1, #clusterTable do
Nick@108 237 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > insertPriority) then
Nick@108 238 print('prioritized insert position:', insertPriority, insertPosition)
Nick@108 239 break
Nick@108 240 else
Nick@108 241 print('passing lower priority frame:', clusterTable[i]:GetName())
Nick@108 242 end
Nick@108 243 insertPosition = i
Nick@108 244 end
Nick@108 245 end
Nick@108 246
Nick@108 247
Nenue@87 248 if not primaryAnchor then
Nenue@97 249 primaryAnchor = 'CENTER'
Nenue@97 250 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {}
Nenue@97 251 clusterTable = clusterTable[primaryAnchor]
Nick@108 252 print('using default anchor')
Nenue@87 253 end
Nick@108 254
Nenue@87 255 if not insertPosition then
Nenue@87 256 insertPosition = #clusterTable + 1
Nick@108 257 print('using default position')
Nenue@87 258 end
Nenue@87 259 return primaryAnchor, clusterTable, insertPosition
Nenue@84 260 end
Nenue@84 261
Nick@108 262 -- args: frame object, list of anchor groups, true for forced top, number for priority layer
Nick@109 263 function Veneer:AddHandler(handler, ...)
Nenue@97 264 print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName())
Nenue@87 265
Nick@108 266
Nick@108 267 for k,v in pairs(VeneerHandlerMixin) do
Nick@108 268 if not handler[k] then
Nick@108 269 print(' * from mixin:', k)
Nick@108 270 handler[k] = v
Nick@108 271 end
Nick@108 272 end
Nick@108 273
Nenue@102 274 if not handler.anchorFrame then
Nick@108 275 local anchorGroup, clusterTable, clusterIndex, clusterPriority = self:GetClusterFromArgs(...)
Nenue@90 276 if clusterIndex == 1 then
Nenue@90 277 for i, frame in ipairs(clusterTable) do
Nenue@90 278 frame.clusterIndex = i + 1
Nenue@90 279 end
Nenue@87 280 end
Nenue@90 281 tinsert(clusterTable, clusterIndex, handler)
Nenue@102 282 print(' cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex)
Nenue@90 283
Nenue@102 284 handler.anchorCluster = clusterTable
Nenue@102 285 handler.anchorIndex = clusterIndex
Nenue@102 286 else
Nenue@103 287 local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP]
Nenue@103 288 handler.anchorCluster = clusterTable
Nenue@103 289 handler.anchorIndex = #clusterTable+1
Nenue@103 290 tinsert(clusterTable, handler.anchorIndex, handler)
Nenue@102 291 print(' free frame')
Nenue@102 292 end
Nenue@87 293
Nenue@90 294 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then
Nenue@90 295 print('|cFFFF4400 -- dependency:', handler.addonTrigger)
Nenue@90 296 self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {}
Nenue@90 297 tinsert(self.AddOnCheck[handler.addonTrigger], handler)
Nenue@90 298 end
Nenue@90 299
Nenue@87 300 if self.initialized then
Nenue@90 301 print(' -- initialization check')
Nenue@90 302 if handler.Setup then
Nenue@90 303 local doInit = (not handler.initialized)
Nenue@90 304 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then
Nenue@90 305 doInit = false
Nenue@90 306 end
Nenue@90 307 -- room to add other checks
Nenue@90 308
Nenue@90 309 if doInit then
Nenue@90 310 handler:Setup()
Nenue@90 311 handler.initialized = true
Nenue@90 312 self:InternalReanchor(handler)
Nenue@90 313 end
Nenue@87 314 end
Nenue@87 315 end
Nenue@87 316 end
Nenue@87 317
Nick@109 318 function Veneer:Reanchor()
Nenue@87 319 self:ExecuteOnClusters(nil, 'Reanchor')
Nenue@88 320 self:DynamicReanchor(self)
Nenue@87 321 end
Nenue@87 322
Nick@109 323 function Veneer:Update()
Nenue@90 324 self:ExecuteOnClusters(nil, function(frame)
Nenue@90 325 if frame.initialized and frame.Update then
Nenue@90 326 frame:Update()
Nenue@90 327 end
Nenue@90 328 end)
Nenue@88 329 self:Reanchor()
Nenue@87 330 end
Nenue@87 331
Nenue@87 332 -- updates anchor relations to and from the target handler
Nick@109 333 function Veneer:GetAnchor(...)
Nenue@87 334
Nenue@87 335 end
Nenue@87 336
Nenue@88 337 -- Evaluates frames visibility and chains them accordingly
Nenue@88 338
Nick@109 339 function Veneer:DynamicReanchor(parent)
Nenue@88 340 parent = parent or self
Nenue@88 341 print('|cFF88FF00DynamicReanchor()')
Nenue@88 342 for anchorPoint, cluster in pairs(parent.FrameClusters) do
Nenue@103 343 if anchorPoint ~= LE_FREE_FRAMES_GROUP then
Nenue@103 344 local lastFrame
Nenue@103 345 for index, frame in ipairs(cluster) do
Nick@108 346 print(' |cFF00FF00'..index, frame:GetName(), frame:IsShown(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent'))
Nick@108 347 if frame:IsShown() then
Nenue@90 348
Nenue@103 349 if frame.anchorFrame then
Nenue@103 350 print(frame.anchorPoint)
Nenue@103 351 frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY)
Nenue@103 352 print(frame:GetTop(), frame:GetRight())
Nenue@90 353 else
Nenue@103 354 anchorPoint = frame.anchorPoint or anchorPoint
Nenue@103 355 frame:ClearAllPoints()
Nenue@103 356 if lastFrame then
Nenue@103 357 frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0)
Nenue@103 358 else
Nenue@103 359 frame:SetPoint(anchorPoint, UIParent, anchorPoint, frame.anchorX, frame.anchorY)
Nenue@103 360 end
Nenue@103 361 print(frame:GetTop(), frame:GetRight())
Nenue@103 362 lastFrame = frame
Nenue@90 363 end
Nenue@103 364
Nenue@88 365 end
Nenue@90 366
Nenue@88 367 end
Nenue@103 368 end
Nenue@88 369
Nenue@88 370 end
Nenue@88 371 end
Nenue@88 372
Nenue@88 373 -- Evaluates the current visibility state and re-anchors adjacent blocks accordingly
Nick@109 374 function Veneer:InternalReanchor(handler, printFunc)
Nenue@87 375 print('|cFF00FFFFVeneer:InternalReanchor('..handler:GetName()..')')
Nenue@90 376 if handler.anchorFrame then
Nenue@90 377 handler:SetPoint(handler.anchorPoint, handler.anchorFrame, handler.anchorFrom, handler.anchorX, handler.anchorY)
Nenue@90 378 return
Nenue@90 379 end
Nenue@90 380
Nenue@90 381
Nenue@87 382 local anchorPoint = handler.anchorPath or handler.anchorPoint
Nenue@87 383 local anchorParent, anchorTo = UIParent, anchorPoint
Nenue@88 384 local subPoint, subTo
Nenue@88 385 local nextFrame
Nenue@88 386 for index, frame in ipairs(handler.anchorCluster) do
Nenue@88 387 print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible())
Nick@108 388 if frame:IsShown() then
Nenue@88 389 if frame ~= handler then
Nenue@88 390 anchorParent = frame
Nenue@88 391 anchorTo = ANCHOR_OFFSET_POINT[anchorPoint]
Nenue@87 392
Nenue@88 393 else
Nenue@88 394 nextFrame = handler.anchorCluster[index+1]
Nenue@88 395 if nextFrame then
Nenue@88 396
Nenue@88 397 subPoint = nextFrame.anchorPath or nextFrame.anchorPoint
Nenue@88 398 subTo = ANCHOR_OFFSET_POINT[subPoint]
Nenue@88 399 nextFrame:ClearAllPoints()
Nenue@88 400 nextFrame:SetPoint(subPoint, handler, subTo, 0, 0)
Nenue@88 401 print(' -- pushing '..nextFrame:GetName()..' down the anchor chain', subPoint, subTo)
Nenue@88 402 end
Nenue@88 403 break
Nenue@87 404 end
Nenue@87 405 end
Nenue@87 406 end
Nenue@87 407
Nick@108 408 if handler:IsShown() then
Nenue@88 409 handler:SetPoint(anchorPoint, anchorParent, anchorTo, 0, 0)
Nenue@88 410 else
Nenue@88 411 if anchorParent and nextFrame then
Nenue@88 412 nextFrame:SetPoint(subPoint, handler, subTo, 0, 0)
Nenue@88 413 end
Nenue@88 414 end
Nenue@88 415
Nenue@87 416
Nenue@87 417 print(handler.anchorPoint, anchorParent, anchorTo)
Nenue@87 418 if printFunc then
Nenue@87 419 printFunc('|cFF88FF00'..handler:GetName()..':SetPoint(', handler.anchorPoint, anchorParent, anchorTo)
Nenue@87 420 end
Nenue@88 421 end
Nenue@87 422
Nick@109 423 function Veneer:SlideBlock(frame, ...)
Nenue@89 424 local aX, aY = frame:GetLeft(), frame:GetTop()
Nenue@88 425
Nenue@89 426 frame:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', aX, aY)
Nenue@89 427 frame.animation = frame.animation or {}
Nenue@89 428 frame.animation.startX = aX
Nenue@89 429 frame.animation.startY = aY
Nenue@88 430
Nenue@89 431 local targetPoint, targetParent, targetAnchor, offsetX, offsetY = ...
Nenue@89 432 frame.BlockSlide:SetScript('OnFinished', function()
Nenue@89 433 frame:SetPoint(targetPoint, targetParent, targetAnchor, offsetX, offsetY)
Nenue@89 434 VeneerAnimationMixin.OnFinished(frame)
Nenue@89 435 end)
Nenue@88 436
Nenue@84 437 end
Nenue@84 438
Nenue@88 439
Nick@109 440 function Veneer:ExecuteOnClusters(layer, method)
Nenue@84 441 self.parserDepth = self.parserDepth + 1
Nenue@84 442 if not layer then
Nenue@87 443 if self.parserDepth > 1 then
Nenue@84 444 tinsert(self.pendingCalls, method)
Nenue@84 445 print('delaying walk for', method)
Nenue@84 446 return
Nenue@84 447 end
Nenue@97 448 print('|cFF00FF00ExecuteOnClusters|r('..tostring(layer)..', '..tostring(method)..')')
Nenue@84 449 else
Nenue@87 450 print(' Level '..self.parserDepth)
Nenue@84 451 end
Nenue@87 452
Nenue@87 453 layer = layer or self.FrameClusters
Nenue@84 454 for anchor, cluster in pairs(layer) do
Nenue@84 455 for index, frame in ipairs(cluster) do
Nenue@87 456 print(' '..anchor..'.'..index..' = '..frame:GetName())
Nenue@90 457 if type(method) == 'function' then
Nenue@90 458 method(frame, true)
Nenue@90 459 elseif frame[method] then
Nenue@87 460 print(' |cFF00FF00'..frame:GetName())
Nenue@87 461 frame[method](frame, true)
Nenue@84 462 end
Nenue@84 463 end
Nenue@84 464 if cluster.FrameClusters then
Nenue@84 465 self:ExecuteOnClusters(cluster.FrameClusters, method)
Nenue@84 466 end
Nenue@84 467 end
Nenue@84 468 self.parserDepth = self.parserDepth - 1
Nenue@84 469
Nenue@84 470 if (self.parserDepth == 0) and (#self.pendingCalls >= 1) then
Nenue@84 471 local delayedMethod = tremove(self.pendingCalls, 1)
Nenue@84 472 print('starting delayed walk for', delayedMethod)
Nenue@84 473 self:ExecuteOnClusters(nil, delayedMethod)
Nenue@84 474 end
Nenue@84 475 end
Nenue@84 476
Nenue@72 477
Nenue@71 478
Nenue@88 479 -- Takes frame handle and assigns a block to it
Nick@109 480 function Veneer:Acquire (frame, template)
Nenue@71 481 if not frame then
Nenue@71 482 print('|cFFFF4400Unable to acquire frame...|r')
Nenue@71 483 return
Nenue@71 484 end
Nenue@84 485 local veneer = self.Frames[frame]
Nenue@84 486 if not veneer then
Nenue@94 487 local name = GetAnonymousName()
Nenue@94 488 veneer = CreateFrame('Frame', name, frame, template)
Nenue@90 489 print(self:GetName()..':Acquire()', frame:GetName(), template)
Nenue@71 490
Nenue@84 491 veneer:SetAllPoints(frame)
Nenue@84 492 veneer:SetParent(frame)
Nenue@84 493 veneer.label:SetText(name)
Nenue@84 494 veneer.bg:SetColorTexture(0,0,0,0)
Nenue@84 495 veneer:Hide()
Nenue@84 496 veneer:EnableMouse(false)
Nenue@84 497 -- find current X/Y
Nenue@84 498 veneer.currentLeft = frame:GetLeft()
Nenue@84 499 veneer.currentTop = frame:GetTop()
Nenue@84 500 self.Frames[frame] = veneer
Nenue@71 501 end
Nenue@84 502 return veneer
Nick@109 503 end
Nick@109 504
Nick@109 505 VeneerCore = Veneer