Mercurial > wow > devian
view Dock.lua @ 73:3745540e8996 v2.1.74
- New commands:
- /dvn remove (index|tag) will remove a channel from the current profile
- /dvncolors resets the tag color cache
- Fixed an issue with creating more than one output channel per UI session.
- Performance improvements:
- Color caching now ignores decimal timestamps, removing a source of cache bloat
- Cleaned up a bunch of global variable use in many areas
author | Nenue |
---|---|
date | Sat, 09 Apr 2016 06:34:04 -0400 |
parents | 516ceb31703d |
children | f6fae1a4c66c |
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 = ... local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight = math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight local db local print = D.print --- 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 local dockn = 1 for i, d in pairs(self.dock.buttons) do dockn = max(i, dockn) end for i = 1, dockn do local d = self.dock.buttons[i] if d then d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', draw_offset, 0) draw_offset= draw_offset + d:GetWidth() + pad_offset end 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 local function queueFade (self, duration, from, to) self:SetAlpha(to) end function D.UpdateBeacon(beacon) local db = D.db local isActive = (beacon.raised or beacon.selected or beacon.newMessage) if isActive then --print(beacon:GetName(), 'active, fade in') queueFade(beacon, getFadeInArgs('dock_button', beacon)) end if beacon.showName or isActive then --print(beacon:GetName(), 'show name, fade in name') queueFade(beacon.caption, getFadeInArgs('dock_button', beacon.caption)) end if not isActive then queueFade(beacon, getFadeOutArgs('dock_button', beacon)) end if (not beacon.showName) and (not isActive) then --print(beacon:GetName(), 'no name no active, fade out') queueFade(beacon.caption,getFadeOutArgs('dock_button', beacon.caption)) end end local function FrameFade(frame) if not D.fader then D.fader = CreateFrame('Frame', 'DevianFaderFrame', UIParent):CreateAnimationGroup('fader'):CreateAnimation('Alpha', 'FadeIn') end end --- Dock interaction framescript function D.DockHighlight(beacon) db = D.db local self = D.dock local mouseOverDock = false if self:IsMouseOver() then mouseOverDock = true end if beacon then --print(beacon:GetName(), ' highlighter got beacon') mouseOverDock = true if not beacon.raised then --print(beacon:GetName(), ' beacon not raised') beacon.raised = true D.UpdateBeacon(beacon) -- IsMouseOver can still return false during its frame's OnEnter beacon.inc = 0 beacon:SetScript('OnUpdate', function(self) if not self:IsMouseOver() then self.inc = self.inc + 1 --print(self:GetName(),self.inc) if self.inc > 10 then --print(self:GetName(), 'lost mouseover, terminating OnUpdate') self.raised = nil D.UpdateBeacon(self) self:SetScript('OnUpdate', nil) end end end) end elseif beacon.raised and beacon.index ~= db.current_channel then beacon.raised = nil D.UpdateBeacon(beacon) --beacon:SetScript('OnUpdate', nil) end if mouseOverDock then -- Raise it up if not self.raised then self.raised = true queueFade(self, getFadeInArgs('dock', self)) end elseif self.raised then -- Drop it down self.raised = nil queueFade(self, getFadeOutArgs('dock', self)) for k, v in pairs(self.buttons) do v.raised = nil D.UpdateBeacon(v) end end end