diff UI.lua @ 36:bec37163b7fe v2.0-beta

rewrote the blocks for '/dvn tag' and SetChannel to be more predictable; currently follows: /dvn tag <source> <dest> if <dest> matches a channel, then the tag for <source> is added or removed if <dest> is a string and it doesn't match a channel, then that channel is created with <dest> as a signature if <dest> is a number that doesn't match a channel index, then <dest> is set to <highest valid index + 1>, the channel is created under that, and <source> is used as its signature SetChannel(cinfo, key) start with an empty table t_info that is filled in as follows: if key doesn't match a valid index/signature, then a channel is being created if key does match a valid index, then a channel is being updated if cinfo is a string, then only the signature value is imposed if cinfo is a table, the values from that table are imposed if a channel is being created, then the new channel info is filled in from primary channel, the index is auto-generated, and the signature value is checked for collision, and the information is passed through CreateConsole to form internal assignments if a channel is being updated, then t_info is populated from the channel data, and any internal table assignments are switched over to t_info the old tables sink into garbage collection
author Nenue
date Sun, 27 Dec 2015 08:19:45 -0500
parents 3304455a3f45
children d432f49e340e
line wrap: on
line diff
--- a/UI.lua	Sun Dec 27 03:51:17 2015 -0500
+++ b/UI.lua	Sun Dec 27 08:19:45 2015 -0500
@@ -14,7 +14,6 @@
 
 local DEVIAN_FRAME = 'DevianConsole'
 local DEVIAN_DOCK_FRAME = 'DevianDockFrame'
-local MSG_NEED_DEV_MODE = 'Must be in development mode to use this function.'
 
 
 local function Console_MinMax(self)
@@ -83,51 +82,6 @@
   self:SetWidth(db.width)
 end
 
--- Console frame toggler
--- @paramsig [...]
--- @param ... one or more space-seperated channel keys
-local function Console_Toggle(input)
-  local db = D.db
-  if db.workspace == 1 then
-    return D:Print(MSG_NEED_DEV_MODE)
-  end
-  local search = {}
-  local n = 0
-  if D:GetArgs(input,1) then
-    repeat
-      key, n = D:GetArgs(input,1,n)
-      if D.sig[key] then
-        table.insert(search, D.sig[key])
-      elseif D.console[key] then
-        table.insert(search, D.console[key])
-      end
-    until n == 1e9
-  else
-    search = D.console
-  end
-
-  db.enabled = (not db.enabled) and true or nil
-  for i, c in ipairs(search) do
-    --print(i,c.index)
-    if db.enabled then
-      c.enabled = true
-      c:Show()
-      if db.current_channel == c.index then
-        c:ToFront()
-      end
-      c:Save()
-    else
-      c:Hide()
-    end
-  end
-
-  if db.enabled then
-    D:Print('toggled on?')
-  else
-    D:Print('toggled off?')
-  end
-end
-
 --- Brings the console to the front.
 -- Frame method used to bring a console frame to the front of the display stack.
 local function Console_ToFront(c)
@@ -142,6 +96,8 @@
   c.out.backdrop:SetTexture(unpack(db.frontdrop))
   c.out.backdrop:SetGradientAlpha(unpack(db.frontgrad))
   c.out.backdrop:SetBlendMode(db.frontblend)
+  c.dropmenu.icon:SetVertexColor(unpack(db.headerfontcolor))
+  c.title:SetTextColor(unpack(db.headerfontcolor))
   db.current_channel = c.index
 
   for _, part in pairs(c.border) do
@@ -158,6 +114,8 @@
       bc.out.backdrop:SetTexture(unpack(db.backdrop))
       bc.out.backdrop:SetGradientAlpha(unpack(db.backgrad))
       bc.out.backdrop:SetBlendMode(db.backblend)
+      bc.dropmenu.icon:SetVertexColor(unpack(db.backborder))
+      bc.title:SetTextColor(unpack(db.backborder))
 
       for _, part in pairs(bc.border) do
         part:SetTexture(unpack(db.backborder))
@@ -219,7 +177,7 @@
   for k,v in pairs(vars) do
     f[k] = v
     --@debug@
-    print(' f['..type(k)..' '..tostring(k)..'] = '..type(v)..' '..tostring(v))
+    --print(' f['..type(k)..' '..tostring(k)..'] = '..type(v)..' '..tostring(v))
   end
 
   f:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', vars.x, vars.y)
@@ -228,12 +186,12 @@
   f.out:SetFont(db.font, db.fontsize, db.fontoutline)
   if (db.current_channel == i) then
     f.out.backdrop:SetTexture(unpack(db.frontdrop))
+    f.dropmenu.icon:SetVertexColor(unpack(db.headerfontcolor))
+    f.title:SetTextColor(unpack(db.headerfontcolor))
   else
     f.out.backdrop:SetTexture(unpack(db.backdrop))
   end
 
-
-
   f.Save = Console_Save
   f.Minimize = Console_Minimize
   f.Maximize = Console_Maximize
@@ -243,6 +201,26 @@
   f:SetScript('OnMouseDown', Console_MouseDown)
   f:SetScript('OnMouseUp', Console_MouseUp)
 
+
+  UIDropDownMenu_Initialize(f.menuFrame, function()
+    local info = { {
+        text= "Close",
+        value = "OptClose",
+        func = function ()
+          f.enabled = nil
+          f:Hide()
+          f:Save()
+        end },
+      {
+        text = "Dock",
+        value = "OptDock",
+        func = function() print('Dvn', 'docking shenanary') end }
+    }
+    for _, v in ipairs(info) do
+      UIDropDownMenu_AddButton(v)
+    end
+  end, 'MENU')
+
   if vars.minimized then
     f:Minimize()
   else
@@ -268,6 +246,8 @@
   local db = self.db
   local t_info = {}
   local channel, isNew, id, sig, t_id
+  --@debug@
+  print('setchan(0) cinfo, key', cinfo, key)--@end-debug@
   -- obtain source data
   if tonumber(key) ~= nil and  db.channels[key] then
     id = tonumber(key)
@@ -281,7 +261,7 @@
   t_id = id           -- overridden later if new
   t_info.index = t_id --
   --@debug@
-  --print('setchan(1) cinfo, key, id=', cinfo, key, id)--@end-debug@
+  print('setchan(1) cinfo, key, id=', cinfo, key, id)--@end-debug@
 
 
   -- obtain config info
@@ -299,7 +279,7 @@
   end
   t_info.signature = sig
   --@debug@
-  --print('setchan(2) sig,id,isNew=', sig, id, isNew)--@end-debug@
+  print('setchan(2) sig,id,isNew=', sig, id, isNew)--@end-debug@
 
   for k,v in pairs(cinfo) do -- allow all cinfo to pass
   t_info[k] = v
@@ -324,23 +304,25 @@
     end
     t_info.signature = result
     end
-    t_id = db.max_channel + 1
+    t_id = self.max_channel + 1
     t_info.index = t_id
     --@debug@
-    --print('setchan(3a) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@
+    print('setchan(3a) t_id, isNew, sig, t_info.signature=', t_id, isNew, sig, t_info.signature)--@end-debug@
   else
     --@debug@
-    --print('setchan(3b) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@
+    print('setchan(3b) t_id, isNew, sig, t_info.signature=', t_id, isNew, sig, t_info.signature)--@end-debug@
   end
 
   local channel
   if not self.console[t_id] then -- create a frame
   if isNew then -- position the channel frame
-  t_info.x = t_info.x + 20
-  t_info.y = t_info.y - 20
-  db.channels[t_id] = t_info
-  --@debug@
-  print('setchan(4a)', 't_id, x, y=', t_id, t_info.x, t_info.y)--@end-debug@
+    self.max_channel = t_id
+    db.max_channel = t_id
+    t_info.x = t_info.x + 20
+    t_info.y = t_info.y - 20
+    db.channels[t_id] = t_info
+    --@debug@
+    print('setchan(4a)', 't_id, x, y=', t_id, t_info.x, t_info.y)--@end-debug@
   end
   channel = CreateConsole(t_id, t_info)
   self.console[t_id] = channel