Mercurial > wow > devian
comparison 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 |
comparison
equal
deleted
inserted
replaced
97:34131d11e61b | 98:33bc8baba858 |
---|---|
5 -- Created: 12/26/2015 12:32 PM | 5 -- Created: 12/26/2015 12:32 PM |
6 -- Docking and arrangement calls | 6 -- Docking and arrangement calls |
7 local _, D = ... | 7 local _, D = ... |
8 local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight = math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight | 8 local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight = math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight |
9 local db | 9 local db |
10 local print = D.print | 10 local print = DEVIAN_WORKSPACE and function(...) print('DvnDock', ...) end or nop |
11 local DOCK_BUTTON_PADDING = 6 | 11 local DOCK_BUTTON_PADDING = 6 |
12 | 12 |
13 DevianDockHandler = { | |
14 usedButtons = {}, | |
15 buttons = {}, | |
16 } | |
13 DevianDockButtonMixin = {} | 17 DevianDockButtonMixin = {} |
14 | 18 |
15 --- Updates region visibility as needed | 19 --- Updates region visibility as needed |
16 local getFadeInArgs = function(sign, region) | 20 local getFadeInArgs = function(sign, region) |
17 --print('Dvn', region) | 21 --print('Dvn', region) |
35 local function queueFade (self, duration, from, to) | 39 local function queueFade (self, duration, from, to) |
36 self:SetAlpha(to) | 40 self:SetAlpha(to) |
37 end | 41 end |
38 | 42 |
39 local numBeacons = 0 | 43 local numBeacons = 0 |
40 function D:GetDockButton(console) | 44 function DevianDockHandler:GetDockButton(console) |
41 self.dock.usedButtons = self.dock.usedButtons or {} | 45 self.usedButtons = self.usedButtons or {} |
42 | 46 local index = console:GetID() |
43 local button = self.dock.usedButtons[console.index] | 47 local button = self.usedButtons[index] |
44 if not button then | 48 if not button then |
45 numBeacons = numBeacons + 1 | 49 numBeacons = numBeacons + 1 |
46 button = CreateFrame('Button', 'DevianDockBeacon'.. numBeacons, UIParent, 'DevianBeacon') | 50 button = CreateFrame('Button', 'DevianDockBeacon'.. numBeacons, UIParent, 'DevianBeacon') |
47 button.color = {r = math.random(), g = math.random(), b = math.random()} | 51 button.color = {r = math.random(), g = math.random(), b = math.random()} |
48 button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1) | 52 button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1) |
49 button.console = console | 53 button.console = console |
50 self.dock.usedButtons[console.index] = button | 54 self.usedButtons[index] = button |
51 tinsert(self.dock.buttons, button) | 55 tinsert(self.buttons, button) |
56 --oldprint('create dock', index, console.signature) | |
52 end | 57 end |
53 button.index = console.index | 58 button.index = console.index |
54 button.caption.name:SetText(console.signature) | 59 button.caption.name:SetText(console.signature) |
55 button:SetShown(true) | 60 button:SetShown(true) |
56 return button | 61 return button |
58 | 63 |
59 function DevianDockButtonMixin:OnMouseDown(button) | 64 function DevianDockButtonMixin:OnMouseDown(button) |
60 --print("click", self:GetName(), button, self.console.index) | 65 --print("click", self:GetName(), button, self.console.index) |
61 if button == "LeftButton" then | 66 if button == "LeftButton" then |
62 if IsShiftKeyDown() then | 67 if IsShiftKeyDown() then |
63 D:Console_Toggle(self.console.index, 0) | 68 self.console:Toggle() |
64 else | 69 else |
65 if self.console.index == D.currentProfile.current_channel or (not self.console.enabled) then | 70 if self.console.isFront or (not self.console.enabled) then |
66 D:Console_Toggle(self.console.index) | 71 |
72 self.console:Toggle() | |
67 if self.console.enabled then | 73 if self.console.enabled then |
68 if self.console.minimized then | 74 if self.console.minimized then |
69 self.console:MinMax() | 75 self.console:MinMax() |
70 end | 76 end |
71 self.console:ToFront() | 77 self.console:ToFront() |
75 end | 81 end |
76 end | 82 end |
77 elseif button == "RightButton" then | 83 elseif button == "RightButton" then |
78 self.console:MinMax() | 84 self.console:MinMax() |
79 end | 85 end |
80 self.console:Save() | |
81 end | 86 end |
82 function DevianDockButtonMixin:OnShow() | 87 function DevianDockButtonMixin:OnShow() |
83 self:Update() | 88 self:Update() |
84 end | 89 end |
85 function DevianDockButtonMixin:OnEnter() | 90 function DevianDockButtonMixin:OnEnter() |
146 frame:Save() | 151 frame:Save() |
147 last = frame | 152 last = frame |
148 end | 153 end |
149 end | 154 end |
150 | 155 |
151 function D:Dock_OnMouseWheel(delta) | 156 function DevianDockHandler:OnMouseWheel(delta) |
152 if delta >= 1 then | 157 if delta >= 1 then |
153 D.dockScale = (D.dockScale or 1) - 0.1 | 158 self.dockScale = (self.dockScale or 1) - 0.1 |
154 else | 159 else |
155 D.dockScale = (D.dockScale or 1) + 0.1 | 160 self.dockScale = (self.dockScale or 1) + 0.1 |
156 end | 161 end |
157 D:UpdateDock() | 162 self:Update() |
158 end | 163 end |
159 | 164 |
160 --- Space everything and set the dock size | 165 --- Space everything and set the dock size |
161 function D:UpdateDock() | 166 function DevianDockHandler:Update() |
162 local pad_offset = 12 | 167 local pad_offset = 12 |
163 local drawWidth = 0 | 168 local drawWidth = 0 |
164 local lastButton | 169 local lastButton |
165 local numButtons = 0 | 170 local numButtons = 0 |
166 for i, d in ipairs(self.dock.buttons) do | 171 for i, d in ipairs(self.buttons) do |
167 if d and d:IsShown() then | 172 if d and d:IsShown() then |
168 d:SetScale(D.dockScale or 1) | 173 d:SetScale(D.dockScale or 1) |
169 if lastButton then | 174 if lastButton then |
170 d:SetPoint('TOPLEFT', lastButton, 'TOPRIGHT', pad_offset, 0) | 175 d:SetPoint('TOPLEFT', lastButton, 'TOPRIGHT', pad_offset, 0) |
171 else | 176 else |
177 numButtons = numButtons + 1 | 182 numButtons = numButtons + 1 |
178 print(numButtons) | 183 print(numButtons) |
179 end | 184 end |
180 end | 185 end |
181 self.numButtons = numButtons | 186 self.numButtons = numButtons |
182 self.dock:SetWidth(drawWidth) | 187 self:SetWidth(drawWidth) |
183 self.db.dockPoint = self.db.dockPoint or 'TOP' | 188 |
184 self.dock:SetPoint(self.db.dockPoint, UIParent, self.db.dockPoint, 0, 0) | 189 D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' |
190 self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) | |
185 end | 191 end |
186 | 192 |
187 | 193 |
188 local function FrameFade(frame) | 194 local function FrameFade(frame) |
189 if not D.fader then | 195 if not D.fader then |