Mercurial > wow > devian
diff 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 |
line wrap: on
line diff
--- a/Dock.lua Thu Oct 27 06:11:04 2016 -0400 +++ b/Dock.lua Tue Jan 17 14:25:18 2017 -0500 @@ -21,26 +21,30 @@ function DevianDockTabMixin:OnMouseDown(button) --print("click", self:GetName(), button, self.console.index) + local console = self.console if button == "LeftButton" then if IsShiftKeyDown() then - self.console:Toggle() + DevianDock:ToggleAll(console) else - if self.console.isFront or (not self.console.enabled) then - self.console:Toggle() - if self.console.enabled then - if self.console.minimized then - self.console:MinMax() + console.newMessage = nil + if console.isFront or (not console.enabled) then + + console:Toggle() + if console.enabled then + if console.minimized then + console:MinMax() end - self.console:ToFront() + console:ToFront() end else - self.console:ToFront() + console:ToFront() end end elseif button == "RightButton" then - self.console:MinMax() + console:MinMax() end + DevianDock:Update() end function DevianDockTabMixin:OnShow() self:Update() @@ -48,13 +52,13 @@ function DevianDockTabMixin:OnEnter() end function DevianDockTabMixin:Update() - local db = D.db - local isActive = (self.raised or self.selected or self.newMessage) + local console = self.console + local isActive = (console.isFront or console.newMessage) - if (self.showName or isActive) then - self.caption:SetAlpha(1) - else - self.caption:SetAlpha(0.5) + if console.newMessage and (not self.pulse:IsPlaying()) then + self.pulse:Play() + elseif not console.newMessage then + self.pulse:Stop() end if self.selected then @@ -63,18 +67,18 @@ self.Background:SetColorTexture(0,0,0,.5) end - if (not self.showName) and (not isActive) then - --print(self:GetName(), 'no name no active, fade out') + if isActive then + self:SetAlpha(1) + else self:SetAlpha(0.5) - else - self:SetAlpha(1) end + + self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING) end function DevianDockTabMixin:Select() - self.caption.pulse:Stop() self:Update() end @@ -150,6 +154,10 @@ local drawWidth = 0 local lastButton local numButtons = 0 + local numOpen = 0 + local numBackground = 0 + local numClosed = 0 + local numMinimized = 0 for i, d in ipairs(self.buttons) do if d and d:IsShown() then d:SetScale(D.dockScale or 1) @@ -159,15 +167,55 @@ d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', pad_offset, 0) end + local console = d.console + if console.enabled then + numOpen = numOpen + 1 + if not console.isFront then + numBackground = numBackground + 1 + end + + else + numClosed = numClosed + 1 + end + if console.minimized then + numMinimized = numMinimized + 1 + end + + d:Update() + drawWidth = drawWidth + d:GetWidth() + pad_offset lastButton = d numButtons = numButtons + 1 print(numButtons) end end - self.numButtons = numButtons + + self.numOpen, self.numMinimized, self.numClosed, self.numButtons, self.numBackground = numOpen, numMinimized, numClosed, numButtons, numBackground self:SetWidth(drawWidth) D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) end + + +function DevianDockHandler:ToggleAll(sender) + local keepSender = IsShiftKeyDown() and sender + local senderID = sender and sender:GetID() + local op, arg = 'Toggle', false + if (keepSender and (self.numBackground == 0)) or (self.numOpen == 0) then + arg = true + elseif self.numClosed == 0 then + arg = false + end + + for index, button in ipairs(self.buttons) do + local frame = button.console + if frame then + if not((frame.index == senderID) and keepSender) then + frame[op](frame, arg) + end + + end + end + self:Update() +end \ No newline at end of file