view Modules/TalkingHead.lua @ 101:f32b63c93275

- implement caching to reduce the number of tooltip queries made for each scan prompt
author Nenue
date Sat, 21 Jan 2017 20:12:17 -0500
parents caded2668701
children 1e511e9aaca5
line wrap: on
line source
-- Veneer
-- TalkingHead.lua
-- Created: 10/23/2016 5:18 AM
-- %file-revision%
--


local print = DEVIAN_WORKSPACE and function(...) print('VnTalkingHead', ...) end or nop

VeneerTalkingHeadMixin = {

  anchorPoint = 'BOTTOMLEFT',
  anchorFrom = 'TOPLEFT',
  anchorX = -4,
  anchorY = 24,
  anchorFrame = 'ChatFrame1',
  addonTrigger = 'Blizzard_TalkingHeadUI'

}

local qf = {}


function VeneerTalkingHeadMixin:OnLoad()
  Veneer:AddHandler(self, self.anchorPoint)
end

function VeneerTalkingHeadMixin:Setup()
  print('|cFF00AAFF'..self:GetName()..'|r:Setup()', TalkingHeadFrame:IsShown(), self:IsShown())

  self:SetSize(TalkingHeadFrame:GetSize())
  self:SetParent(TalkingHeadFrame)

  hooksecurefunc(TalkingHeadFrame, 'SetPoint', function(...)
    print('SetPoint', ...)
    print(debugstack())
  end)

  self:SetShown(true)
  self:ClearAnchor()
end

function VeneerTalkingHeadMixin:ClearAnchor()

  UIPARENT_MANAGED_FRAME_POSITIONS["TalkingHeadFrame"] = nil
  for i, alertSubSystem in pairs(AlertFrame.alertFrameSubSystems) do
    if alertSubSystem.anchorFrame == TalkingHeadFrame then
      tremove(AlertFrame.alertFrameSubSystems, i)
      return
    end
  end
end

function VeneerTalkingHeadMixin:OnShow()
  if TalkingHeadFrame then
    print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', TalkingHeadFrame:IsShown(), self:IsShown())
    print(debugstack())
    self:Update()
  end
end

function VeneerTalkingHeadMixin:Reanchor()
  self:ClearAllPoints()
  self:SetPoint('BOTTOMLEFT', _G[self.anchorFrame], 'TOPLEFT', -4, 24)
  self:SetPoint('RIGHT', _G[self.anchorFrame], 'RIGHT', 2, 0)
  -- independent module,
end

function VeneerTalkingHeadMixin:OnHide()
  if TalkingHeadFrame then
    print('|cFF00AAFF'..self:GetName()..'|r:OnHide()', TalkingHeadFrame:IsShown(), self:IsShown())
  end
  Veneer:Reanchor()
end

function VeneerTalkingHeadMixin:Update()

  print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', TalkingHeadFrame:IsShown(), self:IsShown())
  TalkingHeadFrame:ClearAllPoints()
  TalkingHeadFrame:SetAllPoints(self)

  Veneer:InternalReanchor(self)
end