Ace3 backport

This commit is contained in:
Pinya
2018-07-21 13:29:50 +03:00
parent 332d53e7f6
commit f0eac39bcd
43 changed files with 1071 additions and 846 deletions
@@ -12,10 +12,10 @@ Very light wrapper library that combines all the AceConfig subcomponents into on
]]
local cfgreg = LibStub("AceConfigRegistry-3.0-ElvUI")
local cfgcmd = LibStub("AceConfigCmd-3.0-ElvUI")
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0")
local MAJOR, MINOR = "AceConfig-3.0-ElvUI", 3
local MAJOR, MINOR = "AceConfig-3.0", 3
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfig then return end
@@ -14,9 +14,9 @@ REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
-- TODO: plugin args
local cfgreg = LibStub("AceConfigRegistry-3.0-ElvUI")
local cfgreg = LibStub("AceConfigRegistry-3.0")
local MAJOR, MINOR = "AceConfigCmd-3.0-ElvUI", 14
local MAJOR, MINOR = "AceConfigCmd-3.0", 14
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfigCmd then return end
@@ -29,8 +29,10 @@ local AceConsoleName = "AceConsole-3.0"
-- Lua APIs
local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim
local strgsub, strupper, strfind, strlen, strbyte, strgmatch = string.gsub, string.upper, string.find, string.len, string.byte, string.gmatch
local format, tonumber, tostring = string.format, tonumber, tostring
local tsort, tinsert = table.sort, table.insert
local tsort, tinsert, getn = table.sort, table.insert, table.getn
local fmod = math.fmod
local select, pairs, next, type = select, pairs, next, type
local error, assert = error, assert
@@ -64,9 +66,9 @@ local funcmsg = "expected function or member name"
-- pickfirstset() - picks the first non-nil value and returns it
local function pickfirstset(...)
for i=1,select("#",...) do
if select(i,...)~=nil then
return select(i,...)
for i=1,getn(arg) do
if arg[i]~=nil then
return arg[i]
end
end
end
@@ -101,12 +103,12 @@ local function callmethod(info, inputpos, tab, methodtype, ...)
info.type = tab.type
if type(method)=="function" then
return method(info, ...)
return method(info, unpack(arg))
elseif type(method)=="string" then
if type(info.handler[method])~="function" then
err(info, inputpos, "'"..methodtype.."': '"..method.."' is not a member function of "..tostring(info.handler))
end
return info.handler[method](info.handler, info, ...)
return info.handler[method](info.handler, info, unpack(arg))
else
assert(false) -- type should have already been checked on read
end
@@ -122,7 +124,11 @@ local function callfunction(info, tab, methodtype, ...)
info.type = tab.type
if type(method)=="function" then
return method(info, ...)
if getn(arg) > 0 then
return method(info, unpack(arg))
else
return method(info)
end
else
assert(false) -- type should have already been checked on read
end
@@ -132,7 +138,7 @@ end
local function do_final(info, inputpos, tab, methodtype, ...)
if info.validate then
local res = callmethod(info,inputpos,tab,"validate",...)
local res = callmethod(info,inputpos,tab,"validate",unpack(arg))
if type(res)=="string" then
usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
return
@@ -140,7 +146,7 @@ local function do_final(info, inputpos, tab, methodtype, ...)
end
-- console ignores .confirm
callmethod(info,inputpos,tab,methodtype, ...)
callmethod(info,inputpos,tab,methodtype, unpack(arg))
end
@@ -222,16 +228,16 @@ local function showhelp(info, inputpos, tab, depth, noHead)
local o2 = refTbl[two].order or 100
if type(o1) == "function" or type(o1) == "string" then
info.order = o1
info[#info+1] = one
tinsert(info, one)
o1 = callmethod(info, inputpos, refTbl[one], "order")
info[#info] = nil
tremove(info)
info.order = nil
end
if type(o2) == "function" or type(o1) == "string" then
info.order = o2
info[#info+1] = two
tinsert(info, two)
o2 = callmethod(info, inputpos, refTbl[two], "order")
info[#info] = nil
tremove(info)
info.order = nil
end
if o1<0 and o2<0 then return o1<o2 end
@@ -241,7 +247,7 @@ local function showhelp(info, inputpos, tab, depth, noHead)
return o1<o2
end)
for i = 1, #sortTbl do
for i = 1, getn(sortTbl) do
local k = sortTbl[i]
local v = refTbl[k]
if not checkhidden(info, inputpos, v) then
@@ -260,7 +266,7 @@ local function showhelp(info, inputpos, tab, depth, noHead)
showhelp(info, inputpos, v, depth, true)
info.handler,info.handler_at = oldhandler,oldhandler_at
else
local key = k:gsub(" ", "_")
local key = strgsub(k, " ", "_")
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
end
end
@@ -273,7 +279,7 @@ local function keybindingValidateFunc(text)
if text == nil or text == "NONE" then
return nil
end
text = text:upper()
text = strupper(text)
local shift, ctrl, alt
local modifier
while true do
@@ -311,7 +317,7 @@ local function keybindingValidateFunc(text)
if text == "" then
return false
end
if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] then
if not strfind(text,"^F%d+$") and text ~= "CAPSLOCK" and strlen(text) ~= 1 and (strbyte(text) < 128 or strlen(text) > 4) and not _G["KEY_" .. text] then
return false
end
local s = text
@@ -357,7 +363,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
-- grab next arg from input
local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos)
local _,nextpos,arg = strfind(info.input, " *([^ ]+) *", inputpos)
if not arg then
showhelp(info, inputpos, tab, depth)
return
@@ -370,16 +376,16 @@ local function handle(info, inputpos, tab, depth, retfalse)
-- is this child an inline group? if so, traverse into it
if v.type=="group" and pickfirstset(v.cmdInline, v.inline, false) then
info[depth+1] = k
tinsert(info,k)
if handle(info, inputpos, v, depth+1, true)==false then
info[depth+1] = nil
tremove(info)
-- wasn't found in there, but that's ok, we just keep looking down here
else
return -- done, name was found in inline group
end
-- matching name and not a inline group
elseif strlower(arg)==strlower(k:gsub(" ", "_")) then
info[depth+1] = k
elseif strlower(arg)==strlower(strgsub(k, " ", "_")) then
tinsert(info,k)
return handle(info,nextpos,v,depth+1)
end
end
@@ -471,7 +477,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
return
end
if type(info.step)=="number" then
val = val- (val % info.step)
val = val- fmod(val, info.step)
end
if type(info.min)=="number" and val<info.min then
usererr(info, inputpos, val.." - "..format(L["must be equal to or higher than %s"], tostring(info.min)) )
@@ -500,12 +506,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
local b = callmethod(info, inputpos, tab, "get")
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[#info].."|r:"])
print(L["Options for |cffffff78"..info[getn(info)].."|r:"])
for k, v in pairs(values) do
if b == k then
print(fmt_sel:format(k, v))
print(format(fmt_sel, k, v))
else
print(fmt:format(k, v))
print(format(fmt, k, v))
end
end
return
@@ -540,12 +546,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
if str == "" then
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[#info].."|r (multiple possible):"])
print(L["Options for |cffffff78"..info[getn(info)].."|r (multiple possible):"])
for k, v in pairs(values) do
if callmethod(info, inputpos, tab, "get", k) then
print(fmt_sel:format(k, v))
print(format(fmt_sel, k, v))
else
print(fmt:format(k, v))
print(format(fmt, k, v))
end
end
return
@@ -555,9 +561,9 @@ local function handle(info, inputpos, tab, depth, retfalse)
--parse for =on =off =default in the process
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set
local sels = {}
for v in str:gmatch("[^ ]+") do
for v in strgfind(str, "[^ ]+") do
--parse option=on etc
local opt, val = v:match('(.+)=(.+)')
local _, _, opt, val = strfind(v, '(.+)=(.+)')
--get option if toggling
if not opt then
opt = v
@@ -640,7 +646,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
return
end
local r, g, b, a
local _, r, g, b, a
local hasAlpha = tab.hasAlpha
if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
@@ -650,12 +656,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
end
if hasAlpha then
if str:len() == 8 and str:find("^%x*$") then
if strlen(str) == 8 and strfind(str, "^%x*$") then
--parse a hex string
r,g,b,a = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255, tonumber(str:sub(7, 8), 16) / 255
r,g,b,a = tonumber(strsub(str, 1, 2), 16) / 255, tonumber(strsub(str, 3, 4), 16) / 255, tonumber(strsub(str, 5, 6), 16) / 255, tonumber(strsub(str, 7, 8), 16) / 255
else
--parse seperate values
r,g,b,a = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
_,_,r,g,b,a = strfind(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
r,g,b,a = tonumber(r), tonumber(g), tonumber(b), tonumber(a)
end
if not (r and g and b and a) then
@@ -677,12 +683,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
end
else
a = 1.0
if str:len() == 6 and str:find("^%x*$") then
if strlen(str) == 6 and strfind(str, "^%x*$") then
--parse a hex string
r,g,b = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255
r,g,b = tonumber(strsub(str, 1, 2), 16) / 255, tonumber(strsub(str, 3, 4), 16) / 255, tonumber(strsub(str, 5, 6), 16) / 255
else
--parse seperate values
r,g,b = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
_,_,r,g,b = strfind(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
r,g,b = tonumber(r), tonumber(g), tonumber(b)
end
if not (r and g and b) then
@@ -711,7 +717,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
--TODO: Show current value
return
end
local value = keybindingValidateFunc(str:upper())
local value = keybindingValidateFunc(strupper(str))
if value == false then
usererr(info, inputpos, format(L["'%s' - Invalid Keybinding."], str))
return
@@ -741,7 +747,7 @@ end
-- -- Show the GUI if no input is supplied, otherwise handle the chat input.
-- function MyAddon:ChatCommand(input)
-- -- Assuming "MyOptions" is the appName of a valid options table
-- if not input or input:trim() == "" then
-- if not input or trim(input) == "" then
-- LibStub("AceConfigDialog-3.0"):Open("MyOptions")
-- else
-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
@@ -5,9 +5,9 @@
local LibStub = LibStub
local gui = LibStub("AceGUI-3.0")
local reg = LibStub("AceConfigRegistry-3.0-ElvUI")
local reg = LibStub("AceConfigRegistry-3.0")
local MAJOR, MINOR = "AceConfigDialog-3.0-ElvUI", 65
local MAJOR, MINOR = "AceConfigDialog-3.0", 65
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfigDialog then return end
@@ -21,10 +21,10 @@ AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
-- Lua APIs
local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort
local strmatch, format = string.match, string.format
local tconcat, tinsert, tsort, tremove, tsort, getn, setn = table.concat, table.insert, table.sort, table.remove, table.sort, table.getn, table.setn
local gsub, format, upper, find = string.gsub, string.format, string.upper, string.find
local assert, loadstring, error = assert, loadstring, error
local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs
local pairs, next, type, unpack, wipe, ipairs = pairs, next, type, unpack, wipe, ipairs
local rawset, tostring, tonumber = rawset, tostring, tonumber
local math_min, math_max, math_floor = math.min, math.max, math.floor
@@ -47,14 +47,14 @@ end
local function CreateDispatcher(argCount)
local code = [[
local xpcall, eh = ...
local xpcall, eh = xpcall, function(err) return geterrorhandler()(err) end
local method, ARGS
local function call() return method(ARGS) end
local function dispatch(func, ...)
method = func
if not method then return end
ARGS = ...
ARGS = unpack(arg)
return xpcall(call, eh)
end
@@ -63,7 +63,7 @@ local function CreateDispatcher(argCount)
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", tconcat(ARGS, ", "))
code = gsub(code, "ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
@@ -77,7 +77,7 @@ Dispatchers[0] = function(func)
end
local function safecall(func, ...)
return Dispatchers[select("#", ...)](func, ...)
return Dispatchers[getn(arg)](func, unpack(arg))
end
local width_multiplier = 170
@@ -121,6 +121,7 @@ do
for k, v in pairs(t) do
c[k] = v
end
setn(c, getn(t))
return c
end
function del(t)
@@ -139,11 +140,11 @@ end
-- picks the first non-nil value and returns it
local function pickfirstset(...)
for i=1,select("#",...) do
if select(i,...)~=nil then
return select(i,...)
end
end
for i=1,getn(arg) do
if arg[i]~=nil then
return arg[i]
end
end
end
--gets an option from a given group, checking plugins
@@ -207,7 +208,7 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
if group[membername] ~= nil then
member = group[membername]
end
for i = 1, #path do
for i = 1, getn(path) do
group = GetSubOption(group, path[i])
if group[membername] ~= nil then
member = group[membername]
@@ -226,11 +227,13 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
local group = options
handler = group.handler or handler
for i = 1, #path do
local x = getn(path)
for i = 1, x do
group = GetSubOption(group, path[i])
info[i] = path[i]
handler = group.handler or handler
end
setn(info, x)
info.options = options
info.appName = appName
@@ -242,21 +245,21 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
info.uiType = "dialog"
info.uiName = MAJOR
local a, b, c ,d, e, f, g, h
local a, b, c ,d
--using 4 returns for the get of a color type, increase if a type needs more
if type(member) == "function" then
--Call the function
a,b,c,d, e, f, g, h = member(info, ...)
a,b,c,d = member(info, unpack(arg))
else
--Call the method
if handler and handler[member] then
a,b,c,d,e, f, g, h = handler[member](handler, info, ...)
a,b,c,d = handler[member](handler, info, unpack(arg))
else
error(format("Method %s doesn't exist in handler for type %s", member, membername))
end
end
del(info)
return a,b,c,d,e, f, g, h
return a,b,c,d
else
--The value isnt a function to call, return it
return member
@@ -322,7 +325,7 @@ local function compareOptions(a,b)
if OrderA == OrderB then
local NameA = (type(tempNames[a]) == "string") and tempNames[a] or ""
local NameB = (type(tempNames[b]) == "string") and tempNames[b] or ""
return NameA:upper() < NameB:upper()
return upper(NameA) < upper(NameB)
end
if OrderA < 0 then
if OrderB > 0 then
@@ -352,10 +355,10 @@ local function BuildSortedOptionsTable(group, keySort, opts, options, path, appN
tinsert(keySort, k)
opts[k] = v
path[#path+1] = k
tinsert(path,k)
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
path[#path] = nil
tremove(path)
end
end
end
@@ -366,10 +369,10 @@ local function BuildSortedOptionsTable(group, keySort, opts, options, path, appN
tinsert(keySort, k)
opts[k] = v
path[#path+1] = k
tinsert(path,k)
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
path[#path] = nil
tremove(path)
end
end
@@ -382,7 +385,7 @@ end
local function DelTree(tree)
if tree.children then
local childs = tree.children
for i = 1, #childs do
for i = 1, getn(childs) do
DelTree(childs[i])
del(childs[i])
end
@@ -402,7 +405,7 @@ local function CleanUserData(widget, event)
local tree = user.tree
widget:SetTree(nil)
if tree then
for i = 1, #tree do
for i = 1, getn(tree) do
DelTree(tree[i])
del(tree[i])
end
@@ -444,7 +447,7 @@ function AceConfigDialog:GetStatusTable(appName, path)
status = status[appName]
if path then
for i = 1, #path do
for i = 1, getn(path) do
local v = path[i]
if not status.children[v] then
status.children[v] = {}
@@ -468,7 +471,7 @@ function AceConfigDialog:SelectGroup(appName, ...)
local app = reg:GetOptionsTable(appName)
if not app then
error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
error(format("%s isn't registed with AceConfigRegistry, unable to open config", appName), 2)
end
local options = app("dialog", MAJOR)
local group = options
@@ -480,8 +483,8 @@ function AceConfigDialog:SelectGroup(appName, ...)
local treevalue
local treestatus
for n = 1, select("#",...) do
local key = select(n, ...)
for n = 1, getn(arg) do
local key = arg[n]
if group.childGroups == "tab" or group.childGroups == "select" then
--if this is a tab or select group, select the group
@@ -597,9 +600,11 @@ local function confirmPopup(appName, rootframe, basepath, info, message, func, .
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
del(info)
end
for i = 1, select("#", ...) do
t[i] = select(i, ...) or false
local x = getn(arg)
for i = 1, x do
t[i] = arg[i] or false
end
setn(t, x)
t.timeout = 0
t.whileDead = 1
t.hideOnEscape = 1
@@ -659,7 +664,8 @@ local function ActivateControl(widget, event, ...)
handler = group.handler or handler
confirm = group.confirm
validate = group.validate
for i = 1, #path do
local x = getn(path)
for i = 1, x do
local v = path[i]
group = GetSubOption(group, v)
info[i] = v
@@ -674,6 +680,7 @@ local function ActivateControl(widget, event, ...)
validate = group.validate
end
end
setn(info, x)
info.options = options
info.appName = user.appName
@@ -699,7 +706,7 @@ local function ActivateControl(widget, event, ...)
if option.type == "input" then
if type(pattern)=="string" then
if not strmatch(..., pattern) then
if not find(arg[1], pattern) then
validated = false
end
end
@@ -709,13 +716,13 @@ local function ActivateControl(widget, event, ...)
if validated and option.type ~= "execute" then
if type(validate) == "string" then
if handler and handler[validate] then
success, validated = safecall(handler[validate], handler, info, ...)
success, validated = safecall(handler[validate], handler, info, unpack(arg))
if not success then validated = false end
else
error(format("Method %s doesn't exist in handler for type execute", validate))
end
elseif type(validate) == "function" then
success, validated = safecall(validate, info, ...)
success, validated = safecall(validate, info, unpack(arg))
if not success then validated = false end
end
end
@@ -749,7 +756,7 @@ local function ActivateControl(widget, event, ...)
--call confirm func/method
if type(confirm) == "string" then
if handler and handler[confirm] then
success, confirm = safecall(handler[confirm], handler, info, ...)
success, confirm = safecall(handler[confirm], handler, info, unpack(arg))
if success and type(confirm) == "string" then
confirmText = confirm
confirm = true
@@ -760,7 +767,7 @@ local function ActivateControl(widget, event, ...)
error(format("Method %s doesn't exist in handler for type confirm", confirm))
end
elseif type(confirm) == "function" then
success, confirm = safecall(confirm, info, ...)
success, confirm = safecall(confirm, info, unpack(arg))
if success and type(confirm) == "string" then
confirmText = confirm
confirm = true
@@ -795,12 +802,12 @@ local function ActivateControl(widget, event, ...)
local basepath = user.rootframe:GetUserData("basepath")
if type(func) == "string" then
if handler and handler[func] then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...)
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, unpack(arg))
else
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...)
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, unpack(arg))
end
--func will be called and info deleted when the confirm dialog is responded to
return
@@ -810,12 +817,12 @@ local function ActivateControl(widget, event, ...)
--call the function
if type(func) == "string" then
if handler and handler[func] then
safecall(handler[func],handler, info, ...)
safecall(handler[func],handler, info, unpack(arg))
else
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
safecall(func,info, ...)
safecall(func,info, unpack(arg))
end
@@ -873,7 +880,7 @@ end
--called from a checkbox that is part of an internally created multiselect group
--this type is safe to refresh on activation of one control
local function ActivateMultiControl(widget, event, ...)
ActivateControl(widget, event, widget:GetUserData("value"), ...)
ActivateControl(widget, event, widget:GetUserData("value"), unpack(arg))
local user = widget:GetUserDataTable()
local iscustom = user.rootframe:GetUserData("iscustom")
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
@@ -960,18 +967,18 @@ local function BuildSelect(group, options, path, appName)
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
for i = 1, #keySort do
for i = 1, getn(keySort) do
local k = keySort[i]
local v = opts[k]
if v.type == "group" then
path[#path+1] = k
tinsert(path, k)
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
local hidden = CheckOptionHidden(v, options, path, appName)
if not inline and not hidden then
groups[k] = GetOptionsMemberValue("name", v, options, path, appName)
tinsert(order, k)
end
path[#path] = nil
tremove(path)
end
end
@@ -987,11 +994,11 @@ local function BuildSubGroups(group, tree, options, path, appName)
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
for i = 1, #keySort do
for i = 1, getn(keySort) do
local k = keySort[i]
local v = opts[k]
if v.type == "group" then
path[#path+1] = k
tinsert(path, k)
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
local hidden = CheckOptionHidden(v, options, path, appName)
if not inline and not hidden then
@@ -1007,7 +1014,7 @@ local function BuildSubGroups(group, tree, options, path, appName)
BuildSubGroups(v,entry, options, path, appName)
end
end
path[#path] = nil
tremove(path)
end
end
@@ -1022,11 +1029,11 @@ local function BuildGroups(group, options, path, appName, recurse)
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
for i = 1, #keySort do
for i = 1, getn(keySort) do
local k = keySort[i]
local v = opts[k]
if v.type == "group" then
path[#path+1] = k
tinsert(path,k)
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
local hidden = CheckOptionHidden(v, options, path, appName)
if not inline and not hidden then
@@ -1041,7 +1048,7 @@ local function BuildGroups(group, options, path, appName, recurse)
BuildSubGroups(v,entry, options, path, appName)
end
end
path[#path] = nil
tremove(path)
end
end
del(keySort)
@@ -1051,9 +1058,11 @@ end
local function InjectInfo(control, options, option, path, rootframe, appName)
local user = control:GetUserDataTable()
for i = 1, #path do
local x = getn(path)
for i = 1, x do
user[i] = path[i]
end
setn(user, x)
user.rootframe = rootframe
user.option = option
user.options = options
@@ -1078,7 +1087,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
for i = 1, #keySort do
for i = 1, getn(keySort) do
local k = keySort[i]
local v = opts[k]
tinsert(path, k)
@@ -1144,7 +1153,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
local controlType = v.dialogControl or v.control or (v.multiline and "MultiLineEditBox") or "EditBox"
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
geterrorhandler()(format("Invalid Custom Control Type - %s", tostring(controlType)))
control = gui:Create(v.multiline and "MultiLineEditBox" or "EditBox")
end
@@ -1209,7 +1218,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
local optionValue = GetOptionsMemberValue("get",v, options, path, appName)
local t = {}
for value, text in pairs(values) do
t[#t+1]=value
tinsert(t, value)
end
tsort(t)
for k, value in ipairs(t) do
@@ -1240,12 +1249,12 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
local controlType = v.dialogControl or v.control or "Dropdown"
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
geterrorhandler()(format("Invalid Custom Control Type - %s", tostring(controlType)))
control = gui:Create("Dropdown")
end
local itemType = v.itemControl
if itemType and not gui:GetWidgetVersion(itemType) then
geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType)))
geterrorhandler()(format("Invalid Custom Item Type - %s", tostring(itemType)))
itemType = nil
end
control:SetLabel(name)
@@ -1275,7 +1284,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
if controlType then
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
geterrorhandler()(format("Invalid Custom Control Type - %s", tostring(controlType)))
end
end
if control then
@@ -1296,7 +1305,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
control:SetWidth(width_multiplier)
end
--check:SetTriState(v.tristate)
for i = 1, #valuesort do
for i = 1, getn(valuesort) do
local key = valuesort[i]
local value = GetOptionsMemberValue("get",v, options, path, appName, key)
control:SetItemValue(key,value)
@@ -1309,7 +1318,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
control:PauseLayout()
local width = GetOptionsMemberValue("width",v,options,path,appName)
for i = 1, #valuesort do
for i = 1, getn(valuesort) do
local value = valuesort[i]
local text = values[value]
local check = gui:Create("CheckBox")
@@ -1341,7 +1350,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
del(valuesort)
elseif v.type == "color" then
control = gui:Create("ColorPicker-ElvUI")
control = gui:Create("ColorPicker")
control:SetLabel(name)
control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName))
control:SetColor(GetOptionsMemberValue("get",v, options, path, appName))
@@ -1433,8 +1442,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
end
local function BuildPath(path, ...)
for i = 1, select("#",...) do
tinsert(path, (select(i,...)))
for i = 1, getn(arg) do
tinsert(path, arg[i])
end
end
@@ -1448,13 +1457,15 @@ local function TreeOnButtonEnter(widget, event, uniquevalue, button)
local appName = user.appName
local feedpath = new()
for i = 1, #path do
local x = getn(path)
for i = 1, x do
feedpath[i] = path[i]
end
setn(feedpath, x)
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, strsplit("\001", uniquevalue))
local group = options
for i = 1, #feedpath do
for i = 1, getn(feedpath) do
if not group then return end
group = GetSubOption(group, feedpath[i])
end
@@ -1462,7 +1473,7 @@ local function TreeOnButtonEnter(widget, event, uniquevalue, button)
local name = GetOptionsMemberValue("name", group, options, feedpath, appName)
local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName)
GameTooltip:SetOwner(button, "ANCHOR_CURSOR")
GameTooltip:SetOwner(button, "ANCHOR_NONE")
if widget.type == "TabGroup" then
GameTooltip:SetPoint("BOTTOM",button,"TOP")
else
@@ -1488,14 +1499,16 @@ local function GroupExists(appName, options, path, uniquevalue)
local feedpath = new()
local temppath = new()
for i = 1, #path do
local x = getn(path)
for i = 1, x do
feedpath[i] = path[i]
end
setn(feedpath, x)
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, strsplit("\001", uniquevalue))
local group = options
for i = 1, #feedpath do
for i = 1, getn(feedpath) do
local v = feedpath[i]
temppath[i] = v
group = GetSubOption(group, v)
@@ -1521,13 +1534,15 @@ local function GroupSelected(widget, event, uniquevalue)
local rootframe = user.rootframe
local feedpath = new()
for i = 1, #path do
local x = getn(path)
for i = 1, x do
feedpath[i] = path[i]
end
setn(feedpath, x)
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, strsplit("\001", uniquevalue))
local group = options
for i = 1, #feedpath do
for i = 1, getn(feedpath) do
group = GetSubOption(group, feedpath[i])
end
widget:ReleaseChildren()
@@ -1561,10 +1576,10 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
local grouptype, parenttype = options.childGroups, "none"
for i = 1, #path do
for i = 1, getn(path) do
local v = path[i]
group = GetSubOption(group, v)
inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
inline = inline or pickfirstset(group.dialogInline,group.guiInline,group.inline, false)
parenttype = grouptype
grouptype = group.childGroups
end
@@ -1639,7 +1654,7 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
tab:SetTabs(tabs)
tab:SetUserData("tablist", tabs)
for i = 1, #tabs do
for i = 1, getn(tabs) do
local entry = tabs[i]
if not entry.disabled then
tab:SelectTab((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
@@ -1699,7 +1714,7 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
tree:SetTree(treedefinition)
tree:SetUserData("tree",treedefinition)
for i = 1, #treedefinition do
for i = 1, getn(treedefinition) do
local entry = treedefinition[i]
if not entry.disabled then
tree:SelectByValue((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
@@ -1715,7 +1730,7 @@ end
local old_CloseSpecialWindows
local function RefreshOnUpdate(this)
local function RefreshOnUpdate()
for appName in pairs(this.closing) do
if AceConfigDialog.OpenFrames[appName] then
AceConfigDialog.OpenFrames[appName]:Hide()
@@ -1819,7 +1834,7 @@ function AceConfigDialog:Open(appName, container, ...)
end
local app = reg:GetOptionsTable(appName)
if not app then
error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
error(format("%s isn't registed with AceConfigRegistry, unable to open config", appName), 2)
end
local options = app("dialog", MAJOR)
@@ -1834,13 +1849,13 @@ function AceConfigDialog:Open(appName, container, ...)
tinsert(path, container)
container = nil
end
for n = 1, select("#",...) do
tinsert(path, (select(n, ...)))
for n = 1, getn(arg) do
tinsert(path, arg[n])
end
local option = options
if type(container) == "table" and container.type == "BlizOptionsGroup" and #path > 0 then
for i = 1, #path do
if type(container) == "table" and container.type == "BlizOptionsGroup" and getn(path) > 0 then
for i = 1, getn(path) do
option = options.args[path[i]]
end
name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
@@ -1852,7 +1867,7 @@ function AceConfigDialog:Open(appName, container, ...)
f:ReleaseChildren()
f:SetUserData("appName", appName)
f:SetUserData("iscustom", true)
if #path > 0 then
if getn(path) > 0 then
f:SetUserData("basepath", copy(path))
end
local status = AceConfigDialog:GetStatusTable(appName)
@@ -1878,7 +1893,7 @@ function AceConfigDialog:Open(appName, container, ...)
f:ReleaseChildren()
f:SetCallback("OnClose", FrameOnClose)
f:SetUserData("appName", appName)
if #path > 0 then
if getn(path) > 0 then
f:SetUserData("basepath", copy(path))
end
f:SetTitle(name or "")
@@ -1944,8 +1959,8 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
local BlizOptions = AceConfigDialog.BlizOptions
local key = appName
for n = 1, select("#", ...) do
key = key.."\001"..select(n, ...)
for n = 1, getn(arg) do
key = key.."\001"..arg[n]
end
if not BlizOptions[appName] then
@@ -1959,10 +1974,10 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
group:SetTitle(name or appName)
group:SetUserData("appName", appName)
if select("#", ...) > 0 then
if getn(arg) > 0 then
local path = {}
for n = 1, select("#",...) do
tinsert(path, (select(n, ...)))
for n = 1, getn(arg) do
tinsert(path, arg[n])
end
group:SetUserData("path", path)
end
@@ -1971,6 +1986,6 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
InterfaceOptions_AddCategory(group.frame)
return group.frame
else
error(("%s has already been added to the Blizzard Options Window with the given path"):format(appName), 2)
error(format("%s has already been added to the Blizzard Options Window with the given path", appName), 2)
end
end
@@ -11,7 +11,7 @@
-- @release $Id: AceConfigRegistry-3.0.lua 1105 2013-12-08 22:11:58Z nevcairiel $
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
local MAJOR, MINOR = "AceConfigRegistry-3.0-ElvUI", 17
local MAJOR, MINOR = "AceConfigRegistry-3.0", 17
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfigRegistry then return end
@@ -23,9 +23,9 @@ if not AceConfigRegistry.callbacks then
end
-- Lua APIs
local tinsert, tconcat = table.insert, table.concat
local tinsert, tconcat, getn = table.insert, table.concat, table.getn
local strfind, strmatch = string.find, string.match
local type, tostring, select, pairs = type, tostring, select, pairs
local type, tostring, pairs, unpack = type, tostring, pairs, unpack
local error, assert = error, assert
-----------------------------------------------------------------------
@@ -44,8 +44,8 @@ AceConfigRegistry.validated = {
local function err(msg, errlvl, ...)
local t = {}
for i=select("#",...),1,-1 do
tinsert(t, (select(i, ...)))
for i=getn(arg),1,-1 do
tinsert(t, arg[i])
end
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
end
@@ -90,6 +90,7 @@ local basekeys={
func=optmethodfalse,
arg={["*"]=true},
width=optstring,
-- below here were created by ElvUI --
buttonElvUI=optmethodbool,
}
@@ -164,7 +165,6 @@ local typedkeys={
},
color={
hasAlpha=optmethodbool,
reset=opttable,
},
keybinding={
-- TODO
@@ -174,10 +174,10 @@ local typedkeys={
local function validateKey(k,errlvl,...)
errlvl=(errlvl or 0)+1
if type(k)~="string" then
err("["..tostring(k).."] - key is not a string", errlvl,...)
err("["..tostring(k).."] - key is not a string", errlvl,unpack(arg))
end
if strfind(k, "[%c\127]") then
err("["..tostring(k).."] - key name contained control characters", errlvl,...)
err("["..tostring(k).."] - key name contained control characters", errlvl,unpack(arg))
end
end
@@ -186,11 +186,11 @@ local function validateVal(v, oktypes, errlvl,...)
local isok=oktypes[type(v)] or oktypes["*"]
if not isok then
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...)
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,unpack(arg))
end
if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
if not isok[v] then
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...)
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,unpack(arg))
end
end
end
@@ -199,47 +199,47 @@ local function validate(options,errlvl,...)
errlvl=(errlvl or 0)+1
-- basic consistency
if type(options)~="table" then
err(": expected a table, got a "..type(options), errlvl,...)
err(": expected a table, got a "..type(options), errlvl,unpack(arg))
end
if type(options.type)~="string" then
err(".type: expected a string, got a "..type(options.type), errlvl,...)
err(".type: expected a string, got a "..type(options.type), errlvl,unpack(arg))
end
-- get type and 'typedkeys' member
local tk = typedkeys[options.type]
if not tk then
err(".type: unknown type '"..options.type.."'", errlvl,...)
err(".type: unknown type '"..options.type.."'", errlvl,unpack(arg))
end
-- make sure that all options[] are known parameters
for k,v in pairs(options) do
if not (tk[k] or basekeys[k]) then
err(": unknown parameter", errlvl,tostring(k),...)
err(": unknown parameter", errlvl,tostring(k),unpack(arg))
end
end
-- verify that required params are there, and that everything is the right type
for k,oktypes in pairs(basekeys) do
validateVal(options[k], oktypes, errlvl,k,...)
validateVal(options[k], oktypes, errlvl,k,unpack(arg))
end
for k,oktypes in pairs(tk) do
validateVal(options[k], oktypes, errlvl,k,...)
validateVal(options[k], oktypes, errlvl,k,unpack(arg))
end
-- extra logic for groups
if options.type=="group" then
for k,v in pairs(options.args) do
validateKey(k,errlvl,"args",...)
validate(v, errlvl,k,"args",...)
validateKey(k,errlvl,"args",unpack(arg))
validate(v, errlvl,k,"args",unpack(arg))
end
if options.plugins then
for plugname,plugin in pairs(options.plugins) do
if type(plugin)~="table" then
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...)
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",unpack(arg))
end
for k,v in pairs(plugin) do
validateKey(k,errlvl,tostring(plugname),"plugins",...)
validate(v, errlvl,k,tostring(plugname),"plugins",...)
validateKey(k,errlvl,tostring(plugname),"plugins",unpack(arg))
validate(v, errlvl,k,tostring(plugname),"plugins",unpack(arg))
end
end
end
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0")
local next, ipairs, pairs = next, ipairs, pairs
local upper = string.upper
local tinsert, tremove, sort = table.insert, table.remove, table.sort
do
local widgetType = "LSM30_Background"
local widgetVersion = 11
@@ -15,10 +19,10 @@ do
self:ClearAllPoints()
self:Hide()
self.check:Hide()
table.insert(contentFrameCache, self)
tinsert(contentFrameCache, self)
end
local function ContentOnClick(this, button)
local function ContentOnClick()
local self = this.obj
self:Fire("OnValueChanged", this.text:GetText())
if self.dropdown then
@@ -26,7 +30,7 @@ do
end
end
local function ContentOnEnter(this, button)
local function ContentOnEnter()
local self = this.obj
local text = this.text:GetText()
local background = self.list[text] ~= text and self.list[text] or Media:Fetch('background',text)
@@ -36,7 +40,7 @@ do
local function GetContentLine()
local frame
if next(contentFrameCache) then
frame = table.remove(contentFrameCache)
frame = tremove(contentFrameCache)
else
frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200)
@@ -140,7 +144,7 @@ do
end
local function textSort(a,b)
return string.upper(a) < string.upper(b)
return upper(a) < upper(b)
end
local sortedlist = {}
@@ -156,9 +160,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do
sortedlist[#sortedlist+1] = k
tinsert(sortedlist, k)
end
table.sort(sortedlist, textSort)
sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do
local f = GetContentLine()
f.text:SetText(k)
@@ -180,18 +184,18 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
end
end
local function Drop_OnEnter(this)
local function Drop_OnEnter()
this.obj:Fire("OnEnter")
end
local function Drop_OnLeave(this)
local function Drop_OnLeave()
this.obj:Fire("OnLeave")
end
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0")
local next, ipairs, pairs = next, ipairs, pairs
local upper = string.upper
local tinsert, tremove, sort = table.insert, table.remove, table.sort
do
local widgetType = "LSM30_Border"
local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints()
self:Hide()
self.check:Hide()
table.insert(contentFrameCache, self)
tinsert(contentFrameCache, self)
end
local function ContentOnClick(this, button)
@@ -39,7 +43,7 @@ do
local function GetContentLine()
local frame
if next(contentFrameCache) then
frame = table.remove(contentFrameCache)
frame = tremove(contentFrameCache)
else
frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200)
@@ -135,7 +139,7 @@ do
end
local function textSort(a,b)
return string.upper(a) < string.upper(b)
return upper(a) < upper(b)
end
local sortedlist = {}
@@ -151,9 +155,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do
sortedlist[#sortedlist+1] = k
tinsert(sortedlist, k)
end
table.sort(sortedlist, textSort)
sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do
local f = GetContentLine()
f.text:SetText(k)
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0")
local next, ipairs, pairs = next, ipairs, pairs
local upper = string.upper
local tinsert, tremove, sort = table.insert, table.remove, table.sort
do
local widgetType = "LSM30_Font"
local widgetVersion = 11
@@ -15,10 +19,10 @@ do
self:ClearAllPoints()
self:Hide()
self.check:Hide()
table.insert(contentFrameCache, self)
tinsert(contentFrameCache, self)
end
local function ContentOnClick(this, button)
local function ContentOnClick()
local self = this.obj
self:Fire("OnValueChanged", this.text:GetText())
if self.dropdown then
@@ -29,7 +33,7 @@ do
local function GetContentLine()
local frame
if next(contentFrameCache) then
frame = table.remove(contentFrameCache)
frame = tremove(contentFrameCache)
else
frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200)
@@ -120,11 +124,11 @@ do
end
local function textSort(a,b)
return string.upper(a) < string.upper(b)
return upper(a) < upper(b)
end
local sortedlist = {}
local function ToggleDrop(this)
local function ToggleDrop()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
@@ -136,9 +140,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do
sortedlist[#sortedlist+1] = k
tinsert(sortedlist, k)
end
table.sort(sortedlist, textSort)
sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do
local f = GetContentLine()
local _, size, outline= f.text:GetFont()
@@ -161,18 +165,18 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
end
end
local function Drop_OnEnter(this)
local function Drop_OnEnter()
this.obj:Fire("OnEnter")
end
local function Drop_OnLeave(this)
local function Drop_OnLeave()
this.obj:Fire("OnLeave")
end
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0")
local next, ipairs, pairs = next, ipairs, pairs
local upper = string.upper
local tinsert, tremove, sort = table.insert, table.remove, table.sort
do
local widgetType = "LSM30_Sound"
local widgetVersion = 11
@@ -15,10 +19,10 @@ do
self:ClearAllPoints()
self:Hide()
self.check:Hide()
table.insert(contentFrameCache, self)
tinsert(contentFrameCache, self)
end
local function ContentOnClick(this, button)
local function ContentOnClick()
local self = this.obj
self:Fire("OnValueChanged", this.text:GetText())
if self.dropdown then
@@ -26,7 +30,7 @@ do
end
end
local function ContentSpeakerOnClick(this, button)
local function ContentSpeakerOnClick()
local self = this.frame.obj
local sound = this.frame.text:GetText()
PlaySoundFile(self.list[sound] ~= sound and self.list[sound] or Media:Fetch('sound',sound), "Master")
@@ -35,7 +39,7 @@ do
local function GetContentLine()
local frame
if next(contentFrameCache) then
frame = table.remove(contentFrameCache)
frame = tremove(contentFrameCache)
else
frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200)
@@ -145,11 +149,11 @@ do
end
local function textSort(a,b)
return string.upper(a) < string.upper(b)
return upper(a) < upper(b)
end
local sortedlist = {}
local function ToggleDrop(this)
local function ToggleDrop()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
@@ -161,9 +165,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do
sortedlist[#sortedlist+1] = k
tinsert(sortedlist, k)
end
table.sort(sortedlist, textSort)
sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do
local f = GetContentLine()
f.text:SetText(k)
@@ -183,22 +187,22 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
end
end
local function Drop_OnEnter(this)
local function Drop_OnEnter()
this.obj:Fire("OnEnter")
end
local function Drop_OnLeave(this)
local function Drop_OnLeave()
this.obj:Fire("OnLeave")
end
local function WidgetPlaySound(this)
local function WidgetPlaySound()
local self = this.obj
local sound = self.frame.text:GetText()
PlaySoundFile(self.list[sound] ~= sound and self.list[sound] or Media:Fetch('sound',sound), "Master")
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0")
local next, ipairs, pairs = next, ipairs, pairs
local upper = string.upper
local tinsert, tremove, sort = table.insert, table.remove, table.sort
do
local widgetType = "LSM30_Statusbar"
local widgetVersion = 11
@@ -15,10 +19,10 @@ do
self:ClearAllPoints()
self:Hide()
self.check:Hide()
table.insert(contentFrameCache, self)
tinsert(contentFrameCache, self)
end
local function ContentOnClick(this, button)
local function ContentOnClick()
local self = this.obj
self:Fire("OnValueChanged", this.text:GetText())
if self.dropdown then
@@ -29,7 +33,7 @@ do
local function GetContentLine()
local frame
if next(contentFrameCache) then
frame = table.remove(contentFrameCache)
frame = tremove(contentFrameCache)
else
frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200)
@@ -129,11 +133,11 @@ do
end
local function textSort(a,b)
return string.upper(a) < string.upper(b)
return upper(a) < upper(b)
end
local sortedlist = {}
local function ToggleDrop(this)
local function ToggleDrop()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
@@ -145,9 +149,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do
sortedlist[#sortedlist+1] = k
tinsert(sortedlist, k)
end
table.sort(sortedlist, textSort)
sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do
local f = GetContentLine()
f.text:SetText(k)
@@ -172,18 +176,18 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.dropdown then
self.dropdown = AGSMW:ReturnDropDownFrame(self.dropdown)
end
end
local function Drop_OnEnter(this)
local function Drop_OnEnter()
this.obj:Fire("OnEnter")
end
local function Drop_OnLeave(this)
local function Drop_OnLeave()
this.obj:Fire("OnLeave")
end
@@ -16,6 +16,11 @@ local Media = LibStub("LibSharedMedia-3.0")
AGSMW = AGSMW or {}
local next, ipairs = next, ipairs
local tinsert, tremove = table.insert, table.remove
local GetScreenHeight = GetScreenHeight
AceGUIWidgetLSMlists = {
['font'] = Media:HashTable("font"),
['sound'] = Media:HashTable("sound"),
@@ -156,8 +161,8 @@ do
insets = { left = 11, right = 12, top = 12, bottom = 9 },
}
local function OnMouseWheel(self, dir)
self.slider:SetValue(self.slider:GetValue()+(15*dir*-1))
local function OnMouseWheel()
this.slider:SetValue(this.slider:GetValue()+(15*arg1*-1))
end
local function AddFrame(self, frame)
@@ -166,20 +171,19 @@ do
frame:SetFrameLevel(self:GetFrameLevel() + 100)
if next(self.contentRepo) then
frame:SetPoint("TOPLEFT", self.contentRepo[#self.contentRepo], "BOTTOMLEFT", 0, 0)
frame:SetPoint("TOPLEFT", self.contentRepo[getn(self.contentRepo)], "BOTTOMLEFT", 0, 0)
frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight())
self.contentRepo[#self.contentRepo+1] = frame
else
self.contentframe:SetHeight(frame:GetHeight())
frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0)
frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
self.contentRepo[1] = frame
end
tinsert(self.contentRepo, frame)
if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then
if self.contentframe:GetHeight() > GetScreenHeight()*2/5 - 20 then
self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -28, 12)
self:SetHeight(UIParent:GetHeight()*2/5)
self:SetHeight(GetScreenHeight()*2/5)
self.slider:Show()
self:SetScript("OnMouseWheel", OnMouseWheel)
self.scrollframe:UpdateScrollChildRect()
@@ -202,15 +206,15 @@ do
end
end
local function slider_OnValueChanged(self, value)
self.frame.scrollframe:SetVerticalScroll(value)
local function slider_OnValueChanged()
this.frame.scrollframe:SetVerticalScroll(arg1)
end
local DropDownCache = {}
function AGSMW:GetDropDownFrame()
local frame
if next(DropDownCache) then
frame = table.remove(DropDownCache)
frame = tremove(DropDownCache)
else
frame = CreateFrame("Frame", nil, UIParent)
frame:SetClampedToScreen(true)
@@ -255,7 +259,7 @@ do
slider:SetScript("OnValueChanged", slider_OnValueChanged)
frame.slider = slider
end
frame:SetHeight(UIParent:GetHeight()*2/5)
frame:SetHeight(GetScreenHeight()*2/5)
frame.slider:SetValue(0)
frame:Show()
return frame
@@ -267,7 +271,7 @@ do
frame:Hide()
frame:SetBackdrop(frameBackdrop)
frame.bgTex:SetTexture(nil)
table.insert(DropDownCache, frame)
tinsert(DropDownCache, frame)
return nil
end
end
@@ -31,8 +31,9 @@ local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
if not AceGUI then return end -- No upgrade needed
-- Lua APIs
local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
local select, pairs, next, type = select, pairs, next, type
local tconcat, tremove, tinsert, getn = table.concat, table.remove, table.insert, table.getn
local format, gsub, upper = string.format, string.gsub, string.upper
local pairs, next, type, unpack = pairs, next, type, unpack
local error, assert, loadstring = error, assert, loadstring
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
local math_max = math.max
@@ -68,14 +69,14 @@ end
local function CreateDispatcher(argCount)
local code = [[
local xpcall, eh = ...
local xpcall, eh = xpcall, function(err) return geterrorhandler()(err) end
local method, ARGS
local function call() return method(ARGS) end
local function dispatch(func, ...)
method = func
if not method then return end
ARGS = ...
ARGS = unpack(arg)
return xpcall(call, eh)
end
@@ -84,7 +85,7 @@ local function CreateDispatcher(argCount)
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", tconcat(ARGS, ", "))
code = gsub(code, "ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
@@ -98,7 +99,7 @@ Dispatchers[0] = function(func)
end
local function safecall(func, ...)
return Dispatchers[select("#", ...)](func, ...)
return Dispatchers[getn(arg)](func, unpack(arg))
end
-- Recycling functions
@@ -158,6 +159,18 @@ do
end
local function fixlevels(parent)
local child
local childList = {parent:GetChildren()}
local level = parent:GetFrameLevel() + 1
for i = 1, getn(childList) do
child = childList[i]
child:SetFrameLevel(level)
fixlevels(child)
end
end
-------------------
-- API Functions --
-------------------
@@ -189,7 +202,7 @@ function AceGUI:Create(type)
if widget.OnAcquire then
widget:OnAcquire()
else
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type))
error(format("Widget type %s doesn't supply an OnAcquire Function", type))
end
-- Set the default Layout ("List")
safecall(widget.SetLayout, widget, "List")
@@ -211,7 +224,7 @@ function AceGUI:Release(widget)
if widget.OnRelease then
widget:OnRelease()
-- else
-- error(("Widget type %s doesn't supply an OnRelease Function"):format(widget.type))
-- error(format("Widget type %s doesn't supply an OnRelease Function", widget.type))
end
for k in pairs(widget.userdata) do
widget.userdata[k] = nil
@@ -301,6 +314,7 @@ do
frame:SetParent(nil)
frame:SetParent(parent.content)
self.parent = parent
fixlevels(frame)
end
WidgetBase.SetCallback = function(self, name, func)
@@ -311,7 +325,7 @@ do
WidgetBase.Fire = function(self, name, ...)
if self.events[name] then
local success, ret = safecall(self.events[name], self, name, ...)
local success, ret = safecall(self.events[name], self, name, unpack(arg))
if success then
return ret
end
@@ -363,7 +377,7 @@ do
end
WidgetBase.SetPoint = function(self, ...)
return self.frame:SetPoint(...)
return self.frame:SetPoint(unpack(arg))
end
WidgetBase.ClearAllPoints = function(self)
@@ -375,7 +389,7 @@ do
end
WidgetBase.GetPoint = function(self, ...)
return self.frame:GetPoint(...)
return self.frame:GetPoint(unpack(arg))
end
WidgetBase.GetUserDataTable = function(self)
@@ -463,8 +477,8 @@ do
end
WidgetContainerBase.AddChildren = function(self, ...)
for i = 1, select("#", ...) do
local child = select(i, ...)
for i = 1, getn(arg) do
local child = arg[i]
tinsert(self.children, child)
child:SetParent(self)
child.frame:Show()
@@ -474,9 +488,20 @@ do
WidgetContainerBase.ReleaseChildren = function(self)
local children = self.children
for i = 1,#children do
AceGUI:Release(children[i])
children[i] = nil
for i = 1,getn(children) do
AceGUI:Release(tremove(children))
end
end
WidgetContainerBase.SetParent = function(self, parent)
WidgetBase.SetParent(self, parent)
local level = self.frame:GetFrameLevel()
self.content:SetFrameLevel(level + 1)
local children = self.children
for i = 1,getn(children) do
local child = children[i]
child:SetParent(self)
end
end
@@ -492,7 +517,7 @@ do
end
end
local function FrameResize(this)
local function FrameResize()
local self = this.obj
if this:GetWidth() and this:GetHeight() then
if self.OnWidthSet then
@@ -504,7 +529,7 @@ do
end
end
local function ContentResize(this)
local function ContentResize()
if this:GetWidth() and this:GetHeight() then
this.width = this:GetWidth()
this.height = this:GetHeight()
@@ -573,7 +598,7 @@ end
function AceGUI:RegisterLayout(Name, LayoutFunc)
assert(type(LayoutFunc) == "function")
if type(Name) == "string" then
Name = Name:upper()
Name = upper(Name)
end
LayoutRegistry[Name] = LayoutFunc
end
@@ -582,7 +607,7 @@ end
-- @param Name The name of the layout
function AceGUI:GetLayout(Name)
if type(Name) == "string" then
Name = Name:upper()
Name = upper(Name)
end
return LayoutRegistry[Name]
end
@@ -629,7 +654,7 @@ AceGUI:RegisterLayout("List",
function(content, children)
local height = 0
local width = content.width or content:GetWidth() or 0
for i = 1, #children do
for i = 1, getn(children) do
local child = children[i]
local frame = child.frame
@@ -676,7 +701,7 @@ AceGUI:RegisterLayout("Fill",
local layoutrecursionblock = nil
local function safelayoutcall(object, func, ...)
layoutrecursionblock = true
object[func](object, ...)
object[func](object, unpack(arg))
layoutrecursionblock = nil
end
@@ -703,7 +728,7 @@ AceGUI:RegisterLayout("Flow",
local frameoffset
local lastframeoffset
local oversize
for i = 1, #children do
for i = 1, getn(children) do
local child = children[i]
oversize = nil
local frame = child.frame
@@ -1,29 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="AceGUI-3.0.lua"/>
<!-- Container -->
<Script file="widgets\AceGUIContainer-BlizOptionsGroup.lua"/>
<Script file="widgets\AceGUIContainer-DropDownGroup.lua"/>
<Script file="widgets\AceGUIContainer-Frame.lua"/>
<Script file="widgets\AceGUIContainer-InlineGroup.lua"/>
<Script file="widgets\AceGUIContainer-ScrollFrame.lua"/>
<Script file="widgets\AceGUIContainer-SimpleGroup.lua"/>
<Script file="widgets\AceGUIContainer-TabGroup.lua"/>
<Script file="widgets\AceGUIContainer-TreeGroup.lua"/>
<Script file="widgets\AceGUIContainer-Window.lua"/>
<!-- Widgets -->
<Script file="widgets\AceGUIWidget-Button.lua"/>
<Script file="widgets\AceGUIWidget-Button-ElvUI.lua"/>
<Script file="widgets\AceGUIWidget-CheckBox.lua"/>
<Script file="widgets\AceGUIWidget-ColorPicker.lua"/>
<Script file="widgets\AceGUIWidget-DropDown.lua"/>
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/>
<Script file="widgets\AceGUIWidget-EditBox.lua"/>
<Script file="widgets\AceGUIWidget-Heading.lua"/>
<Script file="widgets\AceGUIWidget-Icon.lua"/>
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/>
<Script file="widgets\AceGUIWidget-Keybinding.lua"/>
<Script file="widgets\AceGUIWidget-Label.lua"/>
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/>
<Script file="widgets\AceGUIWidget-Slider.lua"/>
</Ui>
@@ -20,30 +20,30 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame)
local function Button_OnClick()
PlaySound("gsTitleOptionExit")
frame.obj:Hide()
this.obj:Hide()
end
local function Frame_OnShow(frame)
frame.obj:Fire("OnShow")
local function Frame_OnShow()
this.obj:Fire("OnShow")
end
local function Frame_OnClose(frame)
frame.obj:Fire("OnClose")
local function Frame_OnClose()
this.obj:Fire("OnClose")
end
local function Frame_OnMouseDown(frame)
local function Frame_OnMouseDown()
AceGUI:ClearFocus()
end
local function Title_OnMouseDown(frame)
frame:GetParent():StartMoving()
local function Title_OnMouseDown()
this:GetParent():StartMoving()
AceGUI:ClearFocus()
end
local function MoverSizer_OnMouseUp(mover)
local frame = mover:GetParent()
local function MoverSizer_OnMouseUp()
local frame = this:GetParent()
frame:StopMovingOrSizing()
local self = frame.obj
local status = self.status or self.localstatus
@@ -53,27 +53,27 @@ local function MoverSizer_OnMouseUp(mover)
status.left = frame:GetLeft()
end
local function SizerSE_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOMRIGHT")
local function SizerSE_OnMouseDown()
this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus()
end
local function SizerS_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOM")
local function SizerS_OnMouseDown()
this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus()
end
local function SizerE_OnMouseDown(frame)
frame:GetParent():StartSizing("RIGHT")
local function SizerE_OnMouseDown()
this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus()
end
local function StatusBar_OnEnter(frame)
frame.obj:Fire("OnEnterStatusBar")
local function StatusBar_OnEnter()
this.obj:Fire("OnEnterStatusBar")
end
local function StatusBar_OnLeave(frame)
frame.obj:Fire("OnLeaveStatusBar")
local function StatusBar_OnLeave()
this.obj:Fire("OnLeaveStatusBar")
end
--[[-----------------------------------------------------------------------------
@@ -156,7 +156,7 @@ local methods = {
frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
else
frame:SetPoint("CENTER")
frame:SetPoint("CENTER", 0, 0)
end
end
}
@@ -249,7 +249,7 @@ local function Constructor()
titlebg_r:SetHeight(40)
local sizer_se = CreateFrame("Frame", nil, frame)
sizer_se:SetPoint("BOTTOMRIGHT")
sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
sizer_se:SetWidth(25)
sizer_se:SetHeight(25)
sizer_se:EnableMouse()
@@ -274,7 +274,7 @@ local function Constructor()
local sizer_s = CreateFrame("Frame", nil, frame)
sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
sizer_s:SetPoint("BOTTOMLEFT")
sizer_s:SetPoint("BOTTOMLEFT", 0, 0)
sizer_s:SetHeight(25)
sizer_s:EnableMouse(true)
sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
@@ -282,7 +282,7 @@ local function Constructor()
local sizer_e = CreateFrame("Frame", nil, frame)
sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
sizer_e:SetPoint("TOPRIGHT")
sizer_e:SetPoint("TOPRIGHT", 0, 0)
sizer_e:SetWidth(25)
sizer_e:EnableMouse(true)
sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
@@ -9,6 +9,7 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, assert, type = pairs, assert, type
local min, max, floor, abs = math.min, math.max, math.floor, math.abs
local format = string.format
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -16,24 +17,24 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function FixScrollOnUpdate(frame)
frame:SetScript("OnUpdate", nil)
frame.obj:FixScroll()
local function FixScrollOnUpdate()
this:SetScript("OnUpdate", nil)
this.obj:FixScroll()
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function ScrollFrame_OnMouseWheel(frame, value)
frame.obj:MoveScroll(value)
local function ScrollFrame_OnMouseWheel()
this.obj:MoveScroll(arg1)
end
local function ScrollFrame_OnSizeChanged(frame)
frame:SetScript("OnUpdate", FixScrollOnUpdate)
local function ScrollFrame_OnSizeChanged()
this:SetScript("OnUpdate", FixScrollOnUpdate)
end
local function ScrollBar_OnScrollValueChanged(frame, value)
frame.obj:SetScroll(value)
local function ScrollBar_OnScrollValueChanged()
this.obj:SetScroll(arg1)
end
--[[-----------------------------------------------------------------------------
@@ -50,7 +51,7 @@ local methods = {
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.scrollframe:SetPoint("BOTTOMRIGHT")
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
self.scrollbar:Hide()
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil
@@ -102,7 +103,7 @@ local methods = {
self.scrollBarShown = nil
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
self.scrollframe:SetPoint("BOTTOMRIGHT")
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
self:DoLayout()
end
else
@@ -157,13 +158,13 @@ local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT")
scrollframe:SetPoint("BOTTOMRIGHT")
scrollframe:SetPoint("TOPLEFT", 0, 0)
scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
scrollframe:EnableMouseWheel(true)
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
local scrollbar = CreateFrame("Slider", format("AceConfigDialogScrollFrame%dScrollBar", num), scrollframe, "UIPanelScrollBarTemplate")
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
scrollbar:SetMinMaxValues(0, 1000)
@@ -180,8 +181,8 @@ local function Constructor()
--Container Support
local content = CreateFrame("Frame", nil, scrollframe)
content:SetPoint("TOPLEFT")
content:SetPoint("TOPRIGHT")
content:SetPoint("TOPLEFT", 0, 0)
content:SetPoint("TOPRIGHT", 0, 0)
content:SetHeight(400)
scrollframe:SetScrollChild(content)
@@ -8,6 +8,8 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
local format = string.format
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
@@ -52,34 +54,34 @@ local function Tab_SetDisabled(frame, disabled)
UpdateTabLook(frame)
end
local function BuildTabsOnUpdate(frame)
local self = frame.obj
local function BuildTabsOnUpdate()
local self = this.obj
self:BuildTabs()
frame:SetScript("OnUpdate", nil)
this:SetScript("OnUpdate", nil)
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Tab_OnClick(frame)
if not (frame.selected or frame.disabled) then
local function Tab_OnClick()
if not (this.selected or this.disabled) then
PlaySound("igCharacterInfoTab")
frame.obj:SelectTab(frame.value)
this.obj:SelectTab(this.value)
end
end
local function Tab_OnEnter(frame)
local self = frame.obj
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
local function Tab_OnEnter()
local self = this.obj
self:Fire("OnTabEnter", self.tabs[this.id].value, this)
end
local function Tab_OnLeave(frame)
local self = frame.obj
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
local function Tab_OnLeave()
local self = this.obj
self:Fire("OnTabLeave", self.tabs[this.id].value, this)
end
local function Tab_OnShow(frame)
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
local function Tab_OnShow()
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
end
--[[-----------------------------------------------------------------------------
@@ -102,10 +104,32 @@ local methods = {
end,
["CreateTab"] = function(self, id)
local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
tab.obj = self
tab.id = id
tab:SetHeight(24)
-- Normal texture
local texture = _G[tabname.."Left"]
texture:ClearAllPoints()
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."Middle"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."Right"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
-- Disabled texture
texture = _G[tabname.."LeftDisabled"]
texture:ClearAllPoints()
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."MiddleDisabled"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."RightDisabled"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
tab.text = _G[tabname .. "Text"]
tab.text:ClearAllPoints()
@@ -186,23 +210,28 @@ local methods = {
end
tab:Show()
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
tab.value = v.value
if type(v) == "table" then
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
tab.value = v.value
elseif type(v) == "string" then
tab:SetText(v)
tab.value = v
end
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
end
for i = (#tablist)+1, #tabs, 1 do
for i = getn(tablist)+1, getn(tabs), 1 do
tabs[i]:Hide()
end
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
local numtabs = #tablist
local numtabs = getn(tablist)
local numrows = 1
local usedwidth = 0
for i = 1, #tablist do
for i = 1, numtabs do
--If this is not the first tab of a row and there isn't room for it
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
@@ -213,7 +242,7 @@ local methods = {
usedwidth = usedwidth + widths[i]
end
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
rowends[numrows] = #tablist
rowends[numrows] = numtabs
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
if numrows > 1 then
@@ -9,7 +9,8 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
local math_min, math_max, floor = math.min, math.max, floor
local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat
local tremove, unpack, tconcat, getn = table.remove, unpack, table.concat, getn
local format, split = string.format, string.split
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -80,11 +81,11 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local line = button.line
button.level = level
if ( level == 1 ) then
button:SetTextFontObject("GameFontNormal")
button.text:SetFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else
button:SetTextFontObject("GameFontHighlightSmall")
button.text:SetFontObject("GameFontHighlightSmall")
button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
end
@@ -154,120 +155,115 @@ local function addLine(self, v, tree, level, parent)
else
line.hasChildren = nil
end
self.lines[#self.lines+1] = line
tinsert(self.lines, line)
return line
end
--fire an update after one frame to catch the treeframes height
local function FirstFrameUpdate(frame)
local self = frame.obj
frame:SetScript("OnUpdate", nil)
local function FirstFrameUpdate()
local self = this.obj
this:SetScript("OnUpdate", nil)
self:RefreshTree()
end
local function BuildUniqueValue(...)
local n = select('#', ...)
if n == 1 then
return ...
else
return (...).."\001"..BuildUniqueValue(select(2,...))
end
return tconcat(arg, "\001", 1, getn(arg))
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Expand_OnClick(frame)
local button = frame.button
local function Expand_OnClick()
local button = this.button
local self = button.obj
local status = (self.status or self.localstatus).groups
status[button.uniquevalue] = not status[button.uniquevalue]
self:RefreshTree()
end
local function Button_OnClick(frame)
local self = frame.obj
self:Fire("OnClick", frame.uniquevalue, frame.selected)
if not frame.selected then
self:SetSelected(frame.uniquevalue)
frame.selected = true
frame:LockHighlight()
local function Button_OnClick()
local self = this.obj
self:Fire("OnClick", this.uniquevalue, this.selected)
if not this.selected then
self:SetSelected(this.uniquevalue)
this.selected = true
this:LockHighlight()
self:RefreshTree()
end
AceGUI:ClearFocus()
end
local function Button_OnDoubleClick(button)
local self = button.obj
local function Button_OnDoubleClick()
local self = this.obj
local status = self.status or self.localstatus
local status = (self.status or self.localstatus).groups
status[button.uniquevalue] = not status[button.uniquevalue]
status[this.uniquevalue] = not status[this.uniquevalue]
self:RefreshTree()
end
local function Button_OnEnter(frame)
local self = frame.obj
self:Fire("OnButtonEnter", frame.uniquevalue, frame)
local function Button_OnEnter()
local self = this.obj
self:Fire("OnButtonEnter", this.uniquevalue, this)
if self.enabletooltips then
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",frame,"RIGHT")
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, 1)
GameTooltip:SetOwner(this, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",this,"RIGHT")
GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, 1)
GameTooltip:Show()
end
end
local function Button_OnLeave(frame)
local self = frame.obj
self:Fire("OnButtonLeave", frame.uniquevalue, frame)
local function Button_OnLeave()
local self = this.obj
self:Fire("OnButtonLeave", this.uniquevalue, this)
if self.enabletooltips then
GameTooltip:Hide()
end
end
local function OnScrollValueChanged(frame, value)
if frame.obj.noupdate then return end
local self = frame.obj
local function OnScrollValueChanged()
if this.obj.noupdate then return end
local self = this.obj
local status = self.status or self.localstatus
status.scrollvalue = value
status.scrollvalue = arg1
self:RefreshTree()
AceGUI:ClearFocus()
end
local function Tree_OnSizeChanged(frame)
frame.obj:RefreshTree()
local function Tree_OnSizeChanged()
this.obj:RefreshTree()
end
local function Tree_OnMouseWheel(frame, delta)
local self = frame.obj
local function Tree_OnMouseWheel()
local self = this.obj
if self.showscroll then
local scrollbar = self.scrollbar
local min, max = scrollbar:GetMinMaxValues()
local value = scrollbar:GetValue()
local newvalue = math_min(max,math_max(min,value - delta))
local newvalue = math_min(max,math_max(min,value - arg1))
if value ~= newvalue then
scrollbar:SetValue(newvalue)
end
end
end
local function Dragger_OnLeave(frame)
frame:SetBackdropColor(1, 1, 1, 0)
local function Dragger_OnLeave()
this:SetBackdropColor(1, 1, 1, 0)
end
local function Dragger_OnEnter(frame)
frame:SetBackdropColor(1, 1, 1, 0.8)
local function Dragger_OnEnter()
this:SetBackdropColor(1, 1, 1, 0.8)
end
local function Dragger_OnMouseDown(frame)
local treeframe = frame:GetParent()
local function Dragger_OnMouseDown()
local treeframe = this:GetParent()
treeframe:StartSizing("RIGHT")
end
local function Dragger_OnMouseUp(frame)
local treeframe = frame:GetParent()
local function Dragger_OnMouseUp()
local treeframe = this:GetParent()
local self = treeframe.obj
local frame = treeframe:GetParent()
treeframe:StopMovingOrSizing()
@@ -319,9 +315,39 @@ local methods = {
["CreateButton"] = function(self)
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "InterfaceOptionsButtonTemplate")
local button = CreateFrame("Button", format("AceGUI30TreeButton%d", num), self.treeframe)
button.obj = self
button:SetWidth(175)
button:SetHeight(18)
local toggle = CreateFrame("Button", nil, button)
toggle:SetWidth(14)
toggle:SetHeight(14)
toggle:ClearAllPoints()
toggle:SetPoint("TOPRIGHT", button, "TOPRIGHT", -6, -1)
toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
toggle:SetHighlightTexture("Interface\Buttons\UI-PlusButton-Hilight", "ADD")
toggle:SetScript("OnClick", Button_OnClick)
button.toggle = toggle
toggle.obj = button
local text = button:CreateFontString()
text:SetFontObject(GameFontNormal)
text:SetPoint("RIGHT", toggle, "LEFT", -2, 0)
text:SetJustifyH("LEFT")
button:SetHighlightFontObject(GameFontHighlight)
button.text = text
local highlight = button:CreateTexture(nil, "HIGHLIGHT")
highlight:SetPoint("TOPLEFT", 0, 1)
highlight:SetPoint("BOTTOMRIGHT", 0, 1)
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight")
highlight:SetBlendMode("ADD")
highlight:SetVertexColor(.196, .388, .8)
button.highlight = highlight
local icon = button:CreateTexture(nil, "OVERLAY")
icon:SetWidth(14)
icon:SetHeight(14)
@@ -414,7 +440,7 @@ local methods = {
self:BuildLevel(tree, 1)
local numlines = #lines
local numlines = getn(lines)
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
if maxlines <= 0 then return end
@@ -511,9 +537,8 @@ local methods = {
self.filter = false
local status = self.status or self.localstatus
local groups = status.groups
local path = {...}
for i = 1, #path do
groups[tconcat(path, "\001", 1, i)] = true
for i = 1, getn(arg) do
groups[tconcat(arg, "\001", 1, i)] = true
end
status.selected = uniquevalue
self:RefreshTree(true)
@@ -521,11 +546,11 @@ local methods = {
end,
["SelectByPath"] = function(self, ...)
self:Select(BuildUniqueValue(...), ...)
self:Select(BuildUniqueValue(unpack(arg)), unpack(arg))
end,
["SelectByValue"] = function(self, uniquevalue)
self:Select(uniquevalue, ("\001"):split(uniquevalue))
self:Select(uniquevalue, split("\001", uniquevalue))
end,
["ShowScroll"] = function(self, show)
@@ -632,8 +657,8 @@ local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
local treeframe = CreateFrame("Frame", nil, frame)
treeframe:SetPoint("TOPLEFT")
treeframe:SetPoint("BOTTOMLEFT")
treeframe:SetPoint("TOPLEFT", 0, 0)
treeframe:SetPoint("BOTTOMLEFT", 0, 0)
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
treeframe:EnableMouseWheel(true)
treeframe:SetBackdrop(PaneBackdrop)
@@ -657,7 +682,7 @@ local function Constructor()
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
local scrollbar = CreateFrame("Slider", format("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
scrollbar:SetScript("OnValueChanged", nil)
scrollbar:SetPoint("TOPRIGHT", -10, -26)
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
@@ -673,7 +698,7 @@ local function Constructor()
local border = CreateFrame("Frame",nil,frame)
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
border:SetPoint("BOTTOMRIGHT")
border:SetPoint("BOTTOMRIGHT", 0, 0)
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
@@ -23,29 +23,29 @@ do
local Type = "Window"
local Version = 5
local function frameOnShow(this)
local function frameOnShow()
this.obj:Fire("OnShow")
end
local function frameOnClose(this)
local function frameOnClose()
this.obj:Fire("OnClose")
end
local function closeOnClick(this)
local function closeOnClick()
PlaySound("gsTitleOptionExit")
this.obj:Hide()
end
local function frameOnMouseDown(this)
local function frameOnMouseDown()
AceGUI:ClearFocus()
end
local function titleOnMouseDown(this)
local function titleOnMouseDown()
this:GetParent():StartMoving()
AceGUI:ClearFocus()
end
local function frameOnMouseUp(this)
local function frameOnMouseUp()
local frame = this:GetParent()
frame:StopMovingOrSizing()
local self = frame.obj
@@ -56,22 +56,22 @@ do
status.left = frame:GetLeft()
end
local function sizerseOnMouseDown(this)
local function sizerseOnMouseDown()
this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus()
end
local function sizersOnMouseDown(this)
local function sizersOnMouseDown()
this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus()
end
local function sizereOnMouseDown(this)
local function sizereOnMouseDown()
this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus()
end
local function sizerOnMouseUp(this)
local function sizerOnMouseUp()
this:GetParent():StopMovingOrSizing()
end
@@ -2,32 +2,92 @@
Button Widget (Modified to change text color on SetDisabled method)
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button-ElvUI", 23
local Type, Version = "Button-ElvUI", 2
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
local pairs, unpack = pairs, unpack
-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
local IsShiftKeyDown = IsShiftKeyDown
-- GLOBALS: GameTooltip, ElvUI
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
local dragdropButton
local function lockTooltip()
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
GameTooltip:SetText(" ")
GameTooltip:Show()
end
local function dragdrop_OnMouseDown(...)
if this.obj.dragOnMouseDown then
dragdropButton.mouseDownFrame = this
dragdropButton:SetText(this.obj.value or "Unknown")
dragdropButton:SetWidth(this:GetWidth())
dragdropButton:SetHeight(this:SetHeight())
this.obj.dragOnMouseDown(this, unpack(arg))
end
end
local function dragdrop_OnMouseUp(...)
if this.obj.dragOnMouseUp then
this:SetAlpha(1)
GameTooltip:Hide()
dragdropButton:Hide()
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then
this.obj.dragOnMouseUp(this, unpack(arg))
this.obj.ActivateMultiControl(this.obj, unpack(arg))
end
dragdropButton.enteredFrame = nil
dragdropButton.mouseDownFrame = nil
end
end
local function dragdrop_OnLeave(...)
if this.obj.dragOnLeave then
if dragdropButton.mouseDownFrame then
lockTooltip()
end
if this == dragdropButton.mouseDownFrame then
this:SetAlpha(0)
dragdropButton:Show()
this.obj.dragOnLeave(this, unpack(arg))
end
end
end
local function dragdrop_OnEnter(...)
if this.obj.dragOnEnter and dragdropButton:IsShown() then
dragdropButton.enteredFrame = this
lockTooltip()
this.obj.dragOnEnter(this, unpack(arg))
end
end
local function dragdrop_OnClick()
local button = arg1
if this.obj.dragOnClick and button == "RightButton" then
this.obj.dragOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
elseif this.obj.stateSwitchOnClick and (button == "LeftButton") and IsShiftKeyDown() then
this.obj.stateSwitchOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
end
end
local function Button_OnClick()
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
frame.obj:Fire("OnClick", ...)
this.obj:Fire("OnClick", 2, arg1)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
@@ -76,14 +136,28 @@ Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnClick", Button_OnClick)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
-- dragdrop
if not dragdropButton then
dragdropButton = CreateFrame("Button", "ElvUIAceGUI30DragDropButton", UIParent, "UIPanelButtonTemplate")
dragdropButton:SetFrameStrata("TOOLTIP")
dragdropButton:SetFrameLevel(5)
dragdropButton:SetPoint('BOTTOM', GameTooltip, "BOTTOM", 0, 10)
dragdropButton:Hide()
ElvUI[1]:GetModule('Skins'):HandleButton(dragdropButton)
end
HookScript(frame, "OnClick", dragdrop_OnClick)
HookScript(frame, "OnEnter", dragdrop_OnEnter)
HookScript(frame, "OnLeave", dragdrop_OnLeave)
HookScript(frame, "OnMouseUp", dragdrop_OnMouseUp)
HookScript(frame, "OnMouseDown", dragdrop_OnMouseDown)
local text = frame:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 15, -1)
@@ -16,18 +16,18 @@ local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
local function Button_OnClick()
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
frame.obj:Fire("OnClick", ...)
this.obj:Fire("OnClick", arg1)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
@@ -6,7 +6,9 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs = select, pairs
local pairs = pairs
local unpack = unpack
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
@@ -24,26 +26,26 @@ local function AlignImage(self)
self.text:ClearAllPoints()
if not img then
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
self.text:SetPoint("RIGHT")
self.text:SetPoint("RIGHT", 0, 0)
else
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
self.text:SetPoint("RIGHT")
self.text:SetPoint("RIGHT", 0, 0)
end
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function CheckBox_OnMouseDown(frame)
local self = frame.obj
local function CheckBox_OnMouseDown()
local self = this.obj
if not self.disabled then
if self.image:GetTexture() then
self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
@@ -54,8 +56,8 @@ local function CheckBox_OnMouseDown(frame)
AceGUI:ClearFocus()
end
local function CheckBox_OnMouseUp(frame)
local self = frame.obj
local function CheckBox_OnMouseUp()
local self = this.obj
if not self.disabled then
self:ToggleChecked()
@@ -226,9 +228,9 @@ local methods = {
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -253,7 +255,7 @@ local function Constructor()
local checkbg = frame:CreateTexture(nil, "ARTWORK")
checkbg:SetWidth(24)
checkbg:SetHeight(24)
checkbg:SetPoint("TOPLEFT")
checkbg:SetPoint("TOPLEFT", 0, 0)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
local check = frame:CreateTexture(nil, "OVERLAY")
@@ -264,7 +266,7 @@ local function Constructor()
text:SetJustifyH("LEFT")
text:SetHeight(18)
text:SetPoint("LEFT", checkbg, "RIGHT")
text:SetPoint("RIGHT")
text:SetPoint("RIGHT", 0, 0)
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
@@ -1,7 +1,7 @@
--[[-----------------------------------------------------------------------------
ColorPicker Widget
-------------------------------------------------------------------------------]]
local Type, Version = "ColorPicker-ElvUI", 22
local Type, Version = "ColorPicker", 22
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
@@ -38,20 +38,20 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function ColorSwatch_OnClick(frame)
local function ColorSwatch_OnClick()
HideUIPanel(ColorPickerFrame)
local self = frame.obj
local self = this.obj
if not self.disabled then
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
ColorPickerFrame:SetFrameLevel(this:GetFrameLevel() + 10)
ColorPickerFrame:SetClampedToScreen(true)
ColorPickerFrame.func = function()
@@ -67,20 +67,12 @@ local function ColorSwatch_OnClick(frame)
ColorCallback(self, r, g, b, a, true)
end
local r, g, b, a, dR, dG, dB, dA = self.r, self.g, self.b, self.a, self.dR, self.dG, self.dB, self.dA
local r, g, b, a = self.r, self.g, self.b, self.a
if self.HasAlpha then
ColorPickerFrame.opacity = 1 - (a or 0)
end
ColorPickerFrame:SetColorRGB(r, g, b)
if(ColorPPDefault and self.dR and self.dG and self.dB) then
local alpha = 1
if(self.dA) then
alpha = 1 - self.dA
end
ColorPPDefault.colors = {r = self.dR, g = self.dG, b = self.dB, a = alpha}
end
ColorPickerFrame.cancelFunc = function()
ColorCallback(self, r, g, b, a, true)
end
@@ -109,15 +101,11 @@ local methods = {
self.text:SetText(text)
end,
["SetColor"] = function(self, r, g, b, a, defaultR, defaultG, defaultB, defaultA)
["SetColor"] = function(self, r, g, b, a)
self.r = r
self.g = g
self.b = b
self.a = a or 1
self.dR = defaultR
self.dG = defaultG
self.dB = defaultB
self.dA = defaultA
self.colorSwatch:SetVertexColor(r, g, b, a)
end,
@@ -153,7 +141,7 @@ local function Constructor()
colorSwatch:SetWidth(19)
colorSwatch:SetHeight(19)
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
colorSwatch:SetPoint("LEFT")
colorSwatch:SetPoint("LEFT", 0, 0)
local texture = frame:CreateTexture(nil, "BACKGROUND")
texture:SetWidth(16)
@@ -177,7 +165,7 @@ local function Constructor()
text:SetJustifyH("LEFT")
text:SetTextColor(1, 1, 1)
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
text:SetPoint("RIGHT")
text:SetPoint("RIGHT", 0, 0)
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
@@ -3,31 +3,31 @@
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local select, assert = select, assert
local assert, unpack = assert, unpack
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
local CreateFrame = CreateFrame
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, ...)
local function fixlevels(parent, ...)
local child
local level = parent:GetFrameLevel() + 1
for i = 1, getn(arg) do
child = arg[i]
child:SetFrameLevel(level)
fixlevels(child)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, ...)
local child
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, ...)
for i = 1, getn(arg) do
child = arg[i]
fixstrata(strata, child)
end
end
@@ -45,7 +45,7 @@ local ItemBase = {
counter = 0,
}
function ItemBase.Frame_OnEnter(this)
function ItemBase.Frame_OnEnter()
local self = this.obj
if self.useHighlight then
@@ -58,7 +58,7 @@ function ItemBase.Frame_OnEnter(this)
end
end
function ItemBase.Frame_OnLeave(this)
function ItemBase.Frame_OnLeave()
local self = this.obj
self.highlight:Hide()
@@ -108,7 +108,7 @@ end
-- exported
function ItemBase.SetPoint(self, ...)
self.frame:SetPoint(...)
self.frame:SetPoint(unpack(arg))
end
-- exported
@@ -248,7 +248,7 @@ do
local widgetType = "Dropdown-Item-Header"
local widgetVersion = 1
local function OnEnter(this)
local function OnEnter()
local self = this.obj
self:Fire("OnEnter")
@@ -257,7 +257,7 @@ do
end
end
local function OnLeave(this)
local function OnLeave()
local self = this.obj
self:Fire("OnLeave")
@@ -297,7 +297,7 @@ do
local widgetType = "Dropdown-Item-Execute"
local widgetVersion = 1
local function Frame_OnClick(this, button)
local function Frame_OnClick()
local self = this.obj
if self.disabled then return end
self:Fire("OnClick")
@@ -338,7 +338,7 @@ do
self:SetValue(nil)
end
local function Frame_OnClick(this, button)
local function Frame_OnClick()
local self = this.obj
if self.disabled then return end
self.value = not self.value
@@ -385,7 +385,7 @@ do
local widgetType = "Dropdown-Item-Menu"
local widgetVersion = 2
local function OnEnter(this)
local function OnEnter()
local self = this.obj
self:Fire("OnEnter")
@@ -400,7 +400,7 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.submenu then
self.submenu:Close()
@@ -3,8 +3,9 @@ local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local select, pairs, ipairs, type = select, pairs, ipairs, type
local tsort = table.sort
local pairs, ipairs, type = pairs, ipairs, type
local tsort, tinsert, getn, setn = table.sort, table.insert, table.getn, table.setn
local format = string.format
-- WoW APIs
local PlaySound = PlaySound
@@ -15,25 +16,24 @@ local _G = _G
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, ...)
local function fixlevels(parent, ...)
local child
local level = parent:GetFrameLevel() + 1
for i = 1, getn(arg) do
child = arg[i]
child:SetFrameLevel(level)
fixlevels(child)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, ...)
local child
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, ...)
for i = 1, getn(arg) do
child = arg[i]
fixstrata(strata, child)
end
end
@@ -76,15 +76,15 @@ do
end
-- See the note in Constructor() for each scroll related function
local function OnMouseWheel(this, value)
this.obj:MoveScroll(value)
local function OnMouseWheel()
this.obj:MoveScroll(arg1)
end
local function OnScrollValueChanged(this, value)
this.obj:SetScroll(value)
local function OnScrollValueChanged()
this.obj:SetScroll(arg1)
end
local function OnSizeChanged(this)
local function OnSizeChanged()
this.obj:FixScroll()
end
@@ -169,9 +169,9 @@ do
-- exported
local function AddItem(self, item)
self.items[#self.items + 1] = item
tinsert(self.items, item)
local h = #self.items * 16
local h = getn(self.items) * 16
self.itemFrame:SetHeight(h)
self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement
@@ -222,6 +222,7 @@ do
AceGUI:Release(item)
items[i] = nil
end
setn(items, 0)
end
-- exported
@@ -362,24 +363,24 @@ do
--[[ UI event handler ]]--
local function Control_OnEnter(this)
local function Control_OnEnter()
this.obj.button:LockHighlight()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(this)
local function Control_OnLeave()
this.obj.button:UnlockHighlight()
this.obj:Fire("OnLeave")
end
local function Dropdown_OnHide(this)
local function Dropdown_OnHide()
local self = this.obj
if self.open then
self.pullout:Close()
end
end
local function Dropdown_TogglePullout(this)
local function Dropdown_TogglePullout()
local self = this.obj
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
if self.open then
@@ -571,7 +572,7 @@ do
local function AddListItem(self, value, text, itemType)
if not itemType then itemType = "Dropdown-Item-Toggle" end
local exists = AceGUI:GetWidgetVersion(itemType)
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
if not exists then error(format("The given item type, %q, does not exist within AceGUI-3.0", tostring(itemType)), 2) end
local item = AceGUI:Create(itemType)
item:SetText(text)
@@ -600,7 +601,7 @@ do
if type(order) ~= "table" then
for v in pairs(list) do
sortlist[#sortlist + 1] = v
tinsert(sortlist, v)
end
tsort(sortlist)
@@ -608,6 +609,7 @@ do
AddListItem(self, key, list[key], itemType)
sortlist[i] = nil
end
setn(sortlist, 0)
else
for i, key in ipairs(order) do
AddListItem(self, key, list[key], itemType)
@@ -10,7 +10,7 @@ local tostring, pairs = tostring, pairs
-- WoW APIs
local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
@@ -23,13 +23,12 @@ Support functions
-------------------------------------------------------------------------------]]
if not AceGUIEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
end
function _G.AceGUIEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G["AceGUI-3.0EditBox"..i]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
if editbox and editbox:IsVisible() and editbox.hasfocus then
editbox:Insert(text)
return true
end
@@ -51,26 +50,26 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Frame_OnShowFocus(frame)
frame.obj.editbox:SetFocus()
frame:SetScript("OnShow", nil)
local function Frame_OnShowFocus()
this.obj.editbox:SetFocus()
this:SetScript("OnShow", nil)
end
local function EditBox_OnEscapePressed(frame)
local function EditBox_OnEscapePressed()
AceGUI:ClearFocus()
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
local cancel = self:Fire("OnEnterPressed", value)
if not cancel then
PlaySound("igMainMenuOptionCheckBoxOn")
@@ -78,15 +77,20 @@ local function EditBox_OnEnterPressed(frame)
end
end
local function EditBox_OnReceiveDrag(frame)
local self = frame.obj
local function EditBox_OnReceiveDrag()
if not GetCursorInfo then print("TODO GetCursorInfo") return end -- TODO
local self = this.obj
local type, id, info = GetCursorInfo()
if type == "item" then
self:SetText(info)
self:Fire("OnEnterPressed", info)
ClearCursor()
elseif type == "spell" then
local name = GetSpellInfo(id, info)
local name, rank = GetSpellName(id, info)
if rank ~= "" then
name = name.."("..rank..")"
end
self:SetText(name)
self:Fire("OnEnterPressed", name)
ClearCursor()
@@ -100,9 +104,9 @@ local function EditBox_OnReceiveDrag(frame)
AceGUI:ClearFocus()
end
local function EditBox_OnTextChanged(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnTextChanged()
local self = this.obj
local value = this:GetText()
if tostring(value) ~= tostring(self.lasttext) then
self:Fire("OnTextChanged", value)
self.lasttext = value
@@ -110,14 +114,20 @@ local function EditBox_OnTextChanged(frame)
end
end
local function EditBox_OnFocusGained(frame)
AceGUI:SetFocus(frame.obj)
local function EditBox_OnFocusGained()
this.hasfocus = true
AceGUI:SetFocus(this.obj)
end
local function Button_OnClick(frame)
local editbox = frame.obj.editbox
local function EditBox_OnFocusLost()
this.hasfocus = nil
end
local function Button_OnClick()
local editbox = this.obj.editbox
editbox:ClearFocus()
EditBox_OnEnterPressed(editbox)
this = editbox
EditBox_OnEnterPressed()
end
--[[-----------------------------------------------------------------------------
@@ -155,7 +165,7 @@ local methods = {
["SetText"] = function(self, text)
self.lasttext = text or ""
self.editbox:SetText(text or "")
self.editbox:SetCursorPosition(0)
EditBoxSetCursorPosition(self.editbox, 0)
HideButton(self)
end,
@@ -226,10 +236,11 @@ local function Constructor()
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
editbox:SetScript("OnEditFocusLost", EditBox_OnFocusLost)
editbox:SetTextInsets(0, 0, 3, 3)
editbox:SetMaxLetters(256)
editbox:SetPoint("BOTTOMLEFT", 6, 0)
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetPoint("BOTTOMRIGHT", 0, 0)
editbox:SetHeight(19)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
@@ -43,8 +43,8 @@ local function Constructor()
frame:Hide()
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
label:SetPoint("TOP")
label:SetPoint("BOTTOM")
label:SetPoint("TOP", 0, 0)
label:SetPoint("BOTTOM", 0, 0)
label:SetJustifyH("CENTER")
local left = frame:CreateTexture(nil, "BACKGROUND")
@@ -6,7 +6,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs, print = select, pairs, print
local pairs, print, unpack = pairs, print, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -14,16 +15,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Button_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
local function Button_OnClick()
this.obj:Fire("OnClick", arg1)
AceGUI:ClearFocus()
end
@@ -58,9 +59,9 @@ local methods = {
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -6,7 +6,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs = select, pairs
local pairs, unpack = pairs, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -18,16 +19,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Label_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
local function Label_OnClick()
this.obj:Fire("OnClick", arg1)
AceGUI:ClearFocus()
end
@@ -45,13 +46,13 @@ local methods = {
-- ["OnRelease"] = nil,
["SetHighlight"] = function(self, ...)
self.highlight:SetTexture(...)
self.highlight:SetTexture(unpack(arg))
end,
["SetHighlightTexCoord"] = function(self, ...)
local c = select("#", ...)
local c = getn(arg)
if c == 4 or c == 8 then
self.highlight:SetTexCoord(...)
self.highlight:SetTexCoord(unpack(arg))
else
self.highlight:SetTexCoord(0, 1, 0, 1)
end
@@ -21,33 +21,35 @@ local CreateFrame, UIParent = CreateFrame, UIParent
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Keybinding_OnClick(frame, button)
if button == "LeftButton" or button == "RightButton" then
local self = frame.obj
--[[
local function Keybinding_OnClick()
if arg1 == "LeftButton" or arg1 == "RightButton" then
local self = this.obj
if self.waitingForKey then
frame:EnableKeyboard(false)
frame:EnableMouseWheel(false)
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
frame:UnlockHighlight()
this:UnlockHighlight()
self.waitingForKey = nil
else
frame:EnableKeyboard(true)
frame:EnableMouseWheel(true)
this:EnableKeyboard(true)
this:EnableMouseWheel(true)
self.msgframe:Show()
frame:LockHighlight()
this:LockHighlight()
self.waitingForKey = true
end
end
AceGUI:ClearFocus()
end
]]
local ignoreKeys = {
["BUTTON1"] = true, ["BUTTON2"] = true,
@@ -55,10 +57,10 @@ local ignoreKeys = {
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
}
local function Keybinding_OnKeyDown(frame, key)
local self = frame.obj
local function Keybinding_OnKeyDown()
local self = this.obj
if self.waitingForKey then
local keyPressed = key
local keyPressed = arg1
if keyPressed == "ESCAPE" then
keyPressed = ""
else
@@ -74,10 +76,10 @@ local function Keybinding_OnKeyDown(frame, key)
end
end
frame:EnableKeyboard(false)
frame:EnableMouseWheel(false)
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
frame:UnlockHighlight()
this:UnlockHighlight()
self.waitingForKey = nil
if not self.disabled then
@@ -87,27 +89,49 @@ local function Keybinding_OnKeyDown(frame, key)
end
end
local function Keybinding_OnMouseDown(frame, button)
if button == "LeftButton" or button == "RightButton" then
return
elseif button == "MiddleButton" then
button = "BUTTON3"
elseif button == "Button4" then
button = "BUTTON4"
elseif button == "Button5" then
button = "BUTTON5"
local function Keybinding_OnMouseUp()
if MouseIsOver(this) and not self.disabled then
local self = this.obj
if self.waitingForKey then
if arg1 ~= "LeftButton" and arg1 ~= "RightButton" then
Keybinding_OnKeyDown()
end
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
this:UnlockHighlight()
self.waitingForKey = nil
else
this:EnableKeyboard(true)
this:EnableMouseWheel(true)
self.msgframe:Show()
this:LockHighlight()
self.waitingForKey = true
end
end
Keybinding_OnKeyDown(frame, button)
AceGUI:ClearFocus()
end
local function Keybinding_OnMouseWheel(frame, direction)
local button
if direction >= 0 then
button = "MOUSEWHEELUP"
else
button = "MOUSEWHEELDOWN"
local function Keybinding_OnMouseDown()
if arg1 == "LeftButton" or arg1 == "RightButton" then
return
elseif arg1 == "MiddleButton" then
arg1 = "BUTTON3"
elseif arg1 == "Button4" then
arg1 = "BUTTON4"
elseif arg1 == "Button5" then
arg1 = "BUTTON5"
end
Keybinding_OnKeyDown(frame, button)
Keybinding_OnKeyDown()
end
local function Keybinding_OnMouseWheel()
if arg1 >= 0 then
arg1 = "MOUSEWHEELUP"
else
arg1 = "MOUSEWHEELDOWN"
end
Keybinding_OnKeyDown()
end
--[[-----------------------------------------------------------------------------
@@ -141,10 +165,10 @@ local methods = {
["SetKey"] = function(self, key)
if (key or "") == "" then
self.button:SetText(NOT_BOUND)
self.button:SetNormalFontObject("GameFontNormal")
self.text:SetFontObject("GameFontNormal")
else
self.button:SetText(key)
self.button:SetNormalFontObject("GameFontHighlight")
self.text:SetFontObject("GameFontHighlight")
end
end,
@@ -179,9 +203,9 @@ local ControlBackdrop = {
insets = { left = 3, right = 3, top = 3, bottom = 3 }
}
local function keybindingMsgFixWidth(frame)
frame:SetWidth(frame.msg:GetWidth() + 10)
frame:SetScript("OnUpdate", nil)
local function keybindingMsgFixWidth()
this:SetWidth(this.msg:GetWidth() + 10)
this:SetScript("OnUpdate", nil)
end
local function Constructor()
@@ -195,12 +219,13 @@ local function Constructor()
button:RegisterForClicks("AnyDown")
button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave)
button:SetScript("OnClick", Keybinding_OnClick)
-- button:SetScript("OnClick", Keybinding_OnClick)
button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
button:SetPoint("BOTTOMLEFT")
button:SetPoint("BOTTOMRIGHT")
button:SetPoint("BOTTOMLEFT", 0, 0)
button:SetPoint("BOTTOMRIGHT", 0, 0)
button:SetHeight(24)
button:EnableKeyboard(false)
@@ -209,8 +234,8 @@ local function Constructor()
text:SetPoint("RIGHT", -7, 0)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
label:SetPoint("TOPLEFT")
label:SetPoint("TOPRIGHT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetPoint("TOPRIGHT", 0, 0)
label:SetJustifyH("CENTER")
label:SetHeight(18)
@@ -236,7 +261,8 @@ local function Constructor()
msgframe = msgframe,
frame = frame,
alignoffset = 30,
type = Type
type = Type,
text = text
}
for method, func in pairs(methods) do
widget[method] = func
@@ -7,7 +7,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local max, select, pairs = math.max, select, pairs
local max, pairs, unpack = math.max, pairs, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -35,14 +36,14 @@ local function UpdateImageAnchor(self)
local imagewidth = image:GetWidth()
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
-- image goes on top centered when less than 200 width for the text, or if there is no text
image:SetPoint("TOP")
image:SetPoint("TOP", 0, 0)
label:SetPoint("TOP", image, "BOTTOM")
label:SetPoint("LEFT")
label:SetPoint("LEFT", 0, 0)
label:SetWidth(width)
height = image:GetHeight() + label:GetHeight()
else
-- image on the left
image:SetPoint("TOPLEFT")
image:SetPoint("TOPLEFT", 0, 0)
if image:GetHeight() > label:GetHeight() then
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
else
@@ -53,7 +54,7 @@ local function UpdateImageAnchor(self)
end
else
-- no image shown
label:SetPoint("TOPLEFT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetWidth(width)
height = label:GetHeight()
end
@@ -111,9 +112,9 @@ local methods = {
if image:GetTexture() then
self.imageshown = true
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -4,9 +4,10 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
local format = string.format
-- WoW APIs
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
local GetCursorInfo, GetSpellName, ClearCursor = GetCursorInfo, GetSpellName, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
@@ -20,13 +21,12 @@ Support functions
if not AceGUIMultiLineEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
end
function _G.AceGUIMultiLineEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
local editbox = _G[format("MultiLineEditBox%uEdit",i)]
if editbox and editbox:IsVisible() and editbox.hasfocus then
editbox:Insert(text)
return true
end
@@ -55,78 +55,88 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function OnClick(self) -- Button
self = self.obj
local function OnClick() -- Button
local self = this.obj
self.editBox:ClearFocus()
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
self.button:Disable()
end
end
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
self, y = self.obj.scrollFrame, -y
local function OnCursorChanged() -- EditBox
local self, y = this.obj.scrollFrame, -arg2
local offset = self:GetVerticalScroll()
if y < offset then
self:SetVerticalScroll(y)
else
y = y + cursorHeight - self:GetHeight()
y = y + arg4 - self:GetHeight()
if y > offset then
self:SetVerticalScroll(y)
end
end
end
local function OnEditFocusLost(self) -- EditBox
self:HighlightText(0, 0)
self.obj:Fire("OnEditFocusLost")
local function OnEditFocusLost() -- EditBox
this.hasfocus = nil
this:HighlightText(0, 0)
this.obj:Fire("OnEditFocusLost")
end
local function OnEnter(self) -- EditBox / ScrollFrame
self = self.obj
local function OnEnter() -- EditBox / ScrollFrame
local self = this.obj
if not self.entered then
self.entered = true
self:Fire("OnEnter")
end
end
local function OnLeave(self) -- EditBox / ScrollFrame
self = self.obj
local function OnLeave() -- EditBox / ScrollFrame
local self = this.obj
if self.entered then
self.entered = nil
self:Fire("OnLeave")
end
end
local function OnMouseUp(self) -- ScrollFrame
self = self.obj.editBox
local function OnMouseUp() -- ScrollFrame
local self = this.obj.editBox
self:SetFocus()
self:SetCursorPosition(self:GetNumLetters())
EditBoxSetCursorPosition(self, self:GetNumLetters())
end
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local function OnReceiveDrag() -- EditBox / ScrollFrame
if not GetCursorInfo then print("TODO GetCursorInfo") return end -- TODO
local type, id, info = GetCursorInfo()
if type == "spell" then
info = GetSpellInfo(id, info)
local name, rank = GetSpellName(id, info)
if rank ~= "" then
name = name.."("..rank..")"
end
info = name
elseif type ~= "item" then
return
end
ClearCursor()
self = self.obj
local self = this.obj
local editBox = self.editBox
if not editBox:HasFocus() then
if not this.hasfocus then
this.hasfocus = true
editBox:SetFocus()
editBox:SetCursorPosition(editBox:GetNumLetters())
EditBoxSetCursorPosition(editBox, editBox:GetNumLetters())
end
editBox:Insert(info)
self.button:Enable()
end
local function OnSizeChanged(self, width, height) -- ScrollFrame
self.obj.editBox:SetWidth(width)
local function OnSizeChanged() -- ScrollFrame
this:UpdateScrollChildRect()
this:SetVerticalScroll(this:GetHeight())
this.obj.editBox:SetWidth(arg1)
end
local function OnTextChanged(self) -- EditBox
self = self.obj
local function OnTextChanged() -- EditBox
local self = this.obj
local value = self.editBox:GetText()
if not self.lastText or value ~= self.lastText then
self:Fire("OnTextChanged", value)
@@ -138,26 +148,31 @@ local function OnTextChanged(self)
end
end
local function OnTextSet(self) -- EditBox
self:HighlightText(0, 0)
self:SetCursorPosition(self:GetNumLetters())
self:SetCursorPosition(0)
self.obj.button:Disable()
local function OnTextSet() -- EditBox
this:HighlightText(0, 0)
EditBoxSetCursorPosition(this, this:GetNumLetters())
EditBoxSetCursorPosition(this, 0)
this.obj.button:Disable()
end
local function OnVerticalScroll(self, offset) -- ScrollFrame
local editBox = self.obj.editBox
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
local function OnVerticalScroll() -- ScrollFrame
local editBox = this.obj.editBox
editBox:SetHitRectInsets(0, 0, arg1, editBox:GetHeight() - arg1 - this:GetHeight())
end
local function OnShowFocus(frame)
frame.obj.editBox:SetFocus()
frame:SetScript("OnShow", nil)
local function OnShowFocus()
this.obj.editBox:SetFocus()
this:SetScript("OnShow", nil)
end
local function OnEditFocusGained(frame)
AceGUI:SetFocus(frame.obj)
frame.obj:Fire("OnEditFocusGained")
local function OnEditFocusGained()
this.hasfocus = true
AceGUI:SetFocus(this.obj)
this.obj:Fire("OnEditFocusGained")
end
local function OnEscapePressed()
AceGUI:ClearFocus()
end
--[[-----------------------------------------------------------------------------
@@ -257,11 +272,11 @@ local methods = {
end,
["GetCursorPosition"] = function(self)
return self.editBox:GetCursorPosition()
return EditBoxGetCursorPosition(self.editBox)
end,
["SetCursorPosition"] = function(self, ...)
return self.editBox:SetCursorPosition(...)
["SetCursorPosition"] = function(self, pos)
return EditBoxSetCursorPosition(self.editBox, pos)
end,
@@ -289,7 +304,7 @@ local function Constructor()
label:SetText(ACCEPT)
label:SetHeight(10)
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2")
local button = CreateFrame("Button", format("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
button:SetPoint("BOTTOMLEFT", 0, 4)
button:SetHeight(22)
button:SetWidth(label:GetStringWidth() + 24)
@@ -308,7 +323,7 @@ local function Constructor()
scrollBG:SetBackdropColor(0, 0, 0)
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollFrame = CreateFrame("ScrollFrame", format("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
scrollBar:ClearAllPoints()
@@ -326,10 +341,9 @@ local function Constructor()
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
HookScript(scrollFrame, "OnVerticalScroll", OnVerticalScroll)
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
editBox:SetAllPoints()
local editBox = CreateFrame("EditBox", format("%s%dEdit", Type, widgetNum), scrollFrame)
editBox:SetFontObject(ChatFontNormal)
editBox:SetMultiLine(true)
editBox:EnableMouse(true)
@@ -337,7 +351,7 @@ local function Constructor()
editBox:SetScript("OnCursorChanged", OnCursorChanged)
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
editBox:SetScript("OnEnter", OnEnter)
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
editBox:SetScript("OnEscapePressed", OnEscapePressed)
editBox:SetScript("OnLeave", OnLeave)
editBox:SetScript("OnMouseDown", OnReceiveDrag)
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
@@ -347,6 +361,7 @@ local function Constructor()
scrollFrame:SetScrollChild(editBox)
editBox:SetAllPoints()
local widget = {
button = button,
@@ -9,6 +9,7 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local tonumber, pairs = tonumber, pairs
local format, gsub = string.format, string.gsub
-- WoW APIs
local PlaySound = PlaySound
@@ -24,7 +25,7 @@ Support functions
local function UpdateText(self)
local value = self.value or 0
if self.ispercent then
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
self.editbox:SetText(format("%s%%", floor(value * 1000 + 0.5) / 10))
else
self.editbox:SetText(floor(value * 100 + 0.5) / 100)
end
@@ -33,8 +34,8 @@ end
local function UpdateLabels(self)
local min, max = (self.min or 0), (self.max or 100)
if self.ispercent then
self.lowtext:SetFormattedText("%s%%", (min * 100))
self.hightext:SetFormattedText("%s%%", (max * 100))
self.lowtext:SetText(format("%s%%", (min * 100)))
self.hightext:SetText(format("%s%%", (max * 100)))
else
self.lowtext:SetText(min)
self.hightext:SetText(max)
@@ -44,23 +45,23 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Frame_OnMouseDown(frame)
frame.obj.slider:EnableMouseWheel(true)
local function Frame_OnMouseDown()
this.obj.slider:EnableMouseWheel(true)
AceGUI:ClearFocus()
end
local function Slider_OnValueChanged(frame)
local self = frame.obj
if not frame.setup then
local newvalue = frame:GetValue()
local function Slider_OnValueChanged()
local self = this.obj
if not this.setup then
local newvalue = this:GetValue()
if newvalue ~= self.value and not self.disabled then
self.value = newvalue
self:Fire("OnValueChanged", newvalue)
@@ -71,16 +72,16 @@ local function Slider_OnValueChanged(frame)
end
end
local function Slider_OnMouseUp(frame)
local self = frame.obj
local function Slider_OnMouseUp()
local self = this.obj
self:Fire("OnMouseUp", self.value)
end
local function Slider_OnMouseWheel(frame, v)
local self = frame.obj
local function Slider_OnMouseWheel()
local self = this.obj
if not self.disabled then
local value = self.value
if v > 0 then
if arg1 > 0 then
value = min(value + (self.step or 1), self.max)
else
value = max(value - (self.step or 1), self.min)
@@ -89,15 +90,15 @@ local function Slider_OnMouseWheel(frame, v)
end
end
local function EditBox_OnEscapePressed(frame)
frame:ClearFocus()
local function EditBox_OnEscapePressed()
this:ClearFocus()
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
if self.ispercent then
value = value:gsub('%%', '')
value = gsub(value, '%%', '')
value = tonumber(value) / 100
else
value = tonumber(value)
@@ -110,12 +111,12 @@ local function EditBox_OnEnterPressed(frame)
end
end
local function EditBox_OnEnter(frame)
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
local function EditBox_OnEnter()
this:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
end
local function EditBox_OnLeave(frame)
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
local function EditBox_OnLeave()
this:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
end
--[[-----------------------------------------------------------------------------
@@ -217,8 +218,8 @@ local function Constructor()
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("TOPLEFT")
label:SetPoint("TOPRIGHT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetPoint("TOPRIGHT", 0, 0)
label:SetJustifyH("CENTER")
label:SetHeight(15)
+1 -1
View File
@@ -1 +1 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Include file="AceGUI-3.0\AceGUI-3.0.xml"/> <Include file="AceConfig-3.0\AceConfig-3.0.xml"/> <Include file="AceDBOptions-3.0\AceDBOptions-3.0.xml"/> <Include file="AceGUI-3.0-SharedMediaWidgets\widget.xml"/> </Ui>
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Include file="AceGUI-3.0\AceGUI-3.0.xml"/> <Include file="AceGUI-3.0\widgets\widgets.xml"/> <Include file="AceConfig-3.0\AceConfig-3.0.xml"/> <Include file="AceDBOptions-3.0\AceDBOptions-3.0.xml"/> <Include file="AceGUI-3.0-SharedMediaWidgets\widget.xml"/> </Ui>