comparison 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
comparison
equal deleted inserted replaced
121:1f68c46bc4de 122:ea2c616a3b4f
38 38
39 function ConfigLayer:OnShow() 39 function ConfigLayer:OnShow()
40 self:Update() 40 self:Update()
41 end 41 end
42 42
43 local AnchorButton_OnClick = function(self)
44
45 local module = self:GetParent().handler
46 module.anchorPoint = self.anchorPoint
47 module:Print('Anchor set to '.. self.anchorPoint)
48 self:GetParent():Update()
49 end
50
51 local RelativeButton_OnClick = function(self)
52 end
53
54 local RelativeButton_OnDragStart = function(self) end
55 local RelativeButton_OnDragStop = function(self) end
56
57
43 function ConfigLayer:Update() 58 function ConfigLayer:Update()
44 if not self.anchorButtons then 59 if not self.anchorButtons then
45 self.anchorButtons = {} 60 self.anchorButtons = {}
46 for _, anchorPoint in ipairs(ANCHOR_BUTTON_TYPES) do 61 for _, anchorPoint in ipairs(ANCHOR_BUTTON_TYPES) do
47 local button = CreateFrame('Button', nil, self, 'VeneerAnchorButtonTemplate') 62 local button = CreateFrame('Button', nil, self, 'VeneerAnchorButtonTemplate')
48 button.anchorPoint = anchorPoint 63 button.anchorPoint = anchorPoint
49 button:SetScript('OnMouseDown', function() end) 64 button:RegisterForClicks('AnyUp')
50 button:SetScript('OnMouseUp', function() end) 65 button:SetScript('OnClick', AnchorButton_OnClick)
51 button:SetPoint(anchorPoint) 66 button:SetPoint(anchorPoint)
52 button:SetSize(16,16) 67 button:SetSize(16,16)
53 68
54 self.anchorButtons[anchorPoint] = button 69 self.anchorButtons[anchorPoint] = button
55 end 70 end
61 else 76 else
62 button:GetNormalTexture():SetColorTexture(0.5,0.5,0.5,1) 77 button:GetNormalTexture():SetColorTexture(0.5,0.5,0.5,1)
63 end 78 end
64 end 79 end
65 80
81 if self.handler.anchorFrom and self.handler.anchorFrame then
82 local rb = self.relativeButton
83 if not rb then
84 rb = CreateFrame('Button', nil, self, 'VeneerAnchorButtonTemplate')
85 self.relativeButton = rb
86 rb:RegisterForClicks('AnyUp')
87 rb:RegisterForDrag('AnyDown')
88 rb:SetScript('OnClick', RelativeButton_OnClick)
89 rb:SetScript('OnDragStart', RelativeButton_OnDragStart)
90 rb:SetScript('OnDragStop', RelativeButton_OnDragStop)
91 end
92
93 print('|cFF00FF88Config|r',self.handler.anchorFrom, self.handler.anchorFrame)
94 rb:SetPoint(self.handler.anchorFrom, _G[self.handler.anchorFrame], self.handler.anchorFrom, 0, 0)
95 print(rb:GetPoint(1))
96 rb:GetNormalTexture():SetColorTexture(1,1,1,1)
97 rb:SetSize(16,16)
98 end
99
100
66 self:RegisterForDrag('LeftButton') 101 self:RegisterForDrag('LeftButton')
67 end 102 end
68 103
104
105
69 function ConfigLayer:OnDragStart() 106 function ConfigLayer:OnDragStart()
70 107 self.originalX, self.originalY = self:GetCenter()
108 self.handler:SetMovable(true)
109 self.handler:StartMoving()
71 end 110 end
72 function ConfigLayer:OnDragStop() 111 function ConfigLayer:OnDragStop()
73 112
113 local newX, newY = self:GetCenter()
114 local dX = newX - self.originalX
115 local dY = newY - self.originalY
116 print('registering new X/Y:', dX, dY)
117
118
119 self.handler:StopMovingOrSizing()
74 end 120 end
75 121
76 function ConfigLayer:OnUpdate() 122 function ConfigLayer:OnUpdate()
77 local handler = self:GetParent() 123 local handler = self:GetParent()
78 handler.ConfigLayers = handler.ConfigLayers or {} 124 handler.ConfigLayers = handler.ConfigLayers or {}
99 end 145 end
100 146
101 -- Replace if module requires anything besides fixing frame anchors 147 -- Replace if module requires anything besides fixing frame anchors
102 function Handler:OnShow() 148 function Handler:OnShow()
103 self:Reanchor() 149 self:Reanchor()
104 Veneer:StaticReanchor(self) 150 _G.Veneer:StaticReanchor(self)
105 end 151 end
106 function Handler:OnHide() 152 function Handler:OnHide()
107 Veneer:DynamicReanchor() 153 _G.Veneer:DynamicReanchor()
108 end 154 end
109 function Handler:Reanchor (anchorAll) 155 function Handler:Reanchor (anchorAll)
110 Veneer:DynamicReanchor() 156 _G.Veneer:DynamicReanchor()
111 end 157 end
112 158
113 -- Replace if module needs to do more than reconcile SavedVariables pointers 159 -- Replace if module needs to do more than reconcile SavedVariables pointers
114 function Handler:Setup() 160 function Handler:Setup()
115 print(self:GetName(), '|cFF00FF88Setup()') 161 print(self:GetName(), '|cFF00FF88Setup()')