diff Templates.lua @ 122:ea2c616a3b4f

Standardize anchor variables - anchorGroup sets general position, defers to anchorPoint - anchorPoint and anchorFrom are used in SetPoint, deferring to anchorGroup and its inverse Artifact Power: - scan and update triggers trimmed down BuffFrame: - extra values can be right clicked to hide for particular auras LFG: - Desolate Host link placed above Sisters when searching for best cheevos TalkingHead - Re-enable TalkingHeadFrame click behaviour
author Nenue
date Mon, 21 Aug 2017 22:15:46 -0400
parents 1f68c46bc4de
children 3f4794dca91b
line wrap: on
line diff
--- a/Templates.lua	Mon Jul 17 11:51:31 2017 -0400
+++ b/Templates.lua	Mon Aug 21 22:15:46 2017 -0400
@@ -40,14 +40,29 @@
   self:Update()
 end
 
+local AnchorButton_OnClick = function(self)
+
+  local module = self:GetParent().handler
+  module.anchorPoint = self.anchorPoint
+  module:Print('Anchor set to '.. self.anchorPoint)
+  self:GetParent():Update()
+end
+
+local RelativeButton_OnClick = function(self)
+end
+
+local RelativeButton_OnDragStart = function(self) end
+local RelativeButton_OnDragStop = function(self) end
+
+
 function ConfigLayer:Update()
   if not self.anchorButtons then
     self.anchorButtons = {}
     for _, anchorPoint in ipairs(ANCHOR_BUTTON_TYPES) do
       local button = CreateFrame('Button', nil, self, 'VeneerAnchorButtonTemplate')
       button.anchorPoint = anchorPoint
-      button:SetScript('OnMouseDown', function() end)
-      button:SetScript('OnMouseUp', function() end)
+      button:RegisterForClicks('AnyUp')
+      button:SetScript('OnClick', AnchorButton_OnClick)
       button:SetPoint(anchorPoint)
       button:SetSize(16,16)
 
@@ -63,14 +78,45 @@
     end
   end
 
+  if self.handler.anchorFrom and self.handler.anchorFrame then
+    local rb = self.relativeButton
+    if not rb then
+      rb = CreateFrame('Button', nil, self, 'VeneerAnchorButtonTemplate')
+      self.relativeButton = rb
+      rb:RegisterForClicks('AnyUp')
+      rb:RegisterForDrag('AnyDown')
+      rb:SetScript('OnClick', RelativeButton_OnClick)
+      rb:SetScript('OnDragStart', RelativeButton_OnDragStart)
+      rb:SetScript('OnDragStop', RelativeButton_OnDragStop)
+    end
+
+  print('|cFF00FF88Config|r',self.handler.anchorFrom, self.handler.anchorFrame)
+    rb:SetPoint(self.handler.anchorFrom, _G[self.handler.anchorFrame], self.handler.anchorFrom, 0, 0)
+  print(rb:GetPoint(1))
+    rb:GetNormalTexture():SetColorTexture(1,1,1,1)
+    rb:SetSize(16,16)
+  end
+
+
   self:RegisterForDrag('LeftButton')
 end
 
+
+
 function ConfigLayer:OnDragStart()
-
+  self.originalX, self.originalY = self:GetCenter()
+  self.handler:SetMovable(true)
+  self.handler:StartMoving()
 end
 function ConfigLayer:OnDragStop()
 
+  local newX, newY = self:GetCenter()
+  local dX = newX - self.originalX
+  local dY = newY - self.originalY
+  print('registering new X/Y:', dX, dY)
+
+
+  self.handler:StopMovingOrSizing()
 end
 
 function ConfigLayer:OnUpdate()
@@ -101,13 +147,13 @@
 -- Replace if module requires anything besides fixing frame anchors
 function Handler:OnShow()
   self:Reanchor()
-  Veneer:StaticReanchor(self)
+  _G.Veneer:StaticReanchor(self)
 end
 function Handler:OnHide()
-  Veneer:DynamicReanchor()
+  _G.Veneer:DynamicReanchor()
 end
 function Handler:Reanchor (anchorAll)
-  Veneer:DynamicReanchor()
+  _G.Veneer:DynamicReanchor()
 end
 
 -- Replace if module needs to do more than reconcile SavedVariables pointers