This commit is contained in:
Bunny67
2020-06-02 23:40:06 +03:00
commit f2e1a0928d
516 changed files with 185320 additions and 0 deletions
@@ -0,0 +1,722 @@
--[[-----------------------------------------------------------------------------
WeakAurasTreeGroup Container
Container that uses a tree control to switch between groups.
This file was forked from AceGUIContainer-TreeGroup.lua version 41
-------------------------------------------------------------------------------]]
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasTreeGroup", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local WoW80 = select(4, GetBuildInfo()) >= 80000
-- 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
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GameTooltip, FONT_COLOR_CODE_CLOSE
-- Recycling functions
local new, del
do
local pool = setmetatable({},{__mode='k'})
function new()
local t = next(pool)
if t then
pool[t] = nil
return t
else
return {}
end
end
function del(t)
for k in pairs(t) do
t[k] = nil
end
pool[t] = true
end
end
local DEFAULT_TREE_WIDTH = 175
local DEFAULT_TREE_SIZABLE = true
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function GetButtonUniqueValue(line)
local parent = line.parent
if parent and parent.value then
return GetButtonUniqueValue(parent).."\001"..line.value
else
return line.value
end
end
local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local self = button.obj
local toggle = button.toggle
local text = treeline.text or ""
local icon = treeline.icon
local iconCoords = treeline.iconCoords
local level = treeline.level
local value = treeline.value
local fileId = treeline.fileId
local uniquevalue = treeline.uniquevalue
local disabled = treeline.disabled
button.treeline = treeline
button.value = value
button.fileId = fileId
button.uniquevalue = uniquevalue
if selected then
button:LockHighlight()
button.selected = true
else
button:UnlockHighlight()
button.selected = false
end
button.level = level
if level == 1 then
button:SetNormalFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else
button:SetNormalFontObject("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)
else
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(130838) -- Interface\\Buttons\\UI-PlusButton-UP
toggle:SetPushedTexture(130836) -- Interface\\Buttons\\UI-PlusButton-DOWN
else
toggle:SetNormalTexture(130821) -- Interface\\Buttons\\UI-MinusButton-UP
toggle:SetPushedTexture(130820) -- Interface\\Buttons\\UI-MinusButton-DOWN
end
toggle:Show()
else
toggle:Hide()
end
end
local function ShouldDisplayLevel(tree)
local result = false
for k, v in ipairs(tree) do
if v.children == nil and v.visible ~= false then
result = true
elseif v.children then
result = result or ShouldDisplayLevel(v.children)
end
if result then return result end
end
return false
end
local function addLine(self, v, tree, level, parent)
local line = new()
line.value = v.value
line.text = v.text
line.icon = v.icon
line.iconCoords = v.iconCoords
line.disabled = v.disabled
line.tree = tree
line.level = level
line.parent = parent
line.visible = v.visible
line.uniquevalue = GetButtonUniqueValue(line)
line.fileId = v.fileId
if v.children then
line.hasChildren = true
else
line.hasChildren = nil
end
self.lines[#self.lines+1] = 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)
self:RefreshTree(nil, true)
end
local function BuildUniqueValue(...)
local n = select('#', ...)
if n == 1 then
return ...
else
return (...).."\001"..BuildUniqueValue(select(2,...))
end
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Expand_OnClick(frame)
local button = frame.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.fileId)
frame.selected = true
frame:LockHighlight()
self:RefreshTree()
end
AceGUI:ClearFocus()
end
local function Button_OnDoubleClick(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_OnEnter(frame)
local self = frame.obj
self:Fire("OnButtonEnter", frame.uniquevalue, frame)
if self.enabletooltips then
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",frame,"RIGHT")
GameTooltip:SetText(frame.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)
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 status = self.status or self.localstatus
status.scrollvalue = floor(value + 0.5)
self:RefreshTree()
AceGUI:ClearFocus()
end
local function Tree_OnSizeChanged(frame)
frame.obj:RefreshTree()
end
local function Tree_OnMouseWheel(frame, delta)
local self = frame.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))
if value ~= newvalue then
scrollbar:SetValue(newvalue)
end
end
end
local function Dragger_OnLeave(frame)
frame:SetBackdropColor(1, 1, 1, 0)
end
local function Dragger_OnEnter(frame)
frame:SetBackdropColor(1, 1, 1, 0.8)
end
local function Dragger_OnMouseDown(frame)
local treeframe = frame:GetParent()
treeframe:StartSizing("RIGHT")
end
local function Dragger_OnMouseUp(frame)
local treeframe = frame:GetParent()
local self = treeframe.obj
local parentFrame = 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", parentFrame, "TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT", parentFrame, "BOTTOMLEFT",0,0)
local status = self.status or self.localstatus
status.treewidth = treeframe:GetWidth()
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
-- recalculate the content width
treeframe.obj:OnWidthSet(status.fullwidth)
-- update the layout of the content
treeframe.obj:DoLayout()
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
self:EnableButtonTooltips(true)
self.frame:SetScript("OnUpdate", FirstFrameUpdate)
end,
["OnRelease"] = function(self)
self.status = nil
self.tree = nil
self.frame:SetScript("OnUpdate", nil)
for k, v in pairs(self.localstatus) do
if k == "groups" then
for k2 in pairs(v) do
v[k2] = nil
end
else
self.localstatus[k] = nil
end
end
self.localstatus.scrollvalue = 0
self.localstatus.treewidth = DEFAULT_TREE_WIDTH
self.localstatus.treesizable = DEFAULT_TREE_SIZABLE
end,
["EnableButtonTooltips"] = function(self, enable)
self.enabletooltips = enable
end,
["CreateButton"] = function(self)
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "OptionsListButtonTemplate")
button.obj = self
local icon = button:CreateTexture(nil, "OVERLAY")
icon:SetWidth(14)
icon:SetHeight(14)
button.icon = icon
button:SetScript("OnClick",Button_OnClick)
button:SetScript("OnDoubleClick", Button_OnDoubleClick)
button:SetScript("OnEnter",Button_OnEnter)
button:SetScript("OnLeave",Button_OnLeave)
button.toggle.button = button
button.toggle:SetScript("OnClick",Expand_OnClick)
button.text:SetHeight(14) -- Prevents text wrapping
return button
end,
["SetStatusTable"] = function(self, status)
assert(type(status) == "table")
self.status = status
if not status.groups then
status.groups = {}
end
if not status.scrollvalue then
status.scrollvalue = 0
end
if not status.treewidth then
status.treewidth = DEFAULT_TREE_WIDTH
end
if status.treesizable == nil then
status.treesizable = DEFAULT_TREE_SIZABLE
end
self:SetTreeWidth(status.treewidth,status.treesizable)
self:RefreshTree()
end,
--sets the tree to be displayed
["SetTree"] = function(self, tree, filter)
self.filter = filter
if tree then
assert(type(tree) == "table")
end
self.tree = tree
self:RefreshTree()
end,
["BuildLevel"] = function(self, tree, level, parent)
local groups = (self.status or self.localstatus).groups
for i, v in ipairs(tree) do
if v.children then
if not self.filter or ShouldDisplayLevel(v.children) then
local line = addLine(self, v, tree, level, parent)
if groups[line.uniquevalue] then
self:BuildLevel(v.children, level+1, line)
end
end
elseif v.visible ~= false or not self.filter then
addLine(self, v, tree, level, parent)
end
end
end,
["RefreshTree"] = function(self,scrollToSelection,fromOnUpdate)
local buttons = self.buttons
local lines = self.lines
for i, v in ipairs(buttons) do
v:Hide()
end
while lines[1] do
local t = tremove(lines)
for k in pairs(t) do
t[k] = nil
end
del(t)
end
if not self.tree then return end
--Build the list of visible entries from the tree and status tables
local status = self.status or self.localstatus
local groupstatus = status.groups
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)
local numlines = #lines
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
if maxlines <= 0 then return end
-- WORKAROUND for lag spikes on WoW 8.0
if WoW80 and self.frame:GetParent() == UIParent and not fromOnUpdate then
self.frame:SetScript("OnUpdate", FirstFrameUpdate)
return
end
local first, last
scrollToSelection = status.scrollToSelection
status.scrollToSelection = nil
if numlines <= maxlines then
--the whole tree fits in the frame
status.scrollvalue = 0
self:ShowScroll(false)
first, last = 1, numlines
else
self:ShowScroll(true)
--scrolling will be needed
self.noupdate = true
self.scrollbar:SetMinMaxValues(0, numlines - maxlines)
--check if we are scrolled down too far
if numlines - status.scrollvalue < maxlines then
status.scrollvalue = numlines - maxlines
end
self.noupdate = nil
first, last = status.scrollvalue+1, status.scrollvalue + maxlines
--show selection?
if scrollToSelection and status.selected then
local show
for i,line in ipairs(lines) do -- find the line number
if line.uniquevalue==status.selected then
show=i
end
end
if not show then
-- selection was deleted or something?
elseif show >= first and show <= last then
-- all good
else
-- scrolling needed!
if show < first then
status.scrollvalue = show - 1
else
status.scrollvalue = show-maxlines
end
first, last = status.scrollvalue + 1, status.scrollvalue + maxlines
end
end
if self.scrollbar:GetValue() ~= status.scrollvalue then
self.scrollbar:SetValue(status.scrollvalue)
end
end
local buttonnum = 1
for i = first, last do
local line = lines[i]
local button = buttons[buttonnum]
if not button then
button = self:CreateButton()
buttons[buttonnum] = button
button:SetParent(treeframe)
button:SetFrameLevel(treeframe:GetFrameLevel() + 1)
button:ClearAllPoints()
if buttonnum == 1 then
if self.showscroll then
button:SetPoint("TOPRIGHT", -22, -10)
button:SetPoint("TOPLEFT", 0, -10)
else
button:SetPoint("TOPRIGHT", 0, -10)
button:SetPoint("TOPLEFT", 0, -10)
end
else
button:SetPoint("TOPRIGHT", buttons[buttonnum - 1], "BOTTOMRIGHT", 0, 0)
button:SetPoint("TOPLEFT", buttons[buttonnum - 1], "BOTTOMLEFT", 0, 0)
end
end
UpdateButton(button, line, status.selected == line.uniquevalue, line.hasChildren, groupstatus[line.uniquevalue])
button:Show()
buttonnum = buttonnum + 1
end
end,
["SetSelected"] = function(self, value, fileId)
local status = self.status or self.localstatus
if status.selected ~= value then
status.selected = value
self:Fire("OnGroupSelected", value, fileId)
end
end,
["Select"] = function(self, uniquevalue, ...)
self.filter = false
local status = self.status or self.localstatus
local groups = status.groups
local path = {...}
for i = 1, #path do
groups[tconcat(path, "\001", 1, i)] = true
end
status.selected = uniquevalue
self:RefreshTree(true)
self:Fire("OnGroupSelected", uniquevalue)
end,
["SelectByPath"] = function(self, ...)
self:Select(BuildUniqueValue(...), ...)
end,
["SelectByValue"] = function(self, uniquevalue)
self:Select(uniquevalue, ("\001"):split(uniquevalue))
end,
["ShowScroll"] = function(self, show)
self.showscroll = show
if show then
self.scrollbar:Show()
if self.buttons[1] then
self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe, "TOPRIGHT", -22, -10)
end
else
self.scrollbar:Hide()
if self.buttons[1] then
self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe, "TOPRIGHT", 0, -10)
end
end
end,
["OnWidthSet"] = function(self, width)
local content = self.content
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
treeframe:SetMaxResize(maxtreewidth, 1600)
end,
["OnHeightSet"] = function(self, height)
local content = self.content
local contentheight = height - 20
if contentheight < 0 then
contentheight = 0
end
content:SetHeight(contentheight)
content.height = contentheight
end,
["SetTreeWidth"] = function(self, treewidth, resizable)
if not resizable then
if type(treewidth) == 'number' then
resizable = false
elseif type(treewidth) == 'boolean' then
resizable = treewidth
treewidth = DEFAULT_TREE_WIDTH
else
resizable = false
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)
end
end,
["GetTreeWidth"] = function(self)
local status = self.status or self.localstatus
return status.treewidth or DEFAULT_TREE_WIDTH
end,
["LayoutFinished"] = function(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + 20)
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local PaneBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 3, right = 3, top = 5, bottom = 3 }
}
local DraggerBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = nil,
tile = true, tileSize = 16, edgeSize = 0,
insets = { left = 3, right = 3, top = 7, bottom = 7 }
}
local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame", nil, UIParent)
local treeframe = CreateFrame("Frame", nil, frame)
treeframe:SetPoint("TOPLEFT")
treeframe:SetPoint("BOTTOMLEFT")
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
treeframe:EnableMouseWheel(true)
treeframe:SetBackdrop(PaneBackdrop)
treeframe:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
treeframe:SetBackdropBorderColor(0.4, 0.4, 0.4)
treeframe:SetResizable(true)
treeframe:SetMinResize(100, 1)
treeframe:SetMaxResize(400, 1600)
treeframe:SetScript("OnUpdate", FirstFrameUpdate)
treeframe:SetScript("OnSizeChanged", Tree_OnSizeChanged)
treeframe:SetScript("OnMouseWheel", Tree_OnMouseWheel)
local dragger = CreateFrame("Button", nil, treeframe)
dragger:SetWidth(8)
dragger:SetPoint("TOP", treeframe, "TOPRIGHT")
dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT")
dragger:SetBackdrop(DraggerBackdrop)
dragger:SetBackdropColor(1, 1, 1, 0)
dragger:SetScript("OnEnter", Dragger_OnEnter)
dragger:SetScript("OnLeave", Dragger_OnLeave)
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
scrollbar:SetScript("OnValueChanged", nil)
scrollbar:SetPoint("TOPRIGHT", -10, -26)
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
scrollbar:SetMinMaxValues(0, 0)
scrollbar:SetValueStep(1)
scrollbar:SetValue(0)
scrollbar:SetWidth(16)
scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
scrollbg:SetTexture(0, 0, 0, 0.4)
local border = CreateFrame("Frame", nil, frame)
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
border:SetPoint("BOTTOMRIGHT")
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
--Container Support
local content = CreateFrame("Frame", nil, border)
content:SetPoint("TOPLEFT", 10, -10)
content:SetPoint("BOTTOMRIGHT", -10, 10)
local widget = {
frame = frame,
lines = {},
levels = {},
buttons = {},
hasChildren = {},
localstatus = { groups = {}, scrollvalue = 0 },
filter = false,
treeframe = treeframe,
dragger = dragger,
scrollbar = scrollbar,
border = border,
content = content,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
treeframe.obj, dragger.obj, scrollbar.obj = widget, widget, widget
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,142 @@
--[[-----------------------------------------------------------------------------
Button Widget for our Expand button
-------------------------------------------------------------------------------]]
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasExpand", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs, print = select, pairs, print
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
local function Button_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
AceGUI:ClearFocus()
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetHeight(110)
self:SetWidth(110)
self:SetLabel()
self:SetImage(nil)
self:SetImageSize(64, 64)
self:SetDisabled(false)
end,
-- ["OnRelease"] = nil,
["SetLabel"] = function(self, text)
if text and text ~= "" then
self.label:Show()
self.label:SetText(text)
self:SetHeight(max(self.label:GetStringHeight(), self.image:GetHeight()))
else
self.label:Hide()
self:SetHeight(self.image:GetHeight())
end
end,
["SetImage"] = function(self, path, ...)
local image = self.image
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
if n == 4 or n == 8 then
image:SetTexCoord(...)
else
image:SetTexCoord(0, 1, 0, 1)
end
end
end,
["SetImageSize"] = function(self, width, height)
self.image:SetWidth(width)
self.image:SetHeight(height)
--self.frame:SetWidth(width + 30)
if self.label:IsShown() then
self:SetHeight(max(self.label:GetStringHeight(), self.image:GetHeight()))
else
self:SetHeight(self.image:GetHeight())
end
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
self.label:SetTextColor(0.5, 0.5, 0.5)
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
else
self.frame:Enable()
self.label:SetTextColor(1, 1, 1)
self.image:SetVertexColor(1, 1, 1, 1)
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local frame = CreateFrame("Button", nil, UIParent)
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
frame:SetScript("OnClick", Button_OnClick)
local image = frame:CreateTexture(nil, "BACKGROUND")
image:SetWidth(64)
image:SetHeight(64)
image:SetPoint("LEFT", 0, 0)
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightLarge")
label:SetJustifyH("LEFT")
label:SetJustifyV("TOP")
label:SetPoint("LEFT", image, "RIGHT", 5, 0)
label:SetPoint("TOP")
label:SetPoint("BOTTOM")
label:SetPoint("RIGHT")
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAllPoints(frame)
highlight:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\Square_White")
highlight:SetVertexColor(0.2, 0.4, 0.8, 0.2)
highlight:SetBlendMode("ADD")
local widget = {
label = label,
image = image,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,156 @@
--[[-----------------------------------------------------------------------------
Button Widget for our Expand button
-------------------------------------------------------------------------------]]
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasExpandSmall", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs, print = select, pairs, print
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
local function Button_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
AceGUI:ClearFocus()
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetHeight(20)
self:SetWidth(110)
self:SetLabel()
self:SetImage(nil)
self:SetImageSize(24, 24)
self:SetDisabled(false)
end,
-- ["OnRelease"] = nil,
["SetLabel"] = function(self, text)
if text and text ~= "" then
self.label:Show()
self.label:SetText(text)
self:SetHeight(max(self.label:GetStringHeight(), self.image:GetHeight()))
else
self.label:Hide()
self:SetHeight(self.image:GetHeight())
end
end,
["SetImage"] = function(self, path, ...)
local image = self.image
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
if n == 4 or n == 8 then
image:SetTexCoord(...)
else
image:SetTexCoord(0, 1, 0, 1)
end
end
end,
["SetImageSize"] = function(self, width, height)
self.image:SetWidth(width)
self.image:SetHeight(height)
--self.frame:SetWidth(width + 30)
self:UpdateWidth()
if self.label:IsShown() then
self:SetHeight(max(self.label:GetStringHeight(), self.image:GetHeight()))
else
self:SetHeight(self.image:GetHeight())
end
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
self.label:SetTextColor(0.5, 0.5, 0.5)
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
else
self.frame:Enable()
self.label:SetTextColor(1, 1, 1)
self.image:SetVertexColor(1, 1, 1, 1)
end
end,
["OnWidthSet"] = function(self, width)
self:UpdateWidth()
end,
["UpdateWidth"] = function(self)
self.label:SetWidth(self.frame:GetWidth() - self.image:GetWidth())
if self.label:IsShown() then
self:SetHeight(max(self.label:GetStringHeight(), self.image:GetHeight()))
else
self:SetHeight(self.image:GetHeight())
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local frame = CreateFrame("Button", nil, UIParent)
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
frame:SetScript("OnClick", Button_OnClick)
local image = frame:CreateTexture(nil, "BACKGROUND")
image:SetWidth(64)
image:SetHeight(64)
image:SetPoint("RIGHT", 0, 0)
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
label:SetJustifyH("LEFT")
label:SetJustifyV("CENTER")
label:SetPoint("RIGHT", image, "LEFT", -5, 0)
label:SetPoint("TOP")
label:SetPoint("BOTTOM")
label:SetPoint("LEFT")
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAllPoints(frame)
highlight:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\Square_White")
highlight:SetVertexColor(0.2, 0.4, 0.8, 0.2)
highlight:SetBlendMode("ADD")
local widget = {
label = label,
image = image,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,19 @@
--[[-----------------------------------------------------------------------------
Icon Widget that allows for a tooltip, by preventing SetLabel from actually
setting a label
Graphical Button.
-------------------------------------------------------------------------------]]
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasIcon", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local function Constructor()
local button = AceGUI:Create("Icon")
button.type = Type
button.SetLabel = function() end
return button
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,97 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasIconButton", 21
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("BOTTOM", owner, "TOP");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(52);
self:SetHeight(52);
end,
["OnRelease"] = function(self)
self:ClearPick();
self.texture:SetTexture();
end,
["SetName"] = function(self, name)
self.texture.name = name;
end,
["GetName"] = function(self)
return self.texture.name;
end,
["SetTexture"] = function(self, texturePath)
self.texture.path = texturePath;
local success = self.texture:SetTexture(texturePath);
if not(success) then
self.texture:SetTexture("Interface\\BUTTONS\\UI-Quickslot-Depress.blp");
end
return success;
end,
["GetTexturePath"] = function(self)
return self.texture.path;
end,
["SetClick"] = function(self, func)
self.frame:SetScript("OnClick", func);
end,
["Pick"] = function(self)
self.frame:LockHighlight();
end,
["ClearPick"] = function(self)
self.frame:UnlockHighlight();
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local button = CreateFrame("BUTTON", nil, UIParent);
button:SetHeight(52);
button:SetWidth(52);
local highlighttexture = button:CreateTexture(nil, "OVERLAY");
--highlighttexture:SetTexture("Interface\\BUTTONS\\ButtonHilight-SquareQuickslot.blp");
--highlighttexture:SetTexCoord(0.175, 0.875, 0.125, 0.825);
highlighttexture:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight.blp");
highlighttexture:SetVertexColor(0.25, 0.5, 1);
highlighttexture:SetPoint("BOTTOMLEFT", button, 4, 4);
highlighttexture:SetPoint("TOPRIGHT", button, -4, -4);
button:SetHighlightTexture(highlighttexture);
local texture = button:CreateTexture(nil, "OVERLAY");
texture:SetAllPoints(button);
texture.name = "Undefined";
button:SetScript("OnEnter", function() Show_Tooltip(button, texture.name, texture.path) end);
button:SetScript("OnLeave", Hide_Tooltip);
local widget = {
frame = button,
texture = texture,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,192 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasImportButton", 20
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local L = WeakAuras.L;
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("LEFT", owner, "RIGHT");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(380);
self:SetHeight(18);
end,
["SetTitle"] = function(self, title)
self.title:SetText(title);
end,
["GetTitle"] = function(self)
return self.title:GetText();
end,
["SetDescription"] = function(self, desc)
self.frame.description = desc;
end,
["SetIcon"] = function(self, iconPath)
if(iconPath) then
local icon = self.frame:CreateTexture();
icon:SetTexture(iconPath);
icon:SetPoint("RIGHT", self.frame, "RIGHT");
icon:SetPoint("BOTTOM", self.frame, "BOTTOM");
icon:SetWidth(16);
icon:SetHeight(16);
self.title:SetPoint("RIGHT", icon, "LEFT");
end
end,
-- ["SetChecked"] = function(self, value)
-- print("SetChecked", self.title:GetText(), value);
-- self.checkbox:SetChecked(value);
-- print("After SetChecked", self.checkbox:GetChecked(), self:GetChecked());
-- end,
-- ["GetChecked"] = function(self)
-- local checked = self.checkbox:GetChecked();
-- print("GetChecked", self.title:GetText(), checked);
-- return checked;
-- end,
["SetClick"] = function(self, func)
self.checkbox:SetScript("OnClick", func);
end,
["Expand"] = function(self, reloadTooltip)
self.expand:Enable();
self.expand.expanded = true;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-MinusButton-Up.blp");
self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-MinusButton-Down.blp");
self.expand.title = L["Collapse"];
self.expand:SetScript("OnClick", function() self:Collapse(true) end);
self.expand.func();
if(reloadTooltip) then
Hide_Tooltip();
Show_Tooltip(self.frame, self.expand.title, nil);
end
end,
["Collapse"] = function(self, reloadTooltip)
self.expand:Enable();
self.expand.expanded = nil;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Up.blp");
self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-PlusButton-Down.blp");
self.expand.title = L["Expand"];
self.expand:SetScript("OnClick", function() self:Expand(true) end);
self.expand.func();
if(reloadTooltip) then
Hide_Tooltip();
Show_Tooltip(self.frame, self.expand.title, nil);
end
end,
["SetOnExpandCollapse"] = function(self, func)
self.expand.func = func;
end,
["GetExpanded"] = function(self)
return self.expand.expanded;
end,
["DisableExpand"] = function(self)
self.expand:Disable();
self.expand.disabled = true;
self.expand.expanded = false;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Disabled.blp");
end,
["EnableExpand"] = function(self)
self.expand.disabled = false;
if(self:GetExpanded()) then
self:Expand();
else
self:Collapse();
end
end,
["SetExpandVisible"] = function(self, value)
if(value) then
self.expand:Show();
else
self.expand:Hide();
end
end,
["SetLevel"] = function(self, level)
self.checkbox:SetPoint("left", self.frame, "left", level * 16, 0);
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "WeakAurasImportButton"..AceGUI:GetNextWidgetNum(Type);
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(18);
button:SetWidth(380);
button.dgroup = nil;
local background = button:CreateTexture(nil, "BACKGROUND");
button.background = background;
background:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
background:SetBlendMode("ADD");
background:SetVertexColor(0.5, 0.5, 0.5, 0.25);
background:SetAllPoints(button);
local expand = CreateFrame("BUTTON", nil, button);
button.expand = expand;
expand.expanded = true;
expand.disabled = true;
expand.func = function() end;
expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Disabled.blp");
expand:Disable();
expand:SetWidth(16);
expand:SetHeight(16);
expand:SetPoint("BOTTOM", button, "BOTTOM");
expand:SetPoint("LEFT", button, "LEFT");
expand:SetHighlightTexture("Interface\\BUTTONS\\UI-Panel-MinimizeButton-Highlight.blp");
expand.title = L["Disabled"];
expand:SetScript("OnEnter", function() Show_Tooltip(button, expand.title, nil) end);
expand:SetScript("OnLeave", Hide_Tooltip);
local checkbox = CreateFrame("CheckButton", nil, button, "ChatConfigCheckButtonTemplate");
button.checkbox = checkbox;
checkbox:EnableMouse(false);
checkbox:SetWidth(18);
checkbox:SetHeight(18);
checkbox:SetPoint("BOTTOM", button, "BOTTOM");
checkbox:SetPoint("LEFT", button, "LEFT", 16);
local title = button:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge");
button.title = title;
title:SetHeight(14);
title:SetJustifyH("LEFT");
title:SetPoint("LEFT", checkbox, "RIGHT", 2, 0);
title:SetPoint("RIGHT", button, "RIGHT");
button.description = "";
button:SetScript("OnEnter", function() Show_Tooltip(button, title:GetText(), button.description) end);
button:SetScript("OnLeave", Hide_Tooltip);
button:SetScript("OnClick", function() checkbox:Click() end);
local widget = {
frame = button,
title = title,
checkbox = checkbox,
expand = expand,
background = background,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,190 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasLoadedHeaderButton", 20
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local L = WeakAuras.L
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("LEFT", owner, "RIGHT");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(1000);
self:SetHeight(20);
end,
["SetText"] = function(self, text)
self.frame:SetText(" "..text);
end,
["SetClick"] = function(self, func)
self.frame:SetScript("OnClick", func);
end,
["Disable"] = function(self)
self.frame:Disable();
end,
["Enable"] = function(self)
self.frame:Enable();
end,
["Pick"] = function(self)
self.frame:LockHighlight();
end,
["ClearPick"] = function(self)
self.frame:UnlockHighlight();
end,
["Expand"] = function(self, reloadTooltip)
self.expand:Enable();
self.expanded = true;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-MinusButton-Up.blp");
self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-MinusButton-Down.blp");
self.expand.title = L["Collapse"];
self.expand.desc = self.expand.collapsedesc;
self.expand:SetScript("OnClick", function() self:Collapse(true) end);
self.expand.func();
if(reloadTooltip) then
Hide_Tooltip();
Show_Tooltip(self.frame, self.expand.title, self.expand.desc);
end
end,
["Collapse"] = function(self, reloadTooltip)
self.expand:Enable();
self.expanded = false;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Up.blp");
self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-PlusButton-Down.blp");
self.expand.title = L["Expand"];
self.expand.desc = self.expand.expanddesc;
self.expand:SetScript("OnClick", function() self:Expand(true) end);
self.expand.func();
if(reloadTooltip) then
Hide_Tooltip();
Show_Tooltip(self.frame, self.expand.title, self.expand.desc);
end
end,
["SetOnExpandCollapse"] = function(self, func)
self.expand.func = func;
end,
["GetExpanded"] = function(self)
return self.expanded;
end,
["DisableExpand"] = function(self)
self.expand:Disable();
self.expand.disabled = true;
self.expand.expanded = false;
self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Disabled.blp");
end,
["EnableExpand"] = function(self)
self.expand.disabled = false;
if(self:GetExpanded()) then
self:Expand();
else
self:Collapse();
end
end,
["SetViewClick"] = function(self, func)
self.view:SetScript("OnClick", func);
end,
["SetViewTest"] = function(self, func)
self.view.func = func;
end,
["SetViewDescription"] = function(self, desc)
self.view.desc = desc;
end,
["SetExpandDescription"] = function(self, desc)
self.expand.expanddesc = desc;
end,
["SetCollapseDescription"] = function(self, desc)
self.expand.collapsedesc = desc;
self.expand.desc = desc;
end,
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = Type..AceGUI:GetNextWidgetNum(Type)
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(20);
button:SetWidth(1000);
button:SetDisabledFontObject("GameFontNormal");
local background = button:CreateTexture(nil, "BACKGROUND");
button.background = background;
background:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
background:SetBlendMode("ADD");
background:SetVertexColor(0.5, 0.5, 0.5, 0.25);
background:SetAllPoints(button);
local expand = CreateFrame("BUTTON", nil, button);
button.expand = expand;
expand.expanded = true;
expand.disabled = true;
expand.func = function() end;
expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Disabled.blp");
expand:Disable();
expand:SetWidth(16);
expand:SetHeight(16);
expand:SetPoint("RIGHT", button, "RIGHT");
expand:SetHighlightTexture("Interface\\BUTTONS\\UI-Panel-MinimizeButton-Highlight.blp");
expand.title = L["Disabled"];
expand.desc = L["Expansion is disabled because this group has no children"];
expand.expanddesc = "";
expand.collapsedesc = "";
expand:SetScript("OnEnter", function() Show_Tooltip(button, expand.title, expand.desc) end);
expand:SetScript("OnLeave", Hide_Tooltip);
local view = CreateFrame("BUTTON", nil, button);
button.view = view;
view:SetWidth(16);
view:SetHeight(16);
view:SetPoint("RIGHT", button, "RIGHT", -16, 0);
local viewTexture = view:CreateTexture()
view.texture = viewTexture;
viewTexture:SetTexture("Interface\\LFGFrame\\BattlenetWorking1.blp");
viewTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9);
viewTexture:SetAllPoints(view);
view:SetNormalTexture(viewTexture);
view:SetHighlightTexture("Interface\\BUTTONS\\UI-Panel-MinimizeButton-Highlight.blp");
view.desc = "";
view:SetScript("OnEnter", function() Show_Tooltip(button, L["View"], view.desc) end);
view:SetScript("OnLeave", Hide_Tooltip);
view.visibility = 0;
view.func = function() return view.visibility end;
view:SetScript("OnUpdate", function()
if(view.func() == 2) then
view.texture:SetTexture("Interface\\LFGFrame\\BattlenetWorking0.blp");
elseif(view.func() == 1) then
view.texture:SetTexture("Interface\\LFGFrame\\BattlenetWorking2.blp");
else
view.texture:SetTexture("Interface\\LFGFrame\\BattlenetWorking4.blp");
end
end);
local widget = {
frame = button,
expand = expand,
view = view,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,390 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasMultiLineEditBox", 34
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
-- WoW APIs
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
if not AceGUIWeakAurasMultiLineEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIWeakAurasMultiLineEditBoxInsertLink(...) end)
end
function _G.AceGUIWeakAurasMultiLineEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G[("WeakAurasMultiLineEditBox%uEdit"):format(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)
if self.labelHeight == 0 then
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
else
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
end
if self.disablebutton then
self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21)
self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4)
else
self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18)
self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT")
end
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function OnClick(self) -- Button
self = self.obj
self.editBox:ClearFocus()
if not self:Fire("OnEnterPressed", IndentationLib.decode(self.editBox:GetText())) then
self.button:Disable()
end
end
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
self, y = self.obj.scrollFrame, -y
local offset = self:GetVerticalScroll()
if y < offset then
self:SetVerticalScroll(y)
else
y = y + cursorHeight - 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")
self.obj.scrollFrame:EnableMouseWheel(false);
end
local function OnEnter(self) -- EditBox / ScrollFrame
self = self.obj
if not self.entered then
self.entered = true
self:Fire("OnEnter")
end
end
local function OnLeave(self) -- EditBox / ScrollFrame
self = self.obj
if self.entered then
self.entered = nil
self:Fire("OnLeave")
end
end
local function OnMouseUp(self) -- ScrollFrame
self = self.obj.editBox
self:SetFocus()
self:SetCursorPosition(self:GetNumLetters())
end
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local type, id, info = GetCursorInfo()
if type == "spell" then
info = GetSpellInfo(id, info)
elseif type ~= "item" then
return
end
ClearCursor()
self = self.obj
local editBox = self.editBox
if not editBox:HasFocus() then
editBox:SetFocus()
editBox:SetCursorPosition(editBox:GetNumLetters())
end
editBox:Insert(info)
self.button:Enable()
end
local function OnSizeChanged(self, width, height) -- ScrollFrame
self.obj.editBox:SetWidth(width)
end
local function OnTextChanged(self, userInput) -- EditBox
if userInput then
self = self.obj
self:Fire("OnTextChanged", IndentationLib.decode(self.editBox:GetText()))
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()
end
local function OnVerticalScroll(self, offset) -- ScrollFrame
local editBox = self.obj.editBox
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
end
local function OnFrameShow(frame)
if (frame.focusOnShow) then
frame.obj.editBox:SetFocus()
frame.focusOnShow = nil;
end
local self = frame.obj;
local option = self.userdata.option;
local numExtraButtons = 0;
if (option and option.arg and option.arg.extraFunctions) then
numExtraButtons = #option.arg.extraFunctions;
for index, data in ipairs(option.arg.extraFunctions) do
if (not self.extraButtons[index]) then
local extraButton = CreateFrame("Button", ("%s%dExpandButton%d"):format(Type, self.widgetNum, index), frame, "UIPanelButtonTemplate")
extraButton:SetPoint("LEFT", self.extraButtons[index - 1], "RIGHT");
extraButton:SetHeight(22)
extraButton:SetWidth(100);
self.extraButtons[index] = extraButton;
end
local extraButton = self.extraButtons[index];
extraButton:SetText(data.buttonLabel);
extraButton:SetScript("OnClick", data.func);
extraButton:Show();
end
end
for i = numExtraButtons + 1, #self.extraButtons do
self.extraButtons[i]:Hide();
end
end
local function OnEditFocusGained(frame)
AceGUI:SetFocus(frame.obj)
frame.obj:Fire("OnEditFocusGained")
frame.obj.scrollFrame:EnableMouseWheel(true);
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self.editBox:SetText("")
self:SetDisabled(false)
self:SetWidth(200)
self:DisableButton(false)
self:SetNumLines()
self.entered = nil
self:SetMaxLetters(0)
end,
["OnRelease"] = function(self)
self:ClearFocus()
end,
["SetDisabled"] = function(self, disabled)
local editBox = self.editBox
if disabled then
editBox:ClearFocus()
editBox:EnableMouse(false)
editBox:SetTextColor(0.5, 0.5, 0.5)
self.label:SetTextColor(0.5, 0.5, 0.5)
self.scrollFrame:EnableMouse(false)
self.button:Disable()
else
editBox:EnableMouse(true)
editBox:SetTextColor(1, 1, 1)
self.label:SetTextColor(1, 0.82, 0)
self.scrollFrame:EnableMouse(true)
end
end,
["SetLabel"] = function(self, text)
if text and text ~= "" then
self.label:SetText(text)
if self.labelHeight ~= 10 then
self.labelHeight = 10
self.label:Show()
end
elseif self.labelHeight ~= 0 then
self.labelHeight = 0
self.label:Hide()
end
Layout(self)
end,
["SetNumLines"] = function(self, value)
if not value or value < 4 then
value = 4
end
self.numlines = value
Layout(self)
end,
["SetText"] = function(self, text)
self.editBox:SetText(IndentationLib.encode(text))
end,
["GetText"] = function(self)
return IndentationLib.decode(self.editBox:GetText())
end,
["SetMaxLetters"] = function (self, num)
self.editBox:SetMaxLetters(num or 0)
end,
["DisableButton"] = function(self, disabled)
self.disablebutton = disabled
if disabled then
self.button:Hide()
else
self.button:Show()
end
Layout(self)
end,
["ClearFocus"] = function(self)
self.editBox:ClearFocus()
self.frame.focusOnShow = nil;
end,
["SetFocus"] = function(self)
self.editBox:SetFocus()
if not self.frame:IsShown() then
self.frame.focusOnShow = true;
end
end,
["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(...)
end,
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local backdrop = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = { left = 4, right = 3, top = 4, bottom = 3 }
}
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
frame:Hide()
frame:SetScript("OnShow", OnFrameShow);
local widgetNum = AceGUI:GetNextWidgetNum(Type)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4)
label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4)
label:SetJustifyH("LEFT")
label:SetText(ACCEPT)
label:SetHeight(10)
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate")
button:SetPoint("BOTTOMLEFT", 0, 4)
button:SetHeight(22)
button:SetWidth(100)
button:SetText(ACCEPT)
button:SetScript("OnClick", OnClick)
button:Disable()
local extraButtons = {};
extraButtons[0] = button;
local scrollBG = CreateFrame("Frame", nil, frame)
scrollBG:SetBackdrop(backdrop)
scrollBG:SetBackdropColor(0, 0, 0)
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
scrollFrame:EnableMouseWheel(false);
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
scrollBar:ClearAllPoints()
scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19)
scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18)
scrollBar:SetPoint("RIGHT", frame, "RIGHT")
scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19)
scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT")
scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6)
scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4)
scrollFrame:SetScript("OnEnter", OnEnter)
scrollFrame:SetScript("OnLeave", OnLeave)
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
editBox:SetAllPoints()
editBox:SetFontObject(ChatFontNormal)
editBox:SetMultiLine(true)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetCountInvisibleLetters(false)
editBox:SetScript("OnCursorChanged", OnCursorChanged)
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
editBox:SetScript("OnEnter", OnEnter)
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
editBox:SetScript("OnLeave", OnLeave)
editBox:SetScript("OnMouseDown", OnReceiveDrag)
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
editBox:SetScript("OnTextChanged", OnTextChanged)
editBox:SetScript("OnTextSet", OnTextSet)
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
scrollFrame:SetScrollChild(editBox)
local widget = {
button = button,
extraButtons = extraButtons,
editBox = editBox,
frame = frame,
label = label,
labelHeight = 10,
numlines = 4,
scrollBar = scrollBar,
scrollBG = scrollBG,
scrollFrame = scrollFrame,
type = Type,
widgetNum = widgetNum,
}
for method, func in pairs(methods) do
widget[method] = func
end
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,148 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasNewButton", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("LEFT", owner, "RIGHT");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(570);
self:SetHeight(40);
end,
["SetTitle"] = function(self, title)
self.title:SetText(title);
end,
["GetTitle"] = function(self)
return self.title:GetText();
end,
["SetDescription"] = function(self, desc)
self.frame.description = desc;
self.description:SetText(desc);
end,
["SetClick"] = function(self, func)
self.frame:SetScript("OnClick", func);
end,
["SetIcon"] = function(self, icon)
self:ReleaseThumnail()
if(type(icon) == "string" or type(icon) == "number") then
self.icon:SetTexture(icon);
self.icon:Show();
if(self.iconRegion and self.iconRegion.Hide) then
self.iconRegion:Hide();
end
else
self.iconRegion = icon;
icon:SetAllPoints(self.icon);
icon:SetParent(self.frame);
icon:Show()
self.icon:Hide();
end
end,
["SetThumbnail"] = function(self, regionType, data)
local regionData = WeakAuras.regionOptions[regionType]
if regionData and regionData.acquireThumbnail then
local thumbnail = regionData.acquireThumbnail(self.frame, data)
self:SetIcon(thumbnail)
self.thumbnail = thumbnail
self.thumbnailType = regionType
end
end,
["ReleaseThumnail"] = function(self)
if self.thumbnail then
local regionData = WeakAuras.regionOptions[self.thumbnailType]
if regionData and regionData.releaseThumbnail then
regionData.releaseThumbnail(self.thumbnail)
end
end
self.thumbnail = nil
self.thumbnailType = nil
end,
["OnRelease"] = function(self)
self:ReleaseThumnail()
if(self.iconRegion and self.iconRegion.Hide) then
self.iconRegion:Hide();
end
self.icon:Hide();
self.frame:UnlockHighlight();
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "WeakAurasDisplayButton"..AceGUI:GetNextWidgetNum(Type);
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(40);
button:SetWidth(380);
button.dgroup = nil;
local background = button:CreateTexture(nil, "BACKGROUND");
button.background = background;
background:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
background:SetBlendMode("ADD");
background:SetVertexColor(0.5, 0.5, 0.5, 0.25);
background:SetAllPoints(button);
local icon = button:CreateTexture(nil, "OVERLAY");
button.icon = icon;
icon:SetWidth(40);
icon:SetHeight(40);
icon:SetPoint("LEFT", button, "LEFT");
local title = button:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge");
button.title = title;
title:SetHeight(14);
title:SetJustifyH("LEFT");
title:SetPoint("TOP", button, "TOP", 0, -5);
title:SetPoint("LEFT", icon, "RIGHT", 2, 0);
title:SetPoint("RIGHT", button, "RIGHT");
local description = button:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
button.description = description;
description:SetHeight(14);
description:SetJustifyH("LEFT");
description:SetPoint("BOTTOM", button, "BOTTOM", 0, 2);
description:SetPoint("LEFT", icon, "RIGHT", 2, 0);
description:SetPoint("RIGHT", button, "RIGHT");
button.description = "";
button:SetScript("OnEnter", function() Show_Tooltip(button, title:GetText(), button.description) end);
button:SetScript("OnLeave", Hide_Tooltip);
local widget = {
frame = button,
title = title,
icon = icon,
description = description,
background = background,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,85 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasNewHeaderButton", 20
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local L = WeakAuras.L;
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("LEFT", owner, "RIGHT");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(1000);
self:SetHeight(20);
end,
["SetText"] = function(self, text)
self.frame:SetText(" "..text);
end,
["SetDescription"] = function(self, description)
self.frame.description = description;
end,
["SetClick"] = function(self, func)
self.frame:SetScript("OnClick", func);
end,
["Disable"] = function(self)
self.frame:Disable();
end,
["Enable"] = function(self)
self.frame:Enable();
end,
["Pick"] = function(self)
self.frame:LockHighlight();
end,
["ClearPick"] = function(self)
self.frame:UnlockHighlight();
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = Type..AceGUI:GetNextWidgetNum(Type)
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(20);
button:SetWidth(1000);
button:SetDisabledFontObject("GameFontNormal");
local background = button:CreateTexture(nil, "BACKGROUND");
button.background = background;
background:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp");
background:SetBlendMode("ADD");
background:SetVertexColor(0.5, 0.5, 0.5, 0.25);
background:SetAllPoints(button);
button:SetScript("OnEnter", function() Show_Tooltip(button, button:GetText():sub(2), button.description or L["Add a new display"]) end);
button:SetScript("OnLeave", Hide_Tooltip);
local widget = {
frame = button,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,237 @@
--[[-----------------------------------------------------------------------------
SnippetButton Widget, based on AceGUI Button (and WA ToolbarButton)
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "WeakAurasSnippetButton", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then
return
end
-- Lua APIs
local pairs = pairs
-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
local L = WeakAuras.L
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
if ... == "RightButton" and frame.editable then
AceGUI:ClearFocus()
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
frame.title:Hide()
frame.renameEditBox:Show()
frame.renameEditBox:Enable()
frame.renameEditBox:SetText(frame.title:GetText())
frame.renameEditBox:HighlightText()
frame.renameEditBox:SetFocus()
elseif ... == "LeftButton" then
AceGUI:ClearFocus()
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
frame.obj:Fire("OnClick", ...)
end
end
local function Control_OnEnter(frame)
local tooltip = GameTooltip
tooltip:SetOwner(frame, "ANCHOR_RIGHT")
tooltip:ClearLines()
if frame.editable then
tooltip:AddDoubleLine(frame.titleText, L["(Right click to rename)"], nil, nil, nil, 0.6, 0.6, 0.6)
else
tooltip:AddLine(frame.titleText)
end
tooltip:AddLine(" ")
tooltip:AddLine(frame.descriptionText, 0.8, 0.8, 0.8)
tooltip:Show()
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
GameTooltip:Hide()
frame.obj:Fire("OnLeave")
end
local function rename_complete(self, ...)
self:ClearFocus()
AceGUI:ClearFocus()
self:EnableMouse(false)
self:Hide()
self:GetParent().obj:Fire("OnEnterPressed", ...)
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
-- restore default values
self:SetDisabled(false)
self:SetTitle()
self:SetEditable(false)
end,
-- ["OnRelease"] = nil,
["SetTitle"] = function(self, text)
self.frame.titleText = text
self.title:SetText(text)
end,
["SetDescription"] = function(self, text)
self.frame.descriptionText = text
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
else
self.frame:Enable()
end
end,
["LockHighlight"] = function(self)
self.frame:LockHighlight()
end,
["UnlockHighlight"] = function(self)
self.frame:UnlockHighlight()
end,
["SetEditable"] = function(self, editable)
if editable then
self.frame.editable = true
self.deleteButton:Show()
self.title:SetPoint("RIGHT", self.deleteButton, "LEFT")
else
self.frame.editable = false
self.deleteButton:Hide()
self.title:SetPoint("RIGHT", self.deleteButton, "RIGHT", 4, 0)
end
end,
["SetNew"] = function(self, new)
if new then
AceGUI:ClearFocus()
self.title:Hide()
self.renameEditBox:Show()
self.renameEditBox:EnableMouse(true)
self.renameEditBox:SetText(self.title:GetText())
self.renameEditBox:HighlightText()
self.renameEditBox:SetFocus()
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "WeakAurasSnippetButton" .. AceGUI:GetNextWidgetNum(Type)
local button = CreateFrame("Button", name, UIParent, "OptionsListButtonTemplate")
button:Hide()
button:EnableMouse(true)
button:SetScript("OnClick", Button_OnClick)
button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave)
button:SetHeight(24)
button:SetWidth(170)
local deleteButton = CreateFrame("BUTTON", nil, button)
deleteButton:SetPoint("RIGHT", button, "RIGHT", -3, 0)
deleteButton:SetSize(20, 20)
local deleteTex = deleteButton:CreateTexture()
deleteTex:SetAllPoints()
deleteTex:SetTexture([[Interface\Buttons\CancelButton-Up]])
deleteTex:SetTexCoord(0.1, 0.9, 0.1, 0.9)
deleteButton:SetNormalTexture(deleteTex)
deleteButton:Hide()
button.deleteButton = deleteButton
local title = button:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
title:SetHeight(14)
title:SetJustifyH("LEFT")
title:SetPoint("LEFT", button, "LEFT", 3, 0)
title:SetPoint("RIGHT", deleteButton, "LEFT")
title:SetTextColor(1, 1, 1, 1)
button.title = title
local ntex = button:CreateTexture()
ntex:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
ntex:SetVertexColor(0.8, 0.8, 0.8, 0.25)
ntex:SetPoint("TOPLEFT", 0, -1)
ntex:SetPoint("BOTTOMRIGHT", 0, 1)
button:SetNormalTexture(ntex)
local htex = button:CreateTexture()
htex:SetTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2.blp")
htex:SetVertexColor(0.3, 0.5, 1, 0.5)
htex:SetBlendMode("ADD")
htex:SetAllPoints(ntex)
button:SetHighlightTexture(htex)
button.htex = htex
local ptex = button:CreateTexture()
ptex:SetTexture(1, 1, 1, 0.2)
htex:SetAllPoints(ntex)
button:SetPushedTexture(ptex)
button.ptext = ptex
local delHighlight = deleteButton:CreateTexture()
delHighlight:SetTexture([[Interface\Buttons\CancelButton-Highlight]])
delHighlight:SetTexCoord(0.1, 0.9, 0.1, 0.9)
delHighlight:SetAllPoints()
deleteButton:SetHighlightTexture(delHighlight)
local delPushed = deleteButton:CreateTexture()
delPushed:SetTexture([[Interface\Buttons\CancelButton-Down]])
delPushed:SetTexCoord(0.1, 0.9, 0.1, 0.9)
delPushed:SetAllPoints()
deleteButton:SetPushedTexture(delPushed)
button.deleteHighlight = delHighlight
local renameEditBox = CreateFrame("EditBox", nil, button, "InputBoxTemplate")
renameEditBox:SetHeight(14)
renameEditBox:SetPoint("TOPLEFT", title, "TOPLEFT")
renameEditBox:SetPoint("BOTTOMRIGHT", title, "BOTTOMRIGHT")
renameEditBox:EnableMouse(false)
renameEditBox:Hide()
renameEditBox:SetScript(
"OnEscapePressed",
function(self)
self:ClearFocus()
AceGUI:ClearFocus()
self:EnableMouse(false)
self:Hide()
title:Show()
end
)
renameEditBox:SetScript(
"OnEditFocusLost",
function(self)
self:ClearFocus()
AceGUI:ClearFocus()
self:EnableMouse(false)
self:Hide()
title:Show()
end
)
renameEditBox:SetScript("OnEnterPressed", rename_complete)
button.renameEditBox = renameEditBox
local widget = {
title = title,
frame = button,
type = Type,
htex = htex,
ptex = ptex,
deleteButton = deleteButton,
renameEditBox = renameEditBox
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,42 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasSortedDropdown", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local function Constructor()
local DropDownConstructor = AceGUI.WidgetRegistry["Dropdown"];
if (not DropDownConstructor) then
return nil;
end
local widget = DropDownConstructor();
if (not widget) then
return nil;
end
local oldSetList = widget.SetList
widget.SetList = function(self, list, _, itemType)
local orderTable = {};
for k, v in pairs(list) do
tinsert(orderTable, { key = k, value = v });
end
local order = {};
table.sort(orderTable, function(a, b)
return a.value < b.value;
end);
for i, item in ipairs(orderTable) do
order[i] = item.key;
end
oldSetList(self, list, order, itemType)
end
widget.type = Type;
return widget;
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,128 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasTextureButton", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local function Hide_Tooltip()
GameTooltip:Hide();
end
local function Show_Tooltip(owner, line1, line2)
GameTooltip:SetOwner(owner, "ANCHOR_NONE");
GameTooltip:SetPoint("BOTTOM", owner, "TOP");
GameTooltip:ClearLines();
GameTooltip:AddLine(line1);
GameTooltip:AddLine(line2, 1, 1, 1, 1);
GameTooltip:Show();
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetWidth(128);
self:SetHeight(128);
end,
["OnRelease"] = function(self)
self:ClearPick();
self.texture:SetTexture();
end,
["SetTexture"] = function(self, texturePath, name)
self.texture:SetTexture(texturePath);
self.texture.path = texturePath;
self.texture.name = name;
end,
["ChangeTexture"] = function(self, r, g, b, a, rotate, discrete_rotation, rotation, mirror, blendMode)
local ulx,uly , llx,lly , urx,ury , lrx,lry;
if(rotate) then
local angle = rad(135 - rotation);
local vx = math.cos(angle);
local vy = math.sin(angle);
ulx,uly , llx,lly , urx,ury , lrx,lry = 0.5+vx,0.5-vy , 0.5-vy,0.5-vx , 0.5+vy,0.5+vx , 0.5-vx,0.5+vy;
else
if(discrete_rotation == 0 or discrete_rotation == 360) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,0 , 0,1 , 1,0 , 1,1;
elseif(discrete_rotation == 90) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,0 , 0,0 , 1,1 , 0,1;
elseif(discrete_rotation == 180) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 1,1 , 1,0 , 0,1 , 0,0;
elseif(discrete_rotation == 270) then
ulx,uly , llx,lly , urx,ury , lrx,lry = 0,1 , 1,1 , 0,0 , 1,0;
end
end
if(mirror) then
self.texture:SetTexCoord(urx,ury , lrx,lry , ulx,uly , llx,lly);
else
self.texture:SetTexCoord(ulx,uly , llx,lly , urx,ury , lrx,lry);
end
self.texture:SetVertexColor(r, g, b, a);
self.texture:SetBlendMode(blendMode);
end,
["SetTexCoord"] = function(self, left, right, top, bottom)
self.texture:SetTexCoord(left, right, top, bottom);
end,
["SetOnUpdate"] = function(self, func)
self.frame:SetScript("OnUpdate", func);
end,
["GetTexturePath"] = function(self)
return self.texture.path;
end,
["SetClick"] = function(self, func)
self.frame:SetScript("OnClick", func);
end,
["Pick"] = function(self)
self.frame:LockHighlight();
end,
["ClearPick"] = function(self)
self.frame:UnlockHighlight();
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "WeakAurasTextureButton"..AceGUI:GetNextWidgetNum(Type);
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(128);
button:SetWidth(128);
button:SetBackdrop({
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
});
button:SetBackdropColor(0.1,0.1,0.1);
button:SetBackdropBorderColor(0.4,0.4,0.4);
local highlighttexture = button:CreateTexture(nil, "OVERLAY");
highlighttexture:SetTexture("Interface\\BUTTONS\\ButtonHilight-SquareQuickslot.blp");
highlighttexture:SetTexCoord(0.175, 0.875, 0.125, 0.825);
highlighttexture:SetPoint("BOTTOMLEFT", button, 4, 4);
highlighttexture:SetPoint("TOPRIGHT", button, -4, -4);
button:SetHighlightTexture(highlighttexture);
local texture = button:CreateTexture(nil, "OVERLAY");
texture:SetPoint("BOTTOMLEFT", button, 4, 4);
texture:SetPoint("TOPRIGHT", button, -4, -4);
button:SetScript("OnEnter", function() Show_Tooltip(button, texture.name, texture.path:gsub("\\", "\n")) end);
button:SetScript("OnLeave", Hide_Tooltip);
local widget = {
frame = button,
texture = texture,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,142 @@
--[[-----------------------------------------------------------------------------
ToolbarButton Widget, based on AceGUI Button
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "WeakAurasToolbarButton", 3
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
AceGUI:ClearFocus()
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
frame.obj:Fire("OnClick", ...)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
-- restore default values
self:SetHeight(16)
self:SetWidth(32)
self:SetDisabled(false)
self:SetText()
self.htex:SetVertexColor(1, 1, 1, 0.1)
end,
-- ["OnRelease"] = nil,
["SetText"] = function(self, text)
self.text:SetText(text)
self:SetWidth(self.text:GetStringWidth() + 24)
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
else
self.frame:Enable()
end
end,
["SetTexture"] = function(self, path)
self.icon:SetTexture(path)
end,
["LockHighlight"] = function(self)
self.frame:LockHighlight()
end,
["UnlockHighlight"] = function(self)
self.frame:UnlockHighlight()
end,
["SetStrongHighlight"] = function(self, enable)
if enable then
self.htex:SetVertexColor(1, 1, 1, 0.3)
else
self.htex:SetVertexColor(1, 1, 1, 0.1)
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent)
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnClick", Button_OnClick)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
local icon = frame:CreateTexture()
icon:SetTexture("aaa")
icon:SetPoint("TOPLEFT", frame, "TOPLEFT")
icon:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT")
icon:SetWidth(16)
local text = frame:CreateFontString()
text:SetFontObject("GameFontNormal")
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 20, -1)
text:SetPoint("BOTTOMRIGHT", -4, 1)
text:SetJustifyV("MIDDLE")
--local ntex = frame:CreateTexture()
--ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
--ntex:SetTexCoord(0, 0.625, 0, 0.6875)
--ntex:SetAllPoints()
--frame:SetNormalTexture(ntex)
local htex = frame:CreateTexture()
htex:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\Square_FullWhite")
htex:SetVertexColor(1, 1, 1, 0.1)
htex:SetAllPoints()
frame:SetHighlightTexture(htex)
local ptex = frame:CreateTexture()
ptex:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\Square_FullWhite")
ptex:SetVertexColor(1, 1, 1, 0.2)
ptex:SetAllPoints()
frame:SetPushedTexture(ptex)
local widget = {
text = text,
icon = icon,
frame = frame,
type = Type,
htex = htex
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
@@ -0,0 +1,270 @@
if not WeakAuras.IsCorrectVersion() then return end
local Type, Version = "WeakAurasTwoColumnDropdown", 3
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
local tconcat = table.concat
local select = select
local assert, loadstring = assert, loadstring
local setmetatable, rawset = setmetatable, rawset
local xpcall = xpcall
local function errorhandler(err)
return geterrorhandler()(err)
end
local function CreateDispatcher(argCount)
local code = [[
local xpcall, eh = ...
local method, ARGS
local function call() return method(ARGS) end
local function dispatch(func, ...)
method = func
if not method then return end
ARGS = ...
return xpcall(call, eh)
end
return dispatch
]]
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("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[select("#", ...)](func, ...)
end
AceGUI:RegisterLayout("TwoColumn",
function(content, children)
local height = 0
local width = content.width or content:GetWidth() or 0
for i = 1, #children do
local child = children[i]
local frame = child.frame
frame:ClearAllPoints()
if child.userdata.hideMe then
frame:Hide()
else
frame:Show()
end
if i == 1 then
frame:SetPoint("TOPLEFT", content)
else
frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT")
end
if child.width == "relative" then
child:SetWidth(width * child.relWidth)
if child.DoLayout then
child:DoLayout()
end
end
height = max(height, frame.height or frame:GetHeight() or 0)
end
safecall(content.obj.LayoutFinished, content.obj, nil, height)
end)
local methods = {
["OnAcquire"] = function(widget)
local firstDropdown = AceGUI:Create("Dropdown")
local secondDropDown = AceGUI:Create("Dropdown")
firstDropdown:SetRelativeWidth(0.5)
firstDropdown:SetPulloutWidth(200)
secondDropDown:SetRelativeWidth(0.5)
secondDropDown:SetLabel(" ")
secondDropDown:SetPulloutWidth(200)
secondDropDown.userdata.defaultSelection = {}
widget.firstDropdown = firstDropdown
widget.secondDropDown = secondDropDown
widget:SetLayout("TwoColumn")
widget.SetLayout = function()
-- AceGui wants to set a default layout, but we don't want that
end
widget:AddChild(firstDropdown)
widget:AddChild(secondDropDown)
local OnFirstDropdownValueChanged = function(self, event, value)
local displayName = widget.userdata.firstList[value]
local treeValue = widget.userdata.tree[displayName]
if type(treeValue) == "table" then
local oldValue
if widget.userdata.secondList then
local v = widget.secondDropDown:GetValue()
if v then
oldValue = widget.userdata.secondList[v]
end
end
local secondList = {}
for displayName, _ in pairs(treeValue) do
tinsert(secondList, displayName)
end
table.sort(secondList)
local oldValueIndex = tIndexOf(secondList, oldValue)
widget.userdata.secondList = secondList
widget.secondDropDown:SetList(secondList)
widget.firstDropdown:SetRelativeWidth(0.5)
widget.secondDropDown:SetRelativeWidth(0.5)
widget.secondDropDown.userdata.hideMe = false
widget:DoLayout()
if (oldValueIndex) then
widget.secondDropDown:SetValue(oldValueIndex)
local v = widget:GetValue()
if (v) then
widget:Fire("OnValueChanged", v)
end
else
local default = widget.secondDropDown.userdata.defaultSelection[displayName]
if default then
local index = tIndexOf(secondList, default)
widget.secondDropDown:SetValue(index)
local v = widget:GetValue()
if (v) then
widget:Fire("OnValueChanged", v)
end
else
widget.secondDropDown:SetValue()
end
end
else
widget.firstDropdown:SetRelativeWidth(1)
widget.secondDropDown.userdata.hideMe = true
widget.userdata.secondList = nil
widget:DoLayout()
widget:Fire("OnValueChanged", treeValue)
end
end
firstDropdown.OnFirstDropdownValueChanged = OnFirstDropdownValueChanged
local OnSecondDropdownValueChanged = function(self, event, value)
widget:Fire("OnValueChanged", widget:GetValue())
end
firstDropdown:SetCallback("OnValueChanged", OnFirstDropdownValueChanged)
secondDropDown:SetCallback("OnValueChanged", OnSecondDropdownValueChanged)
end,
["OnRelease"] = function(self)
end,
["SetLabel"] = function(self, ...)
self.firstDropdown:SetLabel(...)
end,
["SetValue"] = function(self, value)
for displayName, treeValue in pairs(self.userdata.tree) do
if treeValue == value then
self.firstDropdown:SetRelativeWidth(1)
self.secondDropDown.userdata.hideMe = true
self:DoLayout()
self.firstDropdown:SetValue(tIndexOf(self.userdata.firstList, displayName))
return
elseif type(treeValue) == "table" then
for displayName2, key in pairs(treeValue) do
if (key == value) then
self.firstDropdown:SetRelativeWidth(0.5)
self.secondDropDown:SetRelativeWidth(0.5)
self.secondDropDown.userdata.hideMe = false
self:DoLayout()
local index = tIndexOf(self.userdata.firstList, displayName);
self.firstDropdown:SetValue(index)
self.firstDropdown:OnFirstDropdownValueChanged("", index)
self.secondDropDown:SetValue(tIndexOf(self.userdata.secondList, displayName2))
return
end
end
end
end
self.firstDropdown:SetRelativeWidth(1)
self.secondDropDown.userdata.hideMe = true
self:DoLayout()
self.firstDropdown:SetValue(nil)
end,
["GetValue"] = function(self)
local displayName1 = self.userdata.firstList[self.firstDropdown:GetValue()]
local treeValue = self.userdata.tree[displayName1]
if not treeValue then
return nil
end
if type(treeValue) ~= "table" then
return treeValue
end
local displayName2 = self.userdata.secondList[self.secondDropDown:GetValue()]
treeValue = treeValue[displayName2]
if not treeValue then
return nil
end
return treeValue
end,
["SetList"] = function(self, list, order, itemType)
local tree = {}
for key, displayName in pairs(list) do
if type(displayName) == "table" then
local base = displayName[1]
local suffix = displayName[2]
tree[base] = tree[base] or {}
tree[base][suffix] = key
if displayName[3] == true then
self.secondDropDown.userdata.defaultSelection[base] = suffix
end
else
tree[displayName] = key
end
end
self.userdata.tree = tree
local firstList = {}
for displayName, _ in pairs(tree) do
tinsert(firstList, displayName)
end
table.sort(firstList)
self.userdata.firstList = firstList
self.firstDropdown:SetList(firstList, order, itemType)
end
}
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
frame:SetHeight(50)
frame:SetWidth(50)
local content = CreateFrame("Frame", nil, frame)
content:SetPoint("TOPLEFT", 0, 0)
content:SetPoint("BOTTOMRIGHT", 0, 0)
local widget = {
frame = frame,
content = content,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)