diff Console.lua @ 100:790dca545f1d v3.0

- Configuration structure overheal; clearing 'Devian.lua' from SaveVariables will be necessary - Removed dependence on embedded libraries. - Console/dock frames are now implemented as XML mixin structures - Console dropdown menu option to 'Pin' frames - Hold SHIFT while clicking dock buttons will cause all but that tab to be closed
author Nenue
date Tue, 17 Jan 2017 14:25:18 -0500
parents 7d94df3804a7
children c3e7d2a3f4e9
line wrap: on
line diff
--- a/Console.lua	Thu Oct 27 06:11:04 2016 -0400
+++ b/Console.lua	Tue Jan 17 14:25:18 2017 -0500
@@ -29,10 +29,13 @@
 
   UIDropDownMenu_Initialize(self.DropdownFrame, function()
     local info = UIDropDownMenu_CreateInfo()
-    info.notCheckable = 1
     info.text = 'Pin'
     info.func = function() self:Pin() end
+    info.isNotRadio = true
+    info.checked = (self.pinned)
     UIDropDownMenu_AddButton(info)
+
+    info.notCheckable = 1
     if self.minimized then
       info.text = 'Maximize'
       info.func = function() self:Maximize() end
@@ -52,6 +55,7 @@
 
   self.width = self:GetWidth()
   self.height = self:GetWidth()
+  self.isHover = false
 end
 
 function DevianConsoleMixin:Setup(info)
@@ -81,6 +85,8 @@
       end
     end
   end
+  D.channels[id].isPressed = nil
+  D.channels[id].isHover = nil
 end
 
 function DevianConsoleMixin:Pin(pinned)
@@ -89,7 +95,6 @@
 end
 
 function DevianConsoleMixin:Update(setFinal)
-  self.title:SetText(self.index..' '.. (self.signature or '?'))
   self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.x, self.y)
 
   if self.minimized then
@@ -106,18 +111,34 @@
 
   --  oldprint(self:GetName(), self.x, self.y)
 
-  local isFront = D.currentProfile.current_channel == self.index
+  local isFront = (D.currentProfile.current_channel == self.index)
   local r,g,b,a = unpack(D.db.backborder)
   if isFront then
     r,g,b,a = unpack(D.db.frontborder)
     self.backdrop:SetColorTexture(0,0,0,1)
+  elseif self.pinned then
+    self.backdrop:SetColorTexture(0,0,0,1)
+    r,g,b,a = unpack(D.db.backborder)
+    self.DropdownButton.Background:SetGradient('VERTICAL', .65,.35,.25, .15, .11, .05)
   else
-    self.backdrop:SetColorTexture(0,0,0,0.5)
+    self.DropdownButton.Background:SetGradient('VERTICAL', .25,.35,.65, .05, .11, .15)
+    self.backdrop:SetColorTexture(0,0,0,1)
+    if self.raised then
+      self.raised = nil
+      self:Lower()
+    end
+  end
+  if self.isPressed then
+    r,g,b,a = 1,1,1,1
+  elseif self.isHover then
+    r,g,b,a = .5,.5,.5,1
+  end
 
-  end
+
   for name, region in pairs(self.border) do
     region:SetColorTexture(r,g,b,a)
   end
+  self.title:SetText(self.index..' '.. (self.signature or '?') .. (' '..self:GetFrameLevel()))
 
   --oldprint(self:GetID(), self.enabled, self.minimized, self.x, self.y)
   self.isFront = isFront
@@ -176,15 +197,15 @@
 end
 
 function DevianConsoleMixin:OnMouseDown(button)
-
-  if button == 'LeftButton' then
-    self:ToFront()
-  end
+  self.isPressed = true
+  self:Update()
 end
 
 
 function DevianConsoleMixin:OnMouseUp(button)
+  self.isPressed = nil
   if button == 'LeftButton' then
+    --print('go to front')
     self:ToFront()
   else
     self:MinMax()
@@ -192,9 +213,13 @@
 end
 
 function DevianConsoleMixin:OnLeave()
+  self.isHover = nil
+  self:Update()
 end
 
 function DevianConsoleMixin:OnEnter()
+  self.isHover = true
+  self:Update()
 end
 
 function DevianConsoleMixin:OnDragStart()
@@ -223,43 +248,51 @@
   self:Update(true)
 
   D.IterateChannels(function(frame)
-    frame:Update()
+    frame:Update(true)
   end, self)
 end
 
 function DevianConsoleMixin:ToFront()
+  D.currentProfile.current_channel = self.index
+
   self:Raise()
-  D.currentProfile.current_channel = self.index
   for index, channel in ipairs(D.console) do
-    channel:Update()
+    channel:Update(true)
   end
 end
 
-function DevianConsoleMixin:Toggle()
-  self.enabled = (not self.enabled)
-  --oldprint(self:GetID(), self.enabled)
-  self:Update()
+function DevianConsoleMixin:Toggle(value)
+  if value == nil then
+    value = (not self.enabled)
+  end
+
+  self.enabled = value
+  D:Print('Console #'..self:GetID(), self.enabled and 'open' or 'closed')
+
+  self:Update(true)
 end
 
 function DevianConsoleMixin:OnEvent(event, arg)
-  oldprint(event, arg)
+  --oldprint(event, arg)
   local db = D.db
   if self.enabled then
+
+    local progress = self.moveFade:GetProgress() or 1
+    self.moveFade:Stop()
+
     if event == 'PLAYER_STARTED_MOVING' then
-      self.moveFade:GetProgress()
+      local F1 = self.moveFade.alphaOut
+      F1:SetFromAlpha(db.movement_fade_from + (1-progress))
+      F1:SetToAlpha(db.movement_fade_to)
+      F1:SetDuration(db.movement_fade_time * (1-progress))
+      self.moveFade:Play()
+      self:EnableMouse(false)
+    elseif event == 'PLAYER_STOPPED_MOVING' then
       self.moveFade:Stop()
       local F1 = self.moveFade.alphaOut
-      F1:SetFromAlpha(db.movement_fade_from)
-      F1:SetToAlpha(db.movement_fade_to)
-      F1:SetDuration(db.movement_fade_time)
-      self.moveFade:Play()
-      self:EnableMouse(false)
-    else
-      self.moveFade:Stop()
-      local F1 = self.moveFade.alphaOut
+      F1:SetFromAlpha(db.movement_fade_to + (1-progress))
       F1:SetToAlpha(db.movement_fade_from)
-      F1:SetFromAlpha(db.movement_fade_to)
-      F1:SetDuration(db.movement_fade_time)
+      F1:SetDuration(db.movement_fade_time * (progress))
       self.moveFade:Play()
       self:EnableMouse(true)
     end
@@ -284,6 +317,7 @@
   end
   frame:StartSizing()
 end
+
 function DevianConsoleSizeButtonMixin:OnDragStop()
   local frame = self:GetParent()
   frame:OnDragStop()