mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
replace Ace3v with Ace3 ElvUI-TBC version
or easy tracking of code difference
This commit is contained in:
@@ -30,17 +30,12 @@ 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, tremove, tinsert, tgetn, tsetn = table.concat, table.remove, table.insert, table.getn, table.setn
|
||||
local pairs, next, type = pairs, next, type
|
||||
local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
|
||||
local select, pairs, next, type = select, 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
|
||||
@@ -56,17 +51,74 @@ 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
|
||||
local HookedFunctions = AceGUI.HookedFunctions
|
||||
|
||||
--[[
|
||||
xpcall safecall implementation
|
||||
]]
|
||||
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
|
||||
|
||||
-- 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
|
||||
@@ -105,16 +157,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function fixlevels(parent,...)
|
||||
local i = 1
|
||||
local child = arg[i]
|
||||
while child do
|
||||
child:SetFrameLevel(parent:GetFrameLevel() + (parent.backdrop and -1 or 2))
|
||||
fixlevels(child, child:GetChildren())
|
||||
i = i + 1
|
||||
child = arg[i]
|
||||
end
|
||||
end
|
||||
|
||||
-------------------
|
||||
-- API Functions --
|
||||
-------------------
|
||||
@@ -130,15 +173,27 @@ 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(strfmt("Widget type %s doesn't supply an OnAcquire Function", type))
|
||||
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type))
|
||||
end
|
||||
|
||||
-- Set the default Layout ("List")
|
||||
safecall(widget.SetLayout, 2, widget, "List")
|
||||
safecall(widget.ResumeLayout, 1, widget)
|
||||
safecall(widget.SetLayout, widget, "List")
|
||||
safecall(widget.ResumeLayout, widget)
|
||||
return widget
|
||||
end
|
||||
end
|
||||
@@ -149,14 +204,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, 1, widget)
|
||||
safecall(widget.PauseLayout, widget)
|
||||
widget:Fire("OnRelease")
|
||||
safecall(widget.ReleaseChildren, 1, widget)
|
||||
safecall(widget.ReleaseChildren, widget)
|
||||
|
||||
if widget.OnRelease then
|
||||
widget:OnRelease()
|
||||
-- else
|
||||
-- error(strfmt("Widget type %s doesn't supply an OnRelease Function", widget.type))
|
||||
-- error(("Widget type %s doesn't supply an OnRelease Function"):format(widget.type))
|
||||
end
|
||||
for k in pairs(widget.userdata) do
|
||||
widget.userdata[k] = nil
|
||||
@@ -191,7 +246,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, 1, self.FocusedWidget)
|
||||
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
|
||||
end
|
||||
self.FocusedWidget = widget
|
||||
end
|
||||
@@ -201,7 +256,7 @@ end
|
||||
-- e.g. titlebar of a frame being clicked
|
||||
function AceGUI:ClearFocus()
|
||||
if self.FocusedWidget then
|
||||
safecall(self.FocusedWidget.ClearFocus, 1, self.FocusedWidget)
|
||||
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
|
||||
self.FocusedWidget = nil
|
||||
end
|
||||
end
|
||||
@@ -246,7 +301,6 @@ do
|
||||
frame:SetParent(nil)
|
||||
frame:SetParent(parent.content)
|
||||
self.parent = parent
|
||||
fixlevels(frame, frame:GetChildren())
|
||||
end
|
||||
|
||||
WidgetBase.SetCallback = function(self, name, func)
|
||||
@@ -255,11 +309,9 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
WidgetBase.Fire = function(self, name, argc, ...)
|
||||
argc = arg.n
|
||||
local func = self.events[name]
|
||||
if func then
|
||||
local success, ret = safecall(func, argc+3, self, name, argc, unpack(arg))
|
||||
WidgetBase.Fire = function(self, name, ...)
|
||||
if self.events[name] then
|
||||
local success, ret = safecall(self.events[name], self, name, ...)
|
||||
if success then
|
||||
return ret
|
||||
end
|
||||
@@ -310,8 +362,8 @@ do
|
||||
AceGUI:Release(self)
|
||||
end
|
||||
|
||||
WidgetBase.SetPoint = function(self, a1,a2,a3,a4,a5)
|
||||
return self.frame:SetPoint(a1,a2,a3,a4,a5)
|
||||
WidgetBase.SetPoint = function(self, ...)
|
||||
return self.frame:SetPoint(...)
|
||||
end
|
||||
|
||||
WidgetBase.ClearAllPoints = function(self)
|
||||
@@ -322,8 +374,8 @@ do
|
||||
return self.frame:GetNumPoints()
|
||||
end
|
||||
|
||||
WidgetBase.GetPoint = function(self, a1,a2,a3,a4,a5)
|
||||
return self.frame:GetPoint(a1,a2,a3,a4,a5)
|
||||
WidgetBase.GetPoint = function(self, ...)
|
||||
return self.frame:GetPoint(...)
|
||||
end
|
||||
|
||||
WidgetBase.GetUserDataTable = function(self)
|
||||
@@ -381,7 +433,7 @@ do
|
||||
if self.LayoutPaused then
|
||||
return
|
||||
end
|
||||
safecall(self.LayoutFunc, 2, self.content, self.children)
|
||||
safecall(self.LayoutFunc, self.content, self.children)
|
||||
end
|
||||
|
||||
--call this function to layout, makes sure layed out objects get a frame to get sizes etc
|
||||
@@ -410,51 +462,24 @@ do
|
||||
self:DoLayout()
|
||||
end
|
||||
|
||||
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
|
||||
WidgetContainerBase.AddChildren = function(self, ...)
|
||||
for i = 1, select("#", ...) do
|
||||
local child = select(i, ...)
|
||||
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(tremove(children))
|
||||
for i = 1,#children do
|
||||
AceGUI:Release(children[i])
|
||||
children[i] = nil
|
||||
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
|
||||
@@ -467,7 +492,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function FrameResize()
|
||||
local function FrameResize(this)
|
||||
local self = this.obj
|
||||
if this:GetWidth() and this:GetHeight() then
|
||||
if self.OnWidthSet then
|
||||
@@ -479,7 +504,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function ContentResize()
|
||||
local function ContentResize(this)
|
||||
if this:GetWidth() and this:GetHeight() then
|
||||
this.width = this:GetWidth()
|
||||
this.height = this:GetHeight()
|
||||
@@ -548,7 +573,7 @@ end
|
||||
function AceGUI:RegisterLayout(Name, LayoutFunc)
|
||||
assert(type(LayoutFunc) == "function")
|
||||
if type(Name) == "string" then
|
||||
Name = string.upper(Name)
|
||||
Name = Name:upper()
|
||||
end
|
||||
LayoutRegistry[Name] = LayoutFunc
|
||||
end
|
||||
@@ -557,7 +582,7 @@ end
|
||||
-- @param Name The name of the layout
|
||||
function AceGUI:GetLayout(Name)
|
||||
if type(Name) == "string" then
|
||||
Name = strupper(Name)
|
||||
Name = Name:upper()
|
||||
end
|
||||
return LayoutRegistry[Name]
|
||||
end
|
||||
@@ -604,7 +629,7 @@ AceGUI:RegisterLayout("List",
|
||||
function(content, children)
|
||||
local height = 0
|
||||
local width = content.width or content:GetWidth() or 0
|
||||
for i = 1, tgetn(children) do
|
||||
for i = 1, #children do
|
||||
local child = children[i]
|
||||
|
||||
local frame = child.frame
|
||||
@@ -633,7 +658,7 @@ AceGUI:RegisterLayout("List",
|
||||
|
||||
height = height + (frame.height or frame:GetHeight() or 0)
|
||||
end
|
||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
|
||||
safecall(content.obj.LayoutFinished, content.obj, nil, height)
|
||||
end)
|
||||
|
||||
-- A single control fills the whole content area
|
||||
@@ -644,15 +669,14 @@ AceGUI:RegisterLayout("Fill",
|
||||
children[1]:SetHeight(content:GetHeight() or 0)
|
||||
children[1].frame:SetAllPoints(content)
|
||||
children[1].frame:Show()
|
||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, children[1].frame:GetHeight())
|
||||
safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
|
||||
end
|
||||
end)
|
||||
|
||||
-- Ace3v: currently only a1 used
|
||||
local layoutrecursionblock = nil
|
||||
local function safelayoutcall(object, func, a1)
|
||||
local function safelayoutcall(object, func, ...)
|
||||
layoutrecursionblock = true
|
||||
object[func](object, a1)
|
||||
object[func](object, ...)
|
||||
layoutrecursionblock = nil
|
||||
end
|
||||
|
||||
@@ -679,7 +703,7 @@ AceGUI:RegisterLayout("Flow",
|
||||
local frameoffset
|
||||
local lastframeoffset
|
||||
local oversize
|
||||
for i = 1, tgetn(children) do
|
||||
for i = 1, #children do
|
||||
local child = children[i]
|
||||
oversize = nil
|
||||
local frame = child.frame
|
||||
@@ -785,5 +809,5 @@ AceGUI:RegisterLayout("Flow",
|
||||
end
|
||||
|
||||
height = height + rowheight + 3
|
||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
|
||||
safecall(content.obj.LayoutFinished, content.obj, nil, height)
|
||||
end)
|
||||
|
||||
@@ -1,4 +1,29 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="AceGUI-3.0.lua"/>
|
||||
<!-- Container -->
|
||||
<Script file="widgets\AceGUIContainer-BlizOptionsGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-DropDownGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-Frame.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-InlineGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-ScrollFrame.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-SimpleGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-TabGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-TreeGroup.lua"/>
|
||||
<Script file="widgets\AceGUIContainer-Window.lua"/>
|
||||
<!-- Widgets -->
|
||||
<Script file="widgets\AceGUIWidget-Button.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Button-ElvUI.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-CheckBox.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-ColorPicker.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-DropDown.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-EditBox.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Heading.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Icon.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Keybinding.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Label.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/>
|
||||
<Script file="widgets\AceGUIWidget-Slider.lua"/>
|
||||
</Ui>
|
||||
|
||||
@@ -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", 1, value)
|
||||
self.parentgroup:Fire("OnGroupSelected", 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", 1, group)
|
||||
self:Fire("OnGroupSelected", group)
|
||||
end,
|
||||
|
||||
["OnWidthSet"] = function(self, width)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Frame Container
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Frame", 24
|
||||
local Type, Version = "Frame", 25
|
||||
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
|
||||
@@ -22,26 +20,30 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Button_OnClick()
|
||||
local function Button_OnClick(frame)
|
||||
PlaySound("gsTitleOptionExit")
|
||||
this.obj:Hide()
|
||||
frame.obj:Hide()
|
||||
end
|
||||
|
||||
local function Frame_OnClose()
|
||||
this.obj:Fire("OnClose")
|
||||
local function Frame_OnShow(frame)
|
||||
frame.obj:Fire("OnShow")
|
||||
end
|
||||
|
||||
local function Frame_OnMouseDown()
|
||||
local function Frame_OnClose(frame)
|
||||
frame.obj:Fire("OnClose")
|
||||
end
|
||||
|
||||
local function Frame_OnMouseDown(frame)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function Title_OnMouseDown()
|
||||
this:GetParent():StartMoving()
|
||||
local function Title_OnMouseDown(frame)
|
||||
frame:GetParent():StartMoving()
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function MoverSizer_OnMouseUp()
|
||||
local frame = this:GetParent()
|
||||
local function MoverSizer_OnMouseUp(mover)
|
||||
local frame = mover:GetParent()
|
||||
frame:StopMovingOrSizing()
|
||||
local self = frame.obj
|
||||
local status = self.status or self.localstatus
|
||||
@@ -51,27 +53,27 @@ local function MoverSizer_OnMouseUp()
|
||||
status.left = frame:GetLeft()
|
||||
end
|
||||
|
||||
local function SizerSE_OnMouseDown()
|
||||
this:GetParent():StartSizing("BOTTOMRIGHT")
|
||||
local function SizerSE_OnMouseDown(frame)
|
||||
frame:GetParent():StartSizing("BOTTOMRIGHT")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function SizerS_OnMouseDown()
|
||||
this:GetParent():StartSizing("BOTTOM")
|
||||
local function SizerS_OnMouseDown(frame)
|
||||
frame:GetParent():StartSizing("BOTTOM")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function SizerE_OnMouseDown()
|
||||
this:GetParent():StartSizing("RIGHT")
|
||||
local function SizerE_OnMouseDown(frame)
|
||||
frame:GetParent():StartSizing("RIGHT")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function StatusBar_OnEnter()
|
||||
this.obj:Fire("OnEnterStatusBar")
|
||||
local function StatusBar_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnterStatusBar")
|
||||
end
|
||||
|
||||
local function StatusBar_OnLeave()
|
||||
this.obj:Fire("OnLeaveStatusBar")
|
||||
local function StatusBar_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeaveStatusBar")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -85,7 +87,7 @@ local methods = {
|
||||
self:SetStatusText()
|
||||
self:ApplyStatus()
|
||||
self:Show()
|
||||
self:EnableResize(true)
|
||||
self:EnableResize(true)
|
||||
end,
|
||||
|
||||
["OnRelease"] = function(self)
|
||||
@@ -105,7 +107,7 @@ local methods = {
|
||||
|
||||
["OnHeightSet"] = function(self, height)
|
||||
local content = self.content
|
||||
local contentheight = height - 67
|
||||
local contentheight = height - 57
|
||||
if contentheight < 0 then
|
||||
contentheight = 0
|
||||
end
|
||||
@@ -154,7 +156,7 @@ local methods = {
|
||||
frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
|
||||
frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
|
||||
else
|
||||
frame:SetPoint("CENTER", UIParent)
|
||||
frame:SetPoint("CENTER")
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -188,6 +190,7 @@ 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)
|
||||
|
||||
@@ -245,9 +248,8 @@ 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:SetPoint("BOTTOMRIGHT")
|
||||
sizer_se:SetWidth(25)
|
||||
sizer_se:SetHeight(25)
|
||||
sizer_se:EnableMouse()
|
||||
@@ -255,13 +257,24 @@ local function Constructor()
|
||||
sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
|
||||
|
||||
local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
|
||||
line1:SetPoint("BOTTOMRIGHT", -10, 10)
|
||||
line1:SetTexture("Interface\\Cursor\\Item")
|
||||
line1:SetTexCoord(1, 0, 1, 0)
|
||||
line1:SetWidth(14)
|
||||
line1:SetHeight(14)
|
||||
line1:SetPoint("BOTTOMRIGHT", -8, 8)
|
||||
line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
||||
local x = 0.1 * 14/17
|
||||
line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
||||
|
||||
local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
|
||||
line2:SetWidth(8)
|
||||
line2:SetHeight(8)
|
||||
line2:SetPoint("BOTTOMRIGHT", -8, 8)
|
||||
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
||||
local x = 0.1 * 8/17
|
||||
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
||||
|
||||
local sizer_s = CreateFrame("Frame", nil, frame)
|
||||
sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
|
||||
sizer_s:SetPoint("BOTTOMLEFT", 0, 0)
|
||||
sizer_s:SetPoint("BOTTOMLEFT")
|
||||
sizer_s:SetHeight(25)
|
||||
sizer_s:EnableMouse(true)
|
||||
sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
|
||||
@@ -269,7 +282,7 @@ local function Constructor()
|
||||
|
||||
local sizer_e = CreateFrame("Frame", nil, frame)
|
||||
sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
|
||||
sizer_e:SetPoint("TOPRIGHT", 0, 0)
|
||||
sizer_e:SetPoint("TOPRIGHT")
|
||||
sizer_e:SetWidth(25)
|
||||
sizer_e:EnableMouse(true)
|
||||
sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
|
||||
@@ -278,7 +291,7 @@ local function Constructor()
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, frame)
|
||||
content:SetPoint("TOPLEFT", 17, -27)
|
||||
--content:SetPoint("BOTTOMRIGHT", -17, 40)
|
||||
content:SetPoint("BOTTOMRIGHT", -17, 40)
|
||||
|
||||
local widget = {
|
||||
localstatus = {},
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
ScrollFrame Container
|
||||
Plain container that scrolls its content and doesn't grow in height.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "ScrollFrame", 24
|
||||
local Type, Version = "ScrollFrame", 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 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
|
||||
@@ -17,24 +16,24 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function FixScrollOnUpdate()
|
||||
this:SetScript("OnUpdate", nil)
|
||||
this.obj:FixScroll()
|
||||
local function FixScrollOnUpdate(frame)
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
frame.obj:FixScroll()
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function ScrollFrame_OnMouseWheel()
|
||||
this.obj:MoveScroll(arg1)
|
||||
local function ScrollFrame_OnMouseWheel(frame, value)
|
||||
frame.obj:MoveScroll(value)
|
||||
end
|
||||
|
||||
local function ScrollFrame_OnSizeChanged()
|
||||
this:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
local function ScrollFrame_OnSizeChanged(frame)
|
||||
frame:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||
end
|
||||
|
||||
local function ScrollBar_OnScrollValueChanged()
|
||||
this.obj:SetScroll(arg1)
|
||||
local function ScrollBar_OnScrollValueChanged(frame, value)
|
||||
frame.obj:SetScroll(value)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -51,7 +50,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")
|
||||
self.scrollbar:Hide()
|
||||
self.scrollBarShown = nil
|
||||
self.content.height, self.content.width = nil, nil
|
||||
@@ -90,46 +89,40 @@ local methods = {
|
||||
end,
|
||||
|
||||
["FixScroll"] = function(self)
|
||||
|
||||
if self.updateLock then return end
|
||||
self.updateLock = true
|
||||
local status = self.status or self.localstatus
|
||||
local scrollframe, content, scrollbar = self.scrollframe, self.content, self.scrollbar
|
||||
local viewheight, height = self.scrollframe:GetHeight(), self.content:GetHeight()
|
||||
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
|
||||
local offset = status.offset or 0
|
||||
local curvalue = scrollbar:GetValue()
|
||||
local curvalue = self.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 height < viewheight + 2 then
|
||||
if viewheight < height + 2 then
|
||||
if self.scrollBarShown then
|
||||
self.scrollBarShown = nil
|
||||
scrollbar:Hide()
|
||||
scrollbar:SetValue(0)
|
||||
scrollframe:SetPoint("BOTTOMRIGHT",0,0)
|
||||
self.scrollbar:Hide()
|
||||
self.scrollbar:SetValue(0)
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT")
|
||||
self:DoLayout()
|
||||
end
|
||||
offset = 0
|
||||
else
|
||||
if not self.scrollBarShown then
|
||||
self.scrollBarShown = true
|
||||
scrollbar:Show()
|
||||
scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
|
||||
self.scrollbar:Show()
|
||||
self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
|
||||
self:DoLayout()
|
||||
end
|
||||
local value = (offset / (height - viewheight) * 1000)
|
||||
if value > 1000 then
|
||||
value = 1000
|
||||
offset = height - viewheight
|
||||
end
|
||||
scrollbar:SetValue(value)
|
||||
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
|
||||
end
|
||||
end
|
||||
status.offset = offset
|
||||
scrollframe:SetScrollChild(content)
|
||||
content:ClearAllPoints()
|
||||
content:SetPoint("TOPLEFT", 0, offset)
|
||||
content:SetPoint("TOPRIGHT", 0, offset)
|
||||
self.updateLock = nil
|
||||
end,
|
||||
|
||||
@@ -148,7 +141,6 @@ local methods = {
|
||||
|
||||
["OnWidthSet"] = function(self, width)
|
||||
local content = self.content
|
||||
content:SetWidth(width)
|
||||
content.width = width
|
||||
end,
|
||||
|
||||
@@ -165,13 +157,13 @@ 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")
|
||||
scrollframe:SetPoint("BOTTOMRIGHT")
|
||||
scrollframe:EnableMouseWheel(true)
|
||||
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
|
||||
-- scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
|
||||
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
|
||||
|
||||
local scrollbar = CreateFrame("Slider", format("AceConfigDialogScrollFrame%dScrollBar", num), scrollframe, "UIPanelScrollBarTemplate")
|
||||
local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
|
||||
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
|
||||
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
|
||||
scrollbar:SetMinMaxValues(0, 1000)
|
||||
@@ -188,8 +180,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")
|
||||
content:SetPoint("TOPRIGHT")
|
||||
content:SetHeight(400)
|
||||
scrollframe:SetScrollChild(content)
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
TabGroup Container
|
||||
Container that uses tabs on top to switch between groups.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "TabGroup-ElvUI", 31
|
||||
local Type, Version = "TabGroup", 31
|
||||
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, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
|
||||
local getn = table.getn
|
||||
local format = string.format
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
@@ -54,34 +52,34 @@ local function Tab_SetDisabled(frame, disabled)
|
||||
UpdateTabLook(frame)
|
||||
end
|
||||
|
||||
local function BuildTabsOnUpdate()
|
||||
local self = this.obj
|
||||
local function BuildTabsOnUpdate(frame)
|
||||
local self = frame.obj
|
||||
self:BuildTabs()
|
||||
this:SetScript("OnUpdate", nil)
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Tab_OnClick()
|
||||
if not (this.selected or this.disabled) then
|
||||
local function Tab_OnClick(frame)
|
||||
if not (frame.selected or frame.disabled) then
|
||||
PlaySound("igCharacterInfoTab")
|
||||
this.obj:SelectTab(this.value)
|
||||
frame.obj:SelectTab(frame.value)
|
||||
end
|
||||
end
|
||||
|
||||
local function Tab_OnEnter()
|
||||
local self = this.obj
|
||||
self:Fire("OnTabEnter", 2, self.tabs[this.id].value, this)
|
||||
local function Tab_OnEnter(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
|
||||
end
|
||||
|
||||
local function Tab_OnLeave()
|
||||
local self = this.obj
|
||||
self:Fire("OnTabLeave", 2, self.tabs[this.id].value, this)
|
||||
local function Tab_OnLeave(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
|
||||
end
|
||||
|
||||
local function Tab_OnShow()
|
||||
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
|
||||
local function Tab_OnShow(frame)
|
||||
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -104,11 +102,10 @@ local methods = {
|
||||
end,
|
||||
|
||||
["CreateTab"] = function(self, id)
|
||||
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
|
||||
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
|
||||
local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
|
||||
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
|
||||
tab.obj = self
|
||||
tab.id = id
|
||||
tab:SetHeight(24)
|
||||
|
||||
tab.text = _G[tabname .. "Text"]
|
||||
tab.text:ClearAllPoints()
|
||||
@@ -156,7 +153,7 @@ local methods = {
|
||||
end
|
||||
status.selected = value
|
||||
if found then
|
||||
self:Fire("OnGroupSelected",1,value)
|
||||
self:Fire("OnGroupSelected",value)
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -196,16 +193,16 @@ local methods = {
|
||||
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
|
||||
|
||||
local numtabs = getn(tablist)
|
||||
for i = numtabs+1, numtabs, 1 do
|
||||
for i = (#tablist)+1, #tabs, 1 do
|
||||
tabs[i]:Hide()
|
||||
end
|
||||
|
||||
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
|
||||
local numtabs = #tablist
|
||||
local numrows = 1
|
||||
local usedwidth = 0
|
||||
|
||||
for i = 1, numtabs do
|
||||
for i = 1, #tablist do
|
||||
--If this is not the first tab of a row and there isn't room for it
|
||||
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
|
||||
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
|
||||
@@ -216,7 +213,7 @@ local methods = {
|
||||
usedwidth = usedwidth + widths[i]
|
||||
end
|
||||
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
|
||||
rowends[numrows] = numtabs
|
||||
rowends[numrows] = #tablist
|
||||
|
||||
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
|
||||
if numrows > 1 then
|
||||
|
||||
@@ -10,8 +10,6 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
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 tgetn = table.getn
|
||||
local strfmt = string.format
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
@@ -82,11 +80,11 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
|
||||
local line = button.line
|
||||
button.level = level
|
||||
if ( level == 1 ) then
|
||||
button.text:SetFontObject("GameFontNormal")
|
||||
button:SetTextFontObject("GameFontNormal")
|
||||
button:SetHighlightFontObject("GameFontHighlight")
|
||||
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
|
||||
else
|
||||
button.text:SetFontObject("GameFontHighlightSmall")
|
||||
button:SetTextFontObject("GameFontHighlightSmall")
|
||||
button:SetHighlightFontObject("GameFontHighlightSmall")
|
||||
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
|
||||
end
|
||||
@@ -156,134 +154,134 @@ local function addLine(self, v, tree, level, parent)
|
||||
else
|
||||
line.hasChildren = nil
|
||||
end
|
||||
tinsert(self.lines, line)
|
||||
self.lines[#self.lines+1] = line
|
||||
return line
|
||||
end
|
||||
|
||||
--fire an update after one frame to catch the treeframes height
|
||||
local function FirstFrameUpdate()
|
||||
local self = this.obj
|
||||
this:SetScript("OnUpdate", nil)
|
||||
local function FirstFrameUpdate(frame)
|
||||
local self = frame.obj
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
self:RefreshTree()
|
||||
end
|
||||
|
||||
local function BuildUniqueValue(...)
|
||||
local n = tgetn(arg)
|
||||
local n = select('#', ...)
|
||||
if n == 1 then
|
||||
return arg[1]
|
||||
return ...
|
||||
else
|
||||
return (unpack(arg)).."\001"..BuildUniqueValue(select(2, unpack(arg)))
|
||||
return (...).."\001"..BuildUniqueValue(select(2,...))
|
||||
end
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Expand_OnClick()
|
||||
local button = this.button
|
||||
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()
|
||||
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()
|
||||
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()
|
||||
self:RefreshTree()
|
||||
end
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function Button_OnDoubleClick()
|
||||
local self = this.obj
|
||||
local function Button_OnDoubleClick(button)
|
||||
local self = button.obj
|
||||
local status = self.status or self.localstatus
|
||||
local status = (self.status or self.localstatus).groups
|
||||
status[this.uniquevalue] = not status[this.uniquevalue]
|
||||
status[button.uniquevalue] = not status[button.uniquevalue]
|
||||
self:RefreshTree()
|
||||
end
|
||||
|
||||
local function Button_OnEnter()
|
||||
local self = this.obj
|
||||
self:Fire("OnButtonEnter", 2, this.uniquevalue, this)
|
||||
local function Button_OnEnter(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnButtonEnter", frame.uniquevalue, frame)
|
||||
|
||||
if self.enabletooltips then
|
||||
GameTooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
GameTooltip:SetPoint("LEFT",this,"RIGHT")
|
||||
GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, true)
|
||||
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
|
||||
GameTooltip:SetPoint("LEFT",frame,"RIGHT")
|
||||
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, 1)
|
||||
|
||||
GameTooltip:Show()
|
||||
end
|
||||
end
|
||||
|
||||
local function Button_OnLeave()
|
||||
local self = this.obj
|
||||
self:Fire("OnButtonLeave", 2, this.uniquevalue, this)
|
||||
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()
|
||||
if this.obj.noupdate then return end
|
||||
local self = this.obj
|
||||
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(arg1 + 0.5)
|
||||
status.scrollvalue = value
|
||||
self:RefreshTree()
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function Tree_OnSizeChanged()
|
||||
this.obj:RefreshTree()
|
||||
local function Tree_OnSizeChanged(frame)
|
||||
frame.obj:RefreshTree()
|
||||
end
|
||||
|
||||
local function Tree_OnMouseWheel()
|
||||
local self = this.obj
|
||||
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 - arg1))
|
||||
local newvalue = math_min(max,math_max(min,value - delta))
|
||||
if value ~= newvalue then
|
||||
scrollbar:SetValue(newvalue)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function Dragger_OnLeave()
|
||||
this:SetBackdropColor(1, 1, 1, 0)
|
||||
local function Dragger_OnLeave(frame)
|
||||
frame:SetBackdropColor(1, 1, 1, 0)
|
||||
end
|
||||
|
||||
local function Dragger_OnEnter()
|
||||
this:SetBackdropColor(1, 1, 1, 0.8)
|
||||
local function Dragger_OnEnter(frame)
|
||||
frame:SetBackdropColor(1, 1, 1, 0.8)
|
||||
end
|
||||
|
||||
local function Dragger_OnMouseDown()
|
||||
local treeframe = this:GetParent()
|
||||
local function Dragger_OnMouseDown(frame)
|
||||
local treeframe = frame:GetParent()
|
||||
treeframe:StartSizing("RIGHT")
|
||||
end
|
||||
|
||||
local function Dragger_OnMouseUp()
|
||||
local treeframe = this:GetParent()
|
||||
local function Dragger_OnMouseUp(frame)
|
||||
local treeframe = frame:GetParent()
|
||||
local self = treeframe.obj
|
||||
local this = treeframe:GetParent()
|
||||
local frame = 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", this, "TOPLEFT",0,0)
|
||||
treeframe:SetPoint("BOTTOMLEFT", this, "BOTTOMLEFT",0,0)
|
||||
treeframe:SetPoint("TOPLEFT", frame, "TOPLEFT",0,0)
|
||||
treeframe:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0)
|
||||
|
||||
local status = self.status or self.localstatus
|
||||
status.treewidth = treeframe:GetWidth()
|
||||
|
||||
treeframe.obj:Fire("OnTreeResize", 1, treeframe:GetWidth())
|
||||
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
|
||||
-- recalculate the content width
|
||||
treeframe.obj:OnWidthSet(status.fullwidth)
|
||||
-- update the layout of the content
|
||||
@@ -297,7 +295,6 @@ 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)
|
||||
@@ -322,36 +319,8 @@ local methods = {
|
||||
|
||||
["CreateButton"] = function(self)
|
||||
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
|
||||
|
||||
local button = CreateFrame("Button", strfmt("AceGUI30TreeButton%d", num), self.treeframe)
|
||||
local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "InterfaceOptionsButtonTemplate")
|
||||
button.obj = self
|
||||
button:SetWidth(DEFAULT_TREE_WIDTH)
|
||||
button:SetHeight(18)
|
||||
|
||||
local toggle = CreateFrame("Button", "$parentToggle", button)
|
||||
toggle:SetWidth(14)
|
||||
toggle:SetHeight(14)
|
||||
toggle:SetPoint("TOPRIGHT", button, "TOPRIGHT", -6, -1)
|
||||
toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
|
||||
toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
|
||||
toggle:SetHighlightTexture("Interface\Buttons\UI-PlusButton-Hilight", "ADD")
|
||||
button.toggle = toggle
|
||||
|
||||
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)
|
||||
@@ -445,7 +414,7 @@ local methods = {
|
||||
|
||||
self:BuildLevel(tree, 1)
|
||||
|
||||
local numlines = tgetn(lines)
|
||||
local numlines = #lines
|
||||
|
||||
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
|
||||
if maxlines <= 0 then return end
|
||||
@@ -499,7 +468,6 @@ local methods = {
|
||||
end
|
||||
|
||||
local buttonnum = 1
|
||||
local treewidth = treeframe:GetWidth()
|
||||
for i = first, last do
|
||||
local line = lines[i]
|
||||
local button = buttons[buttonnum]
|
||||
@@ -509,33 +477,33 @@ local methods = {
|
||||
buttons[buttonnum] = button
|
||||
button:SetParent(treeframe)
|
||||
button:SetFrameLevel(treeframe:GetFrameLevel()+1)
|
||||
end
|
||||
|
||||
button:ClearAllPoints()
|
||||
if buttonnum == 1 then
|
||||
if self.showscroll then
|
||||
button:SetWidth(treewidth - 22)
|
||||
button:SetPoint("TOPRIGHT", -22, -10)
|
||||
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:SetWidth(treewidth)
|
||||
button:SetPoint("TOPRIGHT", 0, -10)
|
||||
button:SetPoint("TOPRIGHT", buttons[buttonnum-1], "BOTTOMRIGHT",0,0)
|
||||
button:SetPoint("TOPLEFT", buttons[buttonnum-1], "BOTTOMLEFT",0,0)
|
||||
end
|
||||
else
|
||||
button:SetWidth(self.showscroll and (treewidth - 22) or treewidth)
|
||||
button:SetPoint("TOPRIGHT", buttons[buttonnum-1], "BOTTOMRIGHT",0,0)
|
||||
end
|
||||
|
||||
UpdateButton(button, line, status.selected == line.uniquevalue, line.hasChildren, groupstatus[line.uniquevalue] )
|
||||
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", 1, value)
|
||||
self:Fire("OnGroupSelected", value)
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -543,20 +511,21 @@ local methods = {
|
||||
self.filter = false
|
||||
local status = self.status or self.localstatus
|
||||
local groups = status.groups
|
||||
for i = 1, arg.n do
|
||||
groups[tconcat(arg, "\001", 1, i)] = true
|
||||
local path = {...}
|
||||
for i = 1, #path do
|
||||
groups[tconcat(path, "\001", 1, i)] = true
|
||||
end
|
||||
status.selected = uniquevalue
|
||||
self:RefreshTree(true)
|
||||
self:Fire("OnGroupSelected", 1, uniquevalue)
|
||||
self:Fire("OnGroupSelected", uniquevalue)
|
||||
end,
|
||||
|
||||
["SelectByPath"] = function(self, ...)
|
||||
self:Select(BuildUniqueValue(unpack(arg)), unpack(arg))
|
||||
self:Select(BuildUniqueValue(...), ...)
|
||||
end,
|
||||
|
||||
["SelectByValue"] = function(self, uniquevalue)
|
||||
self:Select(uniquevalue, strsplit("\001", uniquevalue))
|
||||
self:Select(uniquevalue, ("\001"):split(uniquevalue))
|
||||
end,
|
||||
|
||||
["ShowScroll"] = function(self, show)
|
||||
@@ -564,13 +533,11 @@ local methods = {
|
||||
if show then
|
||||
self.scrollbar:Show()
|
||||
if self.buttons[1] then
|
||||
self.buttons[1]:SetWidth(self.treeframe:GetWidth() - 22)
|
||||
self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10)
|
||||
end
|
||||
else
|
||||
self.scrollbar:Hide()
|
||||
if self.buttons[1] then
|
||||
self.buttons[1]:SetWidth(self.treeframe:GetWidth())
|
||||
self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10)
|
||||
end
|
||||
end
|
||||
@@ -665,8 +632,8 @@ local function Constructor()
|
||||
local frame = CreateFrame("Frame", nil, UIParent)
|
||||
|
||||
local treeframe = CreateFrame("Frame", nil, frame)
|
||||
treeframe:SetPoint("TOPLEFT", 0, 0)
|
||||
treeframe:SetPoint("BOTTOMLEFT", 0, 0)
|
||||
treeframe:SetPoint("TOPLEFT")
|
||||
treeframe:SetPoint("BOTTOMLEFT")
|
||||
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
|
||||
treeframe:EnableMouseWheel(true)
|
||||
treeframe:SetBackdrop(PaneBackdrop)
|
||||
@@ -690,7 +657,7 @@ local function Constructor()
|
||||
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
|
||||
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
|
||||
|
||||
local scrollbar = CreateFrame("Slider", strfmt("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
|
||||
local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
|
||||
scrollbar:SetScript("OnValueChanged", nil)
|
||||
scrollbar:SetPoint("TOPRIGHT", -10, -26)
|
||||
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
|
||||
@@ -706,7 +673,7 @@ local function Constructor()
|
||||
|
||||
local border = CreateFrame("Frame",nil,frame)
|
||||
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
|
||||
border:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||
border:SetPoint("BOTTOMRIGHT")
|
||||
border:SetBackdrop(PaneBackdrop)
|
||||
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
|
||||
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
@@ -739,4 +706,4 @@ local function Constructor()
|
||||
return AceGUI:RegisterAsContainer(widget)
|
||||
end
|
||||
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
AceGUI:RegisterWidgetType(Type, Constructor, Version)
|
||||
@@ -21,27 +21,31 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
]]
|
||||
do
|
||||
local Type = "Window"
|
||||
local Version = 4
|
||||
local Version = 5
|
||||
|
||||
local function frameOnClose()
|
||||
local function frameOnShow(this)
|
||||
this.obj:Fire("OnShow")
|
||||
end
|
||||
|
||||
local function frameOnClose(this)
|
||||
this.obj:Fire("OnClose")
|
||||
end
|
||||
|
||||
local function closeOnClick()
|
||||
|
||||
local function closeOnClick(this)
|
||||
PlaySound("gsTitleOptionExit")
|
||||
this.obj:Hide()
|
||||
end
|
||||
|
||||
local function frameOnMouseDown()
|
||||
|
||||
local function frameOnMouseDown(this)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function titleOnMouseDown()
|
||||
|
||||
local function titleOnMouseDown(this)
|
||||
this:GetParent():StartMoving()
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function frameOnMouseUp()
|
||||
|
||||
local function frameOnMouseUp(this)
|
||||
local frame = this:GetParent()
|
||||
frame:StopMovingOrSizing()
|
||||
local self = frame.obj
|
||||
@@ -51,42 +55,42 @@ do
|
||||
status.top = frame:GetTop()
|
||||
status.left = frame:GetLeft()
|
||||
end
|
||||
|
||||
local function sizerseOnMouseDown()
|
||||
|
||||
local function sizerseOnMouseDown(this)
|
||||
this:GetParent():StartSizing("BOTTOMRIGHT")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function sizersOnMouseDown()
|
||||
|
||||
local function sizersOnMouseDown(this)
|
||||
this:GetParent():StartSizing("BOTTOM")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function sizereOnMouseDown()
|
||||
|
||||
local function sizereOnMouseDown(this)
|
||||
this:GetParent():StartSizing("RIGHT")
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function sizerOnMouseUp()
|
||||
|
||||
local function sizerOnMouseUp(this)
|
||||
this:GetParent():StopMovingOrSizing()
|
||||
end
|
||||
|
||||
local function SetTitle(self,title)
|
||||
self.titletext:SetText(title)
|
||||
end
|
||||
|
||||
|
||||
local function SetStatusText(self,text)
|
||||
-- self.statustext:SetText(text)
|
||||
end
|
||||
|
||||
|
||||
local function Hide(self)
|
||||
self.frame:Hide()
|
||||
end
|
||||
|
||||
|
||||
local function Show(self)
|
||||
self.frame:Show()
|
||||
end
|
||||
|
||||
|
||||
local function OnAcquire(self)
|
||||
self.frame:SetParent(UIParent)
|
||||
self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
@@ -94,21 +98,21 @@ do
|
||||
self:EnableResize(true)
|
||||
self:Show()
|
||||
end
|
||||
|
||||
|
||||
local function OnRelease(self)
|
||||
self.status = nil
|
||||
for k in pairs(self.localstatus) do
|
||||
self.localstatus[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- called to set an external table to store status in
|
||||
local function SetStatusTable(self, status)
|
||||
assert(type(status) == "table")
|
||||
self.status = status
|
||||
self:ApplyStatus()
|
||||
end
|
||||
|
||||
|
||||
local function ApplyStatus(self)
|
||||
local status = self.status or self.localstatus
|
||||
local frame = self.frame
|
||||
@@ -121,7 +125,7 @@ do
|
||||
frame:SetPoint("CENTER",UIParent,"CENTER")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function OnWidthSet(self, width)
|
||||
local content = self.content
|
||||
local contentwidth = width - 34
|
||||
@@ -131,8 +135,8 @@ do
|
||||
content:SetWidth(contentwidth)
|
||||
content.width = contentwidth
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local function OnHeightSet(self, height)
|
||||
local content = self.content
|
||||
local contentheight = height - 57
|
||||
@@ -142,19 +146,19 @@ do
|
||||
content:SetHeight(contentheight)
|
||||
content.height = contentheight
|
||||
end
|
||||
|
||||
|
||||
local function EnableResize(self, state)
|
||||
local func = state and "Show" or "Hide"
|
||||
self.sizer_se[func](self.sizer_se)
|
||||
self.sizer_s[func](self.sizer_s)
|
||||
self.sizer_e[func](self.sizer_e)
|
||||
end
|
||||
|
||||
|
||||
local function Constructor()
|
||||
local frame = CreateFrame("Frame",nil,UIParent)
|
||||
local self = {}
|
||||
self.type = "Window"
|
||||
|
||||
|
||||
self.Hide = Hide
|
||||
self.Show = Show
|
||||
self.SetTitle = SetTitle
|
||||
@@ -166,9 +170,9 @@ do
|
||||
self.OnWidthSet = OnWidthSet
|
||||
self.OnHeightSet = OnHeightSet
|
||||
self.EnableResize = EnableResize
|
||||
|
||||
|
||||
self.localstatus = {}
|
||||
|
||||
|
||||
self.frame = frame
|
||||
frame.obj = self
|
||||
frame:SetWidth(700)
|
||||
@@ -179,7 +183,8 @@ do
|
||||
frame:SetResizable(true)
|
||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
frame:SetScript("OnMouseDown", frameOnMouseDown)
|
||||
|
||||
|
||||
frame:SetScript("OnShow",frameOnShow)
|
||||
frame:SetScript("OnHide",frameOnClose)
|
||||
frame:SetMinResize(240,240)
|
||||
frame:SetToplevel(true)
|
||||
@@ -188,81 +193,81 @@ do
|
||||
titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
|
||||
titlebg:SetPoint("TOPLEFT", 9, -6)
|
||||
titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
|
||||
|
||||
|
||||
local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
|
||||
dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
|
||||
dialogbg:SetPoint("TOPLEFT", 8, -24)
|
||||
dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
|
||||
dialogbg:SetVertexColor(0, 0, 0, .75)
|
||||
|
||||
|
||||
local topleft = frame:CreateTexture(nil, "BORDER")
|
||||
topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
topleft:SetWidth(64)
|
||||
topleft:SetHeight(64)
|
||||
topleft:SetPoint("TOPLEFT")
|
||||
topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
|
||||
|
||||
|
||||
local topright = frame:CreateTexture(nil, "BORDER")
|
||||
topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
topright:SetWidth(64)
|
||||
topright:SetHeight(64)
|
||||
topright:SetPoint("TOPRIGHT")
|
||||
topright:SetTexCoord(0.625, 0.75, 0, 1)
|
||||
|
||||
|
||||
local top = frame:CreateTexture(nil, "BORDER")
|
||||
top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
top:SetHeight(64)
|
||||
top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
|
||||
top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
|
||||
top:SetTexCoord(0.25, 0.369140625, 0, 1)
|
||||
|
||||
|
||||
local bottomleft = frame:CreateTexture(nil, "BORDER")
|
||||
bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottomleft:SetWidth(64)
|
||||
bottomleft:SetHeight(64)
|
||||
bottomleft:SetPoint("BOTTOMLEFT")
|
||||
bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
|
||||
|
||||
|
||||
local bottomright = frame:CreateTexture(nil, "BORDER")
|
||||
bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottomright:SetWidth(64)
|
||||
bottomright:SetHeight(64)
|
||||
bottomright:SetPoint("BOTTOMRIGHT")
|
||||
bottomright:SetTexCoord(0.875, 1, 0, 1)
|
||||
|
||||
|
||||
local bottom = frame:CreateTexture(nil, "BORDER")
|
||||
bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
bottom:SetHeight(64)
|
||||
bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
|
||||
bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
|
||||
bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
|
||||
|
||||
|
||||
local left = frame:CreateTexture(nil, "BORDER")
|
||||
left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
left:SetWidth(64)
|
||||
left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
|
||||
left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
|
||||
left:SetTexCoord(0.001953125, 0.125, 0, 1)
|
||||
|
||||
|
||||
local right = frame:CreateTexture(nil, "BORDER")
|
||||
right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
|
||||
right:SetWidth(64)
|
||||
right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
|
||||
right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
|
||||
right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
|
||||
|
||||
|
||||
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
|
||||
close:SetPoint("TOPRIGHT", 2, 1)
|
||||
close:SetScript("OnClick", closeOnClick)
|
||||
self.closebutton = close
|
||||
close.obj = self
|
||||
|
||||
|
||||
local titletext = frame:CreateFontString(nil, "ARTWORK")
|
||||
titletext:SetFontObject(GameFontNormal)
|
||||
titletext:SetPoint("TOPLEFT", 12, -8)
|
||||
titletext:SetPoint("TOPRIGHT", -32, -8)
|
||||
self.titletext = titletext
|
||||
|
||||
|
||||
local title = CreateFrame("Button", nil, frame)
|
||||
title:SetPoint("TOPLEFT", titlebg)
|
||||
title:SetPoint("BOTTOMRIGHT", titlebg)
|
||||
@@ -270,7 +275,7 @@ do
|
||||
title:SetScript("OnMouseDown",titleOnMouseDown)
|
||||
title:SetScript("OnMouseUp", frameOnMouseUp)
|
||||
self.title = title
|
||||
|
||||
|
||||
local sizer_se = CreateFrame("Frame",nil,frame)
|
||||
sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
|
||||
sizer_se:SetWidth(25)
|
||||
@@ -306,7 +311,7 @@ do
|
||||
sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
|
||||
sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
|
||||
self.sizer_s = sizer_s
|
||||
|
||||
|
||||
local sizer_e = CreateFrame("Frame",nil,frame)
|
||||
sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
|
||||
sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
|
||||
@@ -315,17 +320,17 @@ do
|
||||
sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
|
||||
sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
|
||||
self.sizer_e = sizer_e
|
||||
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame",nil,frame)
|
||||
self.content = content
|
||||
content.obj = self
|
||||
content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
|
||||
content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
|
||||
|
||||
|
||||
AceGUI:RegisterAsContainer(self)
|
||||
return self
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
||||
end
|
||||
|
||||
@@ -2,92 +2,32 @@
|
||||
Button Widget (Modified to change text color on SetDisabled method)
|
||||
Graphical Button.
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "Button-ElvUI", 2
|
||||
local Type, Version = "Button-ElvUI", 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 pairs, unpack = pairs, unpack
|
||||
local pairs = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local _G = _G
|
||||
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
-- GLOBALS: GameTooltip, ElvUI
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local dragdropButton
|
||||
local function lockTooltip()
|
||||
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
||||
GameTooltip:SetText(" ")
|
||||
GameTooltip:Show()
|
||||
end
|
||||
local function dragdrop_OnMouseDown(...)
|
||||
if this.obj.dragOnMouseDown then
|
||||
dragdropButton.mouseDownFrame = this
|
||||
dragdropButton:SetText(this.obj.value or "Unknown")
|
||||
dragdropButton:SetWidth(this:GetWidth())
|
||||
dragdropButton:SetHeight(this:SetHeight())
|
||||
this.obj.dragOnMouseDown(this, unpack(arg))
|
||||
end
|
||||
end
|
||||
local function dragdrop_OnMouseUp(...)
|
||||
if this.obj.dragOnMouseUp then
|
||||
this:SetAlpha(1)
|
||||
GameTooltip:Hide()
|
||||
dragdropButton:Hide()
|
||||
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then
|
||||
this.obj.dragOnMouseUp(this, unpack(arg))
|
||||
this.obj.ActivateMultiControl(this.obj, unpack(arg))
|
||||
end
|
||||
dragdropButton.enteredFrame = nil
|
||||
dragdropButton.mouseDownFrame = nil
|
||||
end
|
||||
end
|
||||
local function dragdrop_OnLeave(...)
|
||||
if this.obj.dragOnLeave then
|
||||
if dragdropButton.mouseDownFrame then
|
||||
lockTooltip()
|
||||
end
|
||||
if this == dragdropButton.mouseDownFrame then
|
||||
this:SetAlpha(0)
|
||||
dragdropButton:Show()
|
||||
this.obj.dragOnLeave(this, unpack(arg))
|
||||
end
|
||||
end
|
||||
end
|
||||
local function dragdrop_OnEnter(...)
|
||||
if this.obj.dragOnEnter and dragdropButton:IsShown() then
|
||||
dragdropButton.enteredFrame = this
|
||||
lockTooltip()
|
||||
this.obj.dragOnEnter(this, unpack(arg))
|
||||
end
|
||||
end
|
||||
local function dragdrop_OnClick()
|
||||
local button = arg1
|
||||
if this.obj.dragOnClick and button == "RightButton" then
|
||||
this.obj.dragOnClick(this, button)
|
||||
this.obj.ActivateMultiControl(this.obj, button)
|
||||
elseif this.obj.stateSwitchOnClick and (button == "LeftButton") and IsShiftKeyDown() then
|
||||
this.obj.stateSwitchOnClick(this, button)
|
||||
this.obj.ActivateMultiControl(this.obj, button)
|
||||
end
|
||||
end
|
||||
|
||||
local function Button_OnClick()
|
||||
local function Button_OnClick(frame, ...)
|
||||
AceGUI:ClearFocus()
|
||||
PlaySound("igMainMenuOption")
|
||||
this.obj:Fire("OnClick", 2, arg1)
|
||||
frame.obj:Fire("OnClick", ...)
|
||||
end
|
||||
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -136,28 +76,14 @@ 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)
|
||||
frame:SetScript("OnClick", Button_OnClick)
|
||||
frame:SetScript("OnEnter", Control_OnEnter)
|
||||
frame:SetScript("OnLeave", Control_OnLeave)
|
||||
|
||||
-- dragdrop
|
||||
if not dragdropButton then
|
||||
dragdropButton = CreateFrame("Button", "ElvUIAceGUI30DragDropButton", UIParent, "UIPanelButtonTemplate")
|
||||
dragdropButton:SetFrameStrata("TOOLTIP")
|
||||
dragdropButton:SetFrameLevel(5)
|
||||
dragdropButton:SetPoint('BOTTOM', GameTooltip, "BOTTOM", 0, 10)
|
||||
dragdropButton:Hide()
|
||||
ElvUI[1]:GetModule('Skins'):HandleButton(dragdropButton)
|
||||
end
|
||||
HookScript(frame, "OnClick", dragdrop_OnClick)
|
||||
HookScript(frame, "OnEnter", dragdrop_OnEnter)
|
||||
HookScript(frame, "OnLeave", dragdrop_OnLeave)
|
||||
HookScript(frame, "OnMouseUp", dragdrop_OnMouseUp)
|
||||
HookScript(frame, "OnMouseDown", dragdrop_OnMouseDown)
|
||||
|
||||
local text = frame:GetFontString()
|
||||
text:ClearAllPoints()
|
||||
text:SetPoint("TOPLEFT", 15, -1)
|
||||
|
||||
@@ -6,31 +6,28 @@ 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 = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local _G = AceCore._G
|
||||
local _G = _G
|
||||
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
-- arg1 is the button for OnClick event
|
||||
local function Button_OnClick()
|
||||
local function Button_OnClick(frame, ...)
|
||||
AceGUI:ClearFocus()
|
||||
PlaySound("igMainMenuOption")
|
||||
this.obj:Fire("OnClick", 1, arg1)
|
||||
frame.obj:Fire("OnClick", ...)
|
||||
end
|
||||
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -54,7 +51,7 @@ local methods = {
|
||||
self:SetWidth(self.text:GetStringWidth() + 30)
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
["SetAutoWidth"] = function(self, autoWidth)
|
||||
self.autoWidth = autoWidth
|
||||
if self.autoWidth then
|
||||
|
||||
@@ -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 pairs = pairs
|
||||
local select, pairs = select, pairs
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
@@ -24,26 +24,26 @@ 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")
|
||||
else
|
||||
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
|
||||
self.text:SetPoint("RIGHT",0,0)
|
||||
self.text:SetPoint("RIGHT")
|
||||
end
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function CheckBox_OnMouseDown()
|
||||
local self = this.obj
|
||||
local function CheckBox_OnMouseDown(frame)
|
||||
local self = frame.obj
|
||||
if not self.disabled then
|
||||
if self.image:GetTexture() then
|
||||
self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
|
||||
@@ -54,9 +54,8 @@ local function CheckBox_OnMouseDown()
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function CheckBox_OnMouseUp()
|
||||
|
||||
local self = this.obj
|
||||
local function CheckBox_OnMouseUp(frame)
|
||||
local self = frame.obj
|
||||
if not self.disabled then
|
||||
self:ToggleChecked()
|
||||
|
||||
@@ -66,7 +65,7 @@ local function CheckBox_OnMouseUp()
|
||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||
end
|
||||
|
||||
self:Fire("OnValueChanged", 1, self.checked)
|
||||
self:Fire("OnValueChanged", self.checked)
|
||||
AlignImage(self)
|
||||
end
|
||||
end
|
||||
@@ -173,7 +172,6 @@ local methods = {
|
||||
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
||||
highlight:SetTexCoord(0, 1, 0, 1)
|
||||
end
|
||||
|
||||
checkbg:SetHeight(size)
|
||||
checkbg:SetWidth(size)
|
||||
end,
|
||||
@@ -223,13 +221,14 @@ local methods = {
|
||||
end
|
||||
end,
|
||||
|
||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
["SetImage"] = function(self, path, ...)
|
||||
local image = self.image
|
||||
image:SetTexture(path)
|
||||
|
||||
if image:GetTexture() then
|
||||
if a4 or a8 then
|
||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
local n = select("#", ...)
|
||||
if n == 4 or n == 8 then
|
||||
image:SetTexCoord(...)
|
||||
else
|
||||
image:SetTexCoord(0, 1, 0, 1)
|
||||
end
|
||||
@@ -254,7 +253,7 @@ local function Constructor()
|
||||
local checkbg = frame:CreateTexture(nil, "ARTWORK")
|
||||
checkbg:SetWidth(24)
|
||||
checkbg:SetHeight(24)
|
||||
checkbg:SetPoint("TOPLEFT",0,0)
|
||||
checkbg:SetPoint("TOPLEFT")
|
||||
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
|
||||
|
||||
local check = frame:CreateTexture(nil, "OVERLAY")
|
||||
@@ -265,7 +264,7 @@ local function Constructor()
|
||||
text:SetJustifyH("LEFT")
|
||||
text:SetHeight(18)
|
||||
text:SetPoint("LEFT", checkbg, "RIGHT")
|
||||
text:SetPoint("RIGHT",0,0)
|
||||
text:SetPoint("RIGHT")
|
||||
|
||||
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
||||
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
ColorPicker Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "ColorPicker", 23
|
||||
local Type, Version = "ColorPicker-ElvUI", 22
|
||||
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", 4, r, g, b, a)
|
||||
self:Fire("OnValueChanged", 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", 4, r, g, b, a)
|
||||
self:Fire("OnValueConfirmed", r, g, b, a)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -38,19 +38,20 @@ end
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function ColorSwatch_OnClick()
|
||||
local function ColorSwatch_OnClick(frame)
|
||||
HideUIPanel(ColorPickerFrame)
|
||||
local self = this.obj
|
||||
local self = frame.obj
|
||||
if not self.disabled then
|
||||
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
|
||||
ColorPickerFrame:SetClampedToScreen(true)
|
||||
|
||||
ColorPickerFrame.func = function()
|
||||
@@ -66,12 +67,20 @@ local function ColorSwatch_OnClick()
|
||||
ColorCallback(self, r, g, b, a, true)
|
||||
end
|
||||
|
||||
local r, g, b, a = self.r, self.g, self.b, self.a
|
||||
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
|
||||
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
|
||||
@@ -100,11 +109,15 @@ local methods = {
|
||||
self.text:SetText(text)
|
||||
end,
|
||||
|
||||
["SetColor"] = function(self, r, g, b, a)
|
||||
["SetColor"] = function(self, r, g, b, a, defaultR, defaultG, defaultB, defaultA)
|
||||
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,
|
||||
|
||||
@@ -140,7 +153,7 @@ local function Constructor()
|
||||
colorSwatch:SetWidth(19)
|
||||
colorSwatch:SetHeight(19)
|
||||
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
|
||||
colorSwatch:SetPoint("LEFT",0,0)
|
||||
colorSwatch:SetPoint("LEFT")
|
||||
|
||||
local texture = frame:CreateTexture(nil, "BACKGROUND")
|
||||
texture:SetWidth(16)
|
||||
@@ -164,7 +177,7 @@ local function Constructor()
|
||||
text:SetJustifyH("LEFT")
|
||||
text:SetTextColor(1, 1, 1)
|
||||
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
|
||||
text:SetPoint("RIGHT",0,0)
|
||||
text:SetPoint("RIGHT")
|
||||
|
||||
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
||||
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1137 2016-05-15 10:57:36Z nevcairiel $ ]]--
|
||||
--[[ $Id: AceGUIWidget-DropDown-Items.lua 996 2010-12-01 18:34:17Z nevcairiel $ ]]--
|
||||
|
||||
local AceGUI = LibStub("AceGUI-3.0")
|
||||
|
||||
local IsLegion = false
|
||||
|
||||
-- Lua APIs
|
||||
local assert = assert
|
||||
local tgetn = table.getn
|
||||
local select, assert = select, assert
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
@@ -14,12 +11,23 @@ local CreateFrame = CreateFrame
|
||||
|
||||
local function fixlevels(parent,...)
|
||||
local i = 1
|
||||
local child = arg[i]
|
||||
local child = select(i, ...)
|
||||
while child do
|
||||
child:SetFrameLevel(parent:GetFrameLevel()+1)
|
||||
fixlevels(child, child:GetChildren())
|
||||
i = i + 1
|
||||
child = arg[i]
|
||||
child = select(i, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local function fixstrata(strata, parent, ...)
|
||||
local i = 1
|
||||
local child = select(i, ...)
|
||||
parent:SetFrameStrata(strata)
|
||||
while child do
|
||||
fixstrata(strata, child, child:GetChildren())
|
||||
i = i + 1
|
||||
child = select(i, ...)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +45,7 @@ local ItemBase = {
|
||||
counter = 0,
|
||||
}
|
||||
|
||||
function ItemBase.Frame_OnEnter()
|
||||
function ItemBase.Frame_OnEnter(this)
|
||||
local self = this.obj
|
||||
|
||||
if self.useHighlight then
|
||||
@@ -50,7 +58,7 @@ function ItemBase.Frame_OnEnter()
|
||||
end
|
||||
end
|
||||
|
||||
function ItemBase.Frame_OnLeave()
|
||||
function ItemBase.Frame_OnLeave(this)
|
||||
local self = this.obj
|
||||
|
||||
self.highlight:Hide()
|
||||
@@ -83,9 +91,8 @@ function ItemBase.SetPullout(self, pullout)
|
||||
self.pullout = pullout
|
||||
|
||||
self.frame:SetParent(nil)
|
||||
local itemFrame = pullout.itemFrame
|
||||
self.frame:SetParent(itemFrame)
|
||||
self.parent = itemFrame
|
||||
self.frame:SetParent(pullout.itemFrame)
|
||||
self.parent = pullout.itemFrame
|
||||
fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
|
||||
end
|
||||
|
||||
@@ -100,8 +107,8 @@ function ItemBase.GetText(self)
|
||||
end
|
||||
|
||||
-- exported
|
||||
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)
|
||||
function ItemBase.SetPoint(self, ...)
|
||||
self.frame:SetPoint(...)
|
||||
end
|
||||
|
||||
-- exported
|
||||
@@ -250,7 +257,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
local function OnLeave(this)
|
||||
local self = this.obj
|
||||
self:Fire("OnLeave")
|
||||
|
||||
@@ -331,7 +338,7 @@ do
|
||||
self:SetValue(nil)
|
||||
end
|
||||
|
||||
local function Frame_OnClick()
|
||||
local function Frame_OnClick(this, button)
|
||||
local self = this.obj
|
||||
if self.disabled then return end
|
||||
self.value = not self.value
|
||||
@@ -341,7 +348,7 @@ do
|
||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||
end
|
||||
UpdateToggle(self)
|
||||
self:Fire("OnValueChanged", 1, self.value)
|
||||
self:Fire("OnValueChanged", self.value)
|
||||
end
|
||||
|
||||
-- exported
|
||||
@@ -378,7 +385,7 @@ do
|
||||
local widgetType = "Dropdown-Item-Menu"
|
||||
local widgetVersion = 2
|
||||
|
||||
local function OnEnter()
|
||||
local function OnEnter(this)
|
||||
local self = this.obj
|
||||
self:Fire("OnEnter")
|
||||
|
||||
@@ -393,7 +400,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local function OnHide()
|
||||
local function OnHide(this)
|
||||
local self = this.obj
|
||||
if self.submenu then
|
||||
self.submenu:Close()
|
||||
@@ -433,7 +440,7 @@ end
|
||||
-- A single line to separate items
|
||||
do
|
||||
local widgetType = "Dropdown-Item-Separator"
|
||||
local widgetVersion = 2
|
||||
local widgetVersion = 1
|
||||
|
||||
-- exported, override
|
||||
local function SetDisabled(self, disabled)
|
||||
@@ -449,7 +456,6 @@ do
|
||||
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)
|
||||
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
--[[ $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 pairs, ipairs, type = pairs, ipairs, type
|
||||
local tsort, tinsert, tgetn, tsetn = table.sort, table.insert, table.getn, table.setn
|
||||
local format = string.format
|
||||
local select, pairs, ipairs, type = select, pairs, ipairs, type
|
||||
local tsort = table.sort
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
local UIParent, CreateFrame = UIParent, CreateFrame
|
||||
local _G = AceCore._G
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
@@ -20,23 +17,23 @@ local _G = AceCore._G
|
||||
|
||||
local function fixlevels(parent,...)
|
||||
local i = 1
|
||||
local child = arg[i]
|
||||
local child = select(i, ...)
|
||||
while child do
|
||||
child:SetFrameLevel(parent:GetFrameLevel()+1)
|
||||
fixlevels(child, child:GetChildren())
|
||||
i = i + 1
|
||||
child = arg[i]
|
||||
child = select(i, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local function fixstrata(strata, parent, ...)
|
||||
local i = 1
|
||||
local child = arg[i]
|
||||
local child = select(i, ...)
|
||||
parent:SetFrameStrata(strata)
|
||||
while child do
|
||||
fixstrata(strata, child, child:GetChildren())
|
||||
i = i + 1
|
||||
child = arg[i]
|
||||
child = select(i, ...)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,15 +76,15 @@ do
|
||||
end
|
||||
|
||||
-- See the note in Constructor() for each scroll related function
|
||||
local function OnMouseWheel()
|
||||
this.obj:MoveScroll(arg1)
|
||||
local function OnMouseWheel(this, value)
|
||||
this.obj:MoveScroll(value)
|
||||
end
|
||||
|
||||
local function OnScrollValueChanged()
|
||||
this.obj:SetScroll(arg1)
|
||||
local function OnScrollValueChanged(this, value)
|
||||
this.obj:SetScroll(value)
|
||||
end
|
||||
|
||||
local function OnSizeChanged()
|
||||
local function OnSizeChanged(this)
|
||||
this.obj:FixScroll()
|
||||
end
|
||||
|
||||
@@ -107,6 +104,7 @@ do
|
||||
end
|
||||
child:ClearAllPoints()
|
||||
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
|
||||
end
|
||||
@@ -150,6 +148,7 @@ do
|
||||
if value < 1000 then
|
||||
child:ClearAllPoints()
|
||||
child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
|
||||
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -12, offset)
|
||||
status.offset = offset
|
||||
end
|
||||
end
|
||||
@@ -170,9 +169,9 @@ do
|
||||
|
||||
-- exported
|
||||
local function AddItem(self, item)
|
||||
tinsert(self.items, item)
|
||||
self.items[#self.items + 1] = item
|
||||
|
||||
local h = tgetn(self.items) * 16
|
||||
local h = #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
|
||||
|
||||
@@ -223,7 +222,6 @@ do
|
||||
AceGUI:Release(item)
|
||||
items[i] = nil
|
||||
end
|
||||
tsetn(items,0)
|
||||
end
|
||||
|
||||
-- exported
|
||||
@@ -322,17 +320,16 @@ do
|
||||
slider.obj = self
|
||||
|
||||
scrollFrame:SetScrollChild(itemFrame)
|
||||
scrollFrame:SetWidth(defaultWidth - 12)
|
||||
scrollFrame:SetHeight(self.maxHeight - 24)
|
||||
scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12)
|
||||
scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12)
|
||||
scrollFrame:EnableMouseWheel(true)
|
||||
scrollFrame:SetScript("OnMouseWheel", OnMouseWheel)
|
||||
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
|
||||
scrollFrame:SetToplevel(true)
|
||||
scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
|
||||
itemFrame:SetWidth(defaultWidth - 12)
|
||||
itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
|
||||
itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0)
|
||||
itemFrame:SetHeight(400)
|
||||
itemFrame:SetToplevel(true)
|
||||
itemFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
@@ -365,24 +362,24 @@ do
|
||||
|
||||
--[[ UI event handler ]]--
|
||||
|
||||
local function Control_OnEnter()
|
||||
local function Control_OnEnter(this)
|
||||
this.obj.button:LockHighlight()
|
||||
this.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
local function Control_OnLeave(this)
|
||||
this.obj.button:UnlockHighlight()
|
||||
this.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Dropdown_OnHide()
|
||||
local function Dropdown_OnHide(this)
|
||||
local self = this.obj
|
||||
if self.open then
|
||||
self.pullout:Close()
|
||||
end
|
||||
end
|
||||
|
||||
local function Dropdown_TogglePullout()
|
||||
local function Dropdown_TogglePullout(this)
|
||||
local self = this.obj
|
||||
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
|
||||
if self.open then
|
||||
@@ -391,10 +388,7 @@ do
|
||||
AceGUI:ClearFocus()
|
||||
else
|
||||
self.open = true
|
||||
local width = self.pulloutWidth or self.frame:GetWidth()
|
||||
self.pullout:SetWidth(width)
|
||||
self.pullout.scrollFrame:SetWidth(width - 12)
|
||||
self.pullout.itemFrame:SetWidth(width - (self.pullout.slider:IsShown() and 24 or 12))
|
||||
self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth())
|
||||
self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0)
|
||||
AceGUI:SetFocus(self)
|
||||
end
|
||||
@@ -436,20 +430,17 @@ do
|
||||
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", 2, this.userdata.value, checked)
|
||||
self:Fire("OnValueChanged", this.userdata.value, checked)
|
||||
ShowMultiText(self)
|
||||
else
|
||||
if checked then
|
||||
self:SetValue(this.userdata.value)
|
||||
self:Fire("OnValueChanged", 1, this.userdata.value)
|
||||
this:SetValue(false)
|
||||
self:Fire("OnValueChanged", this.userdata.value)
|
||||
else
|
||||
self:SetValue(nil)
|
||||
self:Fire("OnValueChanged", 1, nil)
|
||||
this:SetValue(true)
|
||||
end
|
||||
if self.open then
|
||||
@@ -468,7 +459,6 @@ do
|
||||
pullout:SetCallback("OnClose", OnPulloutClose)
|
||||
pullout:SetCallback("OnOpen", OnPulloutOpen)
|
||||
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
|
||||
local frame = self.pullout.frame
|
||||
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
|
||||
|
||||
self:SetHeight(44)
|
||||
@@ -581,7 +571,7 @@ do
|
||||
local function AddListItem(self, value, text, itemType)
|
||||
if not itemType then itemType = "Dropdown-Item-Toggle" end
|
||||
local exists = AceGUI:GetWidgetVersion(itemType)
|
||||
if not exists then error(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)
|
||||
@@ -610,7 +600,7 @@ do
|
||||
|
||||
if type(order) ~= "table" then
|
||||
for v in pairs(list) do
|
||||
tinsert(sortlist, v)
|
||||
sortlist[#sortlist + 1] = v
|
||||
end
|
||||
tsort(sortlist)
|
||||
|
||||
@@ -618,7 +608,6 @@ 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)
|
||||
|
||||
@@ -5,11 +5,6 @@ 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 = tostring, pairs
|
||||
|
||||
@@ -17,7 +12,7 @@ local tostring, pairs = tostring, pairs
|
||||
local PlaySound = PlaySound
|
||||
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
local strlen = string.len
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
@@ -28,100 +23,13 @@ Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
if not AceGUIEditBoxInsertLink then
|
||||
-- upgradeable hook
|
||||
hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
|
||||
return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(BANK_CONTAINER, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("ContainerFrameItemButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(this:GetParent():GetID(), this:GetID()))
|
||||
end
|
||||
end)
|
||||
|
||||
hooksecurefunc("KeyRingItemButton_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
|
||||
return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(KEYRING_CONTAINER, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("LootFrameItem_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() then
|
||||
return _G.AceGUIEditBoxInsertLink(GetLootSlotLink(this.slot))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("SetItemRef",
|
||||
function(link, text, button)
|
||||
if IsShiftKeyDown() then
|
||||
if strsub(link,1,6) == "player" then
|
||||
local name = strsub(link,8)
|
||||
if name and (strlen(name) > 0) then
|
||||
return _G.AceGUIEditBoxInsertLink(name)
|
||||
end
|
||||
else
|
||||
return _G.AceGUIEditBoxInsertLink(text)
|
||||
end
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("MerchantItemButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if MerchantFrame.selectedTab == 1 and button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIEditBoxInsertLink(GetMerchantItemLink(this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("PaperDollItemSlotButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIEditBoxInsertLink(GetInventoryItemLink("player", this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestRewardItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestLogTitleButton_OnClick",
|
||||
function(button)
|
||||
if IsShiftKeyDown() and (not this.isHeader) then
|
||||
return _G.AceGUIEditBoxInsertLink(gsub(this:GetText(), " *(.*)", "%1"))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestLogRewardItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIEditBoxInsertLink(GetQuestLogItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("SpellButton_OnClick",
|
||||
function(drag)
|
||||
local id = SpellBook_GetSpellID(this:GetID())
|
||||
if id <= MAX_SPELLS and (not drag) and IsShiftKeyDown() then
|
||||
local spellName, subSpellName = GetSpellName(id, SpellBookFrame.bookType)
|
||||
if spellName and not IsSpellPassive(id, SpellBookFrame.bookType) then
|
||||
if subSpellName and (strlen(subSpellName) > 0) then
|
||||
_G.AceGUIEditBoxInsertLink(spellName.."("..subSpellName..")");
|
||||
else
|
||||
_G.AceGUIEditBoxInsertLink(spellName);
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
|
||||
end
|
||||
|
||||
function _G.AceGUIEditBoxInsertLink(text)
|
||||
for i = 1, AceGUI:GetWidgetCount(Type) do
|
||||
local editbox = _G["AceGUI-3.0EditBox"..i]
|
||||
if editbox and editbox:IsVisible() and editbox.hasfocus then
|
||||
if editbox and editbox:IsVisible() and editbox:HasFocus() then
|
||||
editbox:Insert(text)
|
||||
return true
|
||||
end
|
||||
@@ -143,82 +51,73 @@ end
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Frame_OnShowFocus()
|
||||
this.obj.editbox:SetFocus()
|
||||
this:SetScript("OnShow", nil)
|
||||
local function Frame_OnShowFocus(frame)
|
||||
frame.obj.editbox:SetFocus()
|
||||
frame:SetScript("OnShow", nil)
|
||||
end
|
||||
|
||||
local function EditBox_OnEscapePressed()
|
||||
local function EditBox_OnEscapePressed(frame)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function EditBox_OnEnterPressed()
|
||||
local self = this.obj
|
||||
local value = this:GetText()
|
||||
local cancel = self:Fire("OnEnterPressed", 1, value)
|
||||
local function EditBox_OnEnterPressed(frame)
|
||||
local self = frame.obj
|
||||
local value = frame:GetText()
|
||||
local cancel = self:Fire("OnEnterPressed", value)
|
||||
if not cancel then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
HideButton(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnReceiveDrag()
|
||||
if not GetCursorInfo then return end
|
||||
local self = this.obj
|
||||
local function EditBox_OnReceiveDrag(frame)
|
||||
local self = frame.obj
|
||||
local type, id, info = GetCursorInfo()
|
||||
if type == "item" then
|
||||
self:SetText(info)
|
||||
self:Fire("OnEnterPressed", 1, info)
|
||||
self:Fire("OnEnterPressed", info)
|
||||
ClearCursor()
|
||||
elseif type == "spell" then
|
||||
local spell, rank = GetSpellName(id, info)
|
||||
if rank ~= "" then spell = spell.."("..rank..")" end
|
||||
self:SetText(spell)
|
||||
self:Fire("OnEnterPressed", 1, spell)
|
||||
local name = GetSpellInfo(id, info)
|
||||
self:SetText(name)
|
||||
self:Fire("OnEnterPressed", name)
|
||||
ClearCursor()
|
||||
elseif type == "macro" then
|
||||
local name = GetMacroInfo(id)
|
||||
self:SetText(name)
|
||||
self:Fire("OnEnterPressed", 1, name)
|
||||
self:Fire("OnEnterPressed", name)
|
||||
ClearCursor()
|
||||
end
|
||||
HideButton(self)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
|
||||
local function EditBox_OnTextChanged()
|
||||
local self = this.obj
|
||||
local value = this:GetText()
|
||||
local function EditBox_OnTextChanged(frame)
|
||||
local self = frame.obj
|
||||
local value = frame:GetText()
|
||||
if tostring(value) ~= tostring(self.lasttext) then
|
||||
self:Fire("OnTextChanged", 1, value)
|
||||
self:Fire("OnTextChanged", value)
|
||||
self.lasttext = value
|
||||
ShowButton(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnFocusGained()
|
||||
this.hasfocus = true
|
||||
AceGUI:SetFocus(this.obj)
|
||||
local function EditBox_OnFocusGained(frame)
|
||||
AceGUI:SetFocus(frame.obj)
|
||||
end
|
||||
|
||||
local function EditBox_OnFocusLost()
|
||||
this.hasfocus = nil
|
||||
end
|
||||
|
||||
local function Button_OnClick()
|
||||
local editbox = this.obj.editbox
|
||||
local function Button_OnClick(frame)
|
||||
local editbox = frame.obj.editbox
|
||||
editbox:ClearFocus()
|
||||
this = editbox -- Ace3v: this is kinda hack here
|
||||
EditBox_OnEnterPressed()
|
||||
EditBox_OnEnterPressed(editbox)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -256,7 +155,7 @@ local methods = {
|
||||
["SetText"] = function(self, text)
|
||||
self.lasttext = text or ""
|
||||
self.editbox:SetText(text or "")
|
||||
self.editbox:HighlightText(0)
|
||||
self.editbox:SetCursorPosition(0)
|
||||
HideButton(self)
|
||||
end,
|
||||
|
||||
@@ -327,11 +226,10 @@ 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", 0, 0)
|
||||
editbox:SetPoint("BOTTOMRIGHT")
|
||||
editbox:SetHeight(19)
|
||||
|
||||
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||
|
||||
@@ -43,8 +43,8 @@ local function Constructor()
|
||||
frame:Hide()
|
||||
|
||||
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
|
||||
label:SetPoint("TOP",0,0)
|
||||
label:SetPoint("BOTTOM",0,0)
|
||||
label:SetPoint("TOP")
|
||||
label:SetPoint("BOTTOM")
|
||||
label:SetJustifyH("CENTER")
|
||||
|
||||
local left = frame:CreateTexture(nil, "BACKGROUND")
|
||||
|
||||
@@ -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 pairs, print = pairs, print
|
||||
local select, pairs, print = select, pairs, print
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
@@ -14,16 +14,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Button_OnClick()
|
||||
this.obj:Fire("OnClick", 1, arg1)
|
||||
local function Button_OnClick(frame, button)
|
||||
frame.obj:Fire("OnClick", button)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
@@ -53,13 +53,14 @@ local methods = {
|
||||
end
|
||||
end,
|
||||
|
||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
["SetImage"] = function(self, path, ...)
|
||||
local image = self.image
|
||||
image:SetTexture(path)
|
||||
|
||||
if image:GetTexture() then
|
||||
if a4 or a8 then
|
||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
local n = select("#", ...)
|
||||
if n == 4 or n == 8 then
|
||||
image:SetTexCoord(...)
|
||||
else
|
||||
image:SetTexCoord(0, 1, 0, 1)
|
||||
end
|
||||
@@ -131,7 +132,7 @@ local function Constructor()
|
||||
widget[method] = func
|
||||
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
|
||||
widget.SetText = widget.SetLabel
|
||||
|
||||
return AceGUI:RegisterAsWidget(widget)
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--[[-----------------------------------------------------------------------------
|
||||
InteractiveLabel Widget
|
||||
-------------------------------------------------------------------------------]]
|
||||
local Type, Version = "InteractiveLabel", 20
|
||||
local Type, Version = "InteractiveLabel", 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 pairs = pairs
|
||||
local select, pairs = select, pairs
|
||||
|
||||
-- WoW APIs
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
@@ -18,16 +18,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Label_OnClick()
|
||||
this.obj:Fire("OnClick", 1, arg1)
|
||||
local function Label_OnClick(frame, button)
|
||||
frame.obj:Fire("OnClick", button)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
@@ -44,13 +44,14 @@ local methods = {
|
||||
|
||||
-- ["OnRelease"] = nil,
|
||||
|
||||
["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)
|
||||
["SetHighlight"] = function(self, ...)
|
||||
self.highlight:SetTexture(...)
|
||||
end,
|
||||
|
||||
["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)
|
||||
["SetHighlightTexCoord"] = function(self, ...)
|
||||
local c = select("#", ...)
|
||||
if c == 4 or c == 8 then
|
||||
self.highlight:SetTexCoord(...)
|
||||
else
|
||||
self.highlight:SetTexCoord(0, 1, 0, 1)
|
||||
end
|
||||
|
||||
@@ -21,32 +21,44 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Keybinding_OnHide()
|
||||
local self = this.obj
|
||||
this:EnableKeyboard(false)
|
||||
this:EnableMouseWheel(false)
|
||||
self.msgframe:Hide()
|
||||
this:UnlockHighlight()
|
||||
self.waitingForKey = nil
|
||||
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()
|
||||
end
|
||||
|
||||
local ignoreKeys = {
|
||||
["BUTTON1"] = true, ["BUTTON2"] = true,
|
||||
["UNKNOWN"] = true,
|
||||
["SHIFT"] = true, ["CTRL"] = true, ["ALT"] = true,
|
||||
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
|
||||
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
|
||||
}
|
||||
local function Keybinding_OnKeyDown()
|
||||
local self = this.obj
|
||||
local function Keybinding_OnKeyDown(frame, key)
|
||||
local self = frame.obj
|
||||
if self.waitingForKey then
|
||||
local keyPressed = arg1
|
||||
local keyPressed = key
|
||||
if keyPressed == "ESCAPE" then
|
||||
keyPressed = ""
|
||||
else
|
||||
@@ -62,58 +74,40 @@ local function Keybinding_OnKeyDown()
|
||||
end
|
||||
end
|
||||
|
||||
this:EnableKeyboard(false)
|
||||
this:EnableMouseWheel(false)
|
||||
frame:EnableKeyboard(false)
|
||||
frame:EnableMouseWheel(false)
|
||||
self.msgframe:Hide()
|
||||
this:UnlockHighlight()
|
||||
frame:UnlockHighlight()
|
||||
self.waitingForKey = nil
|
||||
|
||||
if not self.disabled then
|
||||
self:SetKey(keyPressed)
|
||||
self:Fire("OnKeyChanged", 1, keyPressed)
|
||||
self:Fire("OnKeyChanged", keyPressed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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_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
|
||||
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
|
||||
AceGUI:ClearFocus()
|
||||
Keybinding_OnKeyDown(frame, button)
|
||||
end
|
||||
|
||||
local function Keybinding_OnMouseWheel()
|
||||
if arg1 >= 0 then
|
||||
arg1 = "MOUSEWHEELUP"
|
||||
local function Keybinding_OnMouseWheel(frame, direction)
|
||||
local button
|
||||
if direction >= 0 then
|
||||
button = "MOUSEWHEELUP"
|
||||
else
|
||||
arg1 = "MOUSEWHEELDOWN"
|
||||
button = "MOUSEWHEELDOWN"
|
||||
end
|
||||
Keybinding_OnKeyDown()
|
||||
Keybinding_OnKeyDown(frame, button)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -147,10 +141,10 @@ local methods = {
|
||||
["SetKey"] = function(self, key)
|
||||
if (key or "") == "" then
|
||||
self.button:SetText(NOT_BOUND)
|
||||
self.text:SetFontObject("GameFontNormal")
|
||||
self.button:SetNormalFontObject("GameFontNormal")
|
||||
else
|
||||
self.button:SetText(key)
|
||||
self.text:SetFontObject("GameFontHighlight")
|
||||
self.button:SetNormalFontObject("GameFontHighlight")
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -185,9 +179,9 @@ local ControlBackdrop = {
|
||||
insets = { left = 3, right = 3, top = 3, bottom = 3 }
|
||||
}
|
||||
|
||||
local function keybindingMsgFixWidth()
|
||||
this:SetWidth(this.msg:GetWidth() + 10)
|
||||
this:SetScript("OnUpdate", nil)
|
||||
local function keybindingMsgFixWidth(frame)
|
||||
frame:SetWidth(frame.msg:GetWidth() + 10)
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
local function Constructor()
|
||||
@@ -198,18 +192,15 @@ local function Constructor()
|
||||
|
||||
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:SetScript("OnHide", Keybinding_OnHide)
|
||||
button:SetPoint("BOTTOMLEFT",0,0)
|
||||
button:SetPoint("BOTTOMRIGHT",0,0)
|
||||
button:SetPoint("BOTTOMLEFT")
|
||||
button:SetPoint("BOTTOMRIGHT")
|
||||
button:SetHeight(24)
|
||||
button:EnableKeyboard(false)
|
||||
|
||||
@@ -218,8 +209,8 @@ local function Constructor()
|
||||
text:SetPoint("RIGHT", -7, 0)
|
||||
|
||||
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||
label:SetPoint("TOPLEFT",0,0)
|
||||
label:SetPoint("TOPRIGHT",0,0)
|
||||
label:SetPoint("TOPLEFT")
|
||||
label:SetPoint("TOPRIGHT")
|
||||
label:SetJustifyH("CENTER")
|
||||
label:SetHeight(18)
|
||||
|
||||
@@ -245,8 +236,7 @@ local function Constructor()
|
||||
msgframe = msgframe,
|
||||
frame = frame,
|
||||
alignoffset = 30,
|
||||
type = Type,
|
||||
text = text
|
||||
type = Type
|
||||
}
|
||||
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", 23
|
||||
local Type, Version = "Label", 24
|
||||
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, pairs = math.max, pairs
|
||||
local max, select, pairs = math.max, select, 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",0,0)
|
||||
image:SetPoint("TOP")
|
||||
label:SetPoint("TOP", image, "BOTTOM")
|
||||
label:SetPoint("LEFT",0,0)
|
||||
label:SetPoint("LEFT")
|
||||
label:SetWidth(width)
|
||||
height = image:GetHeight() + label:GetHeight()
|
||||
else
|
||||
-- image on the left
|
||||
image:SetPoint("TOPLEFT",0,0)
|
||||
image:SetPoint("TOPLEFT")
|
||||
if image:GetHeight() > label:GetHeight() then
|
||||
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
|
||||
else
|
||||
@@ -53,11 +53,11 @@ local function UpdateImageAnchor(self)
|
||||
end
|
||||
else
|
||||
-- no image shown
|
||||
label:SetPoint("TOPLEFT",0,0)
|
||||
label:SetPoint("TOPLEFT")
|
||||
label:SetWidth(width)
|
||||
height = label:GetHeight()
|
||||
end
|
||||
|
||||
|
||||
self.resizing = true
|
||||
frame:SetHeight(height)
|
||||
frame.height = height
|
||||
@@ -78,6 +78,8 @@ local methods = {
|
||||
self:SetImageSize(16, 16)
|
||||
self:SetColor()
|
||||
self:SetFontObject()
|
||||
self:SetJustifyH("LEFT")
|
||||
self:SetJustifyV("TOP")
|
||||
|
||||
-- reset the flag
|
||||
self.resizing = nil
|
||||
@@ -103,14 +105,15 @@ local methods = {
|
||||
self.label:SetVertexColor(r, g, b)
|
||||
end,
|
||||
|
||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
["SetImage"] = function(self, path, ...)
|
||||
local image = self.image
|
||||
image:SetTexture(path)
|
||||
|
||||
|
||||
if image:GetTexture() then
|
||||
self.imageshown = true
|
||||
if a4 or a8 then
|
||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
||||
local n = select("#", ...)
|
||||
if n == 4 or n == 8 then
|
||||
image:SetTexCoord(...)
|
||||
else
|
||||
image:SetTexCoord(0, 1, 0, 1)
|
||||
end
|
||||
@@ -133,6 +136,14 @@ 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,
|
||||
}
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -143,9 +154,6 @@ 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,17 +2,13 @@ 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 strfmt = string.format
|
||||
local pairs = pairs
|
||||
|
||||
-- WoW APIs
|
||||
local CursorHasItem, ClearCursor = CursorHasItem, ClearCursor
|
||||
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
|
||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||
local _G = AceCore._G
|
||||
local _G = _G
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
@@ -21,108 +17,23 @@ local _G = AceCore._G
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Support functions
|
||||
-------------------------------------------------------------------------------]]
|
||||
|
||||
if not AceGUIMultiLineEditBoxInsertLink then
|
||||
-- upgradeable hook
|
||||
hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetContainerItemLink(BANK_CONTAINER, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("ContainerFrameItemButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetContainerItemLink(this:GetParent():GetID(), this:GetID()))
|
||||
end
|
||||
end)
|
||||
|
||||
hooksecurefunc("KeyRingItemButton_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetContainerItemLink(KEYRING_CONTAINER, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("LootFrameItem_OnClick",
|
||||
function(button)
|
||||
if button == "LeftButton" and IsShiftKeyDown() then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetLootSlotLink(this.slot))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("SetItemRef",
|
||||
function(link, text, button)
|
||||
if IsShiftKeyDown() then
|
||||
if strsub(link,1,6) == "player" then
|
||||
local name = strsub(link,8)
|
||||
if name and (strlen(name) > 0) then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(name)
|
||||
end
|
||||
else
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(text)
|
||||
end
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("MerchantItemButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if MerchantFrame.selectedTab == 1 and button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetMerchantItemLink(this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("PaperDollItemSlotButton_OnClick",
|
||||
function(button, ignoreModifiers)
|
||||
if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetInventoryItemLink("player", this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestRewardItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestLogTitleButton_OnClick",
|
||||
function(button)
|
||||
if IsShiftKeyDown() and (not this.isHeader) then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(gsub(this:GetText(), " *(.*)", "%1"))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("QuestLogRewardItem_OnClick",
|
||||
function()
|
||||
if IsShiftKeyDown() and this.rewardType ~= "spell" then
|
||||
return _G.AceGUIMultiLineEditBoxInsertLink(GetQuestLogItemLink(this.type, this:GetID()))
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("SpellButton_OnClick",
|
||||
function(drag)
|
||||
local id = SpellBook_GetSpellID(this:GetID())
|
||||
if id <= MAX_SPELLS and (not drag) and IsShiftKeyDown() then
|
||||
local spellName, subSpellName = GetSpellName(id, SpellBookFrame.bookType)
|
||||
if spellName and not IsSpellPassive(id, SpellBookFrame.bookType) then
|
||||
if subSpellName and (strlen(subSpellName) > 0) then
|
||||
_G.AceGUIMultiLineEditBoxInsertLink(spellName.."("..subSpellName..")");
|
||||
else
|
||||
_G.AceGUIMultiLineEditBoxInsertLink(spellName);
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
|
||||
end
|
||||
|
||||
function _G.AceGUIMultiLineEditBoxInsertLink(text)
|
||||
for i = 1, AceGUI:GetWidgetCount(Type) do
|
||||
local editbox = _G[strfmt("MultiLineEditBox%uEdit",i)]
|
||||
if editbox and editbox:IsVisible() and editbox.hasfocus then
|
||||
local editbox = _G[("MultiLineEditBox%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)
|
||||
|
||||
@@ -144,116 +55,109 @@ end
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function OnClick() -- Button
|
||||
local self = this.obj
|
||||
local function OnClick(self) -- Button
|
||||
self = self.obj
|
||||
self.editBox:ClearFocus()
|
||||
if not self:Fire("OnEnterPressed", 1, self.editBox:GetText()) then
|
||||
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
|
||||
self.button:Disable()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnCursorChanged() -- EditBox
|
||||
|
||||
local self, y = this.obj.scrollFrame, -arg2
|
||||
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 + arg4 - self:GetHeight()
|
||||
y = y + cursorHeight - self:GetHeight()
|
||||
if y > offset then
|
||||
self:SetVerticalScroll(y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEditFocusLost() -- EditBox
|
||||
this.hasfocus = nil
|
||||
this:HighlightText(0, 0)
|
||||
this.obj:Fire("OnEditFocusLost")
|
||||
local function OnEditFocusLost(self) -- EditBox
|
||||
self:HighlightText(0, 0)
|
||||
self.obj:Fire("OnEditFocusLost")
|
||||
end
|
||||
|
||||
local function OnEnter() -- EditBox / ScrollFrame
|
||||
local self = this.obj
|
||||
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() -- EditBox / ScrollFrame
|
||||
local self = this.obj
|
||||
local function OnLeave(self) -- EditBox / ScrollFrame
|
||||
self = self.obj
|
||||
if self.entered then
|
||||
self.entered = nil
|
||||
self:Fire("OnLeave")
|
||||
end
|
||||
end
|
||||
|
||||
local function OnMouseUp() -- ScrollFrame
|
||||
local self = this.obj.editBox
|
||||
local function OnMouseUp(self) -- ScrollFrame
|
||||
self = self.obj.editBox
|
||||
self:SetFocus()
|
||||
local n = self:GetNumLetters()
|
||||
self:HighlightText(n,n)
|
||||
self:SetCursorPosition(self:GetNumLetters())
|
||||
end
|
||||
|
||||
local function OnReceiveDrag() -- EditBox / ScrollFrame
|
||||
if not CursorHasItem() then return 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()
|
||||
local self = this.obj
|
||||
self = self.obj
|
||||
local editBox = self.editBox
|
||||
if not this.hasfocus then
|
||||
this.hasfocus = true
|
||||
if not editBox:HasFocus() then
|
||||
editBox:SetFocus()
|
||||
local n = editBox:GetNumLetters()
|
||||
editBox:HighlightText(n,n)
|
||||
editBox:SetCursorPosition(editBox:GetNumLetters())
|
||||
end
|
||||
editBox:Insert(info)
|
||||
self.button:Enable()
|
||||
end
|
||||
|
||||
local function OnSizeChanged() -- ScrollFrame
|
||||
this:UpdateScrollChildRect()
|
||||
this:SetVerticalScroll(this:GetHeight())
|
||||
this.obj.editBox:SetWidth(arg1)
|
||||
local function OnSizeChanged(self, width, height) -- ScrollFrame
|
||||
self.obj.editBox:SetWidth(width)
|
||||
end
|
||||
|
||||
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
|
||||
local function OnTextChanged(self) -- EditBox
|
||||
self = self.obj
|
||||
local value = self.editBox:GetText()
|
||||
if not self.lastText or value ~= self.lastText then
|
||||
self:Fire("OnTextChanged", value)
|
||||
self.lastText = nil
|
||||
self.button:Enable()
|
||||
else
|
||||
self.button:Disable()
|
||||
self.lastText = value
|
||||
end
|
||||
end
|
||||
|
||||
local function OnTextSet() -- EditBox
|
||||
this:HighlightText(0, 0)
|
||||
this.obj.button:Disable()
|
||||
local function OnTextSet(self) -- EditBox
|
||||
self:HighlightText(0, 0)
|
||||
self:SetCursorPosition(self:GetNumLetters())
|
||||
self:SetCursorPosition(0)
|
||||
self.obj.button:Disable()
|
||||
end
|
||||
|
||||
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)
|
||||
local function OnVerticalScroll(self, offset) -- ScrollFrame
|
||||
local editBox = self.obj.editBox
|
||||
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
|
||||
end
|
||||
|
||||
local function OnShowFocus()
|
||||
this.obj.editBox:SetFocus()
|
||||
this:SetScript("OnShow", nil)
|
||||
local function OnShowFocus(frame)
|
||||
frame.obj.editBox:SetFocus()
|
||||
frame:SetScript("OnShow", nil)
|
||||
end
|
||||
|
||||
local function OnEditFocusGained()
|
||||
this.hasfocus = true
|
||||
AceGUI:SetFocus(this.obj)
|
||||
this.obj:Fire("OnEditFocusGained")
|
||||
end
|
||||
|
||||
local function OnEscapePressed() -- EditBox
|
||||
AceGUI:ClearFocus()
|
||||
local function OnEditFocusGained(frame)
|
||||
AceGUI:SetFocus(frame.obj)
|
||||
frame.obj:Fire("OnEditFocusGained")
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -314,10 +218,8 @@ local methods = {
|
||||
end,
|
||||
|
||||
["SetText"] = function(self, text)
|
||||
self.lasttext = text or ""
|
||||
self.editBox:SetText(text or "")
|
||||
self.editBox:HighlightText(0)
|
||||
self.button:Disable()
|
||||
self.lastText = text
|
||||
self.editBox:SetText(text)
|
||||
end,
|
||||
|
||||
["GetText"] = function(self)
|
||||
@@ -353,6 +255,16 @@ 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(...)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -377,7 +289,7 @@ local function Constructor()
|
||||
label:SetText(ACCEPT)
|
||||
label:SetHeight(10)
|
||||
|
||||
local button = CreateFrame("Button", strfmt("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
|
||||
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2")
|
||||
button:SetPoint("BOTTOMLEFT", 0, 4)
|
||||
button:SetHeight(22)
|
||||
button:SetWidth(label:GetStringWidth() + 24)
|
||||
@@ -396,7 +308,7 @@ local function Constructor()
|
||||
scrollBG:SetBackdropColor(0, 0, 0)
|
||||
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
|
||||
local scrollFrame = CreateFrame("ScrollFrame", strfmt("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
|
||||
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
|
||||
|
||||
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
|
||||
scrollBar:ClearAllPoints()
|
||||
@@ -414,17 +326,10 @@ local function Constructor()
|
||||
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
|
||||
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
|
||||
local old = scrollFrame:GetScript("OnVerticalScroll");
|
||||
if old then
|
||||
scrollFrame:SetScript("OnVerticalScroll", function()
|
||||
old()
|
||||
OnVerticalScroll()
|
||||
end)
|
||||
else
|
||||
scrollFrame:SetScript("OnVerticalScroll", OnVerticalScroll)
|
||||
end
|
||||
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
|
||||
|
||||
local editBox = CreateFrame("EditBox", strfmt("%s%dEdit", Type, widgetNum), scrollFrame)
|
||||
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
|
||||
editBox:SetAllPoints()
|
||||
editBox:SetFontObject(ChatFontNormal)
|
||||
editBox:SetMultiLine(true)
|
||||
editBox:EnableMouse(true)
|
||||
@@ -432,7 +337,7 @@ local function Constructor()
|
||||
editBox:SetScript("OnCursorChanged", OnCursorChanged)
|
||||
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
|
||||
editBox:SetScript("OnEnter", OnEnter)
|
||||
editBox:SetScript("OnEscapePressed", OnEscapePressed)
|
||||
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
|
||||
editBox:SetScript("OnLeave", OnLeave)
|
||||
editBox:SetScript("OnMouseDown", OnReceiveDrag)
|
||||
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||
@@ -440,10 +345,8 @@ local function Constructor()
|
||||
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", 21
|
||||
local Type, Version = "Slider", 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 min, max, floor = math.min, math.max, math.floor
|
||||
local format, gsub = string.format, 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)
|
||||
@@ -45,30 +44,26 @@ end
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Control_OnEnter()
|
||||
this.obj:Fire("OnEnter")
|
||||
local function Control_OnEnter(frame)
|
||||
frame.obj:Fire("OnEnter")
|
||||
end
|
||||
|
||||
local function Control_OnLeave()
|
||||
this.obj:Fire("OnLeave")
|
||||
local function Control_OnLeave(frame)
|
||||
frame.obj:Fire("OnLeave")
|
||||
end
|
||||
|
||||
local function Frame_OnMouseDown()
|
||||
this.obj.slider:EnableMouseWheel(true)
|
||||
local function Frame_OnMouseDown(frame)
|
||||
frame.obj.slider:EnableMouseWheel(true)
|
||||
AceGUI:ClearFocus()
|
||||
end
|
||||
|
||||
local function Slider_OnValueChanged()
|
||||
local self = this.obj
|
||||
if not this.setup then
|
||||
local newvalue = this:GetValue()
|
||||
if self.step and self.step > 0 then
|
||||
local min_value = self.min or 0
|
||||
newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
|
||||
end
|
||||
local function Slider_OnValueChanged(frame)
|
||||
local self = frame.obj
|
||||
if not frame.setup then
|
||||
local newvalue = frame:GetValue()
|
||||
if newvalue ~= self.value and not self.disabled then
|
||||
self.value = newvalue
|
||||
self:Fire("OnValueChanged", 1, newvalue)
|
||||
self:Fire("OnValueChanged", newvalue)
|
||||
end
|
||||
if self.value then
|
||||
UpdateText(self)
|
||||
@@ -76,16 +71,16 @@ local function Slider_OnValueChanged()
|
||||
end
|
||||
end
|
||||
|
||||
local function Slider_OnMouseUp()
|
||||
local self = this.obj
|
||||
self:Fire("OnMouseUp", 1, self.value)
|
||||
local function Slider_OnMouseUp(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnMouseUp", self.value)
|
||||
end
|
||||
|
||||
local function Slider_OnMouseWheel()
|
||||
local self = this.obj
|
||||
local function Slider_OnMouseWheel(frame, v)
|
||||
local self = frame.obj
|
||||
if not self.disabled then
|
||||
local value = self.value
|
||||
if arg1 > 0 then
|
||||
if v > 0 then
|
||||
value = min(value + (self.step or 1), self.max)
|
||||
else
|
||||
value = max(value - (self.step or 1), self.min)
|
||||
@@ -94,15 +89,15 @@ local function Slider_OnMouseWheel()
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnEscapePressed()
|
||||
this:ClearFocus()
|
||||
local function EditBox_OnEscapePressed(frame)
|
||||
frame:ClearFocus()
|
||||
end
|
||||
|
||||
local function EditBox_OnEnterPressed()
|
||||
local self = this.obj
|
||||
local value = this:GetText()
|
||||
local function EditBox_OnEnterPressed(frame)
|
||||
local self = frame.obj
|
||||
local value = frame:GetText()
|
||||
if self.ispercent then
|
||||
value = gsub(value, '%%', '')
|
||||
value = value:gsub('%%', '')
|
||||
value = tonumber(value) / 100
|
||||
else
|
||||
value = tonumber(value)
|
||||
@@ -111,16 +106,16 @@ local function EditBox_OnEnterPressed()
|
||||
if value then
|
||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||
self.slider:SetValue(value)
|
||||
self:Fire("OnMouseUp", 1, value)
|
||||
self:Fire("OnMouseUp", value)
|
||||
end
|
||||
end
|
||||
|
||||
local function EditBox_OnEnter()
|
||||
this:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
||||
local function EditBox_OnEnter(frame)
|
||||
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
|
||||
end
|
||||
|
||||
local function EditBox_OnLeave()
|
||||
this:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
|
||||
local function EditBox_OnLeave(frame)
|
||||
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -222,9 +217,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")
|
||||
label:SetPoint("TOPRIGHT")
|
||||
label:SetJustifyH("CENTER")
|
||||
label:SetHeight(15)
|
||||
|
||||
local slider = CreateFrame("Slider", nil, frame)
|
||||
|
||||
Reference in New Issue
Block a user