* Ensure that the scroll bar works on longer addon lists
James Whitehead II [02-08-09 - 17:18]
* Ensure that the scroll bar works on longer addon lists
diff --git a/NinjaPanel.lua b/NinjaPanel.lua
index 7ba1ccb..01c56f3 100644
--- a/NinjaPanel.lua
+++ b/NinjaPanel.lua
@@ -194,19 +194,19 @@ end
function NinjaPanel:ScanForPlugins()
self.warned = self.warned or {}
- local changed = false
for name,dataobj in ldb:DataObjectIterator() do
- if not self.pluginNames[name] then
+ -- Make sure we add it to the full list of plugin names
+ if not self.pluginNames[name] then
self.pluginNames[name] = true
table.insert(self.pluginNames, name)
end
+
+ -- Create any plugins that aren't disabled
if not self:HasPlugin(name) and not self:PluginIsDisabled(name) then
if dataobj.type == "data source" or dataobj.text then
self:SpawnPlugin(name, dataobj, "data source")
- changed = true
elseif dataobj.type == "launcher" or (dataobj.icon and dataobj.OnClick) then
self:SpawnPlugin(name, dataobj, "launcher")
- changed = true
elseif not self.warned[name] then
print("Skipping unknown broker object for " .. name .. "(" .. tostring(dataobj.type) .. ")")
self.warned[name] = true
@@ -295,7 +295,7 @@ function NinjaPanel:UpdateTooltipHandlers(button, dataobj)
button:SetScript("OnLeave", Button_OnLeave)
end
end
-
+
function NinjaPanel:UpdatePanels()
-- Ensure the options table exists
db.panels = db.panels or {}
@@ -303,12 +303,11 @@ function NinjaPanel:UpdatePanels()
-- Iterate over the plugins that have been registered, and claim children
local head = self.panels[1]
for name,entry in pairs(self.plugins) do
+ local opt = db.plugins[name]
if not entry.panel then
- local opt = db.plugins[name]
- local panel = opt.panel and self.panels[opt.panel] or head
- self:AttachPlugin(entry, panel)
- entry.button:SetParent(panel)
+ opt.panel = opt.panel and self.panels[opt.panel] or head
end
+ self:AttachPlugin(entry, opt.panel)
end
-- Loop through each of the panels, updating the visual display
@@ -351,6 +350,14 @@ end
function NinjaPanel:AttachPlugin(plugin, panel)
panel.plugins[plugin.name] = plugin
plugin.panel = panel
+ plugin.button:SetParent(panel)
+end
+
+function NinjaPanel:DetachPlugin(plugin)
+ plugin.panel.plugins[plugin.name] = nil
+ plugin.panel = nil
+ plugin.button:ClearAllPoints()
+ plugin.button:Hide()
end
function NinjaPanel:HardAnchorPlugins()
@@ -379,6 +386,7 @@ function Panel_UpdateLayout(self)
local button = entry.button
local height = panel_opts.height - (panel_opts.border_height * 2)
button:SetHeight(height)
+ button:Show()
if entry.object.icon then
-- Actually update the layout of the button
@@ -693,12 +701,15 @@ frame:SetScript("OnShow", function(frame)
local function OnLeave() GameTooltip:Hide() end
local function OnClick(self)
local opts = NinjaPanelDB.plugins[self.name]
+ local plugin = NinjaPanel.plugins[self.name]
if opts.disabled then
opts.disabled = nil
else
opts.disabled = true
+ NinjaPanel:DetachPlugin(plugin)
end
PlaySound(enabled and "igMainMenuOptionCheckBoxOff" or "igMainMenuOptionCheckBoxOn")
+ NinjaPanel:ScanForPlugins()
Refresh()
end
@@ -752,8 +763,7 @@ frame:SetScript("OnShow", function(frame)
for i,row in ipairs(rows) do
if (i + offset) <= #NinjaPanel.pluginNames then
- print(offset, NinjaPanel.pluginNames[i], NinjaPanel.pluginNames[i+offset])
- local name = NinjaPanel.pluginNames[i]
+ local name = NinjaPanel.pluginNames[i + offset]
local entry = NinjaPanel.plugins[name]
local opts = NinjaPanelDB.plugins[name]
local enabled = not opts.disabled