Download
(4 Kb)
Download
Updated: 11-13-10 11:17 AM
Pictures
File Info
Updated:11-13-10 11:17 AM
Created:07-05-10 11:41 AM
Downloads:1,328
Favorites:2
MD5:
LibXMenu-1.0
Version: 1.0-5
by: Xruptor [More]
THIS ADDON IS OUTDATED! IT HAS BEEN ABANDONED! I DON'T PLAN TO UPDATE IT!

A library to create simple interactive dropdrown menus.

Note: This is for developers only!

This is my custom library and I'm uploading it so folks could use it. No, it's not perfect but it does the job. No one is forcing you to use it. I needed a library that could do dropdown menus easily.

I documented the library to make it easier for developers to implement.

If you feel you would like to contribute or make modifictions to this library. Please feel free to visit my GitHub. Also, if you like you can send me a PM here so I will add you as a team member.



You can view Alpha Builds at my Github tracker.


This library supports the following menu items:
  • Headers
  • Lists -> Lists -> Lists
  • Toggles (checkmarked items)
  • Color Selector
  • Multiple DB outputs (optional parameters available)
  • Extended menu system



Code:
local dd1 = LibStub('LibXMenu-1.0'):New("DropDownName", database)
dd1.db.color1val = { r = 0, g = 0, b = 0, a = 1, }
dd1.initialize = function(self, lvl)
	if lvl == 1 then
		self:AddTitle(lvl, "My DropDown")
		self:AddList(lvl, "Font Size", "fontsize")
		self:AddList(lvl, "Advance List", "advancelist")
		self:AddColor(lvl, "Color 1", "color1val")
		self:AddToggle(lvl, "Switch", "switch")
		self:AddToggle(lvl, "Switch2", "switch2", otherdb, "otherdboption2")
	elseif lvl and lvl > 1 then
		local sub = UIDROPDOWNMENU_MENU_VALUE
		if sub == "fontsize" then
			--loop selection add
			for i = 5, 12, 1 do
				self:AddSelect(lvl, i, i, "fontsize", nil)
			end
		elseif sub == "advancelist" then
			--several different ways of adding selects
			self:AddSelect(lvl, i, i, db, "dboption1", nil)
			self:AddSelect(lvl, i, i, "dboption2", nil)
		end
	end
end
dd1.doUpdate = function()
	--fired after every menu selection click
	doDisplayUpdates();
end

ToggleDropDownMenu(1, nil, dd1, "cursor")
Another example of the library in use. This is how I implemented it in my addon.

Code:
local dd1 = LibStub('LibXMenu-1.0'):New("Xan_DropDown", Xan_DB)
dd1.initialize = function(self, lvl)
	if lvl == 1 then
		self:AddTitle(lvl, "XanMod")
		self:AddList(lvl, L["Combat Session"], "combatsession")
		self:AddList(lvl, L["Data Type"], "datatype")
		self:AddList(lvl, L["Background Opacity"], "bgOpacity")
		self:AddCloseButton(lvl,  L["Close"])
	elseif lvl and lvl > 1 then
		local sub = UIDROPDOWNMENU_MENU_VALUE
		if sub == "combatsession" then
			self:AddSelect(lvl, L["Previous"], "previous", "cSession")
			self:AddSelect(lvl, L["Current"], "current", "cSession")
			self:AddSelect(lvl, L["Total"], "total", "cSession")
		elseif sub == "datatype" then
			local cCount = 0
			for k, v in pairsByKeys(d_modes) do
				cCount = cCount + 1
				self:AddSelect(lvl, L[v.name], v.name, "viewStyle", nil, nil, cCount)
			end
		elseif sub == "bgOpacity" then
			for i = 0, 1, 0.1 do
				self:AddSelect(lvl, i, i, "bgOpacity")
			end
		end
	end
end
dd1.doUpdate = function(bOpt)
        if bOpt == 1 or bOpt == 2 then
             --a button that was assigned a bOpt was pressed with numbers 1 and 2
              doSomethingElse();
        end
	updateDisplay();
end

ToggleDropDownMenu(1, nil, dd1, "cursor", 0, 0)
Version 1.0-5:
-Doh slight fix for AddList. Forgot to remove debug line lol ;)

Version 1.0-4:
-Added overrides for AddColor()

Version 1.0-3:
-Several bug fixes with the AddSelect().
-AddSelect() will now properly toggle previous and current checks.
-Added LibStub just in case someone doesn't have it.
-AddSelect() now requires arg1. (Mandatory)
-Added a few error checks.
-Removed some redundant code.

Version 1.0.2:
-Fixed an issue where AddToggle wasn't saving items correctly.
-Added a new bOpt flag to be used in doUpdate(). Used to determine which button was pressed.
-Added some updates to the guide to make things a bit easier to understand.

Version 1.0.1:
-Small update.
Optional Files (0)


Archived Files (5)
File Name
Version
Size
Author
Date
1.0-4
4kB
Xruptor
08-01-10 08:40 AM
1.0-3
4kB
Xruptor
07-16-10 09:45 AM
1.0.2
3kB
Xruptor
07-08-10 07:48 AM
1.0.1
3kB
Xruptor
07-06-10 03:20 PM
1.0
3kB
Xruptor
07-05-10 11:41 AM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: