changeset 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 e1f6e5c97da6
files Console.lua Console.xml Devian.lua Devian.toc Dock.lua Dock.xml
diffstat 6 files changed, 185 insertions(+), 81 deletions(-) [+]
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()
--- a/Console.xml	Thu Oct 27 06:11:04 2016 -0400
+++ b/Console.xml	Tue Jan 17 14:25:18 2017 -0500
@@ -20,6 +20,7 @@
     <Scripts>
       <OnLoad method="OnLoad" />
       <OnShow method="OnShow" />
+      <OnEvent method="OnEvent" />
       <OnMouseWheel method="OnMouseWheel" />
       <OnDragStart method="OnDragStart" />
       <OnDragStop method="OnDragStop" />
@@ -104,14 +105,18 @@
     </Layers>
     <Frames>
       <Button name="$parentMenuButton"  parentKey="DropdownButton" enableMouse="true">
-        <Size x="24" y="24" />
+        <Size x="18" y="16" />
         <Anchors>
-          <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" x="-4" y="0" />
+          <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" x="-1" y="-1" />
         </Anchors>
         <Layers>
           <Layer level="BACKGROUND">
-            <Texture setAllPoints="true" >
+            <Texture setAllPoints="true" parentKey="Background" >
               <Color a="1" r="1" g="1" b="1" />
+              <Gradient orientation="VERTICAL">
+                <MaxColor a="1" r=".25" g=".35" b=".65" />
+                <MinColor a="1" r=".05" g=".05" b=".05" />
+              </Gradient>
             </Texture>
           </Layer>
         </Layers>
@@ -172,15 +177,15 @@
 
 
       <Button name="$parentHorizontalSizer" parentKey="GripSide" inherits="DevianSizeButtonTemplate" frameLevel="25">
-        <Size x="16" />
+        <Size x="8" />
         <Anchors>
-          <Anchor point="TOPRIGHT"/>
+          <Anchor point="TOPRIGHT" relativePoint="BOTTOMRIGHT" relativeKey="$parent.DropdownButton" />
           <Anchor point="BOTTOM" y="24" />
         </Anchors>
       </Button>
 
       <Button name="$parentVerticalSizer" parentKey="GripBottom" inherits="DevianSizeButtonTemplate" frameLevel="24">
-        <Size y="16" />
+        <Size y="8" />
         <Anchors>
           <Anchor point="BOTTOMLEFT" />
           <Anchor point="RIGHT" x="-24" />
--- a/Devian.lua	Thu Oct 27 06:11:04 2016 -0400
+++ b/Devian.lua	Tue Jan 17 14:25:18 2017 -0500
@@ -5,6 +5,8 @@
 
 --GLOBALS: Devian, DevianLoadMessage, DEVIAN_WORKSPACE, DEVIAN_PNAME, DEVIAN_PID
 
+SLASH_RL1 = "/rl"
+SlashCmdList.RL = function() ReloadUI() end
 DEVIAN_WORKSPACE = false
 DEVIAN_PNAME = 'Dvn'
 DEVIAN_PID = 0
@@ -22,6 +24,7 @@
 local num_dock_tabs = 0
 local charStates ={}
 
+local channels_report = {}
 local registeredTags = {}
 
 
@@ -714,10 +717,11 @@
       prefix = sub(prefix, 0,2)
     end
     channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8)
-    if channel.Dock and not channel.Dock.newMessage then
-      channel.Dock.newMessage = true
-      channel.Dock.caption.pulse:Play()
-      channel.Dock:Update()
+    if not channel.newMessage then
+      channel.newMessage = true
+      if channel.Dock then
+        channel.Dock:Update()
+      end
     end
   end
   wipe(buffer)
@@ -765,7 +769,7 @@
 
 
 function D.ConsoleCommand (cmd)
-  D:Console_Toggle(cmd)
+  DevianDock:ToggleAll()
 end
 
 
@@ -813,11 +817,10 @@
 
   --- initialize the current profile
   local id, name = D.Profile(db.current_profile or 1)
-  D:Print('Using profile |cFFFFFF00'.. id ..'|r: |cFF00FF00'..currentProfile.name..'|r')
   if  currentProfile.workspace then
-    D:Print('Workspace: '.. (#currentProfile.channels) .. ' channels, ' .. #currentProfile.tags .. ' tags.')
+    tinsert(channels_report, 'Profile |cFFFFFF00'.. id ..'|r: |cFF00FF00'..currentProfile.name.. '|r')
     if D.channels[currentProfile.default_channel] then
-      D:Print('Default channel: |cFFFFFF00'..currentProfile.default_channel..'|r: |cFF00FFFF'.. D.channels[currentProfile.default_channel].signature..'|r')
+      tinsert(channels_report, 'Primary: |cFFFFFF00#'..currentProfile.default_channel..'|r |cFF00FFFF'.. D.channels[currentProfile.default_channel].signature..'|r')
     end
   end
 
@@ -831,6 +834,10 @@
     D:GetOrCreateChannel(index)
     D.num_channels = #D.channels
   end
+  if #channels_report >= 1 then
+    D:Print(concat(channels_report, ', '))
+  end
+
   D.primary_channel = D.primary_channel or 1
   D.max_channel = max(D.max_channel, currentProfile.max_channel)
   if currentProfile.max_channel < D.max_channel then
@@ -849,8 +856,6 @@
     end
     DevianDock:Update()
   end
-
-  print('devian')
 end
 
 function D:Print (...)
@@ -893,10 +898,11 @@
   end
 
   local frame = D.console[id]
+
   if not frame then
 
     if DEVIAN_WORKSPACE then
-      D:Print('Adding '.. (info.index) .. ':' .. (info.signature) .. ' (|cFF00FFFF'.. concat(info.tags, '|r; |cFF00FFFF')..'|r)')
+      tinsert(channels_report, (info.index) .. ':' .. (info.signature) .. ' (|cFF00FFFF'.. concat(info.tags, '|r; |cFF00FFFF')..'|r)')
     end
     frame = CreateFrame('Frame', 'DevianConsole'..id, Devian, 'DevianConsoleTemplate')
     frame:SetID(id)
--- a/Devian.toc	Thu Oct 27 06:11:04 2016 -0400
+++ b/Devian.toc	Tue Jan 17 14:25:18 2017 -0500
@@ -1,15 +1,9 @@
 ## Interface: 70100
 ## Title: !|cFF00FFFFDevian|r
-## Notes: AddOn Development Workspace
+## Notes: AddOn development workspace
 ## Author: Krakyn
-## Version: 2.2 @project-revision@
+## Version: @project-revision@
 ## SavedVariables: DevianDB, DevianLoadMessage
-## OptionalDeps: Ace3
-Libs\LibStub\LibStub.lua
-Libs\AceAddon-3.0\AceAddon-3.0.xml
-Libs\AceConsole-3.0\AceConsole-3.0.xml
-Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua
-Libs\AceEvent-3.0\AceEvent-3.0.xml
 Devian.xml
 Console.xml
 Dock.xml
--- a/Dock.lua	Thu Oct 27 06:11:04 2016 -0400
+++ b/Dock.lua	Tue Jan 17 14:25:18 2017 -0500
@@ -21,26 +21,30 @@
 
 function DevianDockTabMixin:OnMouseDown(button)
   --print("click", self:GetName(), button, self.console.index)
+  local console = self.console
   if button == "LeftButton" then
     if IsShiftKeyDown() then
-      self.console:Toggle()
+      DevianDock:ToggleAll(console)
     else
-      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()
+      console.newMessage = nil
+      if console.isFront or (not console.enabled) then
+
+        console:Toggle()
+        if console.enabled then
+          if console.minimized then
+            console:MinMax()
           end
-          self.console:ToFront()
+          console:ToFront()
         end
       else
-        self.console:ToFront()
+        console:ToFront()
       end
     end
   elseif button == "RightButton" then
-    self.console:MinMax()
+    console:MinMax()
   end
+  DevianDock:Update()
 end
 function DevianDockTabMixin:OnShow()
   self:Update()
@@ -48,13 +52,13 @@
 function DevianDockTabMixin:OnEnter()
 end
 function DevianDockTabMixin:Update()
-  local db = D.db
-  local isActive = (self.raised or self.selected or self.newMessage)
+  local console = self.console
+  local isActive = (console.isFront or console.newMessage)
 
-  if (self.showName or isActive) then
-    self.caption:SetAlpha(1)
-  else
-    self.caption:SetAlpha(0.5)
+  if console.newMessage and (not self.pulse:IsPlaying()) then
+    self.pulse:Play()
+  elseif not console.newMessage then
+    self.pulse:Stop()
   end
 
   if self.selected then
@@ -63,18 +67,18 @@
     self.Background:SetColorTexture(0,0,0,.5)
   end
 
-  if (not self.showName) and (not isActive) then
-    --print(self:GetName(), 'no name no active, fade out')
+  if isActive then
+    self:SetAlpha(1)
+  else
     self:SetAlpha(0.5)
-  else
-    self:SetAlpha(1)
   end
 
+
+
   self:SetWidth(self.caption.name:GetStringWidth() + DOCK_BUTTON_PADDING)
 end
 
 function DevianDockTabMixin:Select()
-  self.caption.pulse:Stop()
   self:Update()
 end
 
@@ -150,6 +154,10 @@
   local drawWidth = 0
   local lastButton
   local numButtons = 0
+  local numOpen = 0
+  local numBackground = 0
+  local numClosed = 0
+  local numMinimized = 0
   for i, d in ipairs(self.buttons) do
     if d and d:IsShown() then
       d:SetScale(D.dockScale or 1)
@@ -159,15 +167,55 @@
         d:SetPoint('TOPLEFT',  DevianDock, 'TOPLEFT', pad_offset, 0)
       end
 
+      local console = d.console
+      if console.enabled then
+        numOpen = numOpen + 1
+        if not console.isFront then
+          numBackground = numBackground + 1
+        end
+
+      else
+        numClosed = numClosed + 1
+      end
+      if console.minimized then
+        numMinimized = numMinimized + 1
+      end
+
+      d:Update()
+
       drawWidth =  drawWidth + d:GetWidth() + pad_offset
       lastButton = d
       numButtons = numButtons + 1
       print(numButtons)
     end
   end
-  self.numButtons = numButtons
+
+  self.numOpen, self.numMinimized, self.numClosed, self.numButtons, self.numBackground = numOpen, numMinimized, numClosed, numButtons, numBackground
   self:SetWidth(drawWidth)
 
   D.db.dockPoint = D.db.dockPoint or 'TOPLEFT'
   self:SetPoint(D.db.dockPoint , UIParent, D.db.dockPoint , 0, 0)
 end
+
+
+function DevianDockHandler:ToggleAll(sender)
+  local keepSender = IsShiftKeyDown() and sender
+  local senderID = sender and sender:GetID()
+  local op, arg = 'Toggle', false
+  if (keepSender and (self.numBackground == 0)) or (self.numOpen == 0) then
+    arg = true
+  elseif self.numClosed == 0 then
+    arg = false
+  end
+
+  for index, button in ipairs(self.buttons) do
+    local frame = button.console
+    if frame then
+      if not((frame.index == senderID) and keepSender) then
+        frame[op](frame, arg)
+      end
+
+    end
+  end
+  self:Update()
+end
\ No newline at end of file
--- a/Dock.xml	Thu Oct 27 06:11:04 2016 -0400
+++ b/Dock.xml	Tue Jan 17 14:25:18 2017 -0500
@@ -43,7 +43,6 @@
       <OnShow method="OnShow" />
       <OnEnter method="OnEnter" />
       <OnMouseDown method="OnMouseDown" />
-      <OnClick method="Select" />
     </Scripts>
     <Layers>
       <Layer level="BACKGROUND">
@@ -51,6 +50,11 @@
           <Color a="0.5" r="0" g="0" b="0" />
         </Texture>
       </Layer>
+      <Layer level="BORDER">
+        <Texture parentKey="BackgroundGlow" setAllPoints="true" hidden="true">
+          <Color a="1" r="0" g="1" b="0.5" />
+        </Texture>
+      </Layer>
       <Layer level="OVERLAY">
         <Texture parentKey="Stripe">
           <Anchors>
@@ -80,14 +84,27 @@
             </FontString>
           </Layer>
         </Layers>
-        <Animations>
-          <AnimationGroup parentKey="pulse" looping="BOUNCE" setToFinalAlpha="false">
-            <Alpha fromAlpha=".5" toAlpha="1" duration="0.4" endDelay="0.6" order="1" childKey="name" />
-
-          </AnimationGroup>
-        </Animations>
       </Frame>
     </Frames>
+    <Animations>
+      <AnimationGroup parentKey="pulse" looping="REPEAT" setToFinalAlpha="true">
+        <Alpha fromAlpha=".15" toAlpha=".65" duration="0.4" order="1" childKey="BackgroundGlow" />
+        <Alpha fromAlpha=".65" toAlpha=".15" duration="0.4" order="2" childKey="BackgroundGlow" />
+        <Alpha fromAlpha=".15" toAlpha=".15" duration="0.6" order="3" childKey="BackgroundGlow" />
+        <Scripts>
+          <OnPlay>
+            self:GetParent().BackgroundGlow:SetAlpha(.65)
+            self:GetParent().BackgroundGlow:Show()
+          </OnPlay>
+          <OnStop>
+            self:GetParent().BackgroundGlow:Hide()
+          </OnStop>
+          <OnFinished>
+            self:GetParent().BackgroundGlow:Hide()
+          </OnFinished>
+        </Scripts>
+      </AnimationGroup>
+    </Animations>
   </Button>
 
 </Ui>
\ No newline at end of file