WoWInterface SVN Broadcaster

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/Broadcaster/Libs/AceGUI-3.0/widgets
    from Rev 2 to Rev 16
    Reverse comparison

Rev 2 → Rev 16

AceGUIWidget-DropDownGroup.lua
1,30 → 1,6
local AceGUI = LibStub("AceGUI-3.0")
 
-------------
-- Widgets --
-------------
--[[
Widgets must provide the following functions
Acquire() - Called when the object is aquired, should set everything to a default hidden state
Release() - Called when the object is Released, should remove any anchors and hide the Widget
 
And the following members
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
type - the type of the object, same as the name given to :RegisterWidget()
 
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
It will be cleared automatically when a widget is released
Placing values directly into a widget object should be avoided
 
If the Widget can act as a container for other Widgets the following
content - frame or derivitive that children will be anchored to
 
The Widget can supply the following Optional Members
 
 
]]
 
--[[
Selection Group controls all have an interface to select a group for thier contents
None of them will auto size to thier contents, and should usually be used with a scrollframe
unless you know that the controls will fit inside
40,13 → 16,13
]]
do
local Type = "DropdownGroup"
local Version = 5
local Version = 9
 
local function Acquire(self)
local function OnAcquire(self)
self.dropdown:SetText("")
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.dropdown.list = nil
71,12 → 47,12
local function SelectedGroup(self,event,value)
local group = self.parentgroup
local status = group.status or group.localstatus
status.selectedgroup = value
status.selected = value
self.parentgroup:Fire("OnGroupSelected", value)
end
 
local function SetGroupList(self,list)
self.dropdown.list = list
self.dropdown:SetList(list)
end
 
-- called to set an external table to store status in
88,13 → 64,13
local function SetGroup(self,group)
self.dropdown:SetValue(group)
local status = self.status or self.localstatus
status.selectedgroup = group
status.selected = group
self:Fire("OnGroupSelected", group)
end
 
local function OnWidthSet(self, width)
local content = self.content
local contentwidth = width - 63
local contentwidth = width - 26
if contentwidth < 0 then
contentwidth = 0
end
105,7 → 81,7
 
local function OnHeightSet(self, height)
local content = self.content
local contentheight = height - 26
local contentheight = height - 63
if contentheight < 0 then
contentheight = 0
end
118,10 → 94,10
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.SetTitle = SetTitle
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.SetTitle = SetTitle
self.SetGroupList = SetGroupList
self.SetGroup = SetGroup
self.SetStatusTable = SetStatusTable
AceGUIWidget-ScrollFrame.lua
29,13 → 29,13
--------------------------
do
local Type = "ScrollFrame"
local Version = 2
local Version = 3
 
local function Acquire(self)
local function OnAcquire(self)
 
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.status = nil
161,8 → 161,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.MoveScroll = MoveScroll
self.FixScroll = FixScroll
AceGUIWidget-Button.lua
5,12 → 5,12
--------------------------
do
local Type = "Button"
local Version = 5
local Version = 7
 
local function Acquire(self)
local function OnAcquire(self)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetDisabled(false)
18,6 → 18,7
 
local function Button_OnClick(this)
this.obj:Fire("OnClick")
AceGUI:ClearFocus()
end
 
local function Button_OnEnter(this)
41,11 → 42,11
end
end
 
local count = 0
local function Constructor()
count = count + 1
local frame = CreateFrame("Button","AceGUI30Button"..count,UIParent,"UIPanelButtonTemplate2")
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button","AceGUI30Button"..num,UIParent,"UIPanelButtonTemplate2")
local self = {}
self.num = num
self.type = Type
self.frame = frame
 
66,8 → 67,8
frame:SetHeight(24)
frame:SetWidth(200)
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.frame = frame
frame.obj = self
AceGUIWidget-TreeGroup.lua
21,37 → 21,18
end
end
 
-------------
-- Widgets --
-------------
--[[
Widgets must provide the following functions
Acquire() - Called when the object is aquired, should set everything to a default hidden state
Release() - Called when the object is Released, should remove any anchors and hide the Widget
 
And the following members
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
type - the type of the object, same as the name given to :RegisterWidget()
 
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
It will be cleared automatically when a widget is released
Placing values directly into a widget object should be avoided
 
If the Widget can act as a container for other Widgets the following
content - frame or derivitive that children will be anchored to
 
The Widget can supply the following Optional Members
local WotLK = select(4, GetBuildInfo()) >= 30000
 
 
]]
 
--------------
-- TreeView --
--------------
 
do
local Type = "TreeGroup"
local Version = 6
local Version = 15
 
local DEFAULT_TREE_WIDTH = 175
local DEFAULT_TREE_SIZABLE = true
 
local PaneBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
60,11 → 41,20
insets = { left = 3, right = 3, top = 5, bottom = 3 }
}
 
local function Acquire(self)
 
local DraggerBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = nil,
tile = true, tileSize = 16, edgeSize = 0,
insets = { left = 3, right = 3, top = 7, bottom = 7 }
}
 
local function OnAcquire(self)
self:SetTreeWidth(DEFAULT_TREE_WIDTH,DEFAULT_TREE_SIZABLE)
self:EnableButtonTooltips(true)
end
 
local function Release(self)
local function OnRelease(self)
 
self.frame:ClearAllPoints()
self.frame:Hide()
self.status = nil
78,6 → 68,8
end
end
self.localstatus.scrollvalue = 0
self.localstatus.treewidth = DEFAULT_TREE_WIDTH
self.localstatus.treesizable = DEFAULT_TREE_SIZABLE
end
 
local function GetButtonParents(line)
105,6 → 97,7
this:LockHighlight()
self:RefreshTree()
end
AceGUI:ClearFocus()
end
 
local function ExpandOnClick(this)
122,7 → 115,34
status[button.uniquevalue] = not status[button.uniquevalue]
self:RefreshTree()
end
 
 
local function EnableButtonTooltips(self, enable)
self.enabletooltips = enable
end
 
local function Button_OnEnter(this)
local self = this.obj
self:Fire("OnButtonEnter", this.uniquevalue, this)
 
if self.enabletooltips then
GameTooltip:SetOwner(this, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",this,"RIGHT")
GameTooltip:SetText(this.text:GetText(), 1, .82, 0, 1)
 
GameTooltip:Show()
end
end
 
local function Button_OnLeave(this)
local self = this.obj
self:Fire("OnButtonLeave", this.uniquevalue, this)
 
if self.enabletooltips then
GameTooltip:Hide()
end
end
 
 
local buttoncount = 1
local function CreateButton(self)
local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "InterfaceOptionsButtonTemplate")
131,6 → 151,8
 
button:SetScript("OnClick",ButtonOnClick)
button:SetScript("OnDoubleClick", ButtonOnDoubleClick)
button:SetScript("OnEnter",Button_OnEnter)
button:SetScript("OnLeave",Button_OnLeave)
 
button.toggle.button = button
button.toggle:SetScript("OnClick",ExpandOnClick)
163,11 → 185,19
local line = button.line
button.level = level
if ( level == 1 ) then
button:SetTextFontObject("GameFontNormal")
if WotLK then
button:SetNormalFontObject("GameFontNormal")
else
button:SetTextFontObject("GameFontNormal")
end
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", 8, 2)
else
button:SetTextFontObject("GameFontHighlightSmall")
if WotLK then
button:SetNormalFontObject("GameFontHighlightSmall")
else
button:SetTextFontObject("GameFontHighlightSmall")
end
button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", 8 * level, 2)
end
201,6 → 231,7
local status = self.status or self.localstatus
status.scrollvalue = value
self:RefreshTree()
AceGUI:ClearFocus()
end
 
-- called to set an external table to store status in
213,6 → 244,13
if not status.scrollvalue then
status.scrollvalue = 0
end
if not status.treewidth then
status.treewidth = DEFAULT_TREE_WIDTH
end
if not status.treesizable then
status.treesizable = DEFAULT_TREE_SIZABLE
end
self:SetTreeWidth(status.treewidth,status.treesizable)
self:RefreshTree()
end
 
259,7 → 297,9
}
]]
local function SetTree(self, tree)
assert(type(tree) == "table")
if tree then
assert(type(tree) == "table")
end
self.tree = tree
self:RefreshTree()
end
307,34 → 347,33
end
 
local function RefreshTree(self)
if not self.tree then return end
--Build the list of visible entries from the tree and status tables
local status = self.status or self.localstatus
local groupstatus = status.groups
local tree = self.tree
local buttons = self.buttons
local lines = self.lines
local buttons = self.buttons
 
local treeframe = self.treeframe
 
 
for i, v in ipairs(buttons) do
v:Hide()
end
while lines[1] do
local t = tremove(lines)
for k in pairs(t) do
t[k] = nil
end
del(t)
end
end
 
if not self.tree then return end
--Build the list of visible entries from the tree and status tables
local status = self.status or self.localstatus
local groupstatus = status.groups
local tree = self.tree
 
local treeframe = self.treeframe
 
self:BuildLevel(tree, 1)
 
for i, v in ipairs(buttons) do
v:Hide()
end
 
local numlines = #lines
 
local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 20))
local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
 
local first, last
 
444,12 → 483,22
 
local function OnWidthSet(self, width)
local content = self.content
local contentwidth = width - 199
local treeframe = self.treeframe
local status = self.status or self.localstatus
 
local contentwidth = width - status.treewidth - 20
if contentwidth < 0 then
contentwidth = 0
end
content:SetWidth(contentwidth)
content.width = contentwidth
 
local maxtreewidth = math.min(400, width - 50)
 
if maxtreewidth > 100 and status.treewidth > maxtreewidth then
self:SetTreeWidth(maxtreewidth, status.treesizable)
end
treeframe:SetMaxResize(maxtreewidth,1600)
end
 
 
477,6 → 526,56
end
end
 
local function SetTreeWidth(self, treewidth, resizable)
if not resizable then
if type(treewidth) == 'number' then
resizable = false
elseif type(treewidth) == 'boolean' then
resizable = treewidth
treewidth = DEFAULT_TREE_WIDTH
else
resizable = false
treewidth = DEFAULT_TREE_WIDTH
end
end
self.treeframe:SetWidth(treewidth)
self.dragger:EnableMouse(resizable)
 
local status = self.status or self.localstatus
status.treewidth = treewidth
status.treesizable = resizable
end
 
local function draggerLeave(this)
this:SetBackdropColor(1, 1, 1, 0)
end
 
local function draggerEnter(this)
this:SetBackdropColor(1, 1, 1, 0.8)
end
 
local function draggerDown(this)
local treeframe = this:GetParent()
treeframe:StartSizing("RIGHT")
end
 
local function draggerUp(this)
local treeframe = this:GetParent()
local self = treeframe.obj
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",frame,"TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
 
local status = self.status or self.localstatus
status.treewidth = treeframe:GetWidth()
end
 
local createdcount = 0
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
493,7 → 592,7
treeframe.obj = self
treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
treeframe:SetWidth(183)
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
treeframe:SetScript("OnUpdate",FirstFrameUpdate)
treeframe:SetScript("OnSizeChanged",ResizeUpdate)
 
503,11 → 602,27
treeframe:SetBackdropColor(0.1,0.1,0.1,0.5)
treeframe:SetBackdropBorderColor(0.4,0.4,0.4)
 
treeframe:SetResizable(true)
treeframe:SetMinResize(100, 1)
treeframe:SetMaxResize(400,1600)
local dragger = CreateFrame("Frame", nil, treeframe)
dragger:SetWidth(8)
dragger:SetPoint("TOP", treeframe, "TOPRIGHT")
dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT")
dragger:SetBackdrop(DraggerBackdrop)
dragger:SetBackdropColor(1, 1, 1, 0)
dragger:SetScript("OnMouseDown", draggerDown)
dragger:SetScript("OnMouseUp", draggerUp)
dragger:SetScript("OnEnter", draggerEnter)
dragger:SetScript("OnLeave", draggerLeave)
 
self.dragger = dragger
self.treeframe = treeframe
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.SetTree = SetTree
self.SetTreeWidth = SetTreeWidth
self.RefreshTree = RefreshTree
self.SetStatusTable = SetStatusTable
self.BuildLevel = BuildLevel
520,9 → 635,11
self.SelectByPath = SelectByPath
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
self.EnableButtonTooltips = EnableButtonTooltips
 
self.frame = frame
frame.obj = self
 
createdcount = createdcount + 1
local scrollbar = CreateFrame("Slider",("AceConfigDialogTreeGroup%dScrollBar"):format(createdcount),treeframe,"UIPanelScrollBarTemplate")
self.scrollbar = scrollbar
543,7 → 660,7
 
local border = CreateFrame("Frame",nil,frame)
self.border = border
border:SetPoint("TOPLEFT",frame,"TOPLEFT",179,0)
border:SetPoint("TOPLEFT",treeframe,"TOPRIGHT", 0,0)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
 
border:SetBackdrop(PaneBackdrop)
AceGUIWidget-ColorPicker.lua
5,9 → 5,9
--------------------------
do
local Type = "ColorPicker"
local Version = 8
local Version = 9
 
local function Acquire(self)
local function OnAcquire(self)
self.HasAlpha = false
self:SetColor(0,0,0,1)
end
83,9 → 83,10
end
ShowUIPanel(ColorPickerFrame)
end
AceGUI:ClearFocus()
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
104,8 → 105,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.SetLabel = SetLabel
self.SetColor = SetColor
AceGUIWidget-Label.lua
5,15 → 5,15
--------------------------
do
local Type = "Label"
local Version = 6
local Version = 8
 
local function Acquire(self)
local function OnAcquire(self)
self:SetText("")
self:SetImage(nil)
self:SetColor()
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
51,10 → 51,10
height = self.label:GetHeight()
end
 
frame.resizing = true
self.resizing = true
self.frame:SetHeight(height)
self.frame.height = height
frame.resizing = nil
self.resizing = nil
end
 
local function SetText(self, text)
70,15 → 70,10
end
 
local function OnWidthSet(self, width)
if self.resizing then return end
UpdateImageAnchor(self)
end
 
local function OnFrameResize(this)
if this.resizing then return end
local self = this.obj
OnWidthSet(self, this:GetWidth())
end
 
local function SetImage(self, path, ...)
local image = self.image
image:SetTexture(path)
106,8 → 101,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetText = SetText
self.SetColor = SetColor
self.frame = frame
118,7 → 113,6
 
frame:SetHeight(18)
frame:SetWidth(200)
frame:SetScript("OnSizeChanged", OnFrameResize)
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall")
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
label:SetWidth(200)
AceGUIWidget-MultiLineEditBox.lua
29,7 → 29,7
 
local AceGUI = LibStub("AceGUI-3.0")
 
local Version = 4
local Version = 6
---------------------
-- Common Elements --
---------------------
102,14 → 102,15
ClearCursor()
end
self.button:Disable()
AceGUI:ClearFocus()
end
 
function MultiLineEditBox:Acquire()
function MultiLineEditBox:OnAcquire()
self:SetDisabled(false)
self:ShowButton(true)
end
 
function MultiLineEditBox:Release()
function MultiLineEditBox:OnRelease()
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetDisabled(false)
216,7 → 217,7
button:SetWidth(80)
button:SetHeight(20)
button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2)
button:SetText("Apply")
button:SetText(ACCEPT)
button:SetScript("OnClick", Button_OnClick)
button:Disable()
button:Hide()
AceGUIWidget-Slider.lua
5,16 → 5,16
--------------------------
do
local Type = "Slider"
local Version = 3
local Version = 5
 
local function Acquire(self)
local function OnAcquire(self)
self:SetDisabled(false)
self:SetSliderValues(0,100,1)
self:SetIsPercent(nil)
self:SetValue(0)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.slider:EnableMouseWheel(false)
143,6 → 143,7
 
local function FrameOnMouseDown(this)
this.obj.slider:EnableMouseWheel(true)
AceGUI:ClearFocus()
end
 
local SliderBackdrop = {
157,8 → 158,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.frame = frame
frame.obj = self
205,7 → 206,7
editbox:SetFontObject(GameFontHighlightSmall)
editbox:SetPoint("TOP",slider,"BOTTOM",0,0)
editbox:SetHeight(14)
editbox:SetWidth(100)
editbox:SetWidth(70)
editbox:SetJustifyH("CENTER")
editbox:EnableMouse(true)
editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed)
213,6 → 214,12
self.editbox = editbox
editbox.obj = self
 
local bg = editbox:CreateTexture(nil,"BACKGROUND")
editbox.bg = bg
bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
bg:SetVertexColor(0,0,0,0.25)
bg:SetAllPoints(editbox)
 
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
 
frame:SetWidth(200)
AceGUIWidget-TabGroup.lua
24,12 → 24,15
 
]]
 
local WotLK = select(4, GetBuildInfo()) >= 30000
 
--------------------------
-- Tab Group --
--------------------------
 
do
local Type = "TabGroup"
local Version = 4
local Version = 15
 
local PaneBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
38,48 → 41,38
insets = { left = 3, right = 3, top = 5, bottom = 3 }
}
 
local function Acquire(self)
local function OnAcquire(self)
 
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.status = nil
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.tablist = nil
end
 
local function Tab_FixWidth(self)
self:SetScript("OnUpdate",nil)
self:SetWidth(self.text:GetWidth()+20)
end
 
local function Tab_SetText(self, text)
self.text:SetText(text)
self:SetScript("OnUpdate",Tab_FixWidth)
self:_SetText(text)
-- TODO: Remove when 3.0 hits live
if WotLK then
PanelTemplates_TabResize(self, 0)
else
PanelTemplates_TabResize(0, self)
end
end
 
local function UpdateTabLook(self)
if self.selected then
self.left:SetAlpha(1)
self.right:SetAlpha(1)
self.middle:SetAlpha(1)
self.text:SetTextColor(1,1,1)
self:GetHighlightTexture():Hide()
if self.disabled then
PanelTemplates_SetDisabledTabState(self)
elseif self.selected then
PanelTemplates_SelectTab(self)
else
self.left:SetAlpha(0.5)
self.right:SetAlpha(0.5)
self.middle:SetAlpha(0.5)
self.text:SetTextColor(1,0.82,0)
self:GetHighlightTexture():Show()
PanelTemplates_DeselectTab(self)
end
 
if self.disabled then
self.text:SetTextColor(0.5,0.5,0.5)
self:GetHighlightTexture():Hide()
end
end
 
local function Tab_SetSelected(self, selected)
98,58 → 91,31
UpdateTabLook(self)
end
 
local function Tab_OnEnter(this)
local self = this.obj
self:Fire("OnTabEnter", self.tabs[this.id].value, this)
end
 
local function Tab_OnLeave(this)
local self = this.obj
self:Fire("OnTabLeave", self.tabs[this.id].value, this)
end
 
local function CreateTab(self, id)
local tab = CreateFrame("Button",nil,self.border)
local tabname = "AceGUITabGroup"..self.num.."Tab"..id
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate")
tab.obj = self
tab.id = id
tab:SetWidth(64)
tab:SetHeight(32)
 
tab:SetScript("OnClick",Tab_OnClick)
tab:SetScript("OnEnter",Tab_OnEnter)
tab:SetScript("OnLeave",Tab_OnLeave)
 
tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
tab:GetHighlightTexture():SetBlendMode("ADD")
tab:GetHighlightTexture():SetPoint("TOPLEFT",tab,"TOPLEFT",2,-7)
tab:GetHighlightTexture():SetPoint("BOTTOMRIGHT",tab,"BOTTOMRIGHT",-2,-3)
local left = tab:CreateTexture(nil,"BACKGROUND")
local middle = tab:CreateTexture(nil,"BACKGROUND")
local right = tab:CreateTexture(nil,"BACKGROUND")
local text = tab:CreateFontString(nil,"BACKGROUND","GameFontNormalSmall")
 
tab.text = text
tab.left = left
tab.right = right
tab.middle = middle
tab._SetText = tab.SetText
tab.SetText = Tab_SetText
tab.SetSelected = Tab_SetSelected
tab.SetDisabled = Tab_SetDisabled
 
text:SetPoint("LEFT",tab,"LEFT",5,-4)
text:SetPoint("RIGHT",tab,"RIGHT",-5,-4)
text:SetHeight(18)
text:SetText("")
 
left:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
middle:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
right:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
 
left:SetWidth(16)
left:SetHeight(32)
middle:SetWidth(44)
middle:SetHeight(32)
right:SetWidth(16)
right:SetHeight(32)
 
left:SetTexCoord(0,0.25,0,1)
middle:SetTexCoord(0.25,0.75,0,1)
right:SetTexCoord(0.75,1,0,1)
 
left:SetPoint("TOPLEFT",tab,"TOPLEFT",0,0)
right:SetPoint("TOPRIGHT",tab,"TOPRIGHT",0,0)
 
middle:SetPoint("LEFT",left,"RIGHT",0,0)
middle:SetPoint("RIGHT",right,"LEFT",0,0)
 
return tab
end
 
186,36 → 152,118
self:BuildTabs()
end
 
 
local widths = {}
local rowwidths = {}
local rowends = {}
local function BuildTabs(self)
local status = self.status or self.localstatus
local tablist = self.tablist
 
 
local tabs = self.tabs
 
for i, v in ipairs(tabs) do
v:Hide()
end
if not tablist then return end
 
 
local width = self.frame.width or self.frame:GetWidth() or 0
 
for i = #widths, 1, -1 do
widths[i] = nil
end
for i = #rowwidths, 1, -1 do
rowwidths[i] = nil
end
for i = #rowends, 1, -1 do
rowends[i] = nil
end
 
--Place Text into tabs and get thier initial width
for i, v in ipairs(tablist) do
local tab = tabs[i]
if not tab then
tab = self:CreateTab(i)
tabs[i] = tab
if i == 1 then
tab:SetPoint("BOTTOMLEFT",self.border,"TOPLEFT",0,-3)
else
tab:SetPoint("LEFT",tabs[i-1],"RIGHT",-3,0)
end
end
 
tab:Show()
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
tab.value = v.value
 
widths[i] = tab:GetWidth() - 10 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing
end
if #tablist > 1 then
self:SelectTab(status.selected or tablist[1].value)
 
--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, #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
rowends[numrows] = i - 1
numrows = numrows + 1
usedwidth = 0
end
usedwidth = usedwidth + widths[i]
end
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
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
--if the last row has only one tab
if rowends[numrows-1] == numtabs-1 then
--if there are more than 2 tabs in the 2nd last row
if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
--move 1 tab from the second last row to the last
rowends[numrows-1] = rowends[numrows-1] - 1
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
end
end
end
 
--anchor the rows as defined and resize tabs to fill thier row
local starttab = 1
for row, endtab in ipairs(rowends) do
local first = true
for tabno = starttab, endtab do
local tab = tabs[tabno]
tab:ClearAllPoints()
if first then
tab:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-7-(row-1)*20 )
first = false
else
tab:SetPoint("LEFT",tabs[tabno-1],"RIGHT",-10,0)
end
end
--equal padding for each tab to fill the available width
local padding = (width - rowwidths[row]) / (endtab - starttab+1)
for i = starttab, endtab do
-- TODO: Remove when 3.0 hits live
if WotLK then
PanelTemplates_TabResize(tabs[i], padding)
else
PanelTemplates_TabResize(padding, tabs[i])
end
end
starttab = endtab + 1
end
 
self.borderoffset = 10+((numrows)*20)
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",3,-self.borderoffset)
end
 
local function BuildTabsOnUpdate(this)
BuildTabs(this.obj)
this:SetScript("OnUpdate", nil)
end
 
local function OnWidthSet(self, width)
local content = self.content
local contentwidth = width - 60
224,29 → 272,32
end
content:SetWidth(contentwidth)
content.width = contentwidth
BuildTabs(self)
self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
end
 
 
local function OnHeightSet(self, height)
local content = self.content
local contentheight = height - 26
local contentheight = height - (self.borderoffset + 23)
if contentheight < 0 then
contentheight = 0
end
content:SetHeight(contentheight)
content.height = contentheight
end
 
 
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
local self = {}
self.type = Type
 
self.num = AceGUI:GetNextWidgetNum(Type)
 
self.localstatus = {}
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetTitle = SetTitle
self.CreateTab = CreateTab
self.SelectTab = SelectTab
274,7 → 325,8
 
local border = CreateFrame("Frame",nil,frame)
self.border = border
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-37)
self.borderoffset = 27
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
 
border:SetBackdrop(PaneBackdrop)
AceGUIWidget-Keybinding.lua
5,7 → 5,7
--------------------------
do
local Type = "Keybinding"
local Version = 6
local Version = 8
 
local ControlBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
42,6 → 42,7
self.waitingForKey = true
end
end
AceGUI:ClearFocus()
end
 
local ignoreKeys = nil
96,10 → 97,10
Keybinding_OnKeyDown(this, button)
end
 
local function Acquire(self)
local function OnAcquire(self)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.waitingForKey = nil
125,15 → 126,16
self.label:SetText(label or "")
end
 
local count = 0
 
local function Constructor()
count = count + 1
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame",nil,UIParent)
 
local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..count,frame,"UIPanelButtonTemplate2")
local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..num,frame,"UIPanelButtonTemplate2")
 
local self = {}
self.type = Type
self.num = num
 
local text = button:GetFontString()
text:SetPoint("LEFT",button,"LEFT",7,0)
181,8 → 183,8
msgframe:SetPoint("BOTTOM",button,"TOP",0,0)
msgframe:Hide()
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetLabel = SetLabel
self.SetDisabled = SetDisabled
self.SetKey = SetKey
AceGUIWidget-CheckBox.lua
10,14 → 10,14
]]
do
local Type = "CheckBox"
local Version = 3
local Version = 4
 
local function Acquire(self)
local function OnAcquire(self)
self:SetValue(false)
self.tristate = nil
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self.check:Hide()
60,6 → 60,7
self.text:SetPoint("LEFT",self.check,"RIGHT",1,-1)
self.down = true
end
AceGUI:ClearFocus()
end
 
local function SetDisabled(self,disabled)
159,8 → 160,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.SetValue = SetValue
self.GetValue = GetValue
AceGUIWidget-Icon.lua
5,14 → 5,14
--------------------------
do
local Type = "Icon"
local Version = 3
local Version = 4
 
local function Acquire(self)
local function OnAcquire(self)
self:SetText("")
self:SetImage(nil)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
38,6 → 38,7
 
local function OnClick(this)
this.obj:Fire("OnClick")
AceGUI:ClearFocus()
end
 
local function OnEnter(this)
53,8 → 54,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetText = SetText
self.frame = frame
self.SetImage = SetImage
AceGUIWidget-BlizOptionsGroup.lua
34,13 → 34,13
 
do
local Type = "BlizOptionsGroup"
local Version = 5
local Version = 6
 
local function Acquire(self)
local function OnAcquire(self)
 
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetName()
110,8 → 110,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.frame = frame
self.SetName = SetName
 
AceGUIWidget-Frame.lua
10,7 → 10,7
]]
do
local Type = "Frame"
local Version = 3
local Version = 7
 
local FrameBackdrop = {
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
30,21 → 30,17
this.obj:Fire("OnClose")
end
 
local function frameOnSizeChanged(this)
local self = this.obj
local status = self.status or self.localstatus
status.width = this:GetWidth()
status.height = this:GetHeight()
status.top = this:GetTop()
status.left = this:GetLeft()
end
 
local function closeOnClick(this)
this.obj:Hide()
end
 
local function frameOnMouseDown(this)
AceGUI:ClearFocus()
end
 
local function titleOnMouseDown(this)
this:GetParent():StartMoving()
AceGUI:ClearFocus()
end
 
local function frameOnMouseUp(this)
60,18 → 56,21
 
local function sizerseOnMouseDown(this)
this:GetParent():StartSizing("BOTTOMRIGHT")
AceGUI:ClearFocus()
end
 
local function sizersOnMouseDown(this)
this:GetParent():StartSizing("BOTTOM")
AceGUI:ClearFocus()
end
 
local function sizereOnMouseDown(this)
this:GetParent():StartSizing("RIGHT")
AceGUI:ClearFocus()
end
 
local function sizerOnMouseUp(this)
this:GetParent():StopMovingOrSizing()
this:GetParent():StopMovingOrSizing()
end
 
local function SetTitle(self,title)
90,13 → 89,13
self.frame:Show()
end
 
local function Acquire(self)
local function OnAcquire(self)
self.frame:SetParent(UIParent)
self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
self:ApplyStatus()
end
 
local function Release(self)
local function OnRelease(self)
self.status = nil
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
113,8 → 112,8
local function ApplyStatus(self)
local status = self.status or self.localstatus
local frame = self.frame
frame:SetWidth(status.width or 700)
frame:SetHeight(status.height or 500)
self:SetWidth(status.width or 700)
self:SetHeight(status.height or 500)
if status.top and status.left then
frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
125,7 → 124,7
 
local function OnWidthSet(self, width)
local content = self.content
local contentwidth = width - 44
local contentwidth = width - 34
if contentwidth < 0 then
contentwidth = 0
end
144,7 → 143,6
content.height = contentheight
end
 
 
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
local self = {}
153,8 → 151,8
self.Hide = Hide
self.Show = Show
self.SetTitle = SetTitle
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetStatusText = SetStatusText
self.SetStatusTable = SetStatusTable
self.ApplyStatus = ApplyStatus
172,12 → 170,12
frame:SetMovable(true)
frame:SetResizable(true)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame:SetScript("OnMouseDown", frameOnMouseDown)
 
frame:SetBackdrop(FrameBackdrop)
frame:SetBackdropColor(0,0,0,1)
frame:SetScript("OnHide",frameOnClose)
frame:SetMinResize(400,200)
frame:SetScript("OnSizeChanged", frameOnSizeChanged)
frame:SetToplevel(true)
 
local closebutton = CreateFrame("Button",nil,frame,"UIPanelButtonTemplate")
210,7 → 208,7
local title = CreateFrame("Frame",nil,frame)
self.title = title
title:EnableMouse()
title:SetScript("OnMouseDown",frameOnMouseDown)
title:SetScript("OnMouseDown",titleOnMouseDown)
title:SetScript("OnMouseUp", frameOnMouseUp)
 
 
AceGUIWidget-InlineGroup.lua
35,14 → 35,14
 
do
local Type = "InlineGroup"
local Version = 3
local Version = 4
 
local function Acquire(self)
local function OnAcquire(self)
self:SetWidth(300)
self:SetHeight(100)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
89,8 → 89,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetTitle = SetTitle
self.frame = frame
self.LayoutFinished = LayoutFinished
AceGUIWidget-DropDown.lua
1,17 → 1,37
--[[ $Id: AceGUIWidget-DropDown.lua 81438 2008-09-06 13:44:36Z nevcairiel $ ]]--
local min, max, floor = math.min, math.max, math.floor
 
local AceGUI = LibStub("AceGUI-3.0")
 
--------------------------
-- Dropdown --
--------------------------
--[[
Events :
OnValueChanged
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, ...)
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
 
do
local Type = "Dropdown"
local Version = 10
local ControlBackdrop = {
local widgetType = "Dropdown-Pullout"
local widgetVersion = 2
 
--[[ Static data ]]--
 
local backdrop = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
edgeSize = 32,
19,53 → 39,329
tile = true,
insets = { left = 11, right = 12, top = 12, bottom = 11 },
}
local sliderBackdrop = {
bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
tile = true, tileSize = 8, edgeSize = 8,
insets = { left = 3, right = 3, top = 3, bottom = 3 }
}
 
local function Acquire(self)
self:SetLabel("")
local defaultWidth = 200
local defaultMaxHeight = 600
 
--[[ UI Event Handlers ]]--
 
-- HACK: This should be no part of the pullout, but there
-- is no other 'clean' way to response to any item-OnEnter
-- Used to close Submenus when an other item is entered
local function OnEnter(item)
local self = item.pullout
for k, v in ipairs(self.items) do
if v.CloseMenu and v ~= item then
v:CloseMenu()
end
end
end
 
local function Release(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetLabel(nil)
self.list = nil
self:SetDisabled(false)
-- See the note in Constructor() for each scroll related function
local function OnMouseWheel(this, value)
this.obj:MoveScroll(value)
end
 
local function OnScrollValueChanged(this, value)
this.obj:SetScroll(value)
end
 
local function OnSizeChanged(this)
this.obj:FixScroll()
end
 
--[[ Exported methods ]]--
 
-- exported
local function SetScroll(self, value)
local status = self.scrollStatus
local frame, child = self.scrollFrame, self.itemFrame
local height, viewheight = frame:GetHeight(), child:GetHeight()
 
local function Control_OnEnter(this)
this.obj:Fire("OnEnter")
local offset
if height > viewheight then
offset = 0
else
offset = floor((viewheight - height) / 1000 * value)
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
 
local function Control_OnLeave(this)
this.obj:Fire("OnLeave")
-- exported
local function MoveScroll(self, value)
local status = self.scrollStatus
local frame, child = self.scrollFrame, self.itemFrame
local height, viewheight = frame:GetHeight(), child:GetHeight()
 
if height > viewheight then
self.slider:Hide()
else
self.slider:Show()
local diff = height - viewheight
local delta = 1
if value < 0 then
delta = -1
end
self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
end
end
 
local function SetText(self, text)
self.text:SetText(text or "")
-- exported
local function FixScroll(self)
local status = self.scrollStatus
local frame, child = self.scrollFrame, self.itemFrame
local height, viewheight = frame:GetHeight(), child:GetHeight()
local offset = status.offset or 0
 
if viewheight < height then
self.slider:Hide()
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset)
self.slider:SetValue(0)
else
self.slider:Show()
local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end
self.slider:SetValue(value)
self:SetScroll(value)
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
end
 
local function SetValue(self, value)
if self.list then
self.text:SetText(self.list[value] or "")
-- exported, AceGUI callback
local function OnAcquire(self)
self.frame:SetParent(UIParent)
--self.itemFrame:SetToplevel(true)
end
 
-- exported, AceGUI callback
local function OnRelease(self)
self:Clear()
self.frame:ClearAllPoints()
self.frame:Hide()
end
 
-- exported
local function AddItem(self, item)
self.items[#self.items + 1] = item
 
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
 
item.frame:SetPoint("LEFT", self.itemFrame, "LEFT")
item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT")
 
item:SetPullout(self)
item:SetOnEnter(OnEnter)
end
 
-- exported
local function Open(self, point, relFrame, relPoint, x, y)
local items = self.items
local frame = self.frame
local itemFrame = self.itemFrame
 
frame:SetPoint(point, relFrame, relPoint, x, y)
 
 
local height = 8
for i, item in pairs(items) do
if i == 1 then
item:SetPoint("TOP", itemFrame, "TOP", 0, -2)
else
item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1)
end
 
item:Show()
 
height = height + 16
end
self.text.value = value
itemFrame:SetHeight(height)
fixstrata("TOOLTIP", frame, frame:GetChildren())
frame:Show()
self:Fire("OnOpen")
end
 
-- exported
local function Close(self)
self.frame:Hide()
self:Fire("OnClose")
end
 
-- exported
local function Clear(self)
local items = self.items
for i, item in pairs(items) do
AceGUI:Release(item)
items[i] = nil
end
end
 
-- exported
local function IterateItems(self)
return ipairs(self.items)
end
 
local function SetList(self, list)
self.list = list
-- exported
local function SetHideOnLeave(self, val)
self.hideOnLeave = val
end
 
local function AddItem(self, value, text)
if self.list then
self.list[value] = text
-- exported
local function SetMaxHeight(self, height)
self.maxHeight = height or defaultMaxHeight
if self.frame:GetHeight() > height then
self.frame:SetHeight(height)
elseif (self.itemFrame:GetHeight() + 34) < height then
self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem
end
end
 
-- exported
local function GetRightBorderWidth(self)
return 6 + (self.slider:IsShown() and 12 or 0)
end
 
local function Dropdown_OnEnterPressed(this)
-- exported
local function GetLeftBorderWidth(self)
return 6
end
 
--[[ Constructor ]]--
 
local function Constructor()
local count = AceGUI:GetNextWidgetNum(widgetType)
local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent)
local self = {}
self.count = count
self.type = widgetType
self.frame = frame
frame.obj = self
 
self.OnAcquire = OnAcquire
self.OnRelease = OnRelease
 
self.AddItem = AddItem
self.Open = Open
self.Close = Close
self.Clear = Clear
self.IterateItems = IterateItems
self.SetHideOnLeave = SetHideOnLeave
 
self.SetScroll = SetScroll
self.MoveScroll = MoveScroll
self.FixScroll = FixScroll
 
self.SetMaxHeight = SetMaxHeight
self.GetRightBorderWidth = GetRightBorderWidth
self.GetLeftBorderWidth = GetLeftBorderWidth
 
self.items = {}
 
self.scrollStatus = {
scrollvalue = 0,
}
 
self.maxHeight = defaultMaxHeight
 
frame:SetBackdrop(backdrop)
frame:SetBackdropColor(0, 0, 0)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame:SetClampedToScreen(true)
frame:SetWidth(defaultWidth)
frame:SetHeight(self.maxHeight)
--frame:SetToplevel(true)
 
-- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame
local scrollFrame = CreateFrame("ScrollFrame", nil, frame)
local itemFrame = CreateFrame("Frame", nil, scrollFrame)
 
self.scrollFrame = scrollFrame
self.itemFrame = itemFrame
 
scrollFrame.obj = self
itemFrame.obj = self
 
local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame)
slider:SetOrientation("VERTICAL")
slider:SetHitRectInsets(0, 0, -10, 0)
slider:SetBackdrop(sliderBackdrop)
slider:SetWidth(8)
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
slider:SetFrameStrata("FULLSCREEN_DIALOG")
self.slider = slider
slider.obj = self
 
scrollFrame:SetScrollChild(itemFrame)
scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12)
scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12)
scrollFrame:EnableMouseWheel(true)
scrollFrame:SetScript("OnMouseWheel", OnMouseWheel)
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
scrollFrame:SetToplevel(true)
scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG")
 
itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0)
itemFrame:SetHeight(400)
itemFrame:SetToplevel(true)
itemFrame:SetFrameStrata("FULLSCREEN_DIALOG")
 
slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0)
slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0)
slider:SetScript("OnValueChanged", OnScrollValueChanged)
slider:SetMinMaxValues(0, 1000)
slider:SetValueStep(1)
slider:SetValue(0)
 
scrollFrame:Show()
itemFrame:Show()
slider:Hide()
 
self:FixScroll()
 
AceGUI:RegisterAsWidget(self)
return self
end
 
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
local widgetType = "Dropdown"
local widgetVersion = 18
 
--[[ Static data ]]--
 
--[[ UI event handler ]]--
 
local function Control_OnEnter(this)
this.obj:Fire("OnEnter")
end
 
local function Control_OnLeave(this)
this.obj:Fire("OnLeave")
end
 
local function Dropdown_OnHide(this)
local self = this.obj
if not self.disabled then
local ret = this.value or this:GetText()
self:Fire("OnValueChanged",ret)
if self.open then
self.pullout:Close()
end
end
 
73,37 → 369,105
local self = this.obj
if self.open then
self.open = nil
self.pullout:Hide()
self.pullout:Close()
AceGUI:ClearFocus()
else
self.open = true
self:BuildPullout()
if self.lines[1] and self.lines[1]:IsShown() then
self.pullout:Show()
self.pullout:SetWidth(self.frame:GetWidth())
self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0)
AceGUI:SetFocus(self)
end
end
 
local function OnPulloutOpen(this)
local self = this.userdata.obj
local value = self.value
 
if not self.multiselect then
for i, item in this:IterateItems() do
item:SetValue(item.userdata.value == value)
end
end
 
self.open = true
end
 
local function OnPulloutClose(this)
local self = this.userdata.obj
self.open = nil
self:Fire("OnClosed")
end
 
local function Dropdown_OnHide(this)
this.obj.pullout:Hide()
local function ShowMultiText(self)
local text
for i, widget in self.pullout:IterateItems() do
if widget.type == "Dropdown-Item-Toggle" then
if widget:GetValue() then
if text then
text = text..", "..widget:GetText()
else
text = widget:GetText()
end
end
end
end
self:SetText(text)
end
 
local function Dropdown_LineClicked(this)
local self = this.obj
self.open = false
self.pullout:Hide()
self.text:SetText(this.text:GetText())
self.text.value = this.value
Dropdown_OnEnterPressed(self.text)
local function OnItemValueChanged(this, event, checked)
local self = this.userdata.obj
 
if self.multiselect then
self:Fire("OnValueChanged", this.userdata.value, checked)
ShowMultiText(self)
else
if checked then
self:SetValue(this.userdata.value)
self:Fire("OnValueChanged", this.userdata.value)
else
this:SetValue(true)
end
if self.open then
self.pullout:Close()
end
end
end
 
local function Dropdown_LineEnter(this)
this.highlight:Show()
--[[ Exported methods ]]--
 
-- exported, AceGUI callback
local function OnAcquire(self)
local pullout = AceGUI:Create("Dropdown-Pullout")
self.pullout = pullout
pullout.userdata.obj = self
pullout:SetCallback("OnClose", OnPulloutClose)
pullout:SetCallback("OnOpen", OnPulloutOpen)
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
end
 
local function Dropdown_LineLeave(this)
this.highlight:Hide()
end
-- exported, AceGUI callback
local function OnRelease(self)
if self.open then
self.pullout:Close()
end
AceGUI:Release(self.pullout)
 
self:SetText("")
self:SetLabel("")
self:SetDisabled(false)
self:SetMultiselect(false)
 
self.value = nil
self.list = nil
self.open = nil
self.hasClose = nil
 
self.frame:ClearAllPoints()
self.frame:Hide()
end
 
-- exported
local function SetDisabled(self, disabled)
self.disabled = disabled
if disabled then
117,70 → 481,19
end
end
 
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, ...)
-- exported
local function ClearFocus(self)
if self.open then
self.pullout:Close()
end
end
 
local ddsort = {}
local function BuildPullout(self)
local list = self.list
local lines = self.lines
local totalheight = 22
self:ClearPullout()
self.pullout:SetFrameLevel(self.frame:GetFrameLevel()+1000)
if type(list) == "table" then
for k, v in pairs(list) do
tinsert(ddsort,k)
end
table.sort(ddsort)
for i, value in pairs(ddsort) do
local text = list[value]
if not lines[i] then
lines[i] = self:CreateLine()
if i == 1 then
lines[i]:SetPoint("TOP",self.pullout,"TOP",0,-10)
else
lines[i]:SetPoint("TOP",lines[i-1],"BOTTOM",0,1)
end
end
lines[i].text:SetText(text)
lines[i]:SetFrameLevel(self.frame:GetFrameLevel()+1001)
lines[i].value = value
if lines[i].value == self.text.value then
lines[i].check:Show()
else
lines[i].check:Hide()
end
lines[i]:Show()
totalheight = totalheight + 16
i = i + 1
end
for k in pairs(ddsort) do
ddsort[k] = nil
end
end
self.pullout:SetHeight(totalheight)
fixlevels(self.pullout,self.pullout:GetChildren())
-- exported
local function SetText(self, text)
self.text:SetText(text or "")
end
 
local function ClearPullout(self)
if self.lines then
for i, line in ipairs(self.lines) do
line.text:SetText("")
line:Hide()
end
end
self.pullout:SetHeight(10)
self.pullout:SetWidth(200)
end
 
-- exported
local function SetLabel(self, text)
if text and text ~= "" then
self.label:SetText(text)
194,80 → 507,142
self.frame:SetHeight(26)
end
end
 
local function CreateLine(self, row, column)
local frame = CreateFrame("Button",nil,self.pullout)
frame.text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
frame.text:SetTextColor(1,1,1)
frame.text:SetJustifyH("LEFT")
frame:SetHeight(17)
frame:SetPoint("LEFT",self.pullout,"LEFT",6,0)
frame:SetPoint("RIGHT",self.pullout,"RIGHT",-6,0)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
frame.obj = self
 
local highlight = frame:CreateTexture(nil, "OVERLAY")
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
highlight:SetBlendMode("ADD")
highlight:SetHeight(14)
highlight:ClearAllPoints()
highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
highlight:SetPoint("LEFT",frame,"LEFT",5,0)
highlight:Hide()
frame.highlight = highlight
-- exported
local function SetValue(self, value)
if self.list then
self:SetText(self.list[value] or "")
end
self.value = value
end
 
local check = frame:CreateTexture("OVERLAY")
frame.check = check
check:SetWidth(16)
check:SetHeight(16)
check:SetPoint("LEFT",frame,"LEFT",3,-1)
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
frame.text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
frame.text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
-- exported
local function SetItemValue(self, item, value)
if not self.multiselect then return end
for i, widget in self.pullout:IterateItems() do
if widget.userdata.value == item then
if widget.SetValue then
widget:SetValue(value)
end
end
end
ShowMultiText(self)
end
 
frame:SetScript("OnClick",Dropdown_LineClicked)
frame:SetScript("OnEnter",Dropdown_LineEnter)
frame:SetScript("OnLeave",Dropdown_LineLeave)
return frame
-- exported
local function SetItemDisabled(self, item, disabled)
for i, widget in self.pullout:IterateItems() do
if widget.userdata.value == item then
widget:SetDisabled(disabled)
end
end
end
 
local count = 0
local function AddListItem(self, value, text)
local item = AceGUI:Create("Dropdown-Item-Toggle")
item:SetText(text)
item.userdata.obj = self
item.userdata.value = value
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local function AddCloseButton(self)
if not self.hasClose then
local close = AceGUI:Create("Dropdown-Item-Execute")
close:SetText(CLOSE)
self.pullout:AddItem(close)
self.hasClose = true
end
end
 
-- exported
local sortlist = {}
local function SetList(self, list)
self.list = list
self.pullout:Clear()
self.hasClose = nil
if not list then return end
 
for v in pairs(list) do
sortlist[#sortlist + 1] = v
end
table.sort(sortlist)
 
for i, value in pairs(sortlist) do
AddListItem(self, value, list[value])
sortlist[i] = nil
end
if self.multiselect then
ShowMultiText(self)
AddCloseButton(self)
end
end
 
-- exported
local function AddItem(self, value, text)
if self.list then
self.list[value] = text
AddListItem(self, value, text)
end
end
 
-- exported
local function SetMultiselect(self, multi)
self.multiselect = multi
if multi then
ShowMultiText(self)
AddCloseButton(self)
end
end
 
-- exported
local function GetMultiselect(self)
return self.multiselect
end
 
--[[ Constructor ]]--
 
local function Constructor()
count = count + 1
local count = AceGUI:GetNextWidgetNum(widgetType)
local frame = CreateFrame("Frame", nil, UIParent)
local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate")
 
local self = {}
local frame = CreateFrame("Frame",nil,UIParent)
local dropdown = CreateFrame("Frame","AceGUI30DropDown" .. count,frame, "UIDropDownMenuTemplate")
self.type = widgetType
self.frame = frame
self.dropdown = dropdown
self.type = Type
self.count = count
frame.obj = self
dropdown.obj = self
 
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.ClearFocus = ClearFocus
 
self.Release = Release
self.Acquire = Acquire
 
self.CreateLine = CreateLine
self.ClearPullout = ClearPullout
self.BuildPullout = BuildPullout
self.SetText = SetText
self.SetValue = SetValue
self.SetList = SetList
self.AddItem = AddItem
self.SetLabel = SetLabel
self.SetText = SetText
self.SetValue = SetValue
self.SetList = SetList
self.SetLabel = SetLabel
self.SetDisabled = SetDisabled
self.AddItem = AddItem
self.SetMultiselect = SetMultiselect
self.GetMultiselect = GetMultiselect
self.SetItemValue = SetItemValue
self.SetItemDisabled = SetItemDisabled
 
self.frame = frame
frame.obj = self
self.alignoffset = 31
 
self.alignoffset = 30
 
frame:SetHeight(44)
frame:SetWidth(200)
frame:SetScript("OnHide",Dropdown_OnHide)
 
 
dropdown:ClearAllPoints()
dropdown:SetPoint("TOPLEFT",frame,"TOPLEFT",-15,0)
dropdown:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",17,0)
dropdown:SetScript("OnHide", nil)
 
-- fix anchoring of the dropdown
 
local left = _G[dropdown:GetName() .. "Left"]
local middle = _G[dropdown:GetName() .. "Middle"]
local right = _G[dropdown:GetName() .. "Right"]
293,17 → 668,6
text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2)
text:SetPoint("LEFT", left, "LEFT", 25, 2)
 
local pullout = CreateFrame("Frame",nil,UIParent)
self.pullout = pullout
frame:EnableMouse()
pullout:SetBackdrop(ControlBackdrop)
pullout:SetBackdropColor(0,0,0)
pullout:SetFrameStrata("FULLSCREEN_DIALOG")
pullout:SetPoint("TOPLEFT",frame,"BOTTOMLEFT",0,0)
pullout:SetPoint("TOPRIGHT",frame,"BOTTOMRIGHT",0,0)
pullout:SetClampedToScreen(true)
pullout:Hide()
 
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
311,12 → 675,10
label:SetHeight(18)
label:Hide()
self.label = label
 
self.lines = {}
 
AceGUI:RegisterAsWidget(self)
return self
end
 
AceGUI:RegisterWidgetType(Type,Constructor,Version)
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
AceGUIWidget-EditBox.lua
11,14 → 11,14
]]
do
local Type = "EditBox"
local Version = 5
 
local function Acquire(self)
local Version = 8
 
local function OnAcquire(self)
self:SetDisabled(false)
self.showbutton = true
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetDisabled(false)
80,6 → 80,7
ClearCursor()
end
HideButton(self)
AceGUI:ClearFocus()
end
 
local function EditBox_OnTextChanged(this)
131,17 → 132,18
end
end
 
local count = 0
 
local function Constructor()
count = count + 1
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Frame",nil,UIParent)
local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..count,frame,"InputBoxTemplate")
local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..num,frame,"InputBoxTemplate")
 
local self = {}
self.type = Type
self.num = num
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
 
self.SetDisabled = SetDisabled
self.SetText = SetText
168,6 → 170,7
editbox:SetScript("OnTextChanged",EditBox_OnTextChanged)
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
 
editbox:SetTextInsets(0,0,3,3)
editbox:SetMaxLetters(256)
 
183,10 → 186,10
self.label = label
 
local button = CreateFrame("Button",nil,editbox,"UIPanelButtonTemplate")
button:SetWidth(20)
button:SetWidth(40)
button:SetHeight(20)
button:SetPoint("RIGHT",editbox,"RIGHT",-2,0)
button:SetText("OK")
button:SetText(OKAY)
button:SetScript("OnClick", Button_OnClick)
button:Hide()
 
AceGUIWidget-Heading.lua
5,13 → 5,13
--------------------------
do
local Type = "Heading"
local Version = 2
local Version = 3
 
local function Acquire(self)
local function OnAcquire(self)
self:SetText("")
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
32,8 → 32,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetText = SetText
self.frame = frame
frame.obj = self
AceGUIWidget-SimpleGroup.lua
35,14 → 35,14
 
do
local Type = "SimpleGroup"
local Version = 3
local Version = 4
 
local function Acquire(self)
local function OnAcquire(self)
self:SetWidth(300)
self:SetHeight(100)
end
 
local function Release(self)
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
end
68,8 → 68,8
local self = {}
self.type = Type
 
self.Release = Release
self.Acquire = Acquire
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.frame = frame
self.LayoutFinished = LayoutFinished
self.OnWidthSet = OnWidthSet