comparison Dock.lua @ 100:790dca545f1d v3.0

- Configuration structure overheal; clearing 'Devian.lua' from SaveVariables will be necessary - Removed dependence on embedded libraries. - Console/dock frames are now implemented as XML mixin structures - Console dropdown menu option to 'Pin' frames - Hold SHIFT while clicking dock buttons will cause all but that tab to be closed
author Nenue
date Tue, 17 Jan 2017 14:25:18 -0500
parents 7d94df3804a7
children
comparison
equal deleted inserted replaced
99:7d94df3804a7 100:790dca545f1d
19 } 19 }
20 DevianDockTabMixin = {} 20 DevianDockTabMixin = {}
21 21
22 function DevianDockTabMixin:OnMouseDown(button) 22 function DevianDockTabMixin:OnMouseDown(button)
23 --print("click", self:GetName(), button, self.console.index) 23 --print("click", self:GetName(), button, self.console.index)
24 local console = self.console
24 if button == "LeftButton" then 25 if button == "LeftButton" then
25 if IsShiftKeyDown() then 26 if IsShiftKeyDown() then
26 self.console:Toggle() 27 DevianDock:ToggleAll(console)
27 else 28 else
28 if self.console.isFront or (not self.console.enabled) then 29
29 30 console.newMessage = nil
30 self.console:Toggle() 31 if console.isFront or (not console.enabled) then
31 if self.console.enabled then 32
32 if self.console.minimized then 33 console:Toggle()
33 self.console:MinMax() 34 if console.enabled then
35 if console.minimized then
36 console:MinMax()
34 end 37 end
35 self.console:ToFront() 38 console:ToFront()
36 end 39 end
37 else 40 else
38 self.console:ToFront() 41 console:ToFront()
39 end 42 end
40 end 43 end
41 elseif button == "RightButton" then 44 elseif button == "RightButton" then
42 self.console:MinMax() 45 console:MinMax()
43 end 46 end
47 DevianDock:Update()
44 end 48 end
45 function DevianDockTabMixin:OnShow() 49 function DevianDockTabMixin:OnShow()
46 self:Update() 50 self:Update()
47 end 51 end
48 function DevianDockTabMixin:OnEnter() 52 function DevianDockTabMixin:OnEnter()
49 end 53 end
50 function DevianDockTabMixin:Update() 54 function DevianDockTabMixin:Update()
51 local db = D.db 55 local console = self.console
52 local isActive = (self.raised or self.selected or self.newMessage) 56 local isActive = (console.isFront or console.newMessage)
53 57
54 if (self.showName or isActive) then 58 if console.newMessage and (not self.pulse:IsPlaying()) then
55 self.caption:SetAlpha(1) 59 self.pulse:Play()
56 else 60 elseif not console.newMessage then
57 self.caption:SetAlpha(0.5) 61 self.pulse:Stop()
58 end 62 end
59 63
60 if self.selected then 64 if self.selected then
61 self.Background:SetColorTexture(0.4,0.4,0.4,1) 65 self.Background:SetColorTexture(0.4,0.4,0.4,1)
62 else 66 else
63 self.Background:SetColorTexture(0,0,0,.5) 67 self.Background:SetColorTexture(0,0,0,.5)
64 end 68 end
65 69
66 if (not self.showName) and (not isActive) then 70 if isActive then
67 --print(self:GetName(), 'no name no active, fade out') 71 self:SetAlpha(1)
72 else
68 self:SetAlpha(0.5) 73 self:SetAlpha(0.5)
69 else 74 end
70 self:SetAlpha(1) 75
71 end 76
72 77
73 self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING) 78 self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING)
74 end 79 end
75 80
76 function DevianDockTabMixin:Select() 81 function DevianDockTabMixin:Select()
77 self.caption.pulse:Stop()
78 self:Update() 82 self:Update()
79 end 83 end
80 84
81 --- Spaces each frame evenly across the screen. 85 --- Spaces each frame evenly across the screen.
82 function D:DistributeFrames() -- 86 function D:DistributeFrames() --
148 function DevianDockHandler:Update() 152 function DevianDockHandler:Update()
149 local pad_offset = 12 153 local pad_offset = 12
150 local drawWidth = 0 154 local drawWidth = 0
151 local lastButton 155 local lastButton
152 local numButtons = 0 156 local numButtons = 0
157 local numOpen = 0
158 local numBackground = 0
159 local numClosed = 0
160 local numMinimized = 0
153 for i, d in ipairs(self.buttons) do 161 for i, d in ipairs(self.buttons) do
154 if d and d:IsShown() then 162 if d and d:IsShown() then
155 d:SetScale(D.dockScale or 1) 163 d:SetScale(D.dockScale or 1)
156 if lastButton then 164 if lastButton then
157 d:SetPoint('TOPLEFT', lastButton, 'TOPRIGHT', pad_offset, 0) 165 d:SetPoint('TOPLEFT', lastButton, 'TOPRIGHT', pad_offset, 0)
158 else 166 else
159 d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', pad_offset, 0) 167 d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', pad_offset, 0)
160 end 168 end
161 169
170 local console = d.console
171 if console.enabled then
172 numOpen = numOpen + 1
173 if not console.isFront then
174 numBackground = numBackground + 1
175 end
176
177 else
178 numClosed = numClosed + 1
179 end
180 if console.minimized then
181 numMinimized = numMinimized + 1
182 end
183
184 d:Update()
185
162 drawWidth = drawWidth + d:GetWidth() + pad_offset 186 drawWidth = drawWidth + d:GetWidth() + pad_offset
163 lastButton = d 187 lastButton = d
164 numButtons = numButtons + 1 188 numButtons = numButtons + 1
165 print(numButtons) 189 print(numButtons)
166 end 190 end
167 end 191 end
168 self.numButtons = numButtons 192
193 self.numOpen, self.numMinimized, self.numClosed, self.numButtons, self.numBackground = numOpen, numMinimized, numClosed, numButtons, numBackground
169 self:SetWidth(drawWidth) 194 self:SetWidth(drawWidth)
170 195
171 D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' 196 D.db.dockPoint = D.db.dockPoint or 'TOPLEFT'
172 self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) 197 self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0)
173 end 198 end
199
200
201 function DevianDockHandler:ToggleAll(sender)
202 local keepSender = IsShiftKeyDown() and sender
203 local senderID = sender and sender:GetID()
204 local op, arg = 'Toggle', false
205 if (keepSender and (self.numBackground == 0)) or (self.numOpen == 0) then
206 arg = true
207 elseif self.numClosed == 0 then
208 arg = false
209 end
210
211 for index, button in ipairs(self.buttons) do
212 local frame = button.console
213 if frame then
214 if not((frame.index == senderID) and keepSender) then
215 frame[op](frame, arg)
216 end
217
218 end
219 end
220 self:Update()
221 end