changeset 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 6ccfe2249edb
files AceGUIWidget-lib-st.lua main.lua
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/AceGUIWidget-lib-st.lua	Sat Dec 10 19:12:10 2011 +0000
+++ b/AceGUIWidget-lib-st.lua	Fri Jan 27 01:31:29 2012 +0000
@@ -22,9 +22,10 @@
 Version 1 initial functioning implementation
 Version 2 reshuffle to follow new AceGUI widget coding style
 Version 3 add .tail_offset, defaulting to same absolute value as .head_offset
+Version 4 
 -farmbuyer
 -------------------------------------------------------------------------------]]
-local Type, Version = "lib-st", 3
+local Type, Version = "lib-st", 4
 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
 
@@ -91,8 +92,8 @@
 		self.frame.SetAllPoints = ShiftingSetAllPoints
 	end
 
-	-- This needs the .frame field.  This also creates .obj inside that
-	-- field and calls a SetScript as well.
+	-- This needs the .frame field.  This also unconditionally creates .obj
+	-- inside that field and calls a SetScript on it as well.
 	return AceGUI:RegisterAsWidget(self)
 end
 
--- 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