Mercurial > wow > devian
diff Dock.lua @ 98:33bc8baba858
start of a lot of v3 groundwork based on better knowledge of the addon interface:
- use of mixin as a lexical center for generated frames
- removal of unfinished segments
author | Nenue |
---|---|
date | Wed, 26 Oct 2016 10:17:43 -0400 |
parents | f6fae1a4c66c |
children | 7d94df3804a7 |
line wrap: on
line diff
--- a/Dock.lua Tue Oct 25 12:35:12 2016 -0400 +++ b/Dock.lua Wed Oct 26 10:17:43 2016 -0400 @@ -7,9 +7,13 @@ local _, D = ... local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight = math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight local db -local print = D.print +local print = DEVIAN_WORKSPACE and function(...) print('DvnDock', ...) end or nop local DOCK_BUTTON_PADDING = 6 +DevianDockHandler = { + usedButtons = {}, + buttons = {}, +} DevianDockButtonMixin = {} --- Updates region visibility as needed @@ -37,18 +41,19 @@ end local numBeacons = 0 -function D:GetDockButton(console) - self.dock.usedButtons = self.dock.usedButtons or {} - - local button = self.dock.usedButtons[console.index] +function DevianDockHandler:GetDockButton(console) + self.usedButtons = self.usedButtons or {} + local index = console:GetID() + local button = self.usedButtons[index] if not button then numBeacons = numBeacons + 1 button = CreateFrame('Button', 'DevianDockBeacon'.. numBeacons, UIParent, 'DevianBeacon') button.color = {r = math.random(), g = math.random(), b = math.random()} button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1) button.console = console - self.dock.usedButtons[console.index] = button - tinsert(self.dock.buttons, button) + self.usedButtons[index] = button + tinsert(self.buttons, button) + --oldprint('create dock', index, console.signature) end button.index = console.index button.caption.name:SetText(console.signature) @@ -60,10 +65,11 @@ --print("click", self:GetName(), button, self.console.index) if button == "LeftButton" then if IsShiftKeyDown() then - D:Console_Toggle(self.console.index, 0) + self.console:Toggle() else - if self.console.index == D.currentProfile.current_channel or (not self.console.enabled) then - D:Console_Toggle(self.console.index) + 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() @@ -77,7 +83,6 @@ elseif button == "RightButton" then self.console:MinMax() end - self.console:Save() end function DevianDockButtonMixin:OnShow() self:Update() @@ -148,22 +153,22 @@ end end -function D:Dock_OnMouseWheel(delta) +function DevianDockHandler:OnMouseWheel(delta) if delta >= 1 then - D.dockScale = (D.dockScale or 1) - 0.1 + self.dockScale = (self.dockScale or 1) - 0.1 else - D.dockScale = (D.dockScale or 1) + 0.1 + self.dockScale = (self.dockScale or 1) + 0.1 end - D:UpdateDock() + self:Update() end --- Space everything and set the dock size -function D:UpdateDock() +function DevianDockHandler:Update() local pad_offset = 12 local drawWidth = 0 local lastButton local numButtons = 0 - for i, d in ipairs(self.dock.buttons) do + for i, d in ipairs(self.buttons) do if d and d:IsShown() then d:SetScale(D.dockScale or 1) if lastButton then @@ -179,9 +184,10 @@ end end self.numButtons = numButtons - self.dock:SetWidth(drawWidth) - self.db.dockPoint = self.db.dockPoint or 'TOP' - self.dock:SetPoint(self.db.dockPoint, UIParent, self.db.dockPoint, 0, 0) + self:SetWidth(drawWidth) + + D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' + self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) end