Mercurial > wow > devian
view Dock.lua @ 50:c3166f700438
dock beacons and text fader cleaned up
fixed OnLeave ending at mouseOverDock false and causing beacons to stick
fixed a nil argument in dock framescript
author | Nenue |
---|---|
date | Tue, 05 Jan 2016 01:37:29 -0500 |
parents | 2bf7eb1844cb |
children | 0a9a6740ea5d |
line wrap: on
line source
--- Devian - Dock.lua -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 12/26/2015 12:32 PM -- Docking and arrangement calls local D = LibStub("AceAddon-3.0"):GetAddon("Devian") local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight = math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight local UIFrameFadeIn, UIFrameFadeOut = UIFrameFadeIn, UIFrameFadeOut local db --- Spaces each frame evenly across the screen. function D:DistributeFrames() -- local max = self.num_channels local num_side = ceil(sqrt(max)) local w = GetScreenWidth() / num_side local h = GetScreenHeight() / num_side for i, frame in pairs(D.console) do local dx = (i-1) % num_side local dy = floor((i-1) / num_side) frame.width = w frame.height = h frame.x = dx * w frame.y = -(dy * h) frame:Save() end end --- Place all frames stacked beneath the primary frame. function D:StackFrames() local last for _, frame in pairs(self.console) do if last then frame.x = last.x frame.y = last.y - 20 else frame.x = (GetScreenWidth()-frame:GetWidth())/2 frame.y = 0 end frame:Save() last = frame end end --- Space everything and set the dock size function D:UpdateDock() local pad_offset = 12 local draw_offset = pad_offset for i = 1, #self.dock.buttons do local d = self.dock.buttons[i] d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', draw_offset, 0) draw_offset= draw_offset + d:GetWidth() + pad_offset end self.dock:SetWidth(draw_offset) end --- Updates region visibility as needed local getFadeInArgs = function(sign, region) --print('Dvn', region) local db = D.db local alph = region:GetAlpha() local a = (db[sign..'_alpha_on'] - alph) local b = (db[sign..'_alpha_on']-db[sign..'_alpha_off']) local dur = (a / b) * db[sign..'_fade_in'] return dur, alph, db[sign..'_alpha_on'] end local getFadeOutArgs = function(sign, region) local db = D.db local alph = region:GetAlpha() local a = (alph - db[sign..'_alpha_off']) local b = (db[sign..'_alpha_on']-db[sign..'_alpha_off']) local dur = (a / b) * db[sign..'_fade_out'] return dur, alph, db[sign..'_alpha_off'] end function D.UpdateBeacon(beacon) local db = D.db local isActive = (beacon.raised or beacon.selected) if isActive then UIFrameFadeIn(beacon, getFadeInArgs('dock_button', beacon)) end if beacon.showName or isActive then UIFrameFadeIn(beacon.caption, getFadeInArgs('dock_button', beacon.caption)) end if not isActive then UIFrameFadeOut(beacon, getFadeOutArgs('dock_button', beacon)) end if (not beacon.showName) and (not isActive) then UIFrameFadeOut(beacon.caption,getFadeOutArgs('dock_button', beacon.caption)) end end --- Dock interactions function D.DockHighlight(beacon) db = D.db local self = D.dock local mouseOverDock if self:IsMouseOver() then mouseOverDock = true end if beacon and beacon:IsMouseOver() then mouseOverDock = true if not beacon.raised then beacon.raised = true D.UpdateBeacon(beacon) end elseif beacon.raised and beacon.index ~= db.current_channel then beacon.raised = nil D.UpdateBeacon(beacon) end if mouseOverDock then -- Raise it up if not self.raised then self.raised = true UIFrameFadeIn(self, getFadeInArgs('dock', self)) end elseif self.raised then -- Drop it down self.raised = nil UIFrameFadeOut(self, getFadeOutArgs('dock', self)) end end