big commit

This commit is contained in:
Bunny67
2017-12-16 20:18:25 +03:00
parent 7f59921969
commit 5585bc44b6
103 changed files with 21575 additions and 2175 deletions
+2 -1
View File
@@ -8,4 +8,5 @@
Libraries\Load_Libraries.xml
locales\load_locales.xml
core.lua
core.lua
UnitFrames.lua
@@ -12,14 +12,15 @@ 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 MAJOR, MINOR = "AceConfig-3.0-ElvUI", 2
local MAJOR, MINOR = "AceConfig-3.0", 2
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfig then return end
AceConfig.embeds = AceConfig.embeds or {}
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0")
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
@@ -43,16 +44,27 @@ local pcall, error, type, pairs = pcall, error, type, pairs
-- local AceConfig = LibStub("AceConfig-3.0")
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
if self == AceConfig then
error([[Usage: RegisterOptionsTable(appName, options[, slashcmd]): 'self' - use your own 'self']], 2)
end
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
if not ok then error(msg, 2) end
if slashcmd then
if type(slashcmd) == "table" then
for _,cmd in pairs(slashcmd) do
cfgcmd:CreateChatCommand(cmd, appName)
cfgcmd.CreateChatCommand(self, cmd, appName)
end
else
cfgcmd:CreateChatCommand(slashcmd, appName)
cfgcmd.CreateChatCommand(self, slashcmd, appName)
end
end
end
function AceConfig:Embed(target)
target["RegisterOptionsTable"] = self["RegisterOptionsTable"]
end
for addon in pairs(AceConfig.embeds) do
AceConfig:Embed(addon)
end
@@ -14,29 +14,37 @@ REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
-- TODO: plugin args
local cfgreg = LibStub("AceConfigRegistry-3.0-ElvUI")
local MAJOR, MINOR = "AceConfigCmd-3.0-ElvUI", 2
local MAJOR, MINOR = "AceConfigCmd-3.0", 13
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfigCmd then return end
local AceCore = LibStub("AceCore-3.0")
local Dispatchers = AceCore.Dispatchers
local strtrim = AceCore.strtrim
local strsplit = AceCore.strsplit
local new, del = AceCore.new, AceCore.del
local wipe = AceCore.wipe
AceConfigCmd.commands = AceConfigCmd.commands or {}
AceConfigCmd.embeds = AceConfigCmd.embeds or {}
local commands = AceConfigCmd.commands
local cfgreg = LibStub("AceConfigRegistry-3.0")
local AceConsole -- LoD
local AceConsoleName = "AceConsole-3.0"
-- Lua APIs
local strsub, strsplit, strlower, strmatch, strtrim, strupper = string.sub, string.split, string.lower, string.match, string.trim, string.upper
local format, tonumber, tostring, len, find, byte = string.format, tonumber, tostring, string.len, string.find, string.byte
local tsort, tinsert, tgetn = table.sort, table.insert, table.getn
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
local error, assert = error, assert
local mod = math.mod
local strbyte, strsub = string.byte, string.sub
local strlen, strupper, strlower = string.len, string.upper, string.lower
local strfind, strgfind, strgsub = string.find, string.gfind, string.gsub
local format = string.format
local tsort, tinsert, tgetn, tremove = table.sort, table.insert, table.getn, table.remove
-- WoW APIs
local _G = getfenv()
local _G = AceCore._G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
@@ -61,18 +69,7 @@ local handlermsg = "expected a table"
local functypes = {["function"]=true, ["string"]=true}
local funcmsg = "expected function or member name"
-- pickfirstset() - picks the first non-nil value and returns it
local function pickfirstset(...)
local args = unpack(arg)
for i=1,select("#", args) do
if select(i,args)~=nil then
return select(i,args)
end
end
end
local pickfirstset = AceCore.pickfirstset
-- err() - produce real error() regarding malformed options tables etc
@@ -92,23 +89,26 @@ end
-- callmethod() - call a given named method (e.g. "get", "set") with given arguments
local function callmethod(info, inputpos, tab, methodtype, ...)
local function callmethod(info, inputpos, tab, methodtype, argc, a1, a2, a3, a4)
local method = info[methodtype]
if not method then
err(info, inputpos, "'"..methodtype.."': not set")
end
argc = argc or 0
info.arg = tab.arg
info.option = tab
info.type = tab.type
if type(method)=="function" then
return method(info, unpack(arg))
return Dispatchers[argc+1](method, info, a1, a2, a3, a4)
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, unpack(arg))
return Dispatchers[argc+2](info.handler[method], info.handler, info, a1, a2, a3, a4)
else
assert(false) -- type should have already been checked on read
end
@@ -116,33 +116,35 @@ end
-- callfunction() - call a given named function (e.g. "name", "desc") with given arguments
local function callfunction(info, tab, methodtype, ...)
-- Ace3v: the variable arguments are currently unused, so we removed it
local function callfunction(info, tab, methodtype)
local method = tab[methodtype]
info.arg = tab.arg
info.option = tab
info.type = tab.type
if type(method)=="function" then
return method(info, unpack(arg))
return method(info)
else
assert(false) -- type should have already been checked on read
end
end
-- do_final() - do the final step (set/execute) along with validation and confirmation
local function do_final(info, inputpos, tab, methodtype, ...)
if info.validate then
local res = callmethod(info,inputpos,tab,"validate",unpack(arg))
-- Ace3v: experimental
-- @param argc number of variable arguments
local function do_final(info, inputpos, tab, methodtype, argc, a1, a2, a3, a4) -- currently maximum 4 arguments
if info.validate then
local res = callmethod(info,inputpos,tab,"validate",argc,a1,a2,a3,a4)
if type(res)=="string" then
usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
return
end
end
-- console ignores .confirm
callmethod(info,inputpos,tab,methodtype, unpack(arg))
callmethod(info,inputpos,tab,methodtype,argc,a1,a2,a3,a4)
end
@@ -154,8 +156,8 @@ local function getparam(info, inputpos, tab, depth, paramname, types, errormsg)
if val~=nil then
if val==false then
val=nil
elseif not types[type(val)] then
err(info, inputpos, "'" .. paramname.. "' - "..errormsg)
elseif not types[type(val)] then
err(info, inputpos, "'" .. paramname.. "' - "..errormsg)
end
info[paramname] = val
info[paramname.."_at"] = depth
@@ -165,16 +167,14 @@ end
-- iterateargs(tab) - custom iterator that iterates both t.args and t.plugins.*
local dummytable={}
local function iterateargs(tab)
if not tab.plugins then
return pairs(tab.args)
if not tab.plugins then
return pairs(tab.args)
end
local argtabkey,argtab=next(tab.plugins)
local v
return function(_, k)
while argtab do
k,v = next(argtab, k)
@@ -191,49 +191,53 @@ local function iterateargs(tab)
end
end
local function getValueFromTab(info, inputpos, tab, key)
local v = tab[key]
if type(v) == "function" or type(v) == "string" then
info[key] = v
v = callmethod(info, inputpos, tab, key)
info[key] = nil
end
return v
end
local function checkhidden(info, inputpos, tab)
if tab.cmdHidden~=nil then
return tab.cmdHidden
end
local hidden = tab.hidden
if type(hidden) == "function" or type(hidden) == "string" then
info.hidden = hidden
hidden = callmethod(info, inputpos, tab, 'hidden')
info.hidden = nil
end
return hidden
return getValueFromTab(info, inputpos, tab, "hidden")
end
local function showhelp(info, inputpos, tab, depth, noHead)
if not noHead then
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
end
local sortTbl = {} -- [1..n]=name
local refTbl = {} -- [name]=tableref
local sortTbl = new() -- [1..n]=name
local refTbl = new() -- [name]=tableref
for k,v in iterateargs(tab) do
if not refTbl[k] then -- a plugin overriding something in .args
tinsert(sortTbl, k)
refTbl[k] = v
end
end
tsort(sortTbl, function(one, two)
tsort(sortTbl, function(one, two)
local o1 = refTbl[one].order or 100
local o2 = refTbl[two].order or 100
if type(o1) == "function" or type(o1) == "string" then
info.order = o1
info[tgetn(info)+1] = one
tinsert(info, one)
o1 = callmethod(info, inputpos, refTbl[one], "order")
info[tgetn(info)] = nil
tremove(info)
info.order = nil
end
if type(o2) == "function" or type(o1) == "string" then
info.order = o2
info[tgetn(info)+1] = two
tinsert(info, two)
o2 = callmethod(info, inputpos, refTbl[two], "order")
info[tgetn(info)] = nil
tremove(info)
info.order = nil
end
if o1<0 and o2<0 then return o1<o2 end
@@ -242,7 +246,7 @@ local function showhelp(info, inputpos, tab, depth, noHead)
if o1==o2 then return tostring(one)<tostring(two) end -- compare names
return o1<o2
end)
for i = 1, tgetn(sortTbl) do
local k = sortTbl[i]
local v = refTbl[k]
@@ -256,21 +260,22 @@ local function showhelp(info, inputpos, tab, depth, noHead)
if type(desc) == "function" then
desc = callfunction(info, v, 'desc')
end
if v.type == "group" and pickfirstset(v.cmdInline, v.inline, false) then
if v.type == "group" and pickfirstset(3, v.cmdInline, v.inline, false) then
print(" "..(desc or name)..":")
local oldhandler,oldhandler_at = getparam(info, inputpos, v, depth, "handler", handlertypes, handlermsg)
showhelp(info, inputpos, v, depth, true)
info.handler,info.handler_at = oldhandler,oldhandler_at
else
local key = gsub(k, " ", "_")
local key = strgsub(k, " ", "_")
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
end
end
end
end
del(sortTbl) -- Ace3v: release the tables
del(refTbl)
end
local function keybindingValidateFunc(text)
if text == nil or text == "NONE" then
return nil
@@ -313,7 +318,7 @@ local function keybindingValidateFunc(text)
if text == "" then
return false
end
if not find(text, "^F%d+$") and text ~= "CAPSLOCK" and len(text) ~= 1 and (byte(text) < 128 or len(text) > 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
@@ -329,7 +334,7 @@ local function keybindingValidateFunc(text)
return s
end
-- handle() - selfrecursing function that processes input->optiontable
-- handle() - selfrecursing function that processes input->optiontable
-- - depth - starts at 0
-- - retfalse - return false rather than produce error if a match is not found (used by inlined groups)
@@ -348,45 +353,45 @@ local function handle(info, inputpos, tab, depth, retfalse)
local oldfunc,oldfunc_at = getparam(info,inputpos,tab,depth,"func",functypes,funcmsg)
local oldvalidate,oldvalidate_at = getparam(info,inputpos,tab,depth,"validate",functypes,funcmsg)
--local oldconfirm,oldconfirm_at = getparam(info,inputpos,tab,depth,"confirm",functypes,funcmsg)
-------------------------------------------------------------------
-- Act according to .type of this table
if tab.type=="group" then
------------ group --------------------------------------------
if type(tab.args)~="table" then err(info, inputpos) end
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
-- grab next arg from input
local _,nextpos,arg = find(info.input, " *([^ ]+) *", inputpos)
local _,nextpos,arg = strfind(info.input, " *([^ ]+) *", inputpos)
if not arg then
showhelp(info, inputpos, tab, depth)
return
end
nextpos=nextpos+1
-- loop .args and try to find a key with a matching name
for k,v in iterateargs(tab) do
if not(type(k)=="string" and type(v)=="table" and type(v.type)=="string") then err(info,inputpos, "options table child '"..tostring(k).."' is malformed") end
-- 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
if v.type=="group" and pickfirstset(3, v.cmdInline, v.inline, false) then
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(gsub(k, " ", "_")) then
info[depth+1] = k
elseif strlower(arg)==strlower(strgsub(k, " ", "_")) then
tinsert(info,k)
return handle(info,nextpos,v,depth+1)
end
end
-- no match
-- no match
if retfalse then
-- restore old infotable members and return false to indicate failure
info.handler,info.handler_at = oldhandler,oldhandler_at
@@ -397,36 +402,41 @@ local function handle(info, inputpos, tab, depth, retfalse)
--info.confirm,info.confirm_at = oldconfirm,oldconfirm_at
return false
end
-- couldn't find the command, display error
usererr(info, inputpos, "'"..arg.."' - " .. L["unknown argument"])
return
end
local str = strsub(info.input,inputpos);
if tab.type=="execute" then
------------ execute --------------------------------------------
do_final(info, inputpos, tab, "func")
elseif tab.type=="input" then
------------ input --------------------------------------------
if str=="" and tab.nullable == false then
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
return
end
local res = true
if tab.pattern then
if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end
if not strmatch(str, tab.pattern) then
if not strfind(str, tab.pattern) then
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
return
end
end
do_final(info, inputpos, tab, "set", str)
do_final(info, inputpos, tab, "set", 1, str)
elseif tab.type=="toggle" then
------------ toggle --------------------------------------------
local b
@@ -446,7 +456,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
else
b = not b
end
elseif str==L["on"] then
b = true
elseif str==L["off"] then
@@ -461,48 +471,64 @@ local function handle(info, inputpos, tab, depth, retfalse)
end
return
end
do_final(info, inputpos, tab, "set", b)
do_final(info, inputpos, tab, "set", 1, b)
elseif tab.type=="range" then
------------ range --------------------------------------------
local str = strtrim(strlower(str))
if str == "" then
-- TODO: Show current value
return
end
local val = tonumber(str)
if not val then
usererr(info, inputpos, "'"..str.."' - "..L["expected number"])
return
end
if type(info.step)=="number" then
val = val- mod(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)) )
return
end
if type(info.max)=="number" and val>info.max then
usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(info.max)) )
return
end
do_final(info, inputpos, tab, "set", val)
local step = getValueFromTab(info, inputpos, tab, "step")
local min = getValueFromTab(info, inputpos, tab, "min")
if type(step)=="number" then
val = min + math.floor((val-min)/step) * step
end
if type(min)=="number" and val<min then
usererr(info, inputpos, val.." - "..format(L["must be equal to or higher than %s"], tostring(min)) )
return
end
local max = getValueFromTab(info, inputpos, tab, "max")
if type(max)=="number" and val>max then
usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(max)) )
return
end
do_final(info, inputpos, tab, "set", 1, val)
elseif tab.type=="select" then
------------ select ------------------------------------
local str = strtrim(strlower(str))
local values = tab.values
if type(values) == "function" or type(values) == "string" then
info.values = values
values = callmethod(info, inputpos, tab, "values")
info.values = nil
end
local values = getValueFromTab(info, inputpos, tab, "values")
if str == "" then
local b = callmethod(info, inputpos, tab, "get")
-- Ace3v: it is possbile to not have a current value
-- we do this only for select but not for multiselect
local b = tab.get
if type(b) == "function" or type(b) == "string" then
b = callmethod(info, inputpos, tab, "get")
else
b = nil
end
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[thetn(info)].."|r:"])
print(L["Options for |cffffff78"..info[tgetn(info)].."|r:"])
for k, v in pairs(values) do
if b == k then
print(format(fmt_sel, k, v))
@@ -510,76 +536,75 @@ local function handle(info, inputpos, tab, depth, retfalse)
print(format(fmt, k, v))
end
end
if tab.valuesTableDestroyable then del(values) end
return
end
local ok
for k,v in pairs(values) do
for k,v in pairs(values) do
if strlower(k)==str then
str = k -- overwrite with key (in case of case mismatches)
ok = true
break
end
end
if tab.valuesTableDestroyable then del(values) end
if not ok then
usererr(info, inputpos, "'"..str.."' - "..L["unknown selection"])
return
end
do_final(info, inputpos, tab, "set", str)
do_final(info, inputpos, tab, "set", 1, str)
elseif tab.type=="multiselect" then
------------ multiselect -------------------------------------------
local str = strtrim(strlower(str))
local values = tab.values
if type(values) == "function" or type(values) == "string" then
info.values = values
values = callmethod(info, inputpos, tab, "values")
info.values = nil
end
local values = getValueFromTab(info, inputpos, tab, "values")
if str == "" then
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[tgetn(info)].."|r (multiple possible):"])
for k, v in pairs(values) do
if callmethod(info, inputpos, tab, "get", k) then
if callmethod(info, inputpos, tab, "get", 1, k) then
print(format(fmt_sel, k, v))
else
print(format(fmt, k, v))
end
end
if tab.valuesTableDestroyable then del(values) end
return
end
--build a table of the selections, checking that they exist
--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 gmatch(str, "[^ ]+") do
local sels = new()
for v in strgfind(str, "[^ ]+") do
--parse option=on etc
local opt, val = strmatch(v, '(.+)=(.+)')
local _, _, opt, val = strfind(v, '(.+)=(.+)')
--get option if toggling
if not opt then
opt = v
if not opt then
opt = v
end
--check that the opt is valid
local ok
for k,v in pairs(values) do
for k,v in pairs(values) do
if strlower(k)==opt then
opt = k -- overwrite with key (in case of case mismatches)
ok = true
break
end
end
if tab.valuesTableDestroyable then del(values) end
if not ok then
usererr(info, inputpos, "'"..opt.."' - "..L["unknown selection"])
return
end
--check that if val was supplied it is valid
if val then
if val == L["on"] or val == L["off"] or (tab.tristate and val == L["default"]) then
@@ -591,6 +616,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
else
usererr(info, inputpos, format(L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."], v, val))
end
del(sels)
return
end
else
@@ -598,14 +624,14 @@ local function handle(info, inputpos, tab, depth, retfalse)
sels[opt] = true
end
end
for opt, val in pairs(sels) do
local newval
if (val == true) then
--toggle the option
local b = callmethod(info, inputpos, tab, "get", opt)
local b = callmethod(info, inputpos, tab, "get", 1, opt)
if tab.tristate then
--cycle in true, nil, false order
if b then
@@ -629,11 +655,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
newval = nil
end
end
do_final(info, inputpos, tab, "set", opt, newval)
do_final(info, inputpos, tab, "set", 2, opt, newval)
end
del(sels)
elseif tab.type=="color" then
------------ color --------------------------------------------
local str = strtrim(strlower(str))
@@ -641,30 +668,25 @@ local function handle(info, inputpos, tab, depth, retfalse)
--TODO: Show current value
return
end
local r, g, b, a
local hasAlpha = tab.hasAlpha
if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
info.hasAlpha = hasAlpha
hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha')
info.hasAlpha = nil
end
local _, r, g, b, a
local hasAlpha = getValueFromTab(info, inputpos, tab, 'hasAlpha')
if hasAlpha then
if len(str) == 8 and find(str, "^%x*$") then
if strlen(str) == 8 and strfind(str, "^%x*$") then
--parse a hex string
r,g,b,a = tonumber(sub(str, 1, 2), 16) / 255, tonumber(sub(str, 3, 4), 16) / 255, tonumber(sub(str, 5, 6), 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 = strmatch(str, "^([%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
usererr(info, inputpos, format(L["'%s' - expected 'RRGGBBAA' or 'r g b a'."], str))
return
end
if r >= 0.0 and r <= 1.0 and g >= 0.0 and g <= 1.0 and b >= 0.0 and b <= 1.0 and a >= 0.0 and a <= 1.0 then
--values are valid
elseif r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 and a >= 0 and a <= 255 then
@@ -679,12 +701,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
end
else
a = 1.0
if len(str) == 6 and find(str, "^%x*$") then
if strlen(str) == 6 and strfind(str, "^%x*$") then
--parse a hex string
r,g,b = tonumber(sub(str, 1, 2), 16) / 255, tonumber(sub(str, 3, 4), 16) / 255, tonumber(sub(str, 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 = strmatch(str, "^([%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
@@ -703,8 +725,8 @@ local function handle(info, inputpos, tab, depth, retfalse)
usererr(info, inputpos, format(L["'%s' - values must all be either in the range 0-1 or 0-255."], str))
end
end
do_final(info, inputpos, tab, "set", r,g,b,a)
do_final(info, inputpos, tab, "set", 4, r,g,b,a)
elseif tab.type=="keybinding" then
------------ keybinding --------------------------------------------
@@ -719,7 +741,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
return
end
do_final(info, inputpos, tab, "set", value)
do_final(info, inputpos, tab, "set", 1, value)
elseif tab.type=="description" then
------------ description --------------------
@@ -739,7 +761,7 @@ end
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
-- -- Use AceConsole-3.0 to register a Chat Command
-- MyAddon:RegisterChatCommand("mychat", "ChatCommand")
--
--
-- -- 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
@@ -749,6 +771,9 @@ end
-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
-- end
-- end
-- Ace3v: experimental, user should copy info table if he wanna reuse it outside
-- then handler
local info_ = {}
function AceConfigCmd:HandleCommand(slashcmd, appName, input)
local optgetter = cfgreg:GetOptionsTable(appName)
@@ -756,33 +781,66 @@ function AceConfigCmd:HandleCommand(slashcmd, appName, input)
error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'appName' - no options table "]]..tostring(appName)..[[" has been registered]], 2)
end
local options = assert( optgetter("cmd", MAJOR) )
local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
[0] = slashcmd,
appName = appName,
options = options,
input = input,
self = self,
handler = self,
uiType = "cmd",
uiName = MAJOR,
}
handle(info, 1, options, 0) -- (info, inputpos, table, depth)
-- Ace3v: prevent user from using AceConfigCmd as self
if self == AceConfigCmd then
error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'self' - use your own 'self']], 2)
end
--local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
-- [0] = slashcmd,
-- appName = appName,
-- options = options,
-- input = input,
-- self = self,
-- handler = self,
-- uiType = "cmd",
-- uiName = MAJOR,
--}
wipe(info_)
info_[0] = slashcmd
info_.appName = appName
info_.options = options
info_.input = input
info_.self = self
info_.handler = self
info_.uiType = "cmd"
info_.uiName = MAJOR
handle(info_, 1, options, 0) -- (info, inputpos, table, depth)
end
--- Utility function to create a slash command handler.
-- Also registers tab completion with AceTab
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
-- @param appName The application name as given to `:RegisterOptionsTable()`
function AceConfigCmd:CreateChatCommand(slashcmd, appName)
function AceConfigCmd:CreateChatCommand(slashcmd, appName, func)
if not AceConsole then
AceConsole = LibStub(AceConsoleName)
end
if AceConsole.RegisterChatCommand(self, slashcmd, function(input)
AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
end,
true) then -- succesfully registered so lets get the command -> app table in
-- Ace3v: prevent user from using AceConfigCmd as self
if self == AceConfigCmd then
error([[Usage: CreateChatCommand("slashcmd", "appName"[, "func"]): 'self' - use your own 'self']], 2)
end
local t = type(func)
-- Ace3v: make it possible to call another function
local handler
if t == "string" then
handler = function(input) self[func](self, input, slashcmd, appName) end
elseif t ~= "function" then
handler = function(input)
AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
end
else
handler = func
end
if AceConsole.RegisterChatCommand(self, slashcmd, handler, true) then
-- succesfully registered so lets get the command -> app table in
commands[slashcmd] = appName
end
end
@@ -794,3 +852,12 @@ end
function AceConfigCmd:GetChatCommandOptions(slashcmd)
return commands[slashcmd]
end
function AceConfigCmd:Embed(target)
target["HandleCommand"] = self["HandleCommand"]
target["CreateChatCommand"] = self["CreateChatCommand"]
end
for addon in pairs(AceConfigCmd.embeds) do
AceConfigCmd:Embed(addon)
end
@@ -4,29 +4,28 @@
-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\
-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\
-- * The **appName** field is the options table name as given at registration time \\
--
--
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
-- @class file
-- @name AceConfigRegistry-3.0
-- @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", 2
-- @release $Id: AceConfigRegistry-3.0.lua 1139 2016-07-03 07:43:51Z nevcairiel $
local MAJOR, MINOR = "AceConfigRegistry-3.0", 16
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfigRegistry then return end
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
if not AceConfigRegistry.callbacks then
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
end
-- Lua APIs
local tinsert, tconcat = table.insert, table.concat
local strfind, strmatch = string.find, string.match
local tgetn = table.getn
local type, tostring, select, pairs, unpack = type, tostring, select, pairs, unpack
local tinsert, tconcat, tgetn = table.insert, table.concat, table.getn
local strfind = string.find
local type, tostring, pairs = type, tostring, pairs
local error, assert = error, assert
-----------------------------------------------------------------------
@@ -34,24 +33,24 @@ local error, assert = error, assert
AceConfigRegistry.validated = {
-- list of options table names ran through :ValidateOptionsTable automatically.
-- list of options table names ran through :ValidateOptionsTable automatically.
-- CLEARED ON PURPOSE, since newer versions may have newer validators
cmd = {},
dropdown = {},
dialog = {},
}
local function err(msg, errlvl, ...)
local t = {}
for i=tgetn(arg),1,-1 do
tinsert(t, (arg[i]))
local l = tgetn(arg)
local i,j = 1,l
while i < j do
arg[i], arg[j] = arg[j], arg[i]
i = i+1
j = j-1
end
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
error(MAJOR..":ValidateOptionsTable(): "..tconcat(arg,".")..msg, errlvl+2)
end
local isstring={["string"]=true, _="string"}
local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
local istable={["table"]=true, _="table"}
@@ -92,17 +91,6 @@ local basekeys={
func=optmethodfalse,
arg={["*"]=true},
width=optstring,
customWidth=optnumber,
textWidth=optmethodbool,
buttonElvUI=optmethodbool,
dragdrop=optmethodbool,
dragOnEnter=optmethodfalse,
dragOnLeave=optmethodfalse,
dragOnClick=optmethodfalse,
dragOnMouseUp=optmethodfalse,
dragOnMouseDown=optmethodfalse,
stateSwitchOnClick=optmethodfalse,
stateSwitchGetText=optmethodfalse,
}
local typedkeys={
@@ -137,6 +125,7 @@ local typedkeys={
dialogControl=optstring,
dropdownControl=optstring,
multiline=optboolnumber,
nullable=optbool,
},
toggle={
tristate=optbool,
@@ -156,9 +145,10 @@ local typedkeys={
},
select={
values=ismethodtable,
valuesTableDestroyable=optbool, -- Ace3v: if the values table is generated by AceCore.new
style={
["nil"]=true,
["string"]={dropdown=true,radio=true},
["nil"]=true,
["string"]={dropdown=true,radio=true},
_="string: 'dropdown' or 'radio'"
},
control=optstring,
@@ -168,6 +158,7 @@ local typedkeys={
},
multiselect={
values=ismethodtable,
valuesTableDestroyable=optbool, -- Ace3v: if the values table is generated by AceCore.new
style=optstring,
tristate=optbool,
control=optstring,
@@ -176,82 +167,81 @@ local typedkeys={
},
color={
hasAlpha=optmethodbool,
reset=opttable,
},
keybinding={
-- TODO
},
}
local function validateKey(k,errlvl,...)
local function validateKey(k,errlvl,arg)
errlvl=(errlvl or 0)+1
if type(k)~="string" then
err("["..tostring(k).."] - key is not a string", errlvl,unpack(arg))
err("["..tostring(k).."] - key is not a string", errlvl, arg)
end
if strfind(k, "[%c\127]") then
err("["..tostring(k).."] - key name contained control characters", errlvl,unpack(arg))
err("["..tostring(k).."] - key name contained control characters", errlvl, arg)
end
end
local function validateVal(v, oktypes, errlvl,...)
local function validateVal(v, oktypes, errlvl, arg)
errlvl=(errlvl or 0)+1
local isok=oktypes[type(v)] or oktypes["*"]
if not isok then
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,unpack(arg))
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl, 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,unpack(arg))
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl, arg)
end
end
end
local function validate(options,errlvl,...)
local function validate(options,errlvl,arg)
errlvl=(errlvl or 0)+1
-- basic consistency
if type(options)~="table" then
err(": expected a table, got a "..type(options), errlvl,unpack(arg))
err(": expected a table, got a "..type(options), errlvl, arg)
end
if type(options.type)~="string" then
err(".type: expected a string, got a "..type(options.type), errlvl,unpack(arg))
err(".type: expected a string, got a "..type(options.type), errlvl, arg)
end
-- get type and 'typedkeys' member
local tk = typedkeys[options.type]
if not tk then
err(".type: unknown type '"..options.type.."'", errlvl,unpack(arg))
err(".type: unknown type '"..options.type.."'", errlvl, 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),unpack(arg))
err(": unknown parameter", errlvl,tostring(k), 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,unpack(arg))
validateVal(options[k], oktypes, errlvl, k, arg)
end
for k,oktypes in pairs(tk) do
validateVal(options[k], oktypes, errlvl,k,unpack(arg))
validateVal(options[k], oktypes, errlvl, k, arg)
end
-- extra logic for groups
if options.type=="group" then
for k,v in pairs(options.args) do
validateKey(k,errlvl,"args",unpack(arg))
validate(v, errlvl,k,"args",unpack(arg))
validateKey(k,errlvl,"args", arg)
validate(v, errlvl,k,"args", 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",unpack(arg))
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname), "plugins", arg)
end
for k,v in pairs(plugin) do
validateKey(k,errlvl,tostring(plugname),"plugins",unpack(arg))
validate(v, errlvl,k,tostring(plugname),"plugins",unpack(arg))
validateKey(k,errlvl,tostring(plugname),"plugins",arg)
validate(v, errlvl,k,tostring(plugname),"plugins",arg)
end
end
end
@@ -279,7 +269,7 @@ end
-- @param appName The application name as given to `:RegisterOptionsTable()`
function AceConfigRegistry:NotifyChange(appName)
if not AceConfigRegistry.tables[appName] then return end
AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
AceConfigRegistry.callbacks:Fire("ConfigTableChange", 1, appName)
end
-- -------------------------------------------------------------------
@@ -293,7 +283,7 @@ local function validateGetterArgs(uiType, uiName, errlvl)
if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
end
if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
if not strfind(uiName, "[A-Za-z]+-[0-9]") then -- Expecting e.g. "MyLib-1.2"
error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
end
end
@@ -315,7 +305,7 @@ function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
end
return options
return options
end
elseif type(options)=="function" then
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
@@ -353,7 +343,7 @@ function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
if not f then
return nil
end
if uiType then
return f(uiType,uiName,1) -- get the table for us
else
@@ -1,12 +1,15 @@
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
-- @class file
-- @name AceDBOptions-3.0
-- @release $Id: AceDBOptions-3.0.lua 1066 2012-09-18 14:36:49Z nevcairiel $
-- @release $Id: AceDBOptions-3.0.lua 1140 2016-07-03 07:53:29Z nevcairiel $
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
if not AceDBOptions then return end -- No upgrade needed
local AceCore = LibStub("AceCore-3.0")
local new, del = AceCore.new, AceCore.del
-- Lua APIs
local pairs, next = pairs, next
@@ -230,7 +233,6 @@ elseif LOCALE == "ptBR" then
end
local defaultProfiles
local tmpprofiles = {}
-- Get a list of available profiles for the specified database.
-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
@@ -239,8 +241,8 @@ local tmpprofiles = {}
-- @param nocurrent If true, then getProfileList will not display the current profile in the list
-- @return Hashtable of all profiles with the internal name as keys and the display name as value.
local function getProfileList(db, common, nocurrent)
local profiles = {}
local profiles = new()
local tmpprofiles = new()
-- copy existing profiles into the table
local currentProfile = db:GetCurrentProfile()
for i,v in pairs(db:GetProfiles(tmpprofiles)) do
@@ -248,6 +250,7 @@ local function getProfileList(db, common, nocurrent)
profiles[v] = v
end
end
del(tmpprofiles)
-- add our default profiles to choose from ( or rename existing profiles)
for k,v in pairs(defaultProfiles) do
@@ -290,6 +293,8 @@ end
"common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
"both" - common except the active profile
]]
-- Ace3v: It is recommanded to destroy the returned table by AceCore.del
-- if it is no longer needed
function OptionsHandlerPrototype:ListProfiles(info)
local arg = info.arg
local profiles
@@ -308,7 +313,9 @@ end
function OptionsHandlerPrototype:HasNoProfiles(info)
local profiles = self:ListProfiles(info)
return ((not next(profiles)) and true or false)
local r = (not next(profiles)) and true or false
del(profiles)
return r
end
--[[ Copy a profile ]]
@@ -371,8 +378,7 @@ local optionsTable = {
current = {
order = 11,
type = "description",
--name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
name = "t",
name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
width = "default",
},
choosedesc = {
@@ -387,6 +393,7 @@ local optionsTable = {
order = 30,
get = false,
set = "SetProfile",
nullable = false, -- Ace3v: we do not want a null or empty value
},
choose = {
name = L["choose"],
@@ -396,6 +403,7 @@ local optionsTable = {
get = "GetCurrentProfile",
set = "SetProfile",
values = "ListProfiles",
valuesTableDestroyable = true,
arg = "common",
},
copydesc = {
@@ -411,6 +419,7 @@ local optionsTable = {
get = false,
set = "CopyProfile",
values = "ListProfiles",
valuesTableDestroyable = true,
disabled = "HasNoProfiles",
arg = "nocurrent",
},
@@ -427,6 +436,7 @@ local optionsTable = {
get = false,
set = "DeleteProfile",
values = "ListProfiles",
valuesTableDestroyable = true,
disabled = "HasNoProfiles",
arg = "nocurrent",
confirm = true,
@@ -1,6 +1,6 @@
--- **AceGUI-3.0** provides access to numerous widgets which can be used to create GUIs.
-- AceGUI is used by AceConfigDialog to create the option GUIs, but you can use it by itself
-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3
-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3
-- stand-alone distribution.
--
-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly,
@@ -30,13 +30,17 @@ local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
if not AceGUI then return end -- No upgrade needed
local AceCore = LibStub("AceCore-3.0")
local hooksecurefunc = AceCore.hooksecurefunc
local safecall = AceCore.safecall
-- Lua APIs
local tconcat, tgetn, tremove, tinsert = table.concat, table.getn,table.remove, table.insert
local gsub, strupper = string.gsub, string.upper
local select, pairs, next, type = select, pairs, next, type
local tconcat, tremove, tinsert, tgetn, tsetn = table.concat, table.remove, table.insert, table.getn, table.setn
local pairs, next, type = pairs, next, type
local error, assert, loadstring = error, assert, loadstring
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
local math_max = math.max
local strupper, strfmt = string.upper, string.format
-- WoW APIs
local UIParent = UIParent
@@ -52,73 +56,17 @@ AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {}
AceGUI.WidgetBase = AceGUI.WidgetBase or {}
AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
AceGUI.HookedFunctions = AceGUI.HookedFunctions or {}
-- local upvalues
local WidgetRegistry = AceGUI.WidgetRegistry
local LayoutRegistry = AceGUI.LayoutRegistry
local WidgetVersions = AceGUI.WidgetVersions
--[[
xpcall safecall implementation
]]
local xpcall = xpcall
local function errorhandler(err)
return geterrorhandler()(err)
end
local function CreateDispatcher(argCount)
local code = [[
local method, ARGS
local function call() return method(ARGS) end
local function dispatch(func, ...)
method = func
if not method then return end
ARGS = unpack(arg)
return xpcall(call, function(err) return geterrorhandler()(err) end)
end
return dispatch
]]
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = gsub(code, "ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount)
rawset(self, argCount, dispatcher)
return dispatcher
end})
Dispatchers[0] = function(func)
return xpcall(func, errorhandler)
end
local function safecall(func, ...)
return Dispatchers[tgetn(arg)](func, unpack(arg))
end
local HookedFunctions = AceGUI.HookedFunctions
-- Recycling functions
local newWidget, delWidget
do
-- Version Upgrade in Minor 29
-- Internal Storage of the objects changed, from an array table
-- to a hash table, and additionally we introduced versioning on
-- the widgets which would discard all widgets from a pre-29 version
-- anyway, so we just clear the storage now, and don't try to
-- convert the storage tables to the new format.
-- This should generally not cause *many* widgets to end up in trash,
-- since once dialogs are opened, all addons should be loaded already
-- and AceGUI should be on the latest version available on the users
-- setup.
-- -- nevcairiel - Nov 2nd, 2009
if oldminor and oldminor < 29 and AceGUI.objPools then
AceGUI.objPools = nil
end
AceGUI.objPools = AceGUI.objPools or {}
local objPools = AceGUI.objPools
--Returns a new instance, if none are available either returns a new table or calls the given contructor
@@ -126,11 +74,11 @@ do
if not WidgetRegistry[type] then
error("Attempt to instantiate unknown widget type", 2)
end
if not objPools[type] then
objPools[type] = {}
end
local newObj = next(objPools[type])
if not newObj then
newObj = WidgetRegistry[type]()
@@ -157,6 +105,35 @@ do
end
end
-- Ace3v: when a container contains many children, we can only use the variable arguments
local function _fixlevels(parent, ...)
local lv = parent:GetFrameLevel() + 1
for i = 1, tgetn(arg) do
local child = arg[i]
child:SetFrameLevel(lv)
_fixlevels(child, child:GetChildren())
end
end
local function fixlevels(parent)
return _fixlevels(parent, parent:GetChildren())
end
AceGUI.fixlevels = fixlevels
-- Ace3v: attention! this function is recursive
local function _fixstrata(strata, parent, ...)
parent:SetFrameStrata(strata)
for i = 1, tgetn(arg) do
local child = arg[i]
_fixstrata(strata, child, child:GetChildren())
end
end
local function fixstrata(strata, parent)
return _fixstrata(strata, parent, parent:GetChildren())
end
AceGUI.fixstrata = fixstrata
-------------------
-- API Functions --
@@ -173,27 +150,15 @@ function AceGUI:Create(type)
if WidgetRegistry[type] then
local widget = newWidget(type)
if rawget(widget, "Acquire") then
widget.OnAcquire = widget.Acquire
widget.Acquire = nil
elseif rawget(widget, "Aquire") then
widget.OnAcquire = widget.Aquire
widget.Aquire = nil
end
if rawget(widget, "Release") then
widget.OnRelease = rawget(widget, "Release")
widget.Release = nil
end
if widget.OnAcquire then
widget:OnAcquire()
else
error(format("Widget type %s doesn't supply an OnAcquire Function", type))
error(strfmt("Widget type %s doesn't supply an OnAcquire Function", type))
end
-- Set the default Layout ("List")
safecall(widget.SetLayout, widget, "List")
safecall(widget.ResumeLayout, widget)
safecall(widget.SetLayout, 2, widget, "List")
safecall(widget.ResumeLayout, 1, widget)
return widget
end
end
@@ -204,14 +169,14 @@ end
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
-- @param widget The widget to release
function AceGUI:Release(widget)
safecall(widget.PauseLayout, widget)
safecall(widget.PauseLayout, 1, widget)
widget:Fire("OnRelease")
safecall(widget.ReleaseChildren, widget)
safecall(widget.ReleaseChildren, 1, widget)
if widget.OnRelease then
widget:OnRelease()
-- else
-- error(format("Widget type %s doesn't supply an OnRelease Function", widget.type))
-- error(strfmt("Widget type %s doesn't supply an OnRelease Function", widget.type))
end
for k in pairs(widget.userdata) do
widget.userdata[k] = nil
@@ -246,7 +211,7 @@ end
-- @param widget The widget that should be focused
function AceGUI:SetFocus(widget)
if self.FocusedWidget and self.FocusedWidget ~= widget then
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
safecall(self.FocusedWidget.ClearFocus, 1, self.FocusedWidget)
end
self.FocusedWidget = widget
end
@@ -256,7 +221,7 @@ end
-- e.g. titlebar of a frame being clicked
function AceGUI:ClearFocus()
if self.FocusedWidget then
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
safecall(self.FocusedWidget.ClearFocus, 1, self.FocusedWidget)
self.FocusedWidget = nil
end
end
@@ -267,18 +232,18 @@ end
--[[
Widgets must provide the following functions
OnAcquire() - Called when the object is acquired, should set everything to a default hidden state
And the following members
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
type - the type of the object, same as the name given to :RegisterWidget()
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
It will be cleared automatically when a widget is released
Placing values directly into a widget object should be avoided
If the Widget can act as a container for other Widgets the following
content - frame or derivitive that children will be anchored to
The Widget can supply the following Optional Members
:OnRelease() - Called when the object is Released, should remove any additional anchors and clear any data
:OnWidthSet(width) - Called when the width of the widget is changed
@@ -294,30 +259,33 @@ end
-- Widget Base Template --
--------------------------
do
local WidgetBase = AceGUI.WidgetBase
local WidgetBase = AceGUI.WidgetBase
WidgetBase.SetParent = function(self, parent)
local frame = self.frame
frame:SetParent(nil)
frame:SetParent(parent.content)
self.parent = parent
fixlevels(frame)
end
WidgetBase.SetCallback = function(self, name, func)
if type(func) == "function" then
self.events[name] = func
end
end
WidgetBase.Fire = function(self, name, ...)
if self.events[name] then
local success, ret = safecall(self.events[name], self, name, unpack(arg))
WidgetBase.Fire = function(self,name,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
argc = argc or 0
local func = self.events[name]
if func then
local success, ret = safecall(func,argc+3,self,name,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
if success then
return ret
end
end
end
WidgetBase.SetWidth = function(self, width)
self.frame:SetWidth(width)
self.frame.width = width
@@ -325,7 +293,7 @@ do
self:OnWidthSet(width)
end
end
WidgetBase.SetRelativeWidth = function(self, width)
if width <= 0 or width > 1 then
error(":SetRelativeWidth(width): Invalid relative width.", 2)
@@ -333,7 +301,7 @@ do
self.relWidth = width
self.width = "relative"
end
WidgetBase.SetHeight = function(self, height)
self.frame:SetHeight(height)
self.frame.height = height
@@ -341,7 +309,7 @@ do
self:OnHeightSet(height)
end
end
--[[ WidgetBase.SetRelativeHeight = function(self, height)
if height <= 0 or height > 1 then
error(":SetRelativeHeight(height): Invalid relative height.", 2)
@@ -353,47 +321,47 @@ do
WidgetBase.IsVisible = function(self)
return self.frame:IsVisible()
end
WidgetBase.IsShown= function(self)
return self.frame:IsShown()
end
WidgetBase.Release = function(self)
AceGUI:Release(self)
end
WidgetBase.SetPoint = function(self, ...)
return self.frame:SetPoint(unpack(arg))
WidgetBase.SetPoint = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
return self.frame:SetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
end
WidgetBase.ClearAllPoints = function(self)
return self.frame:ClearAllPoints()
end
WidgetBase.GetNumPoints = function(self)
return self.frame:GetNumPoints()
end
WidgetBase.GetPoint = function(self, ...)
return self.frame:GetPoint(unpack(arg))
end
WidgetBase.GetPoint = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
return self.frame:GetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
end
WidgetBase.GetUserDataTable = function(self)
return self.userdata
end
WidgetBase.SetUserData = function(self, key, value)
self.userdata[key] = value
end
WidgetBase.GetUserData = function(self, key)
return self.userdata[key]
end
WidgetBase.IsFullHeight = function(self)
return self.height == "fill"
end
WidgetBase.SetFullHeight = function(self, isFull)
if isFull then
self.height = "fill"
@@ -401,11 +369,11 @@ do
self.height = nil
end
end
WidgetBase.IsFullWidth = function(self)
return self.width == "fill"
end
WidgetBase.SetFullWidth = function(self, isFull)
if isFull then
self.width = "fill"
@@ -413,29 +381,29 @@ do
self.width = nil
end
end
-- local function LayoutOnUpdate(this)
-- this:SetScript("OnUpdate",nil)
-- this.obj:PerformLayout()
-- end
local WidgetContainerBase = AceGUI.WidgetContainerBase
WidgetContainerBase.PauseLayout = function(self)
self.LayoutPaused = true
end
WidgetContainerBase.ResumeLayout = function(self)
self.LayoutPaused = nil
end
WidgetContainerBase.PerformLayout = function(self)
if self.LayoutPaused then
return
end
safecall(self.LayoutFunc, self.content, self.children)
safecall(self.LayoutFunc, 2, self.content, self.children)
end
--call this function to layout, makes sure layed out objects get a frame to get sizes etc
WidgetContainerBase.DoLayout = function(self)
self:PerformLayout()
@@ -443,7 +411,7 @@ do
-- self.frame:SetScript("OnUpdate", LayoutOnUpdate)
-- end
end
WidgetContainerBase.AddChild = function(self, child, beforeWidget)
if beforeWidget then
local siblingIndex = 1
@@ -451,7 +419,7 @@ do
if widget == beforeWidget then
break
end
siblingIndex = siblingIndex + 1
siblingIndex = siblingIndex + 1
end
tinsert(self.children, siblingIndex, child)
else
@@ -461,25 +429,52 @@ do
child.frame:Show()
self:DoLayout()
end
WidgetContainerBase.AddChildren = function(self, ...)
for i = 1, tgetn(arg) do
local child = arg[i]
do
local args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
WidgetContainerBase.AddChildren = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
args[1] = a1
args[2] = a2
args[3] = a3
args[4] = a4
args[5] = a5
args[6] = a6
args[7] = a7
args[8] = a8
args[9] = a9
args[10] = a10
for i = 1,10 do
local child = args[i]
arg[i] = nil
if not child then break end
tinsert(self.children, child)
child:SetParent(self)
child.frame:Show()
end
self:DoLayout()
end
end -- WidgetContainerBase.AddChildren
WidgetContainerBase.ReleaseChildren = function(self)
local children = self.children
for i = 1,tgetn(children) do
AceGUI:Release(children[i])
children[i] = nil
AceGUI:Release(tremove(children))
end
end
WidgetContainerBase.SetParent = function(self, parent)
WidgetBase.SetParent(self, parent)
local lv = self.frame:GetFrameLevel()
self.content:SetFrameLevel(lv+1)
local children = self.children
for i = 1,tgetn(children) do
local child = children[i]
child:SetParent(self)
end
end
WidgetContainerBase.SetLayout = function(self, Layout)
self.LayoutFunc = AceGUI:GetLayout(Layout)
end
@@ -503,7 +498,7 @@ do
end
end
end
local function ContentResize()
if this:GetWidth() and this:GetHeight() then
this.width = this:GetWidth()
@@ -515,7 +510,7 @@ do
setmetatable(WidgetContainerBase, {__index=WidgetBase})
--One of these function should be called on each Widget Instance as part of its creation process
--- Register a widget-class as a container for newly created widgets.
-- @param widget The widget class
function AceGUI:RegisterAsContainer(widget)
@@ -531,7 +526,7 @@ do
widget:SetLayout("List")
return widget
end
--- Register a widget-class as a widget.
-- @param widget The widget class
function AceGUI:RegisterAsWidget(widget)
@@ -558,11 +553,11 @@ end
-- @param Version The version of the widget
function AceGUI:RegisterWidgetType(Name, Constructor, Version)
assert(type(Constructor) == "function")
assert(type(Version) == "number")
assert(type(Version) == "number")
local oldVersion = WidgetVersions[Name]
if oldVersion and oldVersion >= Version then return end
WidgetVersions[Name] = Version
WidgetRegistry[Name] = Constructor
end
@@ -573,7 +568,7 @@ end
function AceGUI:RegisterLayout(Name, LayoutFunc)
assert(type(LayoutFunc) == "function")
if type(Name) == "string" then
Name = strupper(Name)
Name = string.upper(Name)
end
LayoutRegistry[Name] = LayoutFunc
end
@@ -631,7 +626,7 @@ AceGUI:RegisterLayout("List",
local width = content.width or content:GetWidth() or 0
for i = 1, tgetn(children) do
local child = children[i]
local frame = child.frame
frame:ClearAllPoints()
frame:Show()
@@ -640,25 +635,25 @@ AceGUI:RegisterLayout("List",
else
frame:SetPoint("TOPLEFT", children[i-1].frame, "BOTTOMLEFT")
end
if child.width == "fill" then
child:SetWidth(width)
frame:SetPoint("RIGHT", content)
if child.DoLayout then
child:DoLayout()
end
elseif child.width == "relative" then
child:SetWidth(width * child.relWidth)
if child.DoLayout then
child:DoLayout()
end
end
height = height + (frame.height or frame:GetHeight() or 0)
end
safecall(content.obj.LayoutFinished, content.obj, nil, height)
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
end)
-- A single control fills the whole content area
@@ -669,14 +664,15 @@ AceGUI:RegisterLayout("Fill",
children[1]:SetHeight(content:GetHeight() or 0)
children[1].frame:SetAllPoints(content)
children[1].frame:Show()
safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
safecall(content.obj.LayoutFinished, 3, content.obj, nil, children[1].frame:GetHeight())
end
end)
-- Ace3v: currently only a1 used
local layoutrecursionblock = nil
local function safelayoutcall(object, func, ...)
local function safelayoutcall(object, func, a1)
layoutrecursionblock = true
object[func](object, unpack(arg))
object[func](object, a1)
layoutrecursionblock = nil
end
@@ -691,18 +687,18 @@ AceGUI:RegisterLayout("Flow",
local rowheight = 0
local rowoffset = 0
local lastrowoffset
local width = content.width or content:GetWidth() or 0
--control at the start of the row
local rowstart
local rowstartoffset
local lastrowstart
local isfullheight
local frameoffset
local lastframeoffset
local oversize
local oversize
for i = 1, tgetn(children) do
local child = children[i]
oversize = nil
@@ -710,17 +706,17 @@ AceGUI:RegisterLayout("Flow",
local frameheight = frame.height or frame:GetHeight() or 0
local framewidth = frame.width or frame:GetWidth() or 0
lastframeoffset = frameoffset
-- HACK: Why did we set a frameoffset of (frameheight / 2) ?
-- HACK: Why did we set a frameoffset of (frameheight / 2) ?
-- That was moving all widgets half the widgets size down, is that intended?
-- Actually, it seems to be neccessary for many cases, we'll leave it in for now.
-- If widgets seem to anchor weirdly with this, provide a valid alignoffset for them.
-- TODO: Investigate moar!
frameoffset = child.alignoffset or (frameheight / 2)
if child.width == "relative" then
framewidth = width * child.relWidth
end
frame:Show()
frame:ClearAllPoints()
if i == 1 then
@@ -759,11 +755,11 @@ AceGUI:RegisterLayout("Flow",
else
--handles cases where the new height is higher than either control because of the offsets
--math.max(rowheight-rowoffset+frameoffset, frameheight-frameoffset+rowoffset)
--offset is always the larger of the two offsets
rowoffset = math_max(rowoffset, frameoffset)
rowheight = math_max(rowheight, rowoffset + (frameheight / 2))
frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT", 0, frameoffset - lastframeoffset)
usedwidth = framewidth + usedwidth
end
@@ -772,11 +768,11 @@ AceGUI:RegisterLayout("Flow",
if child.width == "fill" then
safelayoutcall(child, "SetWidth", width)
frame:SetPoint("RIGHT", content)
usedwidth = 0
rowstart = frame
rowstartoffset = frameoffset
if child.DoLayout then
child:DoLayout()
end
@@ -785,7 +781,7 @@ AceGUI:RegisterLayout("Flow",
rowstartoffset = rowoffset
elseif child.width == "relative" then
safelayoutcall(child, "SetWidth", width * child.relWidth)
if child.DoLayout then
child:DoLayout()
end
@@ -794,20 +790,20 @@ AceGUI:RegisterLayout("Flow",
frame:SetPoint("RIGHT", content)
end
end
if child.height == "fill" then
frame:SetPoint("BOTTOM", content)
isfullheight = true
end
end
--anchor the last row, if its full height needs a special case since its height has just been changed by the anchor
if isfullheight then
rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -height)
elseif rowstart then
rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3))
end
height = height + rowheight + 3
safecall(content.obj.LayoutFinished, content.obj, nil, height)
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
end)
@@ -1,5 +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"/>
<Include file="widgets\widgets.xml"/>
</Ui>
@@ -15,11 +15,11 @@ local CreateFrame = CreateFrame
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function SelectedGroup(self, event, value)
local function SelectedGroup(self, event, _, value)
local group = self.parentgroup
local status = group.status or group.localstatus
status.selected = value
self.parentgroup:Fire("OnGroupSelected", value)
self.parentgroup:Fire("OnGroupSelected", 1, value)
end
--[[-----------------------------------------------------------------------------
@@ -63,7 +63,7 @@ local methods = {
self.dropdown:SetValue(group)
local status = self.status or self.localstatus
status.selected = group
self:Fire("OnGroupSelected", group)
self:Fire("OnGroupSelected", 1, group)
end,
["OnWidthSet"] = function(self, width)
@@ -150,7 +150,7 @@ local function Constructor()
widget[method] = func
end
dropdown.parentgroup = widget
return AceGUI:RegisterAsContainer(widget)
end
@@ -1,13 +1,15 @@
--[[-----------------------------------------------------------------------------
Frame Container
-------------------------------------------------------------------------------]]
local Type, Version = "Frame", 26
local Type, Version = "Frame", 24
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
local wipe = AceCore.wipe
-- Lua APIs
local pairs, assert, type = pairs, assert, type
local wipe = table.wipe
-- WoW APIs
local PlaySound = PlaySound
@@ -25,10 +27,6 @@ local function Button_OnClick()
this.obj:Hide()
end
local function Frame_OnShow()
this.obj:Fire("OnShow")
end
local function Frame_OnClose()
this.obj:Fire("OnClose")
end
@@ -190,7 +188,6 @@ local function Constructor()
frame:SetBackdropColor(0, 0, 0, 1)
frame:SetMinResize(400, 200)
frame:SetToplevel(true)
frame:SetScript("OnShow", Frame_OnShow)
frame:SetScript("OnHide", Frame_OnClose)
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
@@ -248,6 +245,7 @@ local function Constructor()
titlebg_r:SetWidth(30)
titlebg_r:SetHeight(40)
-- bottom right sizer
local sizer_se = CreateFrame("Frame", nil, frame)
sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
sizer_se:SetWidth(25)
@@ -6,9 +6,12 @@ local Type, Version = "ScrollFrame", 24
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local fixlevels = AceGUI.fixlevels
-- 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
@@ -24,23 +27,23 @@ 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()
this:SetScript("OnUpdate", FixScrollOnUpdate)
end
local function ScrollBar_OnScrollValueChanged(frame, value)
frame.obj:SetScroll(value)
local function ScrollBar_OnScrollValueChanged()
this.obj:SetScroll(arg1)
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
["OnAcquire"] = function(self)
self:SetScroll(0)
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
end,
@@ -50,7 +53,7 @@ local methods = {
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
self.scrollframe:SetPoint("BOTTOMRIGHT",0,0)
self.scrollbar:Hide()
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil
@@ -77,7 +80,7 @@ local methods = {
["MoveScroll"] = function(self, value)
local status = self.status or self.localstatus
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
if self.scrollBarShown then
local diff = height - viewheight
local delta = 1
@@ -89,40 +92,46 @@ local methods = {
end,
["FixScroll"] = function(self)
if self.updateLock then return end
self.updateLock = true
local status = self.status or self.localstatus
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
local scrollframe, content, scrollbar = self.scrollframe, self.content, self.scrollbar
local viewheight, height = self.scrollframe:GetHeight(), self.content:GetHeight()
local offset = status.offset or 0
local curvalue = self.scrollbar:GetValue()
local curvalue = scrollbar:GetValue()
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
if viewheight < height + 2 then
if height < viewheight + 2 then
if self.scrollBarShown then
self.scrollBarShown = nil
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
scrollbar:Hide()
scrollbar:SetValue(0)
scrollframe:SetPoint("BOTTOMRIGHT",0,0)
self:DoLayout()
end
offset = 0
else
if not self.scrollBarShown then
self.scrollBarShown = true
self.scrollbar:Show()
self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
scrollbar:Show()
scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
self:DoLayout()
end
local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end
self.scrollbar:SetValue(value)
self:SetScroll(value)
if value < 1000 then
self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", 0, offset)
status.offset = offset
local value = (offset / (height - viewheight) * 1000)
if value > 1000 then
value = 1000
offset = height - viewheight
end
scrollbar:SetValue(value)
self:SetScroll(value)
end
status.offset = offset
scrollframe:SetScrollChild(content)
content:ClearAllPoints()
content:SetPoint("TOPLEFT", 0, offset)
content:SetPoint("TOPRIGHT", 0, offset)
self.updateLock = nil
end,
@@ -157,8 +166,8 @@ local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT", 0, 0)
scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
scrollframe:SetPoint("TOPLEFT",0,0)
scrollframe:SetPoint("BOTTOMRIGHT",0,0)
scrollframe:EnableMouseWheel(true)
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
@@ -180,8 +189,8 @@ local function Constructor()
--Container Support
local content = CreateFrame("Frame", nil, scrollframe)
content:SetPoint("TOPLEFT", 0, 0)
content:SetPoint("TOPRIGHT", 0, 0)
content:SetPoint("TOPLEFT",0,0)
content:SetPoint("TOPRIGHT",0,0)
content:SetHeight(400)
scrollframe:SetScrollChild(content)
@@ -2,18 +2,22 @@
TabGroup Container
Container that uses tabs on top to switch between groups.
-------------------------------------------------------------------------------]]
local Type, Version = "TabGroup", 36
local Type, Version = "TabGroup", 35
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
local wipe = AceCore.wipe
-- Lua APIs
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
local tgetn = table.getn
local strfmt = string.format
-- WoW APIs
local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
local _G = AceCore._G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
@@ -30,57 +34,60 @@ Support functions
local function UpdateTabLook(frame)
if frame.disabled then
PanelTemplates_SetDisabledTabState(frame)
frame:SetAlpha(0.5)
elseif frame.selected then
PanelTemplates_SelectTab(frame)
frame:SetAlpha(1)
else
PanelTemplates_DeselectTab(frame)
frame:SetAlpha(0.5)
end
end
local function Tab_SetText(frame, text)
frame:_SetText(text)
local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
PanelTemplates_TabResize(frame, 0, nil, width, frame:GetFontString():GetStringWidth())
local function Tab_SetText(tab, text)
tab:_SetText(text)
local width = tab.obj.frame.width or tab.obj.frame:GetWidth() or 0
PanelTemplates_TabResize(0, tab, nil, width)
end
local function Tab_SetSelected(frame, selected)
frame.selected = selected
UpdateTabLook(frame)
local function Tab_SetSelected(tab, selected)
tab.selected = selected
UpdateTabLook(tab)
end
local function Tab_SetDisabled(frame, disabled)
frame.disabled = disabled
UpdateTabLook(frame)
local function Tab_SetDisabled(tab, disabled)
tab.disabled = disabled
UpdateTabLook(tab)
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", 2, 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", 2, 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
--[[-----------------------------------------------------------------------------
@@ -103,16 +110,31 @@ local methods = {
end,
["CreateTab"] = function(self, id)
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
local tabname = strfmt("AceGUITabGroup%dTab%d", self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
-- Normal texture
local texture = getglobal(tabname.."Left")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture:ClearAllPoints()
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture = getglobal(tabname.."Middle")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = getglobal(tabname.."Right")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
-- Disabled texture
texture = getglobal(tabname.."LeftDisabled")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture = getglobal(tabname.."MiddleDisabled")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = getglobal(tabname.."RightDisabled")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
tab.obj = self
tab.id = id
tab.text = _G[tabname .. "Text"]
tab.text:ClearAllPoints()
tab.text:SetPoint("LEFT", 14, -3)
tab.text:SetPoint("RIGHT", -12, -3)
tab:SetScript("OnClick", Tab_OnClick)
tab:SetScript("OnEnter", Tab_OnEnter)
tab:SetScript("OnLeave", Tab_OnLeave)
@@ -154,7 +176,7 @@ local methods = {
end
status.selected = value
if found then
self:Fire("OnGroupSelected",value)
self:Fire("OnGroupSelected",1,value)
end
end,
@@ -162,22 +184,22 @@ local methods = {
self.tablist = tabs
self:BuildTabs()
end,
["BuildTabs"] = function(self)
local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
local status = self.status or self.localstatus
local tablist = self.tablist
local tabs = self.tabs
if not tablist then return end
local width = self.frame.width or self.frame:GetWidth() or 0
wipe(widths)
wipe(rowwidths)
wipe(rowends)
--Place Text into tabs and get thier initial width
for i, v in ipairs(tablist) do
local tab = tabs[i]
@@ -185,19 +207,24 @@ local methods = {
tab = self:CreateTab(i)
tabs[i] = tab
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 = tgetn(tablist)+1, tgetn(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 = tgetn(tablist)
local numrows = 1
@@ -215,7 +242,7 @@ local methods = {
end
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
rowends[numrows] = tgetn(tablist)
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
if numrows > 1 then
--if the last row has only one tab
@@ -246,23 +273,23 @@ local methods = {
tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
end
end
-- equal padding for each tab to fill the available width,
-- if the used space is above 75% already
-- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
-- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
-- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't
local padding = 0
if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then
padding = (width - rowwidths[row]) / (endtab - starttab+1)
end
for i = starttab, endtab do
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width, tabs[i]:GetFontString():GetStringWidth())
PanelTemplates_TabResize(padding + 4, tabs[i], nil, width)
end
starttab = endtab + 1
end
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)+7
self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
end,
@@ -287,7 +314,7 @@ local methods = {
content:SetHeight(contentheight)
content.height = contentheight
end,
["LayoutFinished"] = function(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + (self.borderoffset + 23))
@@ -344,7 +371,7 @@ local function Constructor()
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsContainer(widget)
end
@@ -6,12 +6,15 @@ local Type, Version = "TreeGroup", 40
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
local strsplit = AceCore.strsplit
local _G = AceCore._G
-- 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 strsplit = string.split
local tgetn = table.getn
local tgetn, tremove, unpack, tconcat = table.getn, table.remove, unpack, table.concat
local strfmt = string.format
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -36,7 +39,7 @@ do
function del(t)
for k in pairs(t) do
t[k] = nil
end
end
pool[t] = true
end
end
@@ -67,7 +70,7 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local value = treeline.value
local uniquevalue = treeline.uniquevalue
local disabled = treeline.disabled
button.treeline = treeline
button.value = value
button.uniquevalue = uniquevalue
@@ -81,16 +84,17 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local normalTexture = button:GetNormalTexture()
local line = button.line
button.level = level
if ( level == 1 ) then
button:SetNormalFontObject("GameFontNormal")
button.text:SetFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else
button:SetNormalFontObject("GameFontHighlightSmall")
button.text:SetFontObject("GameFontHighlightSmall")
button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
end
if disabled then
button:EnableMouse(false)
button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE)
@@ -98,20 +102,20 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
button.text:SetText(text)
button:EnableMouse(true)
end
if icon then
button.icon:SetTexture(icon)
button.icon:SetPoint("LEFT", 8 * level, (level == 1) and 0 or 1)
else
button.icon:SetTexture(nil)
end
if iconCoords then
button.icon:SetTexCoord(unpack(iconCoords))
else
button.icon:SetTexCoord(0, 1, 0, 1)
end
if canExpand then
if not isExpanded then
toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP")
@@ -156,134 +160,143 @@ local function addLine(self, v, tree, level, parent)
else
line.hasChildren = nil
end
self.lines[tgetn(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('#', arg)
if n == 1 then
return arg1
else
return (unpack(arg)).."\001"..BuildUniqueValue(select(2,arg))
end
local BuildUniqueValue
do
local args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
function BuildUniqueValue(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
args[1] = a1
args[2] = a2
args[3] = a3
args[4] = a4
args[5] = a5
args[6] = a6
args[7] = a7
args[8] = a8
args[9] = a9
args[10] = a10
return tconcat(tmp, "\001", 1, tgetn(args))
end
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", 2, 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", 2, 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, true)
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", 2, 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 = floor(value + 0.5)
status.scrollvalue = floor(arg1 + 0.5)
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()
local this = treeframe:GetParent()
treeframe:StopMovingOrSizing()
--treeframe:SetScript("OnUpdate", nil)
treeframe:SetUserPlaced(false)
--Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize
treeframe:SetHeight(0)
treeframe:SetPoint("TOPLEFT", frame, "TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0)
treeframe:SetPoint("TOPLEFT", this, "TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT", this, "BOTTOMLEFT",0,0)
local status = self.status or self.localstatus
status.treewidth = treeframe:GetWidth()
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
treeframe.obj:Fire("OnTreeResize", 1, treeframe:GetWidth())
-- recalculate the content width
treeframe.obj:OnWidthSet(status.fullwidth)
-- update the layout of the content
@@ -293,7 +306,10 @@ end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
local methods
do
local select_args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
methods = {
["OnAcquire"] = function(self)
self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
self:EnableButtonTooltips(true)
@@ -322,8 +338,39 @@ local methods = {
["CreateButton"] = function(self)
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
local button = CreateFrame("Button", format("AceGUI30TreeButton%d", num), self.treeframe, "OptionsListButtonTemplate")
local button = CreateFrame("Button", strfmt("AceGUI30TreeButton%d", num), self.treeframe)
button.obj = self
button:SetWidth(175)
button:SetHeight(18)
local toggle = CreateFrame("Button", nil, button)
toggle.obj = button
button.toggle = toggle
toggle:SetWidth(14)
toggle:SetHeight(14)
toggle:ClearAllPoints()
toggle:SetPoint("TOPRIGHT", button, "TOPRIGHT", -6, -1)
toggle:SetScript("OnClick", Button_OnClick)
toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
toggle:SetHighlightTexture("Interface\Buttons\UI-PlusButton-Hilight", "ADD")
local text = button:CreateFontString()
button.text = text
text:SetFontObject(GameFontNormal)
button:SetHighlightFontObject(GameFontHighlight)
text:SetPoint("RIGHT", toggle, "LEFT", -2, 0);
text:SetJustifyH("LEFT")
local highlight = button:CreateTexture(nil, "HIGHLIGHT");
button.highlight = highlight
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight")
highlight:SetBlendMode("ADD")
highlight:SetVertexColor(.196, .388, .8);
highlight:ClearAllPoints()
highlight:SetPoint("TOPLEFT",0,1)
highlight:SetPoint("BOTTOMRIGHT",0,1)
local icon = button:CreateTexture(nil, "OVERLAY")
icon:SetWidth(14)
@@ -365,8 +412,8 @@ local methods = {
--sets the tree to be displayed
["SetTree"] = function(self, tree, filter)
self.filter = filter
if tree then
assert(type(tree) == "table")
if tree then
assert(type(tree) == "table")
end
self.tree = tree
self:RefreshTree()
@@ -375,7 +422,7 @@ local methods = {
["BuildLevel"] = function(self, tree, level, parent)
local groups = (self.status or self.localstatus).groups
local hasChildren = self.hasChildren
for i, v in ipairs(tree) do
if v.children then
if not self.filter or ShouldDisplayLevel(v.children) then
@@ -391,7 +438,7 @@ local methods = {
end,
["RefreshTree"] = function(self,scrollToSelection)
local buttons = self.buttons
local buttons = self.buttons
local lines = self.lines
for i, v in ipairs(buttons) do
@@ -412,7 +459,7 @@ local methods = {
local tree = self.tree
local treeframe = self.treeframe
status.scrollToSelection = status.scrollToSelection or scrollToSelection -- needs to be cached in case the control hasn't been drawn yet (code bails out below)
self:BuildLevel(tree, 1)
@@ -423,7 +470,7 @@ local methods = {
if maxlines <= 0 then return end
local first, last
scrollToSelection = status.scrollToSelection
status.scrollToSelection = nil
@@ -499,32 +546,41 @@ local methods = {
button:Show()
buttonnum = buttonnum + 1
end
end,
["SetSelected"] = function(self, value)
local status = self.status or self.localstatus
if status.selected ~= value then
status.selected = value
self:Fire("OnGroupSelected", value)
self:Fire("OnGroupSelected", 1, value)
end
end,
["Select"] = function(self, uniquevalue, ...)
["Select"] = function(self, uniquevalue, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
self.filter = false
local status = self.status or self.localstatus
local groups = status.groups
local path = {unpack(arg)}
for i = 1, tgetn(path) do
groups[tconcat(path, "\001", 1, i)] = true
select_args[1] = a1
select_args[2] = a2
select_args[3] = a3
select_args[4] = a4
select_args[5] = a5
select_args[6] = a6
select_args[7] = a7
select_args[8] = a8
select_args[9] = a9
select_args[10] = a10
for i = 1, tgetn(select_args) do
groups[tconcat(select_args, "\001", 1, i)] = true
end
status.selected = uniquevalue
self:RefreshTree(true)
self:Fire("OnGroupSelected", uniquevalue)
self:Fire("OnGroupSelected", 1, uniquevalue)
end,
["SelectByPath"] = function(self, ...)
self:Select(BuildUniqueValue(unpack(arg)), unpack(arg))
["SelectByPath"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
self:Select(BuildUniqueValue(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10), a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
end,
["SelectByValue"] = function(self, uniquevalue)
@@ -551,16 +607,16 @@ local methods = {
local treeframe = self.treeframe
local status = self.status or self.localstatus
status.fullwidth = width
local contentwidth = width - status.treewidth - 20
if contentwidth < 0 then
contentwidth = 0
end
content:SetWidth(contentwidth)
content.width = contentwidth
local maxtreewidth = math_min(400, width - 50)
if maxtreewidth > 100 and status.treewidth > maxtreewidth then
self:SetTreeWidth(maxtreewidth, status.treesizable)
end
@@ -586,16 +642,16 @@ local methods = {
treewidth = DEFAULT_TREE_WIDTH
else
resizable = false
treewidth = DEFAULT_TREE_WIDTH
treewidth = DEFAULT_TREE_WIDTH
end
end
self.treeframe:SetWidth(treewidth)
self.dragger:EnableMouse(resizable)
local status = self.status or self.localstatus
status.treewidth = treewidth
status.treesizable = resizable
-- recalculate the content width
if status.fullwidth then
self:OnWidthSet(status.fullwidth)
@@ -612,6 +668,7 @@ local methods = {
self:SetHeight((height or 0) + 20)
end
}
end -- method
--[[-----------------------------------------------------------------------------
Constructor
@@ -635,8 +692,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)
@@ -660,7 +717,7 @@ local function Constructor()
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
local scrollbar = CreateFrame("Slider", format("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
local scrollbar = CreateFrame("Slider", strfmt("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
scrollbar:SetScript("OnValueChanged", nil)
scrollbar:SetPoint("TOPRIGHT", -10, -26)
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
@@ -676,7 +733,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)
@@ -21,31 +21,27 @@ local CreateFrame, UIParent = CreateFrame, UIParent
]]
do
local Type = "Window"
local Version = 6
local Version = 4
local function frameOnShow(this)
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 +52,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
@@ -184,7 +180,6 @@ do
frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame:SetScript("OnMouseDown", frameOnMouseDown)
frame:SetScript("OnShow",frameOnShow)
frame:SetScript("OnHide",frameOnClose)
frame:SetMinResize(240,240)
frame:SetToplevel(true)
@@ -2,24 +2,27 @@
Button Widget
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button", 24
local Type, Version = "Button", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
-- Lua APIs
local pairs, unpack = pairs, unpack
local pairs = pairs
-- WoW APIs
local _G = _G
local _G = AceCore._G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
-- arg1 is the button for OnClick event
local function Button_OnClick()
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
this.obj:Fire("OnClick", unpack(arg))
this.obj:Fire("OnClick", 1, arg1)
end
local function Control_OnEnter()
@@ -74,7 +77,7 @@ Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
frame:Hide()
frame:EnableMouse(true)
@@ -1,12 +1,12 @@
--[[-----------------------------------------------------------------------------
Checkbox Widget
-------------------------------------------------------------------------------]]
local Type, Version = "CheckBox", 23
local Type, Version = "CheckBox", 22
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, unpack = select, pairs, unpack
local pairs = pairs
-- WoW APIs
local PlaySound = PlaySound
@@ -24,10 +24,10 @@ local function AlignImage(self)
self.text:ClearAllPoints()
if not img then
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
self.text:SetPoint("RIGHT", 0, 0)
self.text:SetPoint("RIGHT",0,0)
else
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
self.text:SetPoint("RIGHT", 0, 0)
self.text:SetPoint("RIGHT",0,0)
end
end
@@ -55,6 +55,7 @@ local function CheckBox_OnMouseDown()
end
local function CheckBox_OnMouseUp()
local self = this.obj
if not self.disabled then
self:ToggleChecked()
@@ -65,7 +66,7 @@ local function CheckBox_OnMouseUp()
PlaySound("igMainMenuOptionCheckBoxOff")
end
self:Fire("OnValueChanged", self.checked)
self:Fire("OnValueChanged", 1, self.checked)
AlignImage(self)
end
end
@@ -172,6 +173,7 @@ local methods = {
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
highlight:SetTexCoord(0, 1, 0, 1)
end
checkbg:SetHeight(size)
checkbg:SetWidth(size)
end,
@@ -220,15 +222,14 @@ local methods = {
self:SetHeight(24)
end
end,
["SetImage"] = function(self, path, ...)
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
local image = self.image
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", arg)
if n == 4 or n == 8 then
image:SetTexCoord(unpack(arg))
if a4 or a8 then
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -253,7 +254,7 @@ local function Constructor()
local checkbg = frame:CreateTexture(nil, "ARTWORK")
checkbg:SetWidth(24)
checkbg:SetHeight(24)
checkbg:SetPoint("TOPLEFT", 0, 0)
checkbg:SetPoint("TOPLEFT",0,0)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
local check = frame:CreateTexture(nil, "OVERLAY")
@@ -261,10 +262,10 @@ local function Constructor()
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetJustifyH("LEFT", 0, 0)
text:SetJustifyH("LEFT")
text:SetHeight(18)
text:SetPoint("LEFT", checkbg, "RIGHT")
text:SetPoint("RIGHT", 0, 0)
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", 1
local Type, Version = "ColorPicker", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
@@ -25,12 +25,12 @@ local function ColorCallback(self, r, g, b, a, isAlpha)
self:SetColor(r, g, b, a)
if ColorPickerFrame:IsVisible() then
--colorpicker is still open
self:Fire("OnValueChanged", r, g, b, a)
self:Fire("OnValueChanged", 4, r, g, b, a)
else
--colorpicker is closed, color callback is first, ignore it,
--alpha callback is the final call after it closes so confirm now
if isAlpha then
self:Fire("OnValueConfirmed", r, g, b, a)
self:Fire("OnValueConfirmed", 4, r, g, b, a)
end
end
end
@@ -38,20 +38,19 @@ 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:SetClampedToScreen(true)
ColorPickerFrame.func = function()
@@ -67,20 +66,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 +100,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 +140,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 +164,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")
@@ -1,39 +1,23 @@
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1153 2016-11-20 09:57:15Z nevcairiel $ ]]--
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1137 2016-05-15 10:57:36Z nevcairiel $ ]]--
local AceGUI = LibStub("AceGUI-3.0")
local IsLegion = false
-- Lua APIs
local select, assert = select, assert
local assert = assert
local tgetn = table.getn
-- WoW APIs
local PlaySound = PlaySound
local CreateFrame = CreateFrame
local function fixlevels(parent,...)
local i = 1
local child = select(i, arg)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, arg)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, arg)
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, arg)
end
end
local fixlevels = AceGUI.fixlevels
local fixstrata = AceGUI.fixstrata
-- ItemBase is the base "class" for all dropdown items.
-- Each item has to use ItemBase.Create(widgetType) to
-- create an initial 'self' value.
-- create an initial 'self' value.
-- ItemBase will add common functions and ui event handlers.
-- Be sure to keep basic usage when you override functions.
@@ -45,25 +29,25 @@ local ItemBase = {
counter = 0,
}
function ItemBase.Frame_OnEnter(this)
function ItemBase.Frame_OnEnter()
local self = this.obj
if self.useHighlight then
self.highlight:Show()
end
self:Fire("OnEnter")
if self.specialOnEnter then
self.specialOnEnter(self)
end
end
function ItemBase.Frame_OnLeave(this)
function ItemBase.Frame_OnLeave()
local self = this.obj
self.highlight:Hide()
self:Fire("OnLeave")
if self.specialOnLeave then
self.specialOnLeave(self)
end
@@ -89,11 +73,12 @@ end
-- Do not call this method directly
function ItemBase.SetPullout(self, pullout)
self.pullout = pullout
self.frame:SetParent(nil)
self.frame:SetParent(pullout.itemFrame)
self.parent = pullout.itemFrame
fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
local itemFrame = pullout.itemFrame
self.frame:SetParent(itemFrame)
self.parent = itemFrame
fixlevels(itemFrame)
end
-- exported
@@ -107,8 +92,8 @@ function ItemBase.GetText(self)
end
-- exported
function ItemBase.SetPoint(self, ...)
self.frame:SetPoint(unpack(arg))
function ItemBase.SetPoint(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
self.frame:SetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
end
-- exported
@@ -155,12 +140,12 @@ function ItemBase.Create(type)
self.frame = frame
frame.obj = self
self.type = type
self.useHighlight = true
frame:SetHeight(17)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
text:SetTextColor(1,1,1)
text:SetJustifyH("LEFT")
@@ -178,7 +163,7 @@ function ItemBase.Create(type)
highlight:Hide()
self.highlight = highlight
local check = frame:CreateTexture("OVERLAY")
local check = frame:CreateTexture("OVERLAY")
check:SetWidth(16)
check:SetHeight(16)
check:SetPoint("LEFT",frame,"LEFT",3,-1)
@@ -192,26 +177,26 @@ function ItemBase.Create(type)
sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
sub:Hide()
self.sub = sub
self.sub = sub
frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
self.OnAcquire = ItemBase.OnAcquire
self.OnRelease = ItemBase.OnRelease
self.SetPullout = ItemBase.SetPullout
self.GetText = ItemBase.GetText
self.SetText = ItemBase.SetText
self.SetDisabled = ItemBase.SetDisabled
self.SetPoint = ItemBase.SetPoint
self.Show = ItemBase.Show
self.Hide = ItemBase.Hide
self.SetOnLeave = ItemBase.SetOnLeave
self.SetOnEnter = ItemBase.SetOnEnter
return self
end
@@ -223,20 +208,20 @@ end
--[[
Template for items:
-- Item:
--
do
local widgetType = "Dropdown-Item-"
local widgetVersion = 1
local function Constructor()
local self = ItemBase.Create(widgetType)
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
--]]
@@ -247,25 +232,25 @@ end
do
local widgetType = "Dropdown-Item-Header"
local widgetVersion = 1
local function OnEnter(this)
local self = this.obj
self:Fire("OnEnter")
if self.specialOnEnter then
self.specialOnEnter(self)
end
end
local function OnLeave(this)
local function OnLeave()
local self = this.obj
self:Fire("OnLeave")
if self.specialOnLeave then
self.specialOnLeave(self)
end
end
-- exported, override
local function SetDisabled(self, disabled)
ItemBase.SetDisabled(self, disabled)
@@ -273,21 +258,21 @@ do
self.text:SetTextColor(1, 1, 0)
end
end
local function Constructor()
local self = ItemBase.Create(widgetType)
self.SetDisabled = SetDisabled
self.frame:SetScript("OnEnter", OnEnter)
self.frame:SetScript("OnLeave", OnLeave)
self.text:SetTextColor(1, 1, 0)
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
@@ -296,7 +281,7 @@ end
do
local widgetType = "Dropdown-Item-Execute"
local widgetVersion = 1
local function Frame_OnClick(this, button)
local self = this.obj
if self.disabled then return end
@@ -305,16 +290,16 @@ do
self.pullout:Close()
end
end
local function Constructor()
local self = ItemBase.Create(widgetType)
self.frame:SetScript("OnClick", Frame_OnClick)
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
@@ -323,8 +308,8 @@ end
-- Does not close the pullout on click.
do
local widgetType = "Dropdown-Item-Toggle"
local widgetVersion = 4
local widgetVersion = 3
local function UpdateToggle(self)
if self.value then
self.check:Show()
@@ -332,13 +317,13 @@ do
self.check:Hide()
end
end
local function OnRelease(self)
ItemBase.OnRelease(self)
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
@@ -348,33 +333,33 @@ do
PlaySound("igMainMenuOptionCheckBoxOff")
end
UpdateToggle(self)
self:Fire("OnValueChanged", self.value)
self:Fire("OnValueChanged", 1, self.value)
end
-- exported
local function SetValue(self, value)
self.value = value
UpdateToggle(self)
end
-- exported
local function GetValue(self)
return self.value
end
local function Constructor()
local self = ItemBase.Create(widgetType)
self.frame:SetScript("OnClick", Frame_OnClick)
self.SetValue = SetValue
self.GetValue = GetValue
self.OnRelease = OnRelease
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
@@ -384,55 +369,55 @@ end
do
local widgetType = "Dropdown-Item-Menu"
local widgetVersion = 2
local function OnEnter(this)
local function OnEnter()
local self = this.obj
self:Fire("OnEnter")
if self.specialOnEnter then
self.specialOnEnter(self)
end
self.highlight:Show()
if not self.disabled and self.submenu then
self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.submenu then
self.submenu:Close()
end
end
-- exported
local function SetMenu(self, menu)
assert(menu.type == "Dropdown-Pullout")
self.submenu = menu
end
-- exported
local function CloseMenu(self)
self.submenu:Close()
end
local function Constructor()
local self = ItemBase.Create(widgetType)
self.sub:Show()
self.frame:SetScript("OnEnter", OnEnter)
self.frame:SetScript("OnHide", OnHide)
self.SetMenu = SetMenu
self.CloseMenu = CloseMenu
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
@@ -441,31 +426,32 @@ end
do
local widgetType = "Dropdown-Item-Separator"
local widgetVersion = 2
-- exported, override
local function SetDisabled(self, disabled)
ItemBase.SetDisabled(self, disabled)
self.useHighlight = false
end
local function Constructor()
local self = ItemBase.Create(widgetType)
self.SetDisabled = SetDisabled
local line = self.frame:CreateTexture(nil, "OVERLAY")
line:SetHeight(1)
line:SetTexture(.5, .5, .5)
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
self.text:Hide()
self.useHighlight = false
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
end
@@ -1,48 +1,31 @@
--[[ $Id: AceGUIWidget-DropDown.lua 1116 2014-10-12 08:15:46Z nevcairiel $ ]]--
local AceGUI = LibStub("AceGUI-3.0")
local AceCore = LibStub("AceCore-3.0")
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local select, pairs, ipairs, type = select, pairs, ipairs, type
local tgetn, tsort = table.getn, table.sort
local pairs, ipairs, type = pairs, ipairs, type
local tsort, tinsert, tgetn, tsetn = table.sort, table.insert, table.getn, table.setn
-- WoW APIs
local PlaySound = PlaySound
local UIParent, CreateFrame = UIParent, CreateFrame
local _G = _G
local _G = AceCore._G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
local function fixlevels(parent,...)
local i = 1
local child = select(i, arg)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, arg)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, arg)
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, arg)
end
end
local fixlevels = AceGUI.fixlevels
local fixstrata = AceGUI.fixstrata
do
local widgetType = "Dropdown-Pullout"
local widgetVersion = 3
--[[ Static data ]]--
local backdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
@@ -60,9 +43,9 @@ do
local defaultWidth = 200
local defaultMaxHeight = 600
--[[ UI Event Handlers ]]--
-- HACK: This should be no part of the pullout, but there
-- is no other 'clean' way to response to any item-OnEnter
-- Used to close Submenus when an other item is entered
@@ -74,22 +57,22 @@ do
end
end
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
--[[ Exported methods ]]--
-- exported
local function SetScroll(self, value)
local status = self.scrollStatus
@@ -106,9 +89,9 @@ do
child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", self.slider:IsShown() and -12 or 0, offset)
status.offset = offset
status.scrollvalue = value
status.scrollvalue = value
end
-- exported
local function MoveScroll(self, value)
local status = self.scrollStatus
@@ -127,7 +110,7 @@ do
self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
end
end
-- exported
local function FixScroll(self)
local status = self.scrollStatus
@@ -140,7 +123,7 @@ do
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset)
self.slider:SetValue(0)
else
self.slider:Show()
self.slider:Show()
local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end
self.slider:SetValue(value)
@@ -153,44 +136,44 @@ do
end
end
end
-- exported, AceGUI callback
local function OnAcquire(self)
self.frame:SetParent(UIParent)
--self.itemFrame:SetToplevel(true)
end
-- exported, AceGUI callback
local function OnRelease(self)
self:Clear()
self.frame:ClearAllPoints()
self.frame:Hide()
end
-- exported
local function AddItem(self, item)
self.items[tgetn(self.items) + 1] = item
tinsert(self.items, item)
local h = tgetn(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
item.frame:SetPoint("LEFT", self.itemFrame, "LEFT")
item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT")
item:SetPullout(self)
item:SetOnEnter(OnEnter)
end
-- exported
local function Open(self, point, relFrame, relPoint, x, y)
local function Open(self, point, relFrame, relPoint, x, y)
local items = self.items
local frame = self.frame
local itemFrame = self.itemFrame
frame:SetPoint(point, relFrame, relPoint, x, y)
local height = 8
for i, item in pairs(items) do
if i == 1 then
@@ -198,23 +181,23 @@ do
else
item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1)
end
item:Show()
height = height + 16
end
itemFrame:SetHeight(height)
fixstrata("TOOLTIP", frame, frame:GetChildren())
fixstrata("TOOLTIP", frame)
frame:Show()
self:Fire("OnOpen")
end
end
-- exported
local function Close(self)
self.frame:Hide()
self:Fire("OnClose")
end
end
-- exported
local function Clear(self)
local items = self.items
@@ -222,18 +205,19 @@ do
AceGUI:Release(item)
items[i] = nil
end
end
tsetn(items,0)
end
-- exported
local function IterateItems(self)
return ipairs(self.items)
end
-- exported
local function SetHideOnLeave(self, val)
self.hideOnLeave = val
end
-- exported
local function SetMaxHeight(self, height)
self.maxHeight = height or defaultMaxHeight
@@ -243,19 +227,19 @@ do
self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem
end
end
-- exported
local function GetRightBorderWidth(self)
return 6 + (self.slider:IsShown() and 12 or 0)
end
-- exported
local function GetLeftBorderWidth(self)
return 6
end
--[[ Constructor ]]--
local function Constructor()
local count = AceGUI:GetNextWidgetNum(widgetType)
local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent)
@@ -264,7 +248,7 @@ do
self.type = widgetType
self.frame = frame
frame.obj = self
self.OnAcquire = OnAcquire
self.OnRelease = OnRelease
@@ -278,37 +262,37 @@ do
self.SetScroll = SetScroll
self.MoveScroll = MoveScroll
self.FixScroll = FixScroll
self.SetMaxHeight = SetMaxHeight
self.GetRightBorderWidth = GetRightBorderWidth
self.GetLeftBorderWidth = GetLeftBorderWidth
self.items = {}
self.scrollStatus = {
scrollvalue = 0,
}
self.maxHeight = defaultMaxHeight
frame:SetBackdrop(backdrop)
frame:SetBackdropColor(0, 0, 0)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame:SetClampedToScreen(true)
frame:SetWidth(defaultWidth)
frame:SetHeight(self.maxHeight)
frame:SetHeight(self.maxHeight)
--frame:SetToplevel(true)
-- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame
local scrollFrame = CreateFrame("ScrollFrame", nil, frame)
local itemFrame = CreateFrame("Frame", nil, scrollFrame)
self.scrollFrame = scrollFrame
self.itemFrame = itemFrame
scrollFrame.obj = self
itemFrame.obj = self
local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame)
slider:SetOrientation("VERTICAL")
slider:SetHitRectInsets(0, 0, -10, 0)
@@ -318,7 +302,7 @@ do
slider:SetFrameStrata("FULLSCREEN_DIALOG")
self.slider = slider
slider.obj = self
scrollFrame:SetScrollChild(itemFrame)
scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12)
scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12)
@@ -327,59 +311,59 @@ do
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:SetToplevel(true)
scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG")
itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0)
itemFrame:SetHeight(400)
itemFrame:SetToplevel(true)
itemFrame:SetFrameStrata("FULLSCREEN_DIALOG")
slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0)
slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0)
slider:SetScript("OnValueChanged", OnScrollValueChanged)
slider:SetMinMaxValues(0, 1000)
slider:SetValueStep(1)
slider:SetValue(0)
scrollFrame:Show()
itemFrame:Show()
slider:Hide()
self:FixScroll()
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
do
local widgetType = "Dropdown"
local widgetVersion = 31
local widgetVersion = 30
--[[ Static data ]]--
--[[ 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
@@ -393,17 +377,17 @@ do
AceGUI:SetFocus(self)
end
end
local function OnPulloutOpen(this)
local self = this.userdata.obj
local value = self.value
if not self.multiselect then
for i, item in this:IterateItems() do
item:SetValue(item.userdata.value == value)
end
end
self.open = true
self:Fire("OnOpened")
end
@@ -413,7 +397,7 @@ do
self.open = nil
self:Fire("OnClosed")
end
local function ShowMultiText(self)
local text
for i, widget in self.pullout:IterateItems() do
@@ -429,28 +413,31 @@ do
end
self:SetText(text)
end
local function OnItemValueChanged(this, event, checked)
local function OnItemValueChanged(this, event, _, checked)
local self = this.userdata.obj
if self.multiselect then
self:Fire("OnValueChanged", this.userdata.value, checked)
self:Fire("OnValueChanged", 2, this.userdata.value, checked)
ShowMultiText(self)
else
if checked then
self:SetValue(this.userdata.value)
self:Fire("OnValueChanged", this.userdata.value)
self:Fire("OnValueChanged", 1, this.userdata.value)
this:SetValue(false)
else
self:SetValue(nil)
self:Fire("OnValueChanged", 1, nil)
this:SetValue(true)
end
if self.open then
if self.open then
self.pullout:Close()
end
end
end
--[[ Exported methods ]]--
-- exported, AceGUI callback
local function OnAcquire(self)
local pullout = AceGUI:Create("Dropdown-Pullout")
@@ -459,14 +446,15 @@ do
pullout:SetCallback("OnClose", OnPulloutClose)
pullout:SetCallback("OnOpen", OnPulloutOpen)
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
local frame = self.pullout.frame
fixlevels(frame)
self:SetHeight(44)
self:SetWidth(200)
self:SetLabel()
self:SetPulloutWidth(nil)
end
-- exported, AceGUI callback
local function OnRelease(self)
if self.open then
@@ -474,20 +462,20 @@ do
end
AceGUI:Release(self.pullout)
self.pullout = nil
self:SetText("")
self:SetDisabled(false)
self:SetMultiselect(false)
self.value = nil
self.list = nil
self.open = nil
self.hasClose = nil
self.frame:ClearAllPoints()
self.frame:Hide()
end
-- exported
local function SetDisabled(self, disabled)
self.disabled = disabled
@@ -503,19 +491,19 @@ do
self.text:SetTextColor(1,1,1)
end
end
-- exported
local function ClearFocus(self)
if self.open then
self.pullout:Close()
end
end
-- exported
local function SetText(self, text)
self.text:SetText(text or "")
end
-- exported
local function SetLabel(self, text)
if text and text ~= "" then
@@ -532,7 +520,7 @@ do
self.alignoffset = 12
end
end
-- exported
local function SetValue(self, value)
if self.list then
@@ -540,12 +528,12 @@ do
end
self.value = value
end
-- exported
local function GetValue(self)
return self.value
end
-- exported
local function SetItemValue(self, item, value)
if not self.multiselect then return end
@@ -558,7 +546,7 @@ do
end
ShowMultiText(self)
end
-- exported
local function SetItemDisabled(self, item, disabled)
for i, widget in self.pullout:IterateItems() do
@@ -567,11 +555,11 @@ do
end
end
end
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(format("The given item type, %q, does not exist within AceGUI-3.0", tostring(itemType)), 2) end
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
local item = AceGUI:Create(itemType)
item:SetText(text)
@@ -580,7 +568,7 @@ do
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
local function AddCloseButton(self)
if not self.hasClose then
local close = AceGUI:Create("Dropdown-Item-Execute")
@@ -589,7 +577,7 @@ do
self.hasClose = true
end
end
-- exported
local sortlist = {}
local function SetList(self, list, order, itemType)
@@ -597,17 +585,18 @@ do
self.pullout:Clear()
self.hasClose = nil
if not list then return end
if type(order) ~= "table" then
for v in pairs(list) do
sortlist[tgetn(sortlist) + 1] = v
tinsert(sortlist, v)
end
tsort(sortlist)
for i, key in ipairs(sortlist) do
AddListItem(self, key, list[key], itemType)
sortlist[i] = nil
end
tsetn(sortlist,0)
else
for i, key in ipairs(order) do
AddListItem(self, key, list[key], itemType)
@@ -618,7 +607,7 @@ do
AddCloseButton(self)
end
end
-- exported
local function AddItem(self, value, text, itemType)
if self.list then
@@ -626,7 +615,7 @@ do
AddListItem(self, value, text, itemType)
end
end
-- exported
local function SetMultiselect(self, multi)
self.multiselect = multi
@@ -635,23 +624,23 @@ do
AddCloseButton(self)
end
end
-- exported
local function GetMultiselect(self)
return self.multiselect
end
local function SetPulloutWidth(self, width)
self.pulloutWidth = width
end
--[[ Constructor ]]--
local function Constructor()
local count = AceGUI:GetNextWidgetNum(widgetType)
local frame = CreateFrame("Frame", nil, UIParent)
local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate")
local self = {}
self.type = widgetType
self.frame = frame
@@ -659,10 +648,10 @@ do
self.count = count
frame.obj = self
dropdown.obj = self
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.ClearFocus = ClearFocus
self.SetText = SetText
@@ -677,9 +666,9 @@ do
self.SetItemValue = SetItemValue
self.SetItemDisabled = SetItemDisabled
self.SetPulloutWidth = SetPulloutWidth
self.alignoffset = 26
frame:SetScript("OnHide",Dropdown_OnHide)
dropdown:ClearAllPoints()
@@ -690,10 +679,10 @@ do
local left = _G[dropdown:GetName() .. "Left"]
local middle = _G[dropdown:GetName() .. "Middle"]
local right = _G[dropdown:GetName() .. "Right"]
middle:ClearAllPoints()
right:ClearAllPoints()
middle:SetPoint("LEFT", left, "RIGHT", 0, 0)
middle:SetPoint("RIGHT", right, "LEFT", 0, 0)
right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17)
@@ -704,7 +693,7 @@ do
button:SetScript("OnEnter",Control_OnEnter)
button:SetScript("OnLeave",Control_OnLeave)
button:SetScript("OnClick",Dropdown_TogglePullout)
local button_cover = CreateFrame("BUTTON",nil,self.frame)
self.button_cover = button_cover
button_cover.obj = self
@@ -713,14 +702,14 @@ do
button_cover:SetScript("OnEnter",Control_OnEnter)
button_cover:SetScript("OnLeave",Control_OnLeave)
button_cover:SetScript("OnClick",Dropdown_TogglePullout)
local text = _G[dropdown:GetName() .. "Text"]
self.text = text
text.obj = self
text:ClearAllPoints()
text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2)
text:SetPoint("LEFT", left, "LEFT", 25, 2)
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
@@ -732,6 +721,6 @@ do
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
end
@@ -1,18 +1,23 @@
--[[-----------------------------------------------------------------------------
EditBox Widget
-------------------------------------------------------------------------------]]
local Type, Version = "EditBox", 27
local Type, Version = "EditBox", 26
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
local hooksecurefunc = AceCore.hooksecurefunc
local _G = AceCore._G
local GetCursorInfo = _G.GetCursorInfo
-- Lua APIs
local tostring, pairs, unpack = tostring, pairs, unpack
local tostring, pairs = tostring, pairs
-- WoW APIs
local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
local strlen = string.len
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
@@ -116,7 +121,7 @@ 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
@@ -138,73 +143,82 @@ 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 cancel = self:Fire("OnEnterPressed", value)
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
local cancel = self:Fire("OnEnterPressed", 1, value)
if not cancel then
PlaySound("igMainMenuOptionCheckBoxOn")
HideButton(self)
end
end
local function EditBox_OnReceiveDrag(frame)
local self = frame.obj
local function EditBox_OnReceiveDrag()
if not GetCursorInfo then return end
local self = this.obj
local type, id, info = GetCursorInfo()
if type == "item" then
self:SetText(info)
self:Fire("OnEnterPressed", info)
self:Fire("OnEnterPressed", 1, info)
ClearCursor()
elseif type == "spell" then
local name = GetSpellInfo(id, info)
self:SetText(name)
self:Fire("OnEnterPressed", name)
local spell, rank = GetSpellName(id, info)
if rank ~= "" then spell = spell.."("..rank..")" end
self:SetText(spell)
self:Fire("OnEnterPressed", 1, spell)
ClearCursor()
elseif type == "macro" then
local name = GetMacroInfo(id)
self:SetText(name)
self:Fire("OnEnterPressed", name)
self:Fire("OnEnterPressed", 1, name)
ClearCursor()
end
HideButton(self)
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:Fire("OnTextChanged", 1, value)
self.lasttext = value
ShowButton(self)
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 -- Ace3v: this is kinda hack here
EditBox_OnEnterPressed()
end
--[[-----------------------------------------------------------------------------
@@ -242,7 +256,7 @@ local methods = {
["SetText"] = function(self, text)
self.lasttext = text or ""
self.editbox:SetText(text or "")
self.editbox:SetCursorPosition(0)
self.editbox:HighlightText(0)
HideButton(self)
end,
@@ -313,10 +327,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,9 +43,9 @@ local function Constructor()
frame:Hide()
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
label:SetPoint("TOP", 0, 0)
label:SetPoint("BOTTOM", 0, 0)
label:SetJustifyH("CENTER", 0, 0)
label:SetPoint("TOP",0,0)
label:SetPoint("BOTTOM",0,0)
label:SetJustifyH("CENTER")
local left = frame:CreateTexture(nil, "BACKGROUND")
left:SetHeight(8)
@@ -6,7 +6,7 @@ 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, unpack = select, pairs, print, unpack
local pairs, print = pairs, print
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -14,16 +14,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", 1, arg1)
AceGUI:ClearFocus()
end
@@ -53,14 +53,13 @@ local methods = {
end
end,
["SetImage"] = function(self, path, ...)
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
local image = self.image
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", arg)
if n == 4 or n == 8 then
image:SetTexCoord(unpack(arg))
if a4 or a8 then
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -132,7 +131,7 @@ local function Constructor()
widget[method] = func
end
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(unpack(arg)) end
widget.SetText = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) end
return AceGUI:RegisterAsWidget(widget)
end
@@ -1,12 +1,12 @@
--[[-----------------------------------------------------------------------------
InteractiveLabel Widget
-------------------------------------------------------------------------------]]
local Type, Version = "InteractiveLabel", 21
local Type, Version = "InteractiveLabel", 20
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, unpack = select, pairs, unpack
local pairs = pairs
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -18,16 +18,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", 1, arg1)
AceGUI:ClearFocus()
end
@@ -44,14 +44,13 @@ local methods = {
-- ["OnRelease"] = nil,
["SetHighlight"] = function(self, ...)
self.highlight:SetTexture(unpack(arg))
["SetHighlight"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
self.highlight:SetTexture(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
end,
["SetHighlightTexCoord"] = function(self, ...)
local c = select("#", arg)
if c == 4 or c == 8 then
self.highlight:SetTexCoord(unpack(arg))
["SetHighlightTexCoord"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8)
if a4 or a8 then
self.highlight:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
else
self.highlight:SetTexCoord(0, 1, 0, 1)
end
@@ -21,44 +21,32 @@ 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
if self.waitingForKey then
frame:EnableKeyboard(false)
frame:EnableMouseWheel(false)
self.msgframe:Hide()
frame:UnlockHighlight()
self.waitingForKey = nil
else
frame:EnableKeyboard(true)
frame:EnableMouseWheel(true)
self.msgframe:Show()
frame:LockHighlight()
self.waitingForKey = true
end
end
AceGUI:ClearFocus()
local function Keybinding_OnHide()
local self = this.obj
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
this:UnlockHighlight()
self.waitingForKey = nil
end
local ignoreKeys = {
["BUTTON1"] = true, ["BUTTON2"] = true,
["UNKNOWN"] = true,
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
["SHIFT"] = true, ["CTRL"] = true, ["ALT"] = 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,40 +62,58 @@ 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
self:SetKey(keyPressed)
self:Fire("OnKeyChanged", keyPressed)
self:Fire("OnKeyChanged", 1, keyPressed)
end
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"
end
Keybinding_OnKeyDown(frame, button)
local function Keybinding_OnMouseDown()
getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
end
local function Keybinding_OnMouseWheel(frame, direction)
local button
if direction >= 0 then
button = "MOUSEWHEELUP"
else
button = "MOUSEWHEELDOWN"
local function Keybinding_OnMouseUp()
getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
local self = this.obj
if MouseIsOver(this) and not self.disabled then
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()
if arg1 >= 0 then
arg1 = "MOUSEWHEELUP"
else
arg1 = "MOUSEWHEELDOWN"
end
Keybinding_OnKeyDown()
end
--[[-----------------------------------------------------------------------------
@@ -141,10 +147,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,28 +185,31 @@ 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()
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame", nil, UIParent)
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2")
button:EnableMouse(true)
button:EnableMouseWheel(false)
button:RegisterForClicks("AnyDown")
button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave)
button:SetScript("OnClick", Keybinding_OnClick)
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
button:RegisterForClicks("AnyDown","AnyUp")
-- Ace3v: RegisterForClicks means OnClick will not be triggered, so use OnKeyDown and OnKeyUp
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
button:SetPoint("BOTTOMLEFT")
button:SetPoint("BOTTOMRIGHT")
button:SetScript("OnHide", Keybinding_OnHide)
button:SetPoint("BOTTOMLEFT",0,0)
button:SetPoint("BOTTOMRIGHT",0,0)
button:SetHeight(24)
button:EnableKeyboard(false)
@@ -209,8 +218,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 +245,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
@@ -2,12 +2,12 @@
Label Widget
Displays text and optionally an icon.
-------------------------------------------------------------------------------]]
local Type, Version = "Label", 24
local Type, Version = "Label", 23
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, unpack = math.max, select, pairs, unpack
local max, pairs = math.max, pairs
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -35,14 +35,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 +53,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
@@ -78,8 +78,6 @@ local methods = {
self:SetImageSize(16, 16)
self:SetColor()
self:SetFontObject()
self:SetJustifyH("LEFT")
self:SetJustifyV("TOP")
-- reset the flag
self.resizing = nil
@@ -105,15 +103,14 @@ local methods = {
self.label:SetVertexColor(r, g, b)
end,
["SetImage"] = function(self, path, ...)
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
local image = self.image
image:SetTexture(path)
if image:GetTexture() then
self.imageshown = true
local n = select("#", arg)
if n == 4 or n == 8 then
image:SetTexCoord(unpack(arg))
if a4 or a8 then
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -136,14 +133,6 @@ local methods = {
self.image:SetHeight(height)
UpdateImageAnchor(self)
end,
["SetJustifyH"] = function(self, justifyH)
self.label:SetJustifyH(justifyH)
end,
["SetJustifyV"] = function(self, justifyV)
self.label:SetJustifyV(justifyV)
end,
}
--[[-----------------------------------------------------------------------------
@@ -154,6 +143,9 @@ local function Constructor()
frame:Hide()
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
label:SetJustifyH("LEFT")
label:SetJustifyV("TOP")
local image = frame:CreateTexture(nil, "BACKGROUND")
-- create widget
@@ -2,13 +2,17 @@ local Type, Version = "MultiLineEditBox", 28
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local AceCore = LibStub("AceCore-3.0")
local hooksecurefunc = AceCore.hooksecurefunc
-- Lua APIs
local pairs, unpack = pairs, unpack
local strfmt = string.format
local pairs = pairs
-- WoW APIs
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
local _G = AceCore._G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
@@ -17,7 +21,6 @@ local _G = _G
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
if not AceGUIMultiLineEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
@@ -112,15 +115,14 @@ end
function _G.AceGUIMultiLineEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G[format("MultiLineEditBox%uEdit", i)]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
local editbox = _G[strfmt("MultiLineEditBox%uEdit",i)]
if editbox and editbox:IsVisible() and editbox.hasfocus then
editbox:Insert(text)
return true
end
end
end
local function Layout(self)
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
@@ -142,104 +144,122 @@ 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
if not self:Fire("OnEnterPressed", 1, 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())
local n = self:GetNumLetters()
self:HighlightText(n,n)
end
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local function OnReceiveDrag() -- EditBox / ScrollFrame
if not GetCursorInfo then return end
local type, id, info = GetCursorInfo()
if type == "spell" then
info = GetSpellInfo(id, info)
local spell, rank = GetSpellName(id, info)
if rank ~= "" then spell = spell.."("..rank..")" end
info = spell
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())
local n = editBox:GetNumLetters()
editBox:HighlightText(n,n)
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.obj.editBox:SetWidth(arg1)
end
local function OnTextChanged(self, userInput) -- EditBox
if userInput then
self = self.obj
self:Fire("OnTextChanged", self.editBox:GetText())
local function OnTextChanged() -- EditBox
local self = this.obj
local value = this:GetText()
if tostring(value) ~= tostring(self.lasttext) then
self:Fire("OnTextChanged", 1, value)
self.lasttext = value
self.button:Enable()
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)
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 self = this.obj
local editBox = self.editBox
editBox:SetHitRectInsets(0, 0, arg1, editBox:GetHeight() - arg1 - this:GetHeight())
self.scrollFrame:SetScrollChild(self.editBox)
self.editBox:SetPoint("TOPLEFT",0,arg1)
self.editBox:SetPoint("TOPRIGHT",0,arg1)
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() -- EditBox
AceGUI:ClearFocus()
end
--[[-----------------------------------------------------------------------------
@@ -300,7 +320,10 @@ local methods = {
end,
["SetText"] = function(self, text)
self.editBox:SetText(text)
self.lasttext = text or ""
self.editBox:SetText(text or "")
self.editBox:HighlightText(0)
self.button:Disable()
end,
["GetText"] = function(self)
@@ -320,7 +343,7 @@ local methods = {
end
Layout(self)
end,
["ClearFocus"] = function(self)
self.editBox:ClearFocus()
self.frame:SetScript("OnShow", nil)
@@ -336,16 +359,6 @@ local methods = {
["HighlightText"] = function(self, from, to)
self.editBox:HighlightText(from, to)
end,
["GetCursorPosition"] = function(self)
return self.editBox:GetCursorPosition()
end,
["SetCursorPosition"] = function(self, ...)
return self.editBox:SetCursorPosition(unpack(arg))
end,
}
--[[-----------------------------------------------------------------------------
@@ -360,7 +373,7 @@ local backdrop = {
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
local widgetNum = AceGUI:GetNextWidgetNum(Type)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
@@ -370,14 +383,14 @@ local function Constructor()
label:SetText(ACCEPT)
label:SetHeight(10)
local button = CreateFrame("Button", format("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
local button = CreateFrame("Button", strfmt("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
button:SetPoint("BOTTOMLEFT", 0, 4)
button:SetHeight(22)
button:SetWidth(label:GetStringWidth() + 24)
button:SetText(ACCEPT)
button:SetScript("OnClick", OnClick)
button:Disable()
local text = button:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5)
@@ -389,7 +402,7 @@ local function Constructor()
scrollBG:SetBackdropColor(0, 0, 0)
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scrollFrame = CreateFrame("ScrollFrame", format("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollFrame = CreateFrame("ScrollFrame", strfmt("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
scrollBar:ClearAllPoints()
@@ -407,28 +420,37 @@ local function Constructor()
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
local old = scrollFrame:GetScript("OnVerticalScroll");
if old then
scrollFrame:SetScript("OnVerticalScroll", function()
old()
OnVerticalScroll()
end)
else
scrollFrame:SetScript("OnVerticalScroll", OnVerticalScroll)
end
local editBox = CreateFrame("EditBox", format("%s%dEdit", Type, widgetNum), scrollFrame)
editBox:SetAllPoints()
local editBox = CreateFrame("EditBox", strfmt("%s%dEdit", Type, widgetNum), scrollFrame)
editBox:SetFontObject(ChatFontNormal)
editBox:SetMultiLine(true)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetCountInvisibleLetters(false)
--editBox:SetCountInvisibleLetters(false)
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)
editBox:SetScript("OnTextChanged", OnTextChanged)
editBox:SetScript("OnTextSet", OnTextSet)
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
-- Ace3v: the orders are important here
scrollFrame:SetScrollChild(editBox)
editBox:SetPoint("TOPLEFT",0,0)
editBox:SetPoint("TOPRIGHT",0,0)
local widget = {
button = button,
@@ -2,13 +2,12 @@
Slider Widget
Graphical Slider, like, for Range values.
-------------------------------------------------------------------------------]]
local Type, Version = "Slider", 22
local Type, Version = "Slider", 21
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 min, max, floor = math.min, math.max, math.floor
local gsub = string.gsub
local tonumber, pairs = tonumber, pairs
-- WoW APIs
@@ -25,7 +24,7 @@ Support functions
local function UpdateText(self)
local value = self.value or 0
if self.ispercent then
self.editbox:SetText(format("%s%%", floor(value * 1000 + 0.5) / 10))
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
else
self.editbox:SetText(floor(value * 100 + 0.5) / 100)
end
@@ -34,8 +33,8 @@ end
local function UpdateLabels(self)
local min, max = (self.min or 0), (self.max or 100)
if self.ispercent then
self.lowtext:SetText(format("%s%%", (min * 100)))
self.hightext:SetText(format("%s%%", (max * 100)))
self.lowtext:SetFormattedText("%s%%", (min * 100))
self.hightext:SetFormattedText("%s%%", (max * 100))
else
self.lowtext:SetText(min)
self.hightext:SetText(max)
@@ -68,7 +67,7 @@ local function Slider_OnValueChanged()
end
if newvalue ~= self.value and not self.disabled then
self.value = newvalue
self:Fire("OnValueChanged", newvalue)
self:Fire("OnValueChanged", 1, newvalue)
end
if self.value then
UpdateText(self)
@@ -78,7 +77,7 @@ end
local function Slider_OnMouseUp()
local self = this.obj
self:Fire("OnMouseUp", self.value)
self:Fire("OnMouseUp", 1, self.value)
end
local function Slider_OnMouseWheel()
@@ -102,7 +101,7 @@ local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
if self.ispercent then
value = gsub(value, '%%', '')
value = value:gsub('%%', '')
value = tonumber(value) / 100
else
value = tonumber(value)
@@ -111,7 +110,7 @@ local function EditBox_OnEnterPressed()
if value then
PlaySound("igMainMenuOptionCheckBoxOn")
self.slider:SetValue(value)
self:Fire("OnMouseUp", value)
self:Fire("OnMouseUp", 1, value)
end
end
@@ -222,9 +221,9 @@ local function Constructor()
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("TOPLEFT", 0, 0)
label:SetPoint("TOPRIGHT", 0, 0)
label:SetJustifyH("CENTER", 0, 0)
label:SetPoint("TOPLEFT",0,0)
label:SetPoint("TOPRIGHT",0,0)
label:SetJustifyH("CENTER",0,0)
label:SetHeight(15)
local slider = CreateFrame("Slider", nil, frame)
@@ -12,7 +12,6 @@
<Script file="AceGUIContainer-Window.lua"/>
<!-- Widgets -->
<Script file="AceGUIWidget-Button.lua"/>
<Script file="AceGUIWidget-Button-ElvUI.lua"/>
<Script file="AceGUIWidget-CheckBox.lua"/>
<Script file="AceGUIWidget-ColorPicker.lua"/>
<Script file="AceGUIWidget-DropDown.lua"/>
@@ -1 +1 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Ui xmlns="http://www.blizzard.com/wow/ui/">
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -14,11 +14,11 @@ local UnitName = UnitName;
local DEFAULT_WIDTH = 890;
local DEFAULT_HEIGHT = 651;
local AC = LibStub("AceConfig-3.0-ElvUI");
local ACD = LibStub("AceConfigDialog-3.0-ElvUI");
local ACR = LibStub("AceConfigRegistry-3.0-ElvUI");
local AC = LibStub("AceConfig-3.0");
local ACD = LibStub("AceConfigDialog-3.0");
local ACR = LibStub("AceConfigRegistry-3.0");
AC:RegisterOptionsTable("ElvUI", E.Options);
AC.RegisterOptionsTable(E, "ElvUI", E.Options);
ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT);
function E:RefreshGUI()