Change so object definition is child of the LAM addon object.

Scott Yeskie [05-23-14 - 19:42]
Change so object definition is child of the LAM addon object.

Renamed lamPanel object to lam.Panel object
Filename
GuildCharNames.lua
lib/LibAddonMenu-1.0.lua
diff --git a/GuildCharNames.lua b/GuildCharNames.lua
index 6a20b43..32a2217 100644
--- a/GuildCharNames.lua
+++ b/GuildCharNames.lua
@@ -344,37 +344,36 @@ GuildCharInfo.initUI = function()
     --Create menu panel
     --
     local LAM = LibStub("LibAddonMenu-1.0")
-    local pre = "GuildCharInfoUI"
-    GuildCharInfo.panelID = LAM:CreateControlPanel("GuildCharNamesUI", "Guild Character Info")
+    GuildCharInfo.panel = LAM.Panel("GuildCharNamesUI", "Guild Character Info")
     --Name formatting options
-    LAM:AddHeader(GuildCharInfo.panelID, pre.."h1", "Name Format")
-    LAM:AddCheckbox(GuildCharInfo.panelID, pre.."h1c1", "Account Name",
+    GuildCharInfo.panel:AddHeader("Name Format")
+    GuildCharInfo.panel:AddCheckbox("Account Name",
         "Show the account name (@name) in guild chat after the character name",
         function() return GuildCharInfo.cfg.showAcct end,
         function(val) GuildCharInfo.cfg.showAcct = val end,
         false --No warning
     )
-    LAM:AddCheckbox(GuildCharInfo.panelID, pre.."h1c2", "Main Character Name",
+    GuildCharInfo.panel:AddCheckbox("Main Character Name",
         "Show the name of the highest character in guild chat after current character name",
         function() return GuildCharInfo.cfg.showMain end,
         function(val) GuildCharInfo.cfg.showMain = val end,
         false --No warning
     )
     --Link options
-    LAM:AddHeader(GuildCharInfo.panelID, pre.."h2", "Info Link Format")
-    LAM:AddCheckbox(GuildCharInfo.panelID, pre.."h2c1", "Show Link",
+    GuildCharInfo.panel:AddHeader("Info Link Format")
+    GuildCharInfo.panel:AddCheckbox("Show Link",
         "Show the info link after the name",
         function() return GuildCharInfo.cfg.showLink end,
         function(val) GuildCharInfo.cfg.showLink = val end,
         true, "If disabled, there is no way to view the player info card"
     )
-    LAM:AddColorPicker(GuildCharInfo.panelID, pre.."h2c2", "Link Color",
+    GuildCharInfo.panel:AddColorPicker("Link Color",
         "Change the color of the text link (default [*]) that shows the info card",
         function() return GuildCharInfo.hex2rgb(GuildCharInfo.cfg.linkColor) end,
         function(r,g,b) GuildCharInfo.cfg.linkColor = GuildCharInfo.rgb2hex(r,g,b) end,
         false -- No warning
     )
-    LAM:AddEditBox(GuildCharInfo.panelID, pre.."h2c3", "Link text",
+    GuildCharInfo.panel:AddEditBox("Link text",
         "Text shown after character name which on click shows the info box",
         false, -- Not multiline
         function() return GuildCharInfo.unsanitizeSavedText(GuildCharInfo.cfg.linkText) end,
diff --git a/lib/LibAddonMenu-1.0.lua b/lib/LibAddonMenu-1.0.lua
index a63750a..e7e7bed 100644
--- a/lib/LibAddonMenu-1.0.lua
+++ b/lib/LibAddonMenu-1.0.lua
@@ -13,16 +13,16 @@ lam.panels = {}
 lam.forceControlName = nil


-local lamPanel = {}
-lamPanel.__index = lamPanel
+lam.Panel = {}
+lam.Panel.__index = lam.Panel

-setmetatable(lamPanel, {
+setmetatable(lam.Panel, {
     __call = function (cls, ...)
         return cls.new(...)
     end,
 })

-function lamPanel:getUniqueName()
+function lam.Panel:getUniqueName()
     if lam.forceControlName == nil then
         self.uniqCounter = self.uniqCounter + 1
         return self.panelName .. "-" .. self.uniqCounter
@@ -33,8 +33,8 @@ function lamPanel:getUniqueName()
     end
 end

-function lamPanel.new(controlPanelID, controlPanelName)
-    local self = setmetatable({}, lamPanel)
+function lam.Panel.new(controlPanelID, controlPanelName)
+    local self = setmetatable({}, lam.Panel)
     self.panelName = controlPanelName
     self.uniqCounter = 0
     self.lastAddedControl = nil
@@ -53,7 +53,7 @@ function lamPanel.new(controlPanelID, controlPanelName)
     return lam.panels[self.panelID]
 end

-function lamPanel:AddHeader(text)
+function lam.Panel:AddHeader(text)
     local isSubMenu = type(self.panelID) == "userdata"
     local controlName = self:getUniqueName()
     --local header = wm:CreateControlFromVirtual(controlName, optionsWindow, self.lastAddedControl and "ZO_Options_SectionTitle_WithDivider" or "ZO_Options_SectionTitle")
@@ -94,7 +94,7 @@ end
 --extra sub-options window out to the right?? (or maybe addon list?)
 --find alternatives to handler hooks

-function lamPanel:AddSlider(text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
+function lam.Panel:AddSlider(text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -141,7 +141,7 @@ function lamPanel:AddSlider(text, tooltip, minValue, maxValue, step, getFunc, se
     return slider
 end

-function lamPanel:AddDropdown(text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
+function lam.Panel:AddDropdown(text, tooltip, validChoices, getFunc, setFunc, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -181,7 +181,7 @@ function lamPanel:AddDropdown(text, tooltip, validChoices, getFunc, setFunc, war
     return dropdown
 end

-function lamPanel:AddCheckbox(text, tooltip, getFunc, setFunc, warning, warningText)
+function lam.Panel:AddCheckbox(text, tooltip, getFunc, setFunc, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -216,7 +216,7 @@ function lamPanel:AddCheckbox(text, tooltip, getFunc, setFunc, warning, warningT
     return checkbox
 end

-function lamPanel:AddColorPicker(text, tooltip, getFunc, setFunc, warning, warningText)
+function lam.Panel:AddColorPicker(text, tooltip, getFunc, setFunc, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -290,7 +290,7 @@ function lamPanel:AddColorPicker(text, tooltip, getFunc, setFunc, warning, warni
     return colorpicker
 end

-function lamPanel:AddEditBox(tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
+function lam.Panel:AddEditBox(text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -337,7 +337,7 @@ function lamPanel:AddEditBox(tooltip, isMultiLine, getFunc, setFunc, warning, wa
     return editbox
 end

-function lamPanel:AddButton(text, tooltip, onClick, warning, warningText)
+function lam.Panel:AddButton(text, tooltip, onClick, warning, warningText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local controlName = self:getUniqueName()
@@ -374,7 +374,7 @@ function lamPanel:AddButton(text, tooltip, onClick, warning, warningText)
     return button
 end

-function lamPanel:AddDescription(text, titleText)
+function lam.Panel:AddDescription(text, titleText)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local isSubMenu = type(panelID) == "userdata"
@@ -417,7 +417,7 @@ end

 --window doesn't hide when escape is pressed
 --color-picker is hidden for some reason
-function lamPanel:AddSubMenu(text, tooltip)
+function lam.Panel:AddSubMenu(text, tooltip)
     local panelID = self.panelID
     local controlName = self:getUniqueName()
     local menubtn = wm:CreateTopLevelWindow(controlName)
@@ -492,7 +492,7 @@ function lamPanel:AddSubMenu(text, tooltip)
     lam:AddHeader(scroll, controlName.."MenuHeader", text)	--create the header for our menu


-    local panel = setmetatable({}, lamPanel)
+    local panel = setmetatable({}, lam.Panel)
     panel.panelName = controlName
     panel.panelID = panelID
     self.panels[panelID] = panel
@@ -501,7 +501,7 @@ end

 --Adapter code for old interface
 function lam:CreateControlPanel(controlPanelID, controlPanelName)
-    local panel = lamPanel(controlPanelID, controlPanelName)
+    local panel = lam.Panel(controlPanelID, controlPanelName)
     return panel.panelID
 end