/trunk/Libs/AceGUI-3.0
ScrollFrame Container |
Plain container that scrolls its content and doesn't grow in height. |
-------------------------------------------------------------------------------]] |
local Type, Version = "ScrollFrame", 21 |
local Type, Version = "ScrollFrame", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local methods = { |
["OnAcquire"] = function(self) |
self:SetScroll(0) |
self:FixScroll() |
end, |
["OnRelease"] = function(self) |
TreeGroup Container |
Container that uses a tree control to switch between groups. |
-------------------------------------------------------------------------------]] |
local Type, Version = "TreeGroup", 33 |
local Type, Version = "TreeGroup", 34 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local 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 = select, table.remove, unpack |
local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
end |
end, |
["RefreshTree"] = function(self) |
["RefreshTree"] = function(self,scrollToSelection) |
local buttons = self.buttons |
local lines = self.lines |
local tree = self.tree |
local treeframe = self.treeframe |
status.scrollToSelection = status.scrollToSelection or scrollToSelection -- needs to be cached in case the control hasn't been drawn yet (code bails out below) |
self:BuildLevel(tree, 1) |
if maxlines <= 0 then return end |
local first, last |
scrollToSelection = status.scrollToSelection |
status.scrollToSelection = nil |
if numlines <= maxlines then |
--the whole tree fits in the frame |
if numlines - status.scrollvalue < maxlines then |
status.scrollvalue = numlines - maxlines |
end |
self.noupdate = nil |
first, last = status.scrollvalue+1, status.scrollvalue + maxlines |
--show selection? |
if scrollToSelection and status.selected then |
local show |
for i,line in ipairs(lines) do -- find the line number |
if line.uniquevalue==status.selected then |
show=i |
end |
end |
if not show then |
-- selection was deleted or something? |
elseif show>=first and show<=last then |
-- all good |
else |
-- scrolling needed! |
if show<first then |
status.scrollvalue = show-1 |
else |
status.scrollvalue = show-maxlines |
end |
first, last = status.scrollvalue+1, status.scrollvalue + maxlines |
end |
end |
if self.scrollbar:GetValue() ~= status.scrollvalue then |
self.scrollbar:SetValue(status.scrollvalue) |
end |
self.noupdate = nil |
first, last = status.scrollvalue+1, status.scrollvalue + maxlines |
end |
local buttonnum = 1 |
button:Show() |
buttonnum = buttonnum + 1 |
end |
end, |
["SetSelected"] = function(self, value) |
self.filter = false |
local status = self.status or self.localstatus |
local groups = status.groups |
for i = 1, select('#', ...) do |
groups[BuildUniqueValue(select(i, ...))] = true |
local path = {...} |
for i = 1, #path do |
groups[tconcat(path, "\001", 1, i)] = true |
end |
status.selected = uniquevalue |
self:RefreshTree() |
self:RefreshTree(true) |
self:Fire("OnGroupSelected", uniquevalue) |
end, |
Button Widget |
Graphical Button. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Button", 21 |
local Type, Version = "Button", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local _G = _G |
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2") |
local frame = CreateFrame("Button", name, UIParent, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
frame:Hide() |
frame:EnableMouse(true) |
Label Widget |
Displays text and optionally an icon. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Label", 21 |
local Type, Version = "Label", 23 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
else |
-- image on the left |
image:SetPoint("TOPLEFT") |
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0) |
if image:GetHeight() > label:GetHeight() then |
label:SetPoint("LEFT", image, "RIGHT", 4, 0) |
else |
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0) |
end |
label:SetWidth(width - imagewidth - 4) |
height = max(image:GetHeight(), label:GetHeight()) |
end |
local Type, Version = "MultiLineEditBox", 25 |
local Type, Version = "MultiLineEditBox", 27 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: ACCEPT, ChatFontNormal |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
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 |
editbox:Insert(text) |
return true |
end |
end |
end |
local function Layout(self) |
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight) |
local function OnEditFocusLost(self) -- EditBox |
self:HighlightText(0, 0) |
self.obj:Fire("OnEditFocusLost") |
end |
local function OnEnter(self) -- EditBox / ScrollFrame |
frame:SetScript("OnShow", nil) |
end |
local function OnFocusGained(frame) |
local function OnEditFocusGained(frame) |
AceGUI:SetFocus(frame.obj) |
frame.obj:Fire("OnEditFocusGained") |
end |
--[[----------------------------------------------------------------------------- |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", OnShowFocus) |
end |
end |
end, |
["GetCursorPosition"] = function(self) |
return self.editBox:GetCursorPosition() |
end, |
["SetCursorPosition"] = function(self, ...) |
return self.editBox:SetCursorPosition(...) |
end, |
} |
--[[----------------------------------------------------------------------------- |
label:SetText(ACCEPT) |
label:SetHeight(10) |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2") |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
button:SetPoint("BOTTOMLEFT", 0, 4) |
button:SetHeight(22) |
button:SetWidth(label:GetStringWidth() + 24) |
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) |
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll) |
local editBox = CreateFrame("EditBox", nil, scrollFrame) |
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame) |
editBox:SetAllPoints() |
editBox:SetFontObject(ChatFontNormal) |
editBox:SetMultiLine(true) |
editBox:SetScript("OnReceiveDrag", OnReceiveDrag) |
editBox:SetScript("OnTextChanged", OnTextChanged) |
editBox:SetScript("OnTextSet", OnTextSet) |
editBox:SetScript("OnEditFocusGained", OnFocusGained) |
editBox:SetScript("OnEditFocusGained", OnEditFocusGained) |
scrollFrame:SetScrollChild(editBox) |
TabGroup Container |
Container that uses tabs on top to switch between groups. |
-------------------------------------------------------------------------------]] |
local Type, Version = "TabGroup", 31 |
local Type, Version = "TabGroup", 35 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local function Tab_SetText(frame, text) |
frame:_SetText(text) |
local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0 |
PanelTemplates_TabResize(frame, 0, nil, width) |
PanelTemplates_TabResize(frame, 0, nil, nil, width, frame:GetFontString():GetStringWidth()) |
end |
local function Tab_SetSelected(frame, selected) |
end |
for i = starttab, endtab do |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, nil, width, tabs[i]:GetFontString():GetStringWidth()) |
end |
starttab = endtab + 1 |
end |
Keybinding Widget |
Set Keybindings in the Config UI. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Keybinding", 22 |
local Type, Version = "Keybinding", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: NOT_BOUND |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame", nil, UIParent) |
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2") |
local button = CreateFrame("Button", name, frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
button:EnableMouse(true) |
button:RegisterForClicks("AnyDown") |
msgframe:SetBackdropColor(0,0,0) |
msgframe:SetFrameStrata("FULLSCREEN_DIALOG") |
msgframe:SetFrameLevel(1000) |
msgframe:SetToplevel(true) |
local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.") |
--[[----------------------------------------------------------------------------- |
Checkbox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "CheckBox", 21 |
local Type, Version = "CheckBox", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
self.frame:Disable() |
self.text:SetTextColor(0.5, 0.5, 0.5) |
SetDesaturation(self.check, true) |
if self.desc then |
self.desc:SetTextColor(0.5, 0.5, 0.5) |
end |
else |
self.frame:Enable() |
self.text:SetTextColor(1, 1, 1) |
else |
SetDesaturation(self.check, false) |
end |
if self.desc then |
self.desc:SetTextColor(1, 1, 1) |
end |
end |
end, |
--[[----------------------------------------------------------------------------- |
Frame Container |
-------------------------------------------------------------------------------]] |
local Type, Version = "Frame", 22 |
local Type, Version = "Frame", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
self:SetStatusText() |
self:ApplyStatus() |
self:Show() |
self:EnableResize(true) |
end, |
["OnRelease"] = function(self) |
self.frame:Show() |
end, |
["EnableResize"] = function(self, state) |
local func = state and "Show" or "Hide" |
self.sizer_se[func](self.sizer_se) |
self.sizer_s[func](self.sizer_s) |
self.sizer_e[func](self.sizer_e) |
end, |
-- called to set an external table to store status in |
["SetStatusTable"] = function(self, status) |
assert(type(status) == "table") |
titletext = titletext, |
statustext = statustext, |
titlebg = titlebg, |
sizer_se = sizer_se, |
sizer_s = sizer_s, |
sizer_e = sizer_e, |
content = content, |
frame = frame, |
type = Type |
--[[ $Id: AceGUIWidget-DropDown.lua 997 2010-12-01 18:36:28Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 1029 2011-06-10 23:10:58Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
do |
local widgetType = "Dropdown" |
local widgetVersion = 24 |
local widgetVersion = 25 |
--[[ Static data ]]-- |
self:SetHeight(44) |
self:SetWidth(200) |
self:SetLabel() |
end |
-- exported, AceGUI callback |
self.pullout = nil |
self:SetText("") |
self:SetLabel("") |
self:SetDisabled(false) |
self:SetMultiselect(false) |
self.label:SetText(text) |
self.label:Show() |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-18) |
self.frame:SetHeight(44) |
self:SetHeight(44) |
self.alignoffset = 30 |
else |
self.label:SetText("") |
self.label:Hide() |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0) |
self.frame:SetHeight(26) |
self:SetHeight(26) |
self.alignoffset = 12 |
end |
end |
self.SetItemValue = SetItemValue |
self.SetItemDisabled = SetItemDisabled |
self.alignoffset = 31 |
self.alignoffset = 30 |
frame:SetHeight(44) |
frame:SetWidth(200) |
frame:SetScript("OnHide",Dropdown_OnHide) |
dropdown:ClearAllPoints() |