Mercurial > wow > devian
comparison Dock.lua @ 99:7d94df3804a7
- Console drag buttons for resizing
- While dragging a console frame, other frames are ghosted out
- Dropdown menu includes Toggle, Pin, and MinMax
| author | Nenue |
|---|---|
| date | Thu, 27 Oct 2016 06:11:04 -0400 |
| parents | 33bc8baba858 |
| children | 790dca545f1d |
comparison
equal
deleted
inserted
replaced
| 98:33bc8baba858 | 99:7d94df3804a7 |
|---|---|
| 4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
| 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 | |
| 10 local CreateFrame, tinsert, random = CreateFrame, tinsert, math.random | |
| 11 local ipairs, pairs = ipairs, pairs | |
| 9 local db | 12 local db |
| 10 local print = DEVIAN_WORKSPACE and function(...) print('DvnDock', ...) end or nop | 13 local print = DEVIAN_WORKSPACE and function(...) print('DvnDock', ...) end or nop |
| 11 local DOCK_BUTTON_PADDING = 6 | 14 local DOCK_BUTTON_PADDING = 6 |
| 12 | 15 |
| 13 DevianDockHandler = { | 16 DevianDockHandler = { |
| 14 usedButtons = {}, | 17 usedButtons = {}, |
| 15 buttons = {}, | 18 buttons = {}, |
| 16 } | 19 } |
| 17 DevianDockButtonMixin = {} | 20 DevianDockTabMixin = {} |
| 18 | 21 |
| 19 --- Updates region visibility as needed | 22 function DevianDockTabMixin:OnMouseDown(button) |
| 20 local getFadeInArgs = function(sign, region) | |
| 21 --print('Dvn', region) | |
| 22 local db = D.db | |
| 23 local alph = region:GetAlpha() | |
| 24 local a = (db[sign..'_alpha_on'] - alph) | |
| 25 local b = (db[sign..'_alpha_on']-db[sign..'_alpha_off']) | |
| 26 local dur = (a / b) * db[sign..'_fade_in'] | |
| 27 return dur, alph, db[sign..'_alpha_on'] | |
| 28 end | |
| 29 | |
| 30 local getFadeOutArgs = function(sign, region) | |
| 31 local db = D.db | |
| 32 local alph = region:GetAlpha() | |
| 33 local a = (alph - db[sign..'_alpha_off']) | |
| 34 local b = (db[sign..'_alpha_on']-db[sign..'_alpha_off']) | |
| 35 local dur = (a / b) * db[sign..'_fade_out'] | |
| 36 return dur, alph, db[sign..'_alpha_off'] | |
| 37 end | |
| 38 | |
| 39 local function queueFade (self, duration, from, to) | |
| 40 self:SetAlpha(to) | |
| 41 end | |
| 42 | |
| 43 local numBeacons = 0 | |
| 44 function DevianDockHandler:GetDockButton(console) | |
| 45 self.usedButtons = self.usedButtons or {} | |
| 46 local index = console:GetID() | |
| 47 local button = self.usedButtons[index] | |
| 48 if not button then | |
| 49 numBeacons = numBeacons + 1 | |
| 50 button = CreateFrame('Button', 'DevianDockBeacon'.. numBeacons, UIParent, 'DevianBeacon') | |
| 51 button.color = {r = math.random(), g = math.random(), b = math.random()} | |
| 52 button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1) | |
| 53 button.console = console | |
| 54 self.usedButtons[index] = button | |
| 55 tinsert(self.buttons, button) | |
| 56 --oldprint('create dock', index, console.signature) | |
| 57 end | |
| 58 button.index = console.index | |
| 59 button.caption.name:SetText(console.signature) | |
| 60 button:SetShown(true) | |
| 61 return button | |
| 62 end | |
| 63 | |
| 64 function DevianDockButtonMixin:OnMouseDown(button) | |
| 65 --print("click", self:GetName(), button, self.console.index) | 23 --print("click", self:GetName(), button, self.console.index) |
| 66 if button == "LeftButton" then | 24 if button == "LeftButton" then |
| 67 if IsShiftKeyDown() then | 25 if IsShiftKeyDown() then |
| 68 self.console:Toggle() | 26 self.console:Toggle() |
| 69 else | 27 else |
| 82 end | 40 end |
| 83 elseif button == "RightButton" then | 41 elseif button == "RightButton" then |
| 84 self.console:MinMax() | 42 self.console:MinMax() |
| 85 end | 43 end |
| 86 end | 44 end |
| 87 function DevianDockButtonMixin:OnShow() | 45 function DevianDockTabMixin:OnShow() |
| 88 self:Update() | 46 self:Update() |
| 89 end | 47 end |
| 90 function DevianDockButtonMixin:OnEnter() | 48 function DevianDockTabMixin:OnEnter() |
| 91 end | 49 end |
| 92 function DevianDockButtonMixin:Update() | 50 function DevianDockTabMixin:Update() |
| 93 local db = D.db | 51 local db = D.db |
| 94 local isActive = (self.raised or self.selected or self.newMessage) | 52 local isActive = (self.raised or self.selected or self.newMessage) |
| 95 | 53 |
| 96 if (self.showName or isActive) then | 54 if (self.showName or isActive) then |
| 97 self.caption:SetAlpha(1) | 55 self.caption:SetAlpha(1) |
| 113 end | 71 end |
| 114 | 72 |
| 115 self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING) | 73 self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING) |
| 116 end | 74 end |
| 117 | 75 |
| 118 function DevianDockButtonMixin:Select() | 76 function DevianDockTabMixin:Select() |
| 119 self.caption.pulse:Stop() | 77 self.caption.pulse:Stop() |
| 120 self:Update() | 78 self:Update() |
| 121 end | 79 end |
| 122 | 80 |
| 123 --- Spaces each frame evenly across the screen. | 81 --- Spaces each frame evenly across the screen. |
| 148 frame.x = (GetScreenWidth()-frame:GetWidth())/2 | 106 frame.x = (GetScreenWidth()-frame:GetWidth())/2 |
| 149 frame.y = 0 | 107 frame.y = 0 |
| 150 end | 108 end |
| 151 frame:Save() | 109 frame:Save() |
| 152 last = frame | 110 last = frame |
| 111 end | |
| 112 end | |
| 113 | |
| 114 | |
| 115 do | |
| 116 local numBeacons = 0 | |
| 117 function DevianDockHandler:GetDockButton(console) | |
| 118 self.usedButtons = self.usedButtons or {} | |
| 119 local index = console:GetID() | |
| 120 local button = self.usedButtons[index] | |
| 121 if not button then | |
| 122 numBeacons = numBeacons + 1 | |
| 123 button = CreateFrame('Button', 'DevianDockBeacon'.. numBeacons, UIParent, 'DevianDockTabTemplate') | |
| 124 button.color = {r = random(), g = random(), b = random()} | |
| 125 button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1) | |
| 126 button.console = console | |
| 127 self.usedButtons[index] = button | |
| 128 tinsert(self.buttons, button) | |
| 129 --oldprint('create dock', index, console.signature) | |
| 130 end | |
| 131 button.index = console.index | |
| 132 button.caption.name:SetText(console.signature) | |
| 133 button:SetShown(true) | |
| 134 return button | |
| 153 end | 135 end |
| 154 end | 136 end |
| 155 | 137 |
| 156 function DevianDockHandler:OnMouseWheel(delta) | 138 function DevianDockHandler:OnMouseWheel(delta) |
| 157 if delta >= 1 then | 139 if delta >= 1 then |
| 187 self:SetWidth(drawWidth) | 169 self:SetWidth(drawWidth) |
| 188 | 170 |
| 189 D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' | 171 D.db.dockPoint = D.db.dockPoint or 'TOPLEFT' |
| 190 self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) | 172 self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0) |
| 191 end | 173 end |
| 192 | |
| 193 | |
| 194 local function FrameFade(frame) | |
| 195 if not D.fader then | |
| 196 D.fader = CreateFrame('Frame', 'DevianFaderFrame', UIParent):CreateAnimationGroup('fader'):CreateAnimation('Alpha', 'FadeIn') | |
| 197 end | |
| 198 end |
