Ace3 backport

This commit is contained in:
Pinya
2018-07-21 13:29:50 +03:00
parent 332d53e7f6
commit f0eac39bcd
43 changed files with 1071 additions and 846 deletions
@@ -20,30 +20,30 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame)
local function Button_OnClick()
PlaySound("gsTitleOptionExit")
frame.obj:Hide()
this.obj:Hide()
end
local function Frame_OnShow(frame)
frame.obj:Fire("OnShow")
local function Frame_OnShow()
this.obj:Fire("OnShow")
end
local function Frame_OnClose(frame)
frame.obj:Fire("OnClose")
local function Frame_OnClose()
this.obj:Fire("OnClose")
end
local function Frame_OnMouseDown(frame)
local function Frame_OnMouseDown()
AceGUI:ClearFocus()
end
local function Title_OnMouseDown(frame)
frame:GetParent():StartMoving()
local function Title_OnMouseDown()
this:GetParent():StartMoving()
AceGUI:ClearFocus()
end
local function MoverSizer_OnMouseUp(mover)
local frame = mover:GetParent()
local function MoverSizer_OnMouseUp()
local frame = this:GetParent()
frame:StopMovingOrSizing()
local self = frame.obj
local status = self.status or self.localstatus
@@ -53,27 +53,27 @@ local function MoverSizer_OnMouseUp(mover)
status.left = frame:GetLeft()
end
local function SizerSE_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOMRIGHT")
local function SizerSE_OnMouseDown()
this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus()
end
local function SizerS_OnMouseDown(frame)
frame:GetParent():StartSizing("BOTTOM")
local function SizerS_OnMouseDown()
this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus()
end
local function SizerE_OnMouseDown(frame)
frame:GetParent():StartSizing("RIGHT")
local function SizerE_OnMouseDown()
this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus()
end
local function StatusBar_OnEnter(frame)
frame.obj:Fire("OnEnterStatusBar")
local function StatusBar_OnEnter()
this.obj:Fire("OnEnterStatusBar")
end
local function StatusBar_OnLeave(frame)
frame.obj:Fire("OnLeaveStatusBar")
local function StatusBar_OnLeave()
this.obj:Fire("OnLeaveStatusBar")
end
--[[-----------------------------------------------------------------------------
@@ -156,7 +156,7 @@ local methods = {
frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
else
frame:SetPoint("CENTER")
frame:SetPoint("CENTER", 0, 0)
end
end
}
@@ -249,7 +249,7 @@ local function Constructor()
titlebg_r:SetHeight(40)
local sizer_se = CreateFrame("Frame", nil, frame)
sizer_se:SetPoint("BOTTOMRIGHT")
sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
sizer_se:SetWidth(25)
sizer_se:SetHeight(25)
sizer_se:EnableMouse()
@@ -274,7 +274,7 @@ local function Constructor()
local sizer_s = CreateFrame("Frame", nil, frame)
sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
sizer_s:SetPoint("BOTTOMLEFT")
sizer_s:SetPoint("BOTTOMLEFT", 0, 0)
sizer_s:SetHeight(25)
sizer_s:EnableMouse(true)
sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
@@ -282,7 +282,7 @@ local function Constructor()
local sizer_e = CreateFrame("Frame", nil, frame)
sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
sizer_e:SetPoint("TOPRIGHT")
sizer_e:SetPoint("TOPRIGHT", 0, 0)
sizer_e:SetWidth(25)
sizer_e:EnableMouse(true)
sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
@@ -9,6 +9,7 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, assert, type = pairs, assert, type
local min, max, floor, abs = math.min, math.max, math.floor, math.abs
local format = string.format
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -16,24 +17,24 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function FixScrollOnUpdate(frame)
frame:SetScript("OnUpdate", nil)
frame.obj:FixScroll()
local function FixScrollOnUpdate()
this:SetScript("OnUpdate", nil)
this.obj:FixScroll()
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function ScrollFrame_OnMouseWheel(frame, value)
frame.obj:MoveScroll(value)
local function ScrollFrame_OnMouseWheel()
this.obj:MoveScroll(arg1)
end
local function ScrollFrame_OnSizeChanged(frame)
frame:SetScript("OnUpdate", FixScrollOnUpdate)
local function ScrollFrame_OnSizeChanged()
this:SetScript("OnUpdate", FixScrollOnUpdate)
end
local function ScrollBar_OnScrollValueChanged(frame, value)
frame.obj:SetScroll(value)
local function ScrollBar_OnScrollValueChanged()
this.obj:SetScroll(arg1)
end
--[[-----------------------------------------------------------------------------
@@ -50,7 +51,7 @@ local methods = {
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.scrollframe:SetPoint("BOTTOMRIGHT")
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
self.scrollbar:Hide()
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil
@@ -102,7 +103,7 @@ local methods = {
self.scrollBarShown = nil
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
self.scrollframe:SetPoint("BOTTOMRIGHT")
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
self:DoLayout()
end
else
@@ -157,13 +158,13 @@ local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT")
scrollframe:SetPoint("BOTTOMRIGHT")
scrollframe:SetPoint("TOPLEFT", 0, 0)
scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
scrollframe:EnableMouseWheel(true)
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
local scrollbar = CreateFrame("Slider", format("AceConfigDialogScrollFrame%dScrollBar", num), scrollframe, "UIPanelScrollBarTemplate")
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
scrollbar:SetMinMaxValues(0, 1000)
@@ -180,8 +181,8 @@ local function Constructor()
--Container Support
local content = CreateFrame("Frame", nil, scrollframe)
content:SetPoint("TOPLEFT")
content:SetPoint("TOPRIGHT")
content:SetPoint("TOPLEFT", 0, 0)
content:SetPoint("TOPRIGHT", 0, 0)
content:SetHeight(400)
scrollframe:SetScrollChild(content)
@@ -8,6 +8,8 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
local format = string.format
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
@@ -52,34 +54,34 @@ local function Tab_SetDisabled(frame, disabled)
UpdateTabLook(frame)
end
local function BuildTabsOnUpdate(frame)
local self = frame.obj
local function BuildTabsOnUpdate()
local self = this.obj
self:BuildTabs()
frame:SetScript("OnUpdate", nil)
this:SetScript("OnUpdate", nil)
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Tab_OnClick(frame)
if not (frame.selected or frame.disabled) then
local function Tab_OnClick()
if not (this.selected or this.disabled) then
PlaySound("igCharacterInfoTab")
frame.obj:SelectTab(frame.value)
this.obj:SelectTab(this.value)
end
end
local function Tab_OnEnter(frame)
local self = frame.obj
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
local function Tab_OnEnter()
local self = this.obj
self:Fire("OnTabEnter", self.tabs[this.id].value, this)
end
local function Tab_OnLeave(frame)
local self = frame.obj
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
local function Tab_OnLeave()
local self = this.obj
self:Fire("OnTabLeave", self.tabs[this.id].value, this)
end
local function Tab_OnShow(frame)
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
local function Tab_OnShow()
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
end
--[[-----------------------------------------------------------------------------
@@ -102,10 +104,32 @@ local methods = {
end,
["CreateTab"] = function(self, id)
local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
tab.obj = self
tab.id = id
tab:SetHeight(24)
-- Normal texture
local texture = _G[tabname.."Left"]
texture:ClearAllPoints()
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."Middle"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."Right"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
-- Disabled texture
texture = _G[tabname.."LeftDisabled"]
texture:ClearAllPoints()
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."MiddleDisabled"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
texture = _G[tabname.."RightDisabled"]
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
tab.text = _G[tabname .. "Text"]
tab.text:ClearAllPoints()
@@ -186,23 +210,28 @@ local methods = {
end
tab:Show()
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
tab.value = v.value
if type(v) == "table" then
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
tab.value = v.value
elseif type(v) == "string" then
tab:SetText(v)
tab.value = v
end
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
end
for i = (#tablist)+1, #tabs, 1 do
for i = getn(tablist)+1, getn(tabs), 1 do
tabs[i]:Hide()
end
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
local numtabs = #tablist
local numtabs = getn(tablist)
local numrows = 1
local usedwidth = 0
for i = 1, #tablist do
for i = 1, numtabs do
--If this is not the first tab of a row and there isn't room for it
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
@@ -213,7 +242,7 @@ local methods = {
usedwidth = usedwidth + widths[i]
end
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
rowends[numrows] = #tablist
rowends[numrows] = numtabs
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
if numrows > 1 then
@@ -9,7 +9,8 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
local math_min, math_max, floor = math.min, math.max, floor
local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat
local tremove, unpack, tconcat, getn = table.remove, unpack, table.concat, getn
local format, split = string.format, string.split
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -80,11 +81,11 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
local line = button.line
button.level = level
if ( level == 1 ) then
button:SetTextFontObject("GameFontNormal")
button.text:SetFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else
button:SetTextFontObject("GameFontHighlightSmall")
button.text:SetFontObject("GameFontHighlightSmall")
button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
end
@@ -154,120 +155,115 @@ local function addLine(self, v, tree, level, parent)
else
line.hasChildren = nil
end
self.lines[#self.lines+1] = line
tinsert(self.lines, line)
return line
end
--fire an update after one frame to catch the treeframes height
local function FirstFrameUpdate(frame)
local self = frame.obj
frame:SetScript("OnUpdate", nil)
local function FirstFrameUpdate()
local self = this.obj
this:SetScript("OnUpdate", nil)
self:RefreshTree()
end
local function BuildUniqueValue(...)
local n = select('#', ...)
if n == 1 then
return ...
else
return (...).."\001"..BuildUniqueValue(select(2,...))
end
return tconcat(arg, "\001", 1, getn(arg))
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Expand_OnClick(frame)
local button = frame.button
local function Expand_OnClick()
local button = this.button
local self = button.obj
local status = (self.status or self.localstatus).groups
status[button.uniquevalue] = not status[button.uniquevalue]
self:RefreshTree()
end
local function Button_OnClick(frame)
local self = frame.obj
self:Fire("OnClick", frame.uniquevalue, frame.selected)
if not frame.selected then
self:SetSelected(frame.uniquevalue)
frame.selected = true
frame:LockHighlight()
local function Button_OnClick()
local self = this.obj
self:Fire("OnClick", this.uniquevalue, this.selected)
if not this.selected then
self:SetSelected(this.uniquevalue)
this.selected = true
this:LockHighlight()
self:RefreshTree()
end
AceGUI:ClearFocus()
end
local function Button_OnDoubleClick(button)
local self = button.obj
local function Button_OnDoubleClick()
local self = this.obj
local status = self.status or self.localstatus
local status = (self.status or self.localstatus).groups
status[button.uniquevalue] = not status[button.uniquevalue]
status[this.uniquevalue] = not status[this.uniquevalue]
self:RefreshTree()
end
local function Button_OnEnter(frame)
local self = frame.obj
self:Fire("OnButtonEnter", frame.uniquevalue, frame)
local function Button_OnEnter()
local self = this.obj
self:Fire("OnButtonEnter", this.uniquevalue, this)
if self.enabletooltips then
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",frame,"RIGHT")
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, 1)
GameTooltip:SetOwner(this, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",this,"RIGHT")
GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, 1)
GameTooltip:Show()
end
end
local function Button_OnLeave(frame)
local self = frame.obj
self:Fire("OnButtonLeave", frame.uniquevalue, frame)
local function Button_OnLeave()
local self = this.obj
self:Fire("OnButtonLeave", this.uniquevalue, this)
if self.enabletooltips then
GameTooltip:Hide()
end
end
local function OnScrollValueChanged(frame, value)
if frame.obj.noupdate then return end
local self = frame.obj
local function OnScrollValueChanged()
if this.obj.noupdate then return end
local self = this.obj
local status = self.status or self.localstatus
status.scrollvalue = value
status.scrollvalue = arg1
self:RefreshTree()
AceGUI:ClearFocus()
end
local function Tree_OnSizeChanged(frame)
frame.obj:RefreshTree()
local function Tree_OnSizeChanged()
this.obj:RefreshTree()
end
local function Tree_OnMouseWheel(frame, delta)
local self = frame.obj
local function Tree_OnMouseWheel()
local self = this.obj
if self.showscroll then
local scrollbar = self.scrollbar
local min, max = scrollbar:GetMinMaxValues()
local value = scrollbar:GetValue()
local newvalue = math_min(max,math_max(min,value - delta))
local newvalue = math_min(max,math_max(min,value - arg1))
if value ~= newvalue then
scrollbar:SetValue(newvalue)
end
end
end
local function Dragger_OnLeave(frame)
frame:SetBackdropColor(1, 1, 1, 0)
local function Dragger_OnLeave()
this:SetBackdropColor(1, 1, 1, 0)
end
local function Dragger_OnEnter(frame)
frame:SetBackdropColor(1, 1, 1, 0.8)
local function Dragger_OnEnter()
this:SetBackdropColor(1, 1, 1, 0.8)
end
local function Dragger_OnMouseDown(frame)
local treeframe = frame:GetParent()
local function Dragger_OnMouseDown()
local treeframe = this:GetParent()
treeframe:StartSizing("RIGHT")
end
local function Dragger_OnMouseUp(frame)
local treeframe = frame:GetParent()
local function Dragger_OnMouseUp()
local treeframe = this:GetParent()
local self = treeframe.obj
local frame = treeframe:GetParent()
treeframe:StopMovingOrSizing()
@@ -319,9 +315,39 @@ local methods = {
["CreateButton"] = function(self)
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "InterfaceOptionsButtonTemplate")
local button = CreateFrame("Button", format("AceGUI30TreeButton%d", num), self.treeframe)
button.obj = self
button:SetWidth(175)
button:SetHeight(18)
local toggle = CreateFrame("Button", nil, button)
toggle:SetWidth(14)
toggle:SetHeight(14)
toggle:ClearAllPoints()
toggle:SetPoint("TOPRIGHT", button, "TOPRIGHT", -6, -1)
toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
toggle:SetHighlightTexture("Interface\Buttons\UI-PlusButton-Hilight", "ADD")
toggle:SetScript("OnClick", Button_OnClick)
button.toggle = toggle
toggle.obj = button
local text = button:CreateFontString()
text:SetFontObject(GameFontNormal)
text:SetPoint("RIGHT", toggle, "LEFT", -2, 0)
text:SetJustifyH("LEFT")
button:SetHighlightFontObject(GameFontHighlight)
button.text = text
local highlight = button:CreateTexture(nil, "HIGHLIGHT")
highlight:SetPoint("TOPLEFT", 0, 1)
highlight:SetPoint("BOTTOMRIGHT", 0, 1)
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight")
highlight:SetBlendMode("ADD")
highlight:SetVertexColor(.196, .388, .8)
button.highlight = highlight
local icon = button:CreateTexture(nil, "OVERLAY")
icon:SetWidth(14)
icon:SetHeight(14)
@@ -414,7 +440,7 @@ local methods = {
self:BuildLevel(tree, 1)
local numlines = #lines
local numlines = getn(lines)
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
if maxlines <= 0 then return end
@@ -511,9 +537,8 @@ local methods = {
self.filter = false
local status = self.status or self.localstatus
local groups = status.groups
local path = {...}
for i = 1, #path do
groups[tconcat(path, "\001", 1, i)] = true
for i = 1, getn(arg) do
groups[tconcat(arg, "\001", 1, i)] = true
end
status.selected = uniquevalue
self:RefreshTree(true)
@@ -521,11 +546,11 @@ local methods = {
end,
["SelectByPath"] = function(self, ...)
self:Select(BuildUniqueValue(...), ...)
self:Select(BuildUniqueValue(unpack(arg)), unpack(arg))
end,
["SelectByValue"] = function(self, uniquevalue)
self:Select(uniquevalue, ("\001"):split(uniquevalue))
self:Select(uniquevalue, split("\001", uniquevalue))
end,
["ShowScroll"] = function(self, show)
@@ -632,8 +657,8 @@ local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
local treeframe = CreateFrame("Frame", nil, frame)
treeframe:SetPoint("TOPLEFT")
treeframe:SetPoint("BOTTOMLEFT")
treeframe:SetPoint("TOPLEFT", 0, 0)
treeframe:SetPoint("BOTTOMLEFT", 0, 0)
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
treeframe:EnableMouseWheel(true)
treeframe:SetBackdrop(PaneBackdrop)
@@ -657,7 +682,7 @@ local function Constructor()
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
local scrollbar = CreateFrame("Slider", format("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
scrollbar:SetScript("OnValueChanged", nil)
scrollbar:SetPoint("TOPRIGHT", -10, -26)
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
@@ -673,7 +698,7 @@ local function Constructor()
local border = CreateFrame("Frame",nil,frame)
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
border:SetPoint("BOTTOMRIGHT")
border:SetPoint("BOTTOMRIGHT", 0, 0)
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
@@ -23,29 +23,29 @@ do
local Type = "Window"
local Version = 5
local function frameOnShow(this)
local function frameOnShow()
this.obj:Fire("OnShow")
end
local function frameOnClose(this)
local function frameOnClose()
this.obj:Fire("OnClose")
end
local function closeOnClick(this)
local function closeOnClick()
PlaySound("gsTitleOptionExit")
this.obj:Hide()
end
local function frameOnMouseDown(this)
local function frameOnMouseDown()
AceGUI:ClearFocus()
end
local function titleOnMouseDown(this)
local function titleOnMouseDown()
this:GetParent():StartMoving()
AceGUI:ClearFocus()
end
local function frameOnMouseUp(this)
local function frameOnMouseUp()
local frame = this:GetParent()
frame:StopMovingOrSizing()
local self = frame.obj
@@ -56,22 +56,22 @@ do
status.left = frame:GetLeft()
end
local function sizerseOnMouseDown(this)
local function sizerseOnMouseDown()
this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus()
end
local function sizersOnMouseDown(this)
local function sizersOnMouseDown()
this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus()
end
local function sizereOnMouseDown(this)
local function sizereOnMouseDown()
this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus()
end
local function sizerOnMouseUp(this)
local function sizerOnMouseUp()
this:GetParent():StopMovingOrSizing()
end
@@ -2,32 +2,92 @@
Button Widget (Modified to change text color on SetDisabled method)
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button-ElvUI", 23
local Type, Version = "Button-ElvUI", 2
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
local pairs, unpack = pairs, unpack
-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
local IsShiftKeyDown = IsShiftKeyDown
-- GLOBALS: GameTooltip, ElvUI
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
local dragdropButton
local function lockTooltip()
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
GameTooltip:SetText(" ")
GameTooltip:Show()
end
local function dragdrop_OnMouseDown(...)
if this.obj.dragOnMouseDown then
dragdropButton.mouseDownFrame = this
dragdropButton:SetText(this.obj.value or "Unknown")
dragdropButton:SetWidth(this:GetWidth())
dragdropButton:SetHeight(this:SetHeight())
this.obj.dragOnMouseDown(this, unpack(arg))
end
end
local function dragdrop_OnMouseUp(...)
if this.obj.dragOnMouseUp then
this:SetAlpha(1)
GameTooltip:Hide()
dragdropButton:Hide()
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then
this.obj.dragOnMouseUp(this, unpack(arg))
this.obj.ActivateMultiControl(this.obj, unpack(arg))
end
dragdropButton.enteredFrame = nil
dragdropButton.mouseDownFrame = nil
end
end
local function dragdrop_OnLeave(...)
if this.obj.dragOnLeave then
if dragdropButton.mouseDownFrame then
lockTooltip()
end
if this == dragdropButton.mouseDownFrame then
this:SetAlpha(0)
dragdropButton:Show()
this.obj.dragOnLeave(this, unpack(arg))
end
end
end
local function dragdrop_OnEnter(...)
if this.obj.dragOnEnter and dragdropButton:IsShown() then
dragdropButton.enteredFrame = this
lockTooltip()
this.obj.dragOnEnter(this, unpack(arg))
end
end
local function dragdrop_OnClick()
local button = arg1
if this.obj.dragOnClick and button == "RightButton" then
this.obj.dragOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
elseif this.obj.stateSwitchOnClick and (button == "LeftButton") and IsShiftKeyDown() then
this.obj.stateSwitchOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
end
end
local function Button_OnClick()
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
frame.obj:Fire("OnClick", ...)
this.obj:Fire("OnClick", 2, arg1)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
@@ -76,14 +136,28 @@ Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnClick", Button_OnClick)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
-- dragdrop
if not dragdropButton then
dragdropButton = CreateFrame("Button", "ElvUIAceGUI30DragDropButton", UIParent, "UIPanelButtonTemplate")
dragdropButton:SetFrameStrata("TOOLTIP")
dragdropButton:SetFrameLevel(5)
dragdropButton:SetPoint('BOTTOM', GameTooltip, "BOTTOM", 0, 10)
dragdropButton:Hide()
ElvUI[1]:GetModule('Skins'):HandleButton(dragdropButton)
end
HookScript(frame, "OnClick", dragdrop_OnClick)
HookScript(frame, "OnEnter", dragdrop_OnEnter)
HookScript(frame, "OnLeave", dragdrop_OnLeave)
HookScript(frame, "OnMouseUp", dragdrop_OnMouseUp)
HookScript(frame, "OnMouseDown", dragdrop_OnMouseDown)
local text = frame:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 15, -1)
@@ -16,18 +16,18 @@ local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
local function Button_OnClick()
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
frame.obj:Fire("OnClick", ...)
this.obj:Fire("OnClick", arg1)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
@@ -6,7 +6,9 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs = select, pairs
local pairs = pairs
local unpack = unpack
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
@@ -24,26 +26,26 @@ local function AlignImage(self)
self.text:ClearAllPoints()
if not img then
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
self.text:SetPoint("RIGHT")
self.text:SetPoint("RIGHT", 0, 0)
else
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
self.text:SetPoint("RIGHT")
self.text:SetPoint("RIGHT", 0, 0)
end
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function CheckBox_OnMouseDown(frame)
local self = frame.obj
local function CheckBox_OnMouseDown()
local self = this.obj
if not self.disabled then
if self.image:GetTexture() then
self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
@@ -54,8 +56,8 @@ local function CheckBox_OnMouseDown(frame)
AceGUI:ClearFocus()
end
local function CheckBox_OnMouseUp(frame)
local self = frame.obj
local function CheckBox_OnMouseUp()
local self = this.obj
if not self.disabled then
self:ToggleChecked()
@@ -226,9 +228,9 @@ local methods = {
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -253,7 +255,7 @@ local function Constructor()
local checkbg = frame:CreateTexture(nil, "ARTWORK")
checkbg:SetWidth(24)
checkbg:SetHeight(24)
checkbg:SetPoint("TOPLEFT")
checkbg:SetPoint("TOPLEFT", 0, 0)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
local check = frame:CreateTexture(nil, "OVERLAY")
@@ -264,7 +266,7 @@ local function Constructor()
text:SetJustifyH("LEFT")
text:SetHeight(18)
text:SetPoint("LEFT", checkbg, "RIGHT")
text:SetPoint("RIGHT")
text:SetPoint("RIGHT", 0, 0)
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
@@ -1,7 +1,7 @@
--[[-----------------------------------------------------------------------------
ColorPicker Widget
-------------------------------------------------------------------------------]]
local Type, Version = "ColorPicker-ElvUI", 22
local Type, Version = "ColorPicker", 22
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
@@ -38,20 +38,20 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function ColorSwatch_OnClick(frame)
local function ColorSwatch_OnClick()
HideUIPanel(ColorPickerFrame)
local self = frame.obj
local self = this.obj
if not self.disabled then
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
ColorPickerFrame:SetFrameLevel(this:GetFrameLevel() + 10)
ColorPickerFrame:SetClampedToScreen(true)
ColorPickerFrame.func = function()
@@ -67,20 +67,12 @@ local function ColorSwatch_OnClick(frame)
ColorCallback(self, r, g, b, a, true)
end
local r, g, b, a, dR, dG, dB, dA = self.r, self.g, self.b, self.a, self.dR, self.dG, self.dB, self.dA
local r, g, b, a = self.r, self.g, self.b, self.a
if self.HasAlpha then
ColorPickerFrame.opacity = 1 - (a or 0)
end
ColorPickerFrame:SetColorRGB(r, g, b)
if(ColorPPDefault and self.dR and self.dG and self.dB) then
local alpha = 1
if(self.dA) then
alpha = 1 - self.dA
end
ColorPPDefault.colors = {r = self.dR, g = self.dG, b = self.dB, a = alpha}
end
ColorPickerFrame.cancelFunc = function()
ColorCallback(self, r, g, b, a, true)
end
@@ -109,15 +101,11 @@ local methods = {
self.text:SetText(text)
end,
["SetColor"] = function(self, r, g, b, a, defaultR, defaultG, defaultB, defaultA)
["SetColor"] = function(self, r, g, b, a)
self.r = r
self.g = g
self.b = b
self.a = a or 1
self.dR = defaultR
self.dG = defaultG
self.dB = defaultB
self.dA = defaultA
self.colorSwatch:SetVertexColor(r, g, b, a)
end,
@@ -153,7 +141,7 @@ local function Constructor()
colorSwatch:SetWidth(19)
colorSwatch:SetHeight(19)
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
colorSwatch:SetPoint("LEFT")
colorSwatch:SetPoint("LEFT", 0, 0)
local texture = frame:CreateTexture(nil, "BACKGROUND")
texture:SetWidth(16)
@@ -177,7 +165,7 @@ local function Constructor()
text:SetJustifyH("LEFT")
text:SetTextColor(1, 1, 1)
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
text:SetPoint("RIGHT")
text:SetPoint("RIGHT", 0, 0)
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
@@ -3,31 +3,31 @@
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local select, assert = select, assert
local assert, unpack = assert, unpack
local getn = table.getn
-- WoW APIs
local PlaySound = PlaySound
local CreateFrame = CreateFrame
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, ...)
local function fixlevels(parent, ...)
local child
local level = parent:GetFrameLevel() + 1
for i = 1, getn(arg) do
child = arg[i]
child:SetFrameLevel(level)
fixlevels(child)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, ...)
local child
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, ...)
for i = 1, getn(arg) do
child = arg[i]
fixstrata(strata, child)
end
end
@@ -45,7 +45,7 @@ local ItemBase = {
counter = 0,
}
function ItemBase.Frame_OnEnter(this)
function ItemBase.Frame_OnEnter()
local self = this.obj
if self.useHighlight then
@@ -58,7 +58,7 @@ function ItemBase.Frame_OnEnter(this)
end
end
function ItemBase.Frame_OnLeave(this)
function ItemBase.Frame_OnLeave()
local self = this.obj
self.highlight:Hide()
@@ -108,7 +108,7 @@ end
-- exported
function ItemBase.SetPoint(self, ...)
self.frame:SetPoint(...)
self.frame:SetPoint(unpack(arg))
end
-- exported
@@ -248,7 +248,7 @@ do
local widgetType = "Dropdown-Item-Header"
local widgetVersion = 1
local function OnEnter(this)
local function OnEnter()
local self = this.obj
self:Fire("OnEnter")
@@ -257,7 +257,7 @@ do
end
end
local function OnLeave(this)
local function OnLeave()
local self = this.obj
self:Fire("OnLeave")
@@ -297,7 +297,7 @@ do
local widgetType = "Dropdown-Item-Execute"
local widgetVersion = 1
local function Frame_OnClick(this, button)
local function Frame_OnClick()
local self = this.obj
if self.disabled then return end
self:Fire("OnClick")
@@ -338,7 +338,7 @@ do
self:SetValue(nil)
end
local function Frame_OnClick(this, button)
local function Frame_OnClick()
local self = this.obj
if self.disabled then return end
self.value = not self.value
@@ -385,7 +385,7 @@ do
local widgetType = "Dropdown-Item-Menu"
local widgetVersion = 2
local function OnEnter(this)
local function OnEnter()
local self = this.obj
self:Fire("OnEnter")
@@ -400,7 +400,7 @@ do
end
end
local function OnHide(this)
local function OnHide()
local self = this.obj
if self.submenu then
self.submenu:Close()
@@ -3,8 +3,9 @@ local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local select, pairs, ipairs, type = select, pairs, ipairs, type
local tsort = table.sort
local pairs, ipairs, type = pairs, ipairs, type
local tsort, tinsert, getn, setn = table.sort, table.insert, table.getn, table.setn
local format = string.format
-- WoW APIs
local PlaySound = PlaySound
@@ -15,25 +16,24 @@ local _G = _G
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
while child do
child:SetFrameLevel(parent:GetFrameLevel()+1)
fixlevels(child, child:GetChildren())
i = i + 1
child = select(i, ...)
local function fixlevels(parent, ...)
local child
local level = parent:GetFrameLevel() + 1
for i = 1, getn(arg) do
child = arg[i]
child:SetFrameLevel(level)
fixlevels(child)
end
end
local function fixstrata(strata, parent, ...)
local i = 1
local child = select(i, ...)
local child
parent:SetFrameStrata(strata)
while child do
fixstrata(strata, child, child:GetChildren())
i = i + 1
child = select(i, ...)
for i = 1, getn(arg) do
child = arg[i]
fixstrata(strata, child)
end
end
@@ -76,15 +76,15 @@ do
end
-- See the note in Constructor() for each scroll related function
local function OnMouseWheel(this, value)
this.obj:MoveScroll(value)
local function OnMouseWheel()
this.obj:MoveScroll(arg1)
end
local function OnScrollValueChanged(this, value)
this.obj:SetScroll(value)
local function OnScrollValueChanged()
this.obj:SetScroll(arg1)
end
local function OnSizeChanged(this)
local function OnSizeChanged()
this.obj:FixScroll()
end
@@ -169,9 +169,9 @@ do
-- exported
local function AddItem(self, item)
self.items[#self.items + 1] = item
tinsert(self.items, item)
local h = #self.items * 16
local h = getn(self.items) * 16
self.itemFrame:SetHeight(h)
self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement
@@ -222,6 +222,7 @@ do
AceGUI:Release(item)
items[i] = nil
end
setn(items, 0)
end
-- exported
@@ -362,24 +363,24 @@ do
--[[ UI event handler ]]--
local function Control_OnEnter(this)
local function Control_OnEnter()
this.obj.button:LockHighlight()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(this)
local function Control_OnLeave()
this.obj.button:UnlockHighlight()
this.obj:Fire("OnLeave")
end
local function Dropdown_OnHide(this)
local function Dropdown_OnHide()
local self = this.obj
if self.open then
self.pullout:Close()
end
end
local function Dropdown_TogglePullout(this)
local function Dropdown_TogglePullout()
local self = this.obj
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
if self.open then
@@ -571,7 +572,7 @@ do
local function AddListItem(self, value, text, itemType)
if not itemType then itemType = "Dropdown-Item-Toggle" end
local exists = AceGUI:GetWidgetVersion(itemType)
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
if not exists then error(format("The given item type, %q, does not exist within AceGUI-3.0", tostring(itemType)), 2) end
local item = AceGUI:Create(itemType)
item:SetText(text)
@@ -600,7 +601,7 @@ do
if type(order) ~= "table" then
for v in pairs(list) do
sortlist[#sortlist + 1] = v
tinsert(sortlist, v)
end
tsort(sortlist)
@@ -608,6 +609,7 @@ do
AddListItem(self, key, list[key], itemType)
sortlist[i] = nil
end
setn(sortlist, 0)
else
for i, key in ipairs(order) do
AddListItem(self, key, list[key], itemType)
@@ -10,7 +10,7 @@ local tostring, pairs = tostring, pairs
-- WoW APIs
local PlaySound = PlaySound
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
@@ -23,13 +23,12 @@ Support functions
-------------------------------------------------------------------------------]]
if not AceGUIEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
end
function _G.AceGUIEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G["AceGUI-3.0EditBox"..i]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
if editbox and editbox:IsVisible() and editbox.hasfocus then
editbox:Insert(text)
return true
end
@@ -51,26 +50,26 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Frame_OnShowFocus(frame)
frame.obj.editbox:SetFocus()
frame:SetScript("OnShow", nil)
local function Frame_OnShowFocus()
this.obj.editbox:SetFocus()
this:SetScript("OnShow", nil)
end
local function EditBox_OnEscapePressed(frame)
local function EditBox_OnEscapePressed()
AceGUI:ClearFocus()
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
local cancel = self:Fire("OnEnterPressed", value)
if not cancel then
PlaySound("igMainMenuOptionCheckBoxOn")
@@ -78,15 +77,20 @@ local function EditBox_OnEnterPressed(frame)
end
end
local function EditBox_OnReceiveDrag(frame)
local self = frame.obj
local function EditBox_OnReceiveDrag()
if not GetCursorInfo then print("TODO GetCursorInfo") return end -- TODO
local self = this.obj
local type, id, info = GetCursorInfo()
if type == "item" then
self:SetText(info)
self:Fire("OnEnterPressed", info)
ClearCursor()
elseif type == "spell" then
local name = GetSpellInfo(id, info)
local name, rank = GetSpellName(id, info)
if rank ~= "" then
name = name.."("..rank..")"
end
self:SetText(name)
self:Fire("OnEnterPressed", name)
ClearCursor()
@@ -100,9 +104,9 @@ local function EditBox_OnReceiveDrag(frame)
AceGUI:ClearFocus()
end
local function EditBox_OnTextChanged(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnTextChanged()
local self = this.obj
local value = this:GetText()
if tostring(value) ~= tostring(self.lasttext) then
self:Fire("OnTextChanged", value)
self.lasttext = value
@@ -110,14 +114,20 @@ local function EditBox_OnTextChanged(frame)
end
end
local function EditBox_OnFocusGained(frame)
AceGUI:SetFocus(frame.obj)
local function EditBox_OnFocusGained()
this.hasfocus = true
AceGUI:SetFocus(this.obj)
end
local function Button_OnClick(frame)
local editbox = frame.obj.editbox
local function EditBox_OnFocusLost()
this.hasfocus = nil
end
local function Button_OnClick()
local editbox = this.obj.editbox
editbox:ClearFocus()
EditBox_OnEnterPressed(editbox)
this = editbox
EditBox_OnEnterPressed()
end
--[[-----------------------------------------------------------------------------
@@ -155,7 +165,7 @@ local methods = {
["SetText"] = function(self, text)
self.lasttext = text or ""
self.editbox:SetText(text or "")
self.editbox:SetCursorPosition(0)
EditBoxSetCursorPosition(self.editbox, 0)
HideButton(self)
end,
@@ -226,10 +236,11 @@ local function Constructor()
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
editbox:SetScript("OnEditFocusLost", EditBox_OnFocusLost)
editbox:SetTextInsets(0, 0, 3, 3)
editbox:SetMaxLetters(256)
editbox:SetPoint("BOTTOMLEFT", 6, 0)
editbox:SetPoint("BOTTOMRIGHT")
editbox:SetPoint("BOTTOMRIGHT", 0, 0)
editbox:SetHeight(19)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
@@ -43,8 +43,8 @@ local function Constructor()
frame:Hide()
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
label:SetPoint("TOP")
label:SetPoint("BOTTOM")
label:SetPoint("TOP", 0, 0)
label:SetPoint("BOTTOM", 0, 0)
label:SetJustifyH("CENTER")
local left = frame:CreateTexture(nil, "BACKGROUND")
@@ -6,7 +6,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs, print = select, pairs, print
local pairs, print, unpack = pairs, print, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -14,16 +15,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Button_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
local function Button_OnClick()
this.obj:Fire("OnClick", arg1)
AceGUI:ClearFocus()
end
@@ -58,9 +59,9 @@ local methods = {
image:SetTexture(path)
if image:GetTexture() then
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -6,7 +6,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local select, pairs = select, pairs
local pairs, unpack = pairs, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -18,16 +19,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Label_OnClick(frame, button)
frame.obj:Fire("OnClick", button)
local function Label_OnClick()
this.obj:Fire("OnClick", arg1)
AceGUI:ClearFocus()
end
@@ -45,13 +46,13 @@ local methods = {
-- ["OnRelease"] = nil,
["SetHighlight"] = function(self, ...)
self.highlight:SetTexture(...)
self.highlight:SetTexture(unpack(arg))
end,
["SetHighlightTexCoord"] = function(self, ...)
local c = select("#", ...)
local c = getn(arg)
if c == 4 or c == 8 then
self.highlight:SetTexCoord(...)
self.highlight:SetTexCoord(unpack(arg))
else
self.highlight:SetTexCoord(0, 1, 0, 1)
end
@@ -21,33 +21,35 @@ local CreateFrame, UIParent = CreateFrame, UIParent
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Keybinding_OnClick(frame, button)
if button == "LeftButton" or button == "RightButton" then
local self = frame.obj
--[[
local function Keybinding_OnClick()
if arg1 == "LeftButton" or arg1 == "RightButton" then
local self = this.obj
if self.waitingForKey then
frame:EnableKeyboard(false)
frame:EnableMouseWheel(false)
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
frame:UnlockHighlight()
this:UnlockHighlight()
self.waitingForKey = nil
else
frame:EnableKeyboard(true)
frame:EnableMouseWheel(true)
this:EnableKeyboard(true)
this:EnableMouseWheel(true)
self.msgframe:Show()
frame:LockHighlight()
this:LockHighlight()
self.waitingForKey = true
end
end
AceGUI:ClearFocus()
end
]]
local ignoreKeys = {
["BUTTON1"] = true, ["BUTTON2"] = true,
@@ -55,10 +57,10 @@ local ignoreKeys = {
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
}
local function Keybinding_OnKeyDown(frame, key)
local self = frame.obj
local function Keybinding_OnKeyDown()
local self = this.obj
if self.waitingForKey then
local keyPressed = key
local keyPressed = arg1
if keyPressed == "ESCAPE" then
keyPressed = ""
else
@@ -74,10 +76,10 @@ local function Keybinding_OnKeyDown(frame, key)
end
end
frame:EnableKeyboard(false)
frame:EnableMouseWheel(false)
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
frame:UnlockHighlight()
this:UnlockHighlight()
self.waitingForKey = nil
if not self.disabled then
@@ -87,27 +89,49 @@ local function Keybinding_OnKeyDown(frame, key)
end
end
local function Keybinding_OnMouseDown(frame, button)
if button == "LeftButton" or button == "RightButton" then
return
elseif button == "MiddleButton" then
button = "BUTTON3"
elseif button == "Button4" then
button = "BUTTON4"
elseif button == "Button5" then
button = "BUTTON5"
local function Keybinding_OnMouseUp()
if MouseIsOver(this) and not self.disabled then
local self = this.obj
if self.waitingForKey then
if arg1 ~= "LeftButton" and arg1 ~= "RightButton" then
Keybinding_OnKeyDown()
end
this:EnableKeyboard(false)
this:EnableMouseWheel(false)
self.msgframe:Hide()
this:UnlockHighlight()
self.waitingForKey = nil
else
this:EnableKeyboard(true)
this:EnableMouseWheel(true)
self.msgframe:Show()
this:LockHighlight()
self.waitingForKey = true
end
end
Keybinding_OnKeyDown(frame, button)
AceGUI:ClearFocus()
end
local function Keybinding_OnMouseWheel(frame, direction)
local button
if direction >= 0 then
button = "MOUSEWHEELUP"
else
button = "MOUSEWHEELDOWN"
local function Keybinding_OnMouseDown()
if arg1 == "LeftButton" or arg1 == "RightButton" then
return
elseif arg1 == "MiddleButton" then
arg1 = "BUTTON3"
elseif arg1 == "Button4" then
arg1 = "BUTTON4"
elseif arg1 == "Button5" then
arg1 = "BUTTON5"
end
Keybinding_OnKeyDown(frame, button)
Keybinding_OnKeyDown()
end
local function Keybinding_OnMouseWheel()
if arg1 >= 0 then
arg1 = "MOUSEWHEELUP"
else
arg1 = "MOUSEWHEELDOWN"
end
Keybinding_OnKeyDown()
end
--[[-----------------------------------------------------------------------------
@@ -141,10 +165,10 @@ local methods = {
["SetKey"] = function(self, key)
if (key or "") == "" then
self.button:SetText(NOT_BOUND)
self.button:SetNormalFontObject("GameFontNormal")
self.text:SetFontObject("GameFontNormal")
else
self.button:SetText(key)
self.button:SetNormalFontObject("GameFontHighlight")
self.text:SetFontObject("GameFontHighlight")
end
end,
@@ -179,9 +203,9 @@ local ControlBackdrop = {
insets = { left = 3, right = 3, top = 3, bottom = 3 }
}
local function keybindingMsgFixWidth(frame)
frame:SetWidth(frame.msg:GetWidth() + 10)
frame:SetScript("OnUpdate", nil)
local function keybindingMsgFixWidth()
this:SetWidth(this.msg:GetWidth() + 10)
this:SetScript("OnUpdate", nil)
end
local function Constructor()
@@ -195,12 +219,13 @@ local function Constructor()
button:RegisterForClicks("AnyDown")
button:SetScript("OnEnter", Control_OnEnter)
button:SetScript("OnLeave", Control_OnLeave)
button:SetScript("OnClick", Keybinding_OnClick)
-- button:SetScript("OnClick", Keybinding_OnClick)
button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
button:SetPoint("BOTTOMLEFT")
button:SetPoint("BOTTOMRIGHT")
button:SetPoint("BOTTOMLEFT", 0, 0)
button:SetPoint("BOTTOMRIGHT", 0, 0)
button:SetHeight(24)
button:EnableKeyboard(false)
@@ -209,8 +234,8 @@ local function Constructor()
text:SetPoint("RIGHT", -7, 0)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
label:SetPoint("TOPLEFT")
label:SetPoint("TOPRIGHT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetPoint("TOPRIGHT", 0, 0)
label:SetJustifyH("CENTER")
label:SetHeight(18)
@@ -236,7 +261,8 @@ local function Constructor()
msgframe = msgframe,
frame = frame,
alignoffset = 30,
type = Type
type = Type,
text = text
}
for method, func in pairs(methods) do
widget[method] = func
@@ -7,7 +7,8 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local max, select, pairs = math.max, select, pairs
local max, pairs, unpack = math.max, pairs, unpack
local getn = table.getn
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
@@ -35,14 +36,14 @@ local function UpdateImageAnchor(self)
local imagewidth = image:GetWidth()
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
-- image goes on top centered when less than 200 width for the text, or if there is no text
image:SetPoint("TOP")
image:SetPoint("TOP", 0, 0)
label:SetPoint("TOP", image, "BOTTOM")
label:SetPoint("LEFT")
label:SetPoint("LEFT", 0, 0)
label:SetWidth(width)
height = image:GetHeight() + label:GetHeight()
else
-- image on the left
image:SetPoint("TOPLEFT")
image:SetPoint("TOPLEFT", 0, 0)
if image:GetHeight() > label:GetHeight() then
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
else
@@ -53,7 +54,7 @@ local function UpdateImageAnchor(self)
end
else
-- no image shown
label:SetPoint("TOPLEFT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetWidth(width)
height = label:GetHeight()
end
@@ -111,9 +112,9 @@ local methods = {
if image:GetTexture() then
self.imageshown = true
local n = select("#", ...)
local n = getn(arg)
if n == 4 or n == 8 then
image:SetTexCoord(...)
image:SetTexCoord(unpack(arg))
else
image:SetTexCoord(0, 1, 0, 1)
end
@@ -4,9 +4,10 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
local format = string.format
-- WoW APIs
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
local GetCursorInfo, GetSpellName, ClearCursor = GetCursorInfo, GetSpellName, ClearCursor
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
@@ -20,13 +21,12 @@ Support functions
if not AceGUIMultiLineEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
end
function _G.AceGUIMultiLineEditBoxInsertLink(text)
for i = 1, AceGUI:GetWidgetCount(Type) do
local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
local editbox = _G[format("MultiLineEditBox%uEdit",i)]
if editbox and editbox:IsVisible() and editbox.hasfocus then
editbox:Insert(text)
return true
end
@@ -55,78 +55,88 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function OnClick(self) -- Button
self = self.obj
local function OnClick() -- Button
local self = this.obj
self.editBox:ClearFocus()
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
self.button:Disable()
end
end
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
self, y = self.obj.scrollFrame, -y
local function OnCursorChanged() -- EditBox
local self, y = this.obj.scrollFrame, -arg2
local offset = self:GetVerticalScroll()
if y < offset then
self:SetVerticalScroll(y)
else
y = y + cursorHeight - self:GetHeight()
y = y + arg4 - self:GetHeight()
if y > offset then
self:SetVerticalScroll(y)
end
end
end
local function OnEditFocusLost(self) -- EditBox
self:HighlightText(0, 0)
self.obj:Fire("OnEditFocusLost")
local function OnEditFocusLost() -- EditBox
this.hasfocus = nil
this:HighlightText(0, 0)
this.obj:Fire("OnEditFocusLost")
end
local function OnEnter(self) -- EditBox / ScrollFrame
self = self.obj
local function OnEnter() -- EditBox / ScrollFrame
local self = this.obj
if not self.entered then
self.entered = true
self:Fire("OnEnter")
end
end
local function OnLeave(self) -- EditBox / ScrollFrame
self = self.obj
local function OnLeave() -- EditBox / ScrollFrame
local self = this.obj
if self.entered then
self.entered = nil
self:Fire("OnLeave")
end
end
local function OnMouseUp(self) -- ScrollFrame
self = self.obj.editBox
local function OnMouseUp() -- ScrollFrame
local self = this.obj.editBox
self:SetFocus()
self:SetCursorPosition(self:GetNumLetters())
EditBoxSetCursorPosition(self, self:GetNumLetters())
end
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
local function OnReceiveDrag() -- EditBox / ScrollFrame
if not GetCursorInfo then print("TODO GetCursorInfo") return end -- TODO
local type, id, info = GetCursorInfo()
if type == "spell" then
info = GetSpellInfo(id, info)
local name, rank = GetSpellName(id, info)
if rank ~= "" then
name = name.."("..rank..")"
end
info = name
elseif type ~= "item" then
return
end
ClearCursor()
self = self.obj
local self = this.obj
local editBox = self.editBox
if not editBox:HasFocus() then
if not this.hasfocus then
this.hasfocus = true
editBox:SetFocus()
editBox:SetCursorPosition(editBox:GetNumLetters())
EditBoxSetCursorPosition(editBox, editBox:GetNumLetters())
end
editBox:Insert(info)
self.button:Enable()
end
local function OnSizeChanged(self, width, height) -- ScrollFrame
self.obj.editBox:SetWidth(width)
local function OnSizeChanged() -- ScrollFrame
this:UpdateScrollChildRect()
this:SetVerticalScroll(this:GetHeight())
this.obj.editBox:SetWidth(arg1)
end
local function OnTextChanged(self) -- EditBox
self = self.obj
local function OnTextChanged() -- EditBox
local self = this.obj
local value = self.editBox:GetText()
if not self.lastText or value ~= self.lastText then
self:Fire("OnTextChanged", value)
@@ -138,26 +148,31 @@ local function OnTextChanged(self)
end
end
local function OnTextSet(self) -- EditBox
self:HighlightText(0, 0)
self:SetCursorPosition(self:GetNumLetters())
self:SetCursorPosition(0)
self.obj.button:Disable()
local function OnTextSet() -- EditBox
this:HighlightText(0, 0)
EditBoxSetCursorPosition(this, this:GetNumLetters())
EditBoxSetCursorPosition(this, 0)
this.obj.button:Disable()
end
local function OnVerticalScroll(self, offset) -- ScrollFrame
local editBox = self.obj.editBox
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
local function OnVerticalScroll() -- ScrollFrame
local editBox = this.obj.editBox
editBox:SetHitRectInsets(0, 0, arg1, editBox:GetHeight() - arg1 - this:GetHeight())
end
local function OnShowFocus(frame)
frame.obj.editBox:SetFocus()
frame:SetScript("OnShow", nil)
local function OnShowFocus()
this.obj.editBox:SetFocus()
this:SetScript("OnShow", nil)
end
local function OnEditFocusGained(frame)
AceGUI:SetFocus(frame.obj)
frame.obj:Fire("OnEditFocusGained")
local function OnEditFocusGained()
this.hasfocus = true
AceGUI:SetFocus(this.obj)
this.obj:Fire("OnEditFocusGained")
end
local function OnEscapePressed()
AceGUI:ClearFocus()
end
--[[-----------------------------------------------------------------------------
@@ -257,11 +272,11 @@ local methods = {
end,
["GetCursorPosition"] = function(self)
return self.editBox:GetCursorPosition()
return EditBoxGetCursorPosition(self.editBox)
end,
["SetCursorPosition"] = function(self, ...)
return self.editBox:SetCursorPosition(...)
["SetCursorPosition"] = function(self, pos)
return EditBoxSetCursorPosition(self.editBox, pos)
end,
@@ -289,7 +304,7 @@ local function Constructor()
label:SetText(ACCEPT)
label:SetHeight(10)
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2")
local button = CreateFrame("Button", format("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
button:SetPoint("BOTTOMLEFT", 0, 4)
button:SetHeight(22)
button:SetWidth(label:GetStringWidth() + 24)
@@ -308,7 +323,7 @@ local function Constructor()
scrollBG:SetBackdropColor(0, 0, 0)
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollFrame = CreateFrame("ScrollFrame", format("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
scrollBar:ClearAllPoints()
@@ -326,10 +341,9 @@ local function Constructor()
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
HookScript(scrollFrame, "OnVerticalScroll", OnVerticalScroll)
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
editBox:SetAllPoints()
local editBox = CreateFrame("EditBox", format("%s%dEdit", Type, widgetNum), scrollFrame)
editBox:SetFontObject(ChatFontNormal)
editBox:SetMultiLine(true)
editBox:EnableMouse(true)
@@ -337,7 +351,7 @@ local function Constructor()
editBox:SetScript("OnCursorChanged", OnCursorChanged)
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
editBox:SetScript("OnEnter", OnEnter)
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
editBox:SetScript("OnEscapePressed", OnEscapePressed)
editBox:SetScript("OnLeave", OnLeave)
editBox:SetScript("OnMouseDown", OnReceiveDrag)
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
@@ -347,6 +361,7 @@ local function Constructor()
scrollFrame:SetScrollChild(editBox)
editBox:SetAllPoints()
local widget = {
button = button,
@@ -9,6 +9,7 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local tonumber, pairs = tonumber, pairs
local format, gsub = string.format, string.gsub
-- WoW APIs
local PlaySound = PlaySound
@@ -24,7 +25,7 @@ Support functions
local function UpdateText(self)
local value = self.value or 0
if self.ispercent then
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
self.editbox:SetText(format("%s%%", floor(value * 1000 + 0.5) / 10))
else
self.editbox:SetText(floor(value * 100 + 0.5) / 100)
end
@@ -33,8 +34,8 @@ end
local function UpdateLabels(self)
local min, max = (self.min or 0), (self.max or 100)
if self.ispercent then
self.lowtext:SetFormattedText("%s%%", (min * 100))
self.hightext:SetFormattedText("%s%%", (max * 100))
self.lowtext:SetText(format("%s%%", (min * 100)))
self.hightext:SetText(format("%s%%", (max * 100)))
else
self.lowtext:SetText(min)
self.hightext:SetText(max)
@@ -44,23 +45,23 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
local function Control_OnEnter()
this.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
local function Control_OnLeave()
this.obj:Fire("OnLeave")
end
local function Frame_OnMouseDown(frame)
frame.obj.slider:EnableMouseWheel(true)
local function Frame_OnMouseDown()
this.obj.slider:EnableMouseWheel(true)
AceGUI:ClearFocus()
end
local function Slider_OnValueChanged(frame)
local self = frame.obj
if not frame.setup then
local newvalue = frame:GetValue()
local function Slider_OnValueChanged()
local self = this.obj
if not this.setup then
local newvalue = this:GetValue()
if newvalue ~= self.value and not self.disabled then
self.value = newvalue
self:Fire("OnValueChanged", newvalue)
@@ -71,16 +72,16 @@ local function Slider_OnValueChanged(frame)
end
end
local function Slider_OnMouseUp(frame)
local self = frame.obj
local function Slider_OnMouseUp()
local self = this.obj
self:Fire("OnMouseUp", self.value)
end
local function Slider_OnMouseWheel(frame, v)
local self = frame.obj
local function Slider_OnMouseWheel()
local self = this.obj
if not self.disabled then
local value = self.value
if v > 0 then
if arg1 > 0 then
value = min(value + (self.step or 1), self.max)
else
value = max(value - (self.step or 1), self.min)
@@ -89,15 +90,15 @@ local function Slider_OnMouseWheel(frame, v)
end
end
local function EditBox_OnEscapePressed(frame)
frame:ClearFocus()
local function EditBox_OnEscapePressed()
this:ClearFocus()
end
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
if self.ispercent then
value = value:gsub('%%', '')
value = gsub(value, '%%', '')
value = tonumber(value) / 100
else
value = tonumber(value)
@@ -110,12 +111,12 @@ local function EditBox_OnEnterPressed(frame)
end
end
local function EditBox_OnEnter(frame)
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
local function EditBox_OnEnter()
this:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
end
local function EditBox_OnLeave(frame)
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
local function EditBox_OnLeave()
this:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
end
--[[-----------------------------------------------------------------------------
@@ -217,8 +218,8 @@ local function Constructor()
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("TOPLEFT")
label:SetPoint("TOPRIGHT")
label:SetPoint("TOPLEFT", 0, 0)
label:SetPoint("TOPRIGHT", 0, 0)
label:SetJustifyH("CENTER")
label:SetHeight(15)