diff 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
line wrap: on
line diff
--- a/Dock.lua	Wed Oct 26 10:17:43 2016 -0400
+++ b/Dock.lua	Thu Oct 27 06:11:04 2016 -0400
@@ -6,6 +6,9 @@
 -- Docking and arrangement calls
 local _, D = ...
 local ceil, floor, sqrt, pairs, GetScreenWidth, GetScreenHeight =  math.ceil, math.floor, math.sqrt, pairs, GetScreenWidth, GetScreenHeight
+
+local CreateFrame, tinsert, random = CreateFrame, tinsert, math.random
+local ipairs, pairs = ipairs, pairs
 local db
 local print = DEVIAN_WORKSPACE and function(...) print('DvnDock', ...) end or nop
 local DOCK_BUTTON_PADDING = 6
@@ -14,54 +17,9 @@
   usedButtons = {},
   buttons = {},
 }
-DevianDockButtonMixin = {}
+DevianDockTabMixin = {}
 
---- 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
-
-local numBeacons = 0
-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.usedButtons[index] = button
-    tinsert(self.buttons, button)
-    --oldprint('create dock', index, console.signature)
-  end
-  button.index = console.index
-  button.caption.name:SetText(console.signature)
-  button:SetShown(true)
-  return button
-end
-
-function DevianDockButtonMixin:OnMouseDown(button)
+function DevianDockTabMixin:OnMouseDown(button)
   --print("click", self:GetName(), button, self.console.index)
   if button == "LeftButton" then
     if IsShiftKeyDown() then
@@ -84,12 +42,12 @@
     self.console:MinMax()
   end
 end
-function DevianDockButtonMixin:OnShow()
+function DevianDockTabMixin:OnShow()
   self:Update()
 end
-function DevianDockButtonMixin:OnEnter()
+function DevianDockTabMixin:OnEnter()
 end
-function DevianDockButtonMixin:Update()
+function DevianDockTabMixin:Update()
   local db = D.db
   local isActive = (self.raised or self.selected or self.newMessage)
 
@@ -115,7 +73,7 @@
   self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING)
 end
 
-function DevianDockButtonMixin:Select()
+function DevianDockTabMixin:Select()
   self.caption.pulse:Stop()
   self:Update()
 end
@@ -153,6 +111,30 @@
   end
 end
 
+
+do
+  local numBeacons = 0
+  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, 'DevianDockTabTemplate')
+      button.color = {r = random(), g = random(), b = random()}
+      button.Stripe:SetColorTexture(button.color.r, button.color.g, button.color.b,1)
+      button.console = console
+      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)
+    button:SetShown(true)
+    return button
+  end
+end
+
 function DevianDockHandler:OnMouseWheel(delta)
   if delta >= 1 then
     self.dockScale = (self.dockScale or 1) - 0.1
@@ -189,10 +171,3 @@
   D.db.dockPoint = D.db.dockPoint or 'TOPLEFT'
   self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0)
 end
-
-
-local function FrameFade(frame)
-  if not D.fader then
-    D.fader = CreateFrame('Frame', 'DevianFaderFrame', UIParent):CreateAnimationGroup('fader'):CreateAnimation('Alpha', 'FadeIn')
-  end
-end
\ No newline at end of file