diff main.lua @ 8:e6382ba088c3

Potentially avoid side tabs being glued to lib-st widgets.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 27 Jan 2012 01:31:29 +0000
parents 332550e56fd2
children 3a2beea01a28
line wrap: on
line diff
--- a/main.lua	Sat Dec 10 19:12:10 2011 +0000
+++ b/main.lua	Fri Jan 27 01:31:29 2012 +0000
@@ -78,7 +78,7 @@
 local sidetabs
 local incomplete
 
--- Remove children widgets without explicitly Release()'ing them.
+-- Remove children ST widgets without explicitly Release()'ing them.
 local function DisownChildren (container)
 	for i,v in ipairs(container.children) do
 		container.children[i] = nil
@@ -129,7 +129,7 @@
 
 function addon:OnEnable()
 	self:RegisterEvent("GUILD_RANKS_UPDATE")
-	self:RegisterChatCommand("wrdw", "OnChatCommand")
+	self:RegisterChatCommand("wrdw", "OnSlashCommand")
 
 	-- Ideally, most of this stuff wouldn't be done at load time at all; this
 	-- whole addon should be LoD.
@@ -160,7 +160,7 @@
 	end
 end
 
-function addon:OnChatCommand (input)
+function addon:OnSlashCommand (input)
 	if not NUM_RANK_FLAGS then  -- in case a GM didn't get it loaded earlier
 		GuildFrame_LoadUI()
 		UIParentLoadAddOn("Blizzard_GuildControlUI")
@@ -372,6 +372,9 @@
 end
 
 
+-- Under normal conditions, this massive wodge is built once, and then merely
+-- :Show'n and :Hide'n.  Only if info gets out of date do we release/destroy
+-- the UI elements and rebuild.
 function addon:BuildWindow()
 	local need_tabs
 	if self.display then
@@ -380,6 +383,7 @@
 		self.display = AceGUI:Create("Frame")
 		self.display:SetTitle("Which Rank Does What")
 		self.display:SetLayout("Fill")
+		self.display:EnableResize(false)
 		self.display:SetStatusTable{
 			width = (st_colwidth+4) * (NUM_RANK_FLAGS-1)  -- flag columns
 			        + 105,                                -- rank label column
@@ -391,13 +395,15 @@
 				-- stuff changed while open
 				self.perms = nil
 				self.display = nil
+				if sidetabs then for i,s in ipairs(sidetabs) do
+					s:Hide()
+					s:ClearAllPoints()
+					s:SetParent(nil)   -- Blizzard does this too.  Huh.
+				end end
 				sidetabs = nil
 				AceGUI:Release(_d)
 			end
 		end)
-		if self.display.EnableResize then
-			self.display:EnableResize(false)
-		end
 		need_tabs = true
 	end
 
@@ -407,6 +413,11 @@
 		DisownChildren(self.display)
 		-- Could be new rows, fewer rows, changed tickboxes... ugh, trying to
 		-- update the scrolltable is a pain.  Throw it out and start over.
+		if sidetabs then for i,s in ipairs(sidetabs) do
+			s:Hide()
+			s:ClearAllPoints()
+			s:SetParent(nil)   -- Blizzard does this too.  Huh.
+		end end
 		if self.main_st and self.main_st.st then
 			self.main_st:Release()
 		end