/trunk/PocketPlot/libs/AceGUI-3.0
<Script file="widgets\AceGUIWidget-Label.lua"/> |
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/> |
<Script file="widgets\AceGUIWidget-BlizOptionsGroup.lua"/> |
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/> |
<Script file="widgets\AceGUIWidget-Icon.lua"/> |
</Ui> |
--- AceGUI-3.0 provides access to numerous widgets which can be used to create GUIs. |
--- **AceGUI-3.0** provides access to numerous widgets which can be used to create GUIs. |
-- AceGUI is used by AceConfigDialog to create the option GUIs, but you can use it by itself |
-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3 |
-- stand-alone distribution. |
-- |
-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly, |
-- as any "unknown" change to the widgets will cause addons that get your widget out of the widget pool |
-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we'll |
-- implement a proper API to modify it. |
-- @usage |
-- local AceGUI = LibStub("AceGUI-3.0") |
-- -- Create a container frame |
-- local f = AceGUI:Create("Frame") |
-- f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) |
-- f:SetTitle("AceGUI-3.0 Example") |
-- f:SetStatusText("Status Bar") |
-- f:SetLayout("Flow") |
-- -- Create a button |
-- local btn = AceGUI:Create("Button") |
-- btn:SetWidth(170) |
-- btn:SetText("Button !") |
-- btn:SetCallback("OnClick", function() print("Click!") end) |
-- -- Add the button to the container |
-- f:AddChild(btn) |
-- @class file |
-- @name AceGUI-3.0 |
-- @release $Id: AceGUI-3.0.lua 740 2009-02-15 13:56:40Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 18 |
-- @release $Id: AceGUI-3.0.lua 815 2009-07-08 20:58:17Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 25 |
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR) |
if not AceGUI then return end -- No upgrade needed |
-- Gets a widget Object |
--- Create a new Widget of the given type. |
-- This function will instantiate a new widget (or use one from the widget pool), and call the |
-- OnAcquire function on it, before returning. |
-- @param type The type of the widget. |
-- @return The newly created widget. |
function AceGUI:Create(type) |
local reg = WidgetRegistry |
if reg[type] then |
widget:OnAcquire() |
else |
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type)) |
end |
end |
-- Set the default Layout ('List') |
safecall(widget.SetLayout, widget, 'List') |
safecall(widget.ResumeLayout, widget) |
return widget |
end |
end |
-- Releases a widget Object |
--- Releases a widget Object. |
-- This function calls OnRelease on the widget and places it back in the widget pool. |
-- Any data on the widget is being erased, and the widget will be hidden.\\ |
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well. |
-- @param widget The widget to release |
function AceGUI:Release(widget) |
safecall( widget.PauseLayout, widget ) |
widget:Fire("OnRelease") |
for k in pairs(widget.events) do |
widget.events[k] = nil |
end |
widget.width = nil |
--widget.frame:SetParent(nil) |
widget.width = nil |
widget.relWidth = nil |
widget.height = nil |
widget.relHeight = nil |
widget.noAutoHeight = nil |
widget.frame:ClearAllPoints() |
widget.frame:Hide() |
widget.frame:SetParent(nil) |
widget.frame:SetParent(UIParent) |
widget.frame.width = nil |
widget.frame.height = nil |
if widget.content then |
widget.content.width = nil |
widget.content.height = nil |
-- Focus -- |
----------- |
----- |
-- Called when a widget has taken focus |
--- Called when a widget has taken focus. |
-- e.g. Dropdowns opening, Editboxes gaining kb focus |
----- |
-- @param widget The widget that should be focused |
function AceGUI:SetFocus(widget) |
if self.FocusedWidget and self.FocusedWidget ~= widget then |
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget) |
self.FocusedWidget = widget |
end |
----- |
-- Called when something has happened that could cause widgets with focus to drop it |
--- Called when something has happened that could cause widgets with focus to drop it |
-- e.g. titlebar of a frame being clicked |
----- |
function AceGUI:ClearFocus() |
if self.FocusedWidget then |
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget) |
frame:SetParent(nil) |
frame:SetParent(parent.content) |
self.parent = parent |
fixlevels(parent.frame,parent.frame:GetChildren()) |
--fixlevels(parent.frame,parent.frame:GetChildren()) |
end |
WidgetBase.SetCallback = function(self, name, func) |
end |
end |
WidgetBase.SetRelativeWidth = function(self, width) |
if width <= 0 or width > 1 then |
error(":SetRelativeWidth(width): Invalid relative width.", 2) |
end |
self.relWidth = width |
self.width = "relative" |
end |
WidgetBase.SetHeight = function(self, height) |
self.frame:SetHeight(height) |
self.frame.height = height |
self:OnHeightSet(height) |
end |
end |
--[[ WidgetBase.SetRelativeHeight = function(self, height) |
if height <= 0 or height > 1 then |
error(":SetRelativeHeight(height): Invalid relative height.", 2) |
end |
self.relHeight = height |
self.height = "relative" |
end ]] |
WidgetBase.IsVisible = function(self) |
return self.frame:IsVisible() |
self:DoLayout() |
end |
WidgetContainerBase.AddChildren = function(self, ...) |
for i = 1, select("#", ...) do |
local child = select(i, ...) |
tinsert(self.children, child) |
child:SetParent(self) |
child.frame:Show() |
end |
self:DoLayout() |
end |
WidgetContainerBase.ReleaseChildren = function(self) |
local children = self.children |
for i in ipairs(children) do |
for i = 1,#children do |
AceGUI:Release(children[i]) |
children[i] = nil |
end |
self.LayoutFunc = AceGUI:GetLayout(Layout) |
end |
WidgetContainerBase.SetAutoAdjustHeight = function(self, adjust) |
if adjust then |
self.noAutoHeight = nil |
else |
self.noAutoHeight = true |
end |
end |
local function FrameResize(this) |
local self = this.obj |
if this:GetWidth() and this:GetHeight() then |
setmetatable(WidgetContainerBase,{__index=WidgetBase}) |
--One of these function should be called on each Widget Instance as part of its creation process |
--- Register a widget-class as a container for newly created widgets. |
-- @param widget The widget class |
function AceGUI:RegisterAsContainer(widget) |
widget.children = {} |
widget.userdata = {} |
widget:SetLayout("List") |
end |
--- Register a widget-class as a widget. |
-- @param widget The widget class |
function AceGUI:RegisterAsWidget(widget) |
widget.userdata = {} |
widget.events = {} |
------------------ |
-- Widget API -- |
------------------ |
-- Registers a widget Constructor, this function returns a new instance of the Widget |
--- Registers a widget Constructor, this function returns a new instance of the Widget |
-- @param Name The name of the widget |
-- @param Constructor The widget constructor function |
-- @param Version The version of the widget |
function AceGUI:RegisterWidgetType(Name, Constructor, Version) |
assert(type(Constructor) == "function") |
assert(type(Version) == "number") |
WidgetRegistry[Name] = Constructor |
end |
-- Registers a Layout Function |
--- Registers a Layout Function |
-- @param Name The name of the layout |
-- @param LayoutFunc Reference to the layout function |
function AceGUI:RegisterLayout(Name, LayoutFunc) |
assert(type(LayoutFunc) == "function") |
if type(Name) == "string" then |
LayoutRegistry[Name] = LayoutFunc |
end |
--- Get a Layout Function from the registry |
-- @param Name The name of the layout |
function AceGUI:GetLayout(Name) |
if type(Name) == "string" then |
Name = Name:upper() |
AceGUI.counts = AceGUI.counts or {} |
--- A type-based counter to count the number of widgets created. |
-- This is used by widgets that require a named frame, e.g. when a Blizzard |
-- Template requires it. |
-- @param type The widget type |
function AceGUI:GetNextWidgetNum(type) |
if not self.counts[type] then |
self.counts[type] = 0 |
if child.DoLayout then |
child:DoLayout() |
end |
elseif child.width == "relative" then |
child:SetWidth(width * child.relWidth) |
if child.OnWidthSet then |
child:OnWidthSet(content.width or content:GetWidth()) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
end |
height = height + (frame.height or frame:GetHeight() or 0) |
lastframeoffset = frameoffset |
frameoffset = child.alignoffset or (frameheight / 2) |
if child.width == "relative" then |
framewidth = width * child.relWidth |
end |
frame:Show() |
frame:ClearAllPoints() |
if i == 1 then |
-- anchor the first control to the top left |
--frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0) |
frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0) |
rowheight = frameheight |
rowoffset = frameoffset |
rowstart = frame |
rowstartoffset = frameoffset |
rowheight = frameheight |
rowoffset = frameoffset |
usedwidth = frame.width or frame:GetWidth() |
usedwidth = framewidth |
if usedwidth > width then |
oversize = true |
end |
rowstart = frame |
rowstartoffset = frameoffset |
if child.OnWidthSet then |
child:OnWidthSet(width) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
rowheight = frame.height or frame:GetHeight() or 0 |
rowoffset = child.alignoffset or (rowheight / 2) |
rowstartoffset = rowoffset |
elseif child.width == "relative" then |
child:SetWidth(width * child.relWidth) |
if child.OnWidthSet then |
child:OnWidthSet(width) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
elseif oversize then |
if width > 1 then |
frame:SetPoint("RIGHT",content,"RIGHT",0,0) |
do |
local Type = "SimpleGroup" |
local Version = 4 |
local Version = 5 |
local function OnAcquire(self) |
self:SetWidth(300) |
end |
local function LayoutFinished(self, width, height) |
if self.noAutoHeight then return end |
self:SetHeight(height or 0) |
end |
]] |
do |
local Type = "DropdownGroup" |
local Version = 9 |
local Version = 11 |
local function OnAcquire(self) |
self.dropdown:SetText("") |
self:SetDropdownWidth(200) |
end |
local function OnRelease(self) |
content.height = contentheight |
end |
local function LayoutFinished(self, width, height) |
self:SetHeight((height or 0) + 63) |
end |
local function SetDropdownWidth(self, width) |
self.dropdown:SetWidth(width) |
end |
local function Constructor() |
local frame = CreateFrame("Frame") |
local self = {} |
self.SetGroupList = SetGroupList |
self.SetGroup = SetGroup |
self.SetStatusTable = SetStatusTable |
self.SetDropdownWidth = SetDropdownWidth |
self.OnWidthSet = OnWidthSet |
self.OnHeightSet = OnHeightSet |
self.LayoutFinished = LayoutFinished |
self.localstatus = {} |
frame:SetFrameStrata("FULLSCREEN_DIALOG") |
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") |
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0) |
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0) |
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",4,0) |
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-4,0) |
titletext:SetJustifyH("LEFT") |
titletext:SetHeight(18) |
self.titletext = titletext |
self.titletext = titletext |
local dropdown = AceGUI:Create("Dropdown") |
self.dropdown = dropdown |
dropdown.parentgroup = self |
dropdown:SetCallback("OnValueChanged",SelectedGroup) |
dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-7,3) |
dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-3,3) |
dropdown.frame:Show() |
dropdown:SetLabel("") |
-------------------------- |
do |
local Type = "ScrollFrame" |
local Version = 3 |
local Version = 4 |
local function OnAcquire(self) |
scrollframe:SetScrollChild(content) |
scrollframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-16,0) |
scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-20,0) |
scrollframe:EnableMouseWheel(true) |
scrollframe:SetScript("OnMouseWheel", OnMouseWheel) |
scrollframe:SetScript("OnSizeChanged", OnSizeChanged) |
content:SetPoint("TOPRIGHT",scrollframe,"TOPRIGHT",0,0) |
content:SetHeight(400) |
scrollbar:SetPoint("TOPLEFT",scrollframe,"TOPRIGHT",0,-16) |
scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",0,16) |
scrollbar:SetPoint("TOPLEFT",scrollframe,"TOPRIGHT",4,-16) |
scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",4,16) |
scrollbar:SetScript("OnValueChanged", OnScrollValueChanged) |
scrollbar:SetMinMaxValues(0,1000) |
scrollbar:SetValueStep(1) |
-------------------------- |
do |
local Type = "Button" |
local Version = 7 |
local Version = 11 |
local function OnAcquire(self) |
-- restore default values |
self:SetHeight(24) |
self:SetWidth(200) |
end |
local function OnRelease(self) |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Button","AceGUI30Button"..num,UIParent,"UIPanelButtonTemplate2") |
local name = "AceGUI30Button"..num |
local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2") |
local self = {} |
self.num = num |
self.type = Type |
self.frame = frame |
local left = _G[name .. "Left"] |
local right = _G[name .. "Right"] |
local middle = _G[name .. "Middle"] |
left:SetPoint("TOP", frame, "TOP", 0, 0) |
left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
right:SetPoint("TOP", frame, "TOP", 0, 0) |
right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
middle:SetPoint("TOP", frame, "TOP", 0, 0) |
middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
local text = frame:GetFontString() |
self.text = text |
text:SetPoint("LEFT",frame,"LEFT",15,0) |
text:SetPoint("RIGHT",frame,"RIGHT",-15,0) |
text:ClearAllPoints() |
text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1) |
text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1) |
text:SetJustifyV("MIDDLE") |
frame:SetScript("OnClick",Button_OnClick) |
frame:SetScript("OnEnter",Button_OnEnter) |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
end |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 656 2008-05-31 11:47:08Z nargiddley $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 808 2009-05-07 14:45:15Z ammo $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Does not close the pullout on click |
do |
local widgetType = "Dropdown-Item-Menu" |
local widgetVersion = 1 |
local widgetVersion = 2 |
local function OnEnter(this) |
local self = this.obj |
end |
-- exported |
function SetMenu(self, menu) |
local function SetMenu(self, menu) |
assert(menu.type == "Dropdown-Pullout") |
self.submenu = menu |
end |
-- exported |
function CloseMenu(self) |
local function CloseMenu(self) |
self.submenu:Close() |
end |
-------------------------- |
do |
local Type = "ColorPicker" |
local Version = 9 |
local Version = 11 |
local function OnAcquire(self) |
self.HasAlpha = false |
self:SetColor(0,0,0,1) |
self:SetHeight(24) |
self:SetWidth(200) |
end |
local function SetLabel(self, text) |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if self.disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
end |
end |
do |
local Type = "TreeGroup" |
local Version = 17 |
local Version = 20 |
local DEFAULT_TREE_WIDTH = 175 |
local DEFAULT_TREE_SIZABLE = true |
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) |
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() or "", 1, .82, 0, 1) |
GameTooltip:Show() |
end |
end |
local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "OptionsListButtonTemplate") |
buttoncount = buttoncount + 1 |
button.obj = self |
local icon = button:CreateTexture(nil, "OVERLAY") |
icon:SetWidth(14) |
icon:SetHeight(14) |
button.icon = icon |
button:SetScript("OnClick",ButtonOnClick) |
button:SetScript("OnDoubleClick", ButtonOnDoubleClick) |
button:SetScript("OnEnter",Button_OnEnter) |
local toggle = button.toggle |
local frame = self.frame |
local text = treeline.text or "" |
local icon = treeline.icon |
local level = treeline.level |
local value = treeline.value |
local uniquevalue = treeline.uniquevalue |
button:UnlockHighlight() |
button.selected = false |
end |
local normalText = button.text |
local normalTexture = button:GetNormalTexture() |
local line = button.line |
button.level = level |
if ( level == 1 ) then |
button:SetNormalFontObject("GameFontNormal") |
button:SetHighlightFontObject("GameFontHighlight") |
button.text:SetPoint("LEFT", 8, 2) |
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2) |
else |
button:SetNormalFontObject("GameFontHighlightSmall") |
button:SetHighlightFontObject("GameFontHighlightSmall") |
button.text:SetPoint("LEFT", 8 * level, 2) |
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2) |
end |
if disabled then |
button:EnableMouse(true) |
end |
if icon then |
button.icon:SetTexture(icon) |
button.icon:SetPoint("LEFT", button, "LEFT", 8 * level, (level == 1) and 0 or 1) |
else |
button.icon:SetTexture(nil) |
end |
if canExpand then |
if not isExpanded then |
toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP") |
local line = new() |
line.value = v.value |
line.text = v.text |
line.icon = v.icon |
line.disabled = v.disabled |
line.tree = tree |
line.level = level |
local status = self.status or self.localstatus |
status.treewidth = treeframe:GetWidth() |
end |
local function LayoutFinished(self, width, height) |
if self.noAutoHeight then return end |
self:SetHeight((height or 0) + 20) |
end |
local createdcount = 0 |
local function Constructor() |
self.OnHeightSet = OnHeightSet |
self.EnableButtonTooltips = EnableButtonTooltips |
self.Filter = Filter |
self.LayoutFinished = LayoutFinished |
self.frame = frame |
frame.obj = self |
-------------------------- |
do |
local Type = "Label" |
local Version = 8 |
local Version = 10 |
local function OnAcquire(self) |
self:SetHeight(18) |
self:SetWidth(200) |
self:SetText("") |
self:SetImage(nil) |
self:SetColor() |
self:SetFontObject() |
end |
local function OnRelease(self) |
UpdateImageAnchor(self) |
end |
local function SetFont(self, font, height, flags) |
self.label:SetFont(font, height, flags) |
end |
local function SetFontObject(self, font) |
self.label:SetFontObject(font or GameFontHighlightSmall) |
end |
local function SetImageSize(self, width, height) |
self.image:SetWidth(width) |
self.image:SetHeight(height) |
self.OnWidthSet = OnWidthSet |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
self.SetFont = SetFont |
self.SetFontObject = SetFontObject |
frame.obj = self |
frame:SetHeight(18) |
local AceGUI = LibStub("AceGUI-3.0") |
local Version = 7 |
local Version = 10 |
--------------------- |
-- Common Elements -- |
--------------------- |
self:Fire("OnEnterPressed",name) |
ClearCursor() |
end |
self.button:Disable() |
--self.button:Disable() |
AceGUI:ClearFocus() |
end |
function MultiLineEditBox:OnAcquire() |
self:SetWidth(200) |
self:SetHeight(116) |
self:SetNumLines(4) |
self:SetDisabled(false) |
self:ShowButton(true) |
end |
self.label:SetText(text) |
end |
end |
function MultiLineEditBox:SetNumLines(number) |
number = number or 4 |
self:SetHeight(60 + (14*number)) |
end |
function MultiLineEditBox:GetText() |
return self.editbox:GetText() |
scrollframe.obj = self |
self.scrollframe = scrollframe |
local scrollchild = CreateFrame("Frame", nil, scrollframe) |
scrollframe:SetScrollChild(scrollchild) |
scrollchild:SetHeight(2) |
scrollchild:SetWidth(2) |
--local scrollchild = CreateFrame("Frame", nil, scrollframe) |
--scrollframe:SetScrollChild(scrollchild) |
--scrollchild:SetHeight(2) |
--scrollchild:SetWidth(2) |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2) |
label:SetHeight(18) |
self.label = label |
local editbox = CreateFrame("EditBox", nil, scrollchild) |
local editbox = CreateFrame("EditBox", nil, scrollframe) |
self.editbox = editbox |
editbox.obj = self |
editbox:SetPoint("TOPLEFT") |
editbox:SetPoint("BOTTOMLEFT") |
editbox:SetHeight(50) |
editbox:SetWidth(50) |
editbox:SetMultiLine(true) |
editbox:EnableMouse(true) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(ChatFontNormal) |
scrollframe:SetScrollChild(editbox) |
local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate") |
button:SetWidth(80) |
button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2) |
button:SetText(ACCEPT) |
button:SetScript("OnClick", Button_OnClick) |
button:SetFrameLevel(editbox:GetFrameLevel() + 1) |
button:Disable() |
button:Hide() |
self.button = button |
editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) |
local function FixSize() |
scrollchild:SetHeight(scrollframe:GetHeight()) |
scrollchild:SetWidth(scrollframe:GetWidth()) |
--scrollchild:SetHeight(scrollframe:GetHeight()) |
--scrollchild:SetWidth(scrollframe:GetWidth()) |
editbox:SetWidth(scrollframe:GetWidth()) |
end |
scrollframe:SetScript("OnShow", FixSize) |
scrollframe:UpdateScrollChildRect() |
local value = editbox:GetText() |
if value ~= self.lasttext then |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
self.button:Enable() |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
self.button:Enable() |
end |
end) |
local cursorOffset, cursorHeight |
local idleTime |
local function FixScroll(_, elapsed) |
if cursorOffset and cursorHeight then |
idleTime = 0 |
local height = scrollframe:GetHeight() |
local range = scrollframe:GetVerticalScrollRange() |
local scroll = scrollframe:GetVerticalScroll() |
local size = height + range |
cursorOffset = -cursorOffset |
while cursorOffset < scroll do |
scroll = scroll - (height / 2) |
if scroll < 0 then scroll = 0 end |
scrollframe:SetVerticalScroll(scroll) |
if cursorOffset and cursorHeight then |
idleTime = 0 |
local height = scrollframe:GetHeight() |
local range = scrollframe:GetVerticalScrollRange() |
local scroll = scrollframe:GetVerticalScroll() |
local size = height + range |
cursorOffset = -cursorOffset |
while cursorOffset < scroll do |
scroll = scroll - (height / 2) |
if scroll < 0 then scroll = 0 end |
scrollframe:SetVerticalScroll(scroll) |
end |
while cursorOffset + cursorHeight > scroll + height and scroll < range do |
scroll = scroll + (height / 2) |
if scroll > range then scroll = range end |
scrollframe:SetVerticalScroll(scroll) |
end |
elseif not idleTime or idleTime > 2 then |
frame:SetScript("OnUpdate", nil) |
idleTime = nil |
else |
idleTime = idleTime + elapsed |
end |
while cursorOffset + cursorHeight > scroll + height and scroll < range do |
scroll = scroll + (height / 2) |
if scroll > range then scroll = range end |
scrollframe:SetVerticalScroll(scroll) |
end |
elseif not idleTime or idleTime > 2 then |
frame:SetScript("OnUpdate", nil) |
idleTime = nil |
else |
idleTime = idleTime + elapsed |
cursorOffset = nil |
end |
cursorOffset = nil |
end |
editbox:SetScript("OnCursorChanged", function(_, x, y, w, h) |
cursorOffset, cursorHeight = y, h |
if not idleTime then |
frame:SetScript("OnUpdate", FixScroll) |
end |
cursorOffset, cursorHeight = y, h |
if not idleTime then |
frame:SetScript("OnUpdate", FixScroll) |
end |
end) |
end |
-------------------------- |
do |
local Type = "Slider" |
local Version = 5 |
local Version = 7 |
local function OnAcquire(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetDisabled(false) |
self:SetIsPercent(nil) |
self:SetSliderValues(0,100,1) |
self:SetIsPercent(nil) |
self:SetValue(0) |
end |
end |
local function UpdateText(self) |
local value = self.value or 0 |
if self.ispercent then |
self.editbox:SetText((math.floor(self.value*1000+0.5)/10)..'%') |
self.editbox:SetText(("%s%%"):format(math.floor(value*1000+0.5)/10)) |
else |
self.editbox:SetText(math.floor(self.value*100+0.5)/100) |
self.editbox:SetText(math.floor(value*100+0.5)/100) |
end |
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)) |
else |
self.lowtext:SetText(min) |
self.hightext:SetText(max) |
end |
end |
local function Slider_OnValueChanged(this) |
local self = this.obj |
if not this.setup then |
self.label:SetText(text) |
end |
local function SetSliderValues(self,min, max, step) |
local function SetSliderValues(self, min, max, step) |
local frame = self.slider |
frame.setup = true |
self.min = min |
self.max = max |
self.step = step |
frame:SetMinMaxValues(min or 0,max or 100) |
self.lowtext:SetText(min or 0) |
self.hightext:SetText(max or 100) |
UpdateLabels(self) |
frame:SetValueStep(step or 1) |
frame.setup = nil |
end |
local function SetIsPercent(self, value) |
self.ispercent = value |
UpdateLabels(self) |
UpdateText(self) |
end |
local function FrameOnMouseDown(this) |
do |
local Type = "TabGroup" |
local Version = 17 |
local Version = 20 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
self.localstatus[k] = nil |
end |
self.tablist = nil |
for _, tab in pairs(self.tabs) do |
tab:Hide() |
end |
end |
local function Tab_SetText(self, text) |
self:_SetText(text) |
PanelTemplates_TabResize(self, 0) |
local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0 |
PanelTemplates_TabResize(self, 0, nil, width) |
end |
local function UpdateTabLook(self) |
tab.obj = self |
tab.id = id |
tab.text = _G[tabname .. "Text"] |
tab.text:ClearAllPoints() |
tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3) |
tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3) |
tab:SetScript("OnClick",Tab_OnClick) |
tab:SetScript("OnEnter",Tab_OnEnter) |
tab:SetScript("OnLeave",Tab_OnLeave) |
v:SetSelected(true) |
found = true |
else |
v:SetSelected(false) |
v:SetSelected(false) |
end |
end |
status.selected = value |
local widths = {} |
local rowwidths = {} |
local rowends = {} |
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 |
tab = self:CreateTab(i) |
tabs[i] = tab |
end |
tab:Show() |
tab:SetText(v.text) |
tab:SetDisabled(v.disabled) |
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 |
tabs[i]:Hide() |
end |
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout |
local numtabs = #tablist |
local numrows = 1 |
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] |
--move 1 tab from the second last row to the last, if there is enough space |
if (rowwidths[numrows] + widths[numtabs-1]) <= width then |
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 |
end |
end |
for i = starttab, endtab do |
PanelTemplates_TabResize(tabs[i], padding + 4) |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) |
end |
starttab = endtab + 1 |
end |
content:SetHeight(contentheight) |
content.height = contentheight |
end |
local function LayoutFinished(self, width, height) |
if self.noAutoHeight then return end |
self:SetHeight((height or 0) + (self.borderoffset + 23)) |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
self.BuildTabs = BuildTabs |
self.SetStatusTable = SetStatusTable |
self.SetTabs = SetTabs |
self.LayoutFinished = LayoutFinished |
self.frame = frame |
self.OnWidthSet = OnWidthSet |
titletext:SetJustifyH("LEFT") |
titletext:SetHeight(18) |
self.titletext = titletext |
self.titletext = titletext |
local border = CreateFrame("Frame",nil,frame) |
self.border = border |
do |
local Type = "Keybinding" |
local Version = 11 |
local Version = 13 |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
end |
local function OnAcquire(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetLabel("") |
self:SetKey("") |
end |
self.frame:Hide() |
self.waitingForKey = nil |
self.msgframe:Hide() |
self:SetDisabled(false) |
end |
local function SetDisabled(self, disabled) |
]] |
do |
local Type = "CheckBox" |
local Version = 4 |
local Version = 7 |
local function OnAcquire(self) |
self:SetValue(false) |
self.tristate = nil |
self:SetHeight(24) |
self:SetWidth(200) |
end |
local function OnRelease(self) |
local function CheckBox_OnEnter(this) |
local self = this.obj |
if not self.disabled then |
self.highlight:Show() |
end |
self.highlight:Show() |
self:Fire("OnEnter") |
end |
local function CheckBox_OnLeave(this) |
local self = this.obj |
if not self.down then |
self.highlight:Hide() |
end |
self.highlight:Hide() |
self:Fire("OnLeave") |
end |
local function SetDisabled(self,disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
SetDesaturation(self.check, true) |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
if self.tristate and self.checked == nil then |
SetDesaturation(self.check, true) |
--Nil is the unknown tristate value |
if self.tristate and value == nil then |
SetDesaturation(self.check, true) |
check:SetWidth(20) |
check:SetHeight(20) |
check:SetWidth(24) |
check:SetHeight(24) |
self.check:Show() |
else |
SetDesaturation(self.check, false) |
-------------------------- |
do |
local Type = "Icon" |
local Version = 4 |
local Version = 10 |
local function OnAcquire(self) |
self:SetText("") |
self:SetHeight(110) |
self:SetWidth(110) |
self:SetLabel("") |
self:SetImage(nil) |
self:SetImageSize(64, 64) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
local function SetText(self, text) |
self.label:SetText(text or "") |
local function SetLabel(self, text) |
if text and text ~= "" then |
self.label:Show() |
self.label:SetText(text) |
self.frame:SetHeight(self.image:GetHeight() + 25) |
else |
self.label:Hide() |
self.frame:SetHeight(self.image:GetHeight() + 10) |
end |
end |
local function SetImage(self, path, ...) |
end |
end |
local function OnClick(this) |
this.obj:Fire("OnClick") |
local function SetImageSize(self, width, height) |
self.image:SetWidth(width) |
self.image:SetHeight(height) |
--self.frame:SetWidth(width + 30) |
if self.label:IsShown() then |
self.frame:SetHeight(height + 25) |
else |
self.frame:SetHeight(height + 10) |
end |
end |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.label:SetTextColor(0.5,0.5,0.5) |
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5) |
else |
self.frame:Enable() |
self.label:SetTextColor(1,1,1) |
self.image:SetVertexColor(1, 1, 1) |
end |
end |
local function OnClick(this, button) |
this.obj:Fire("OnClick", button) |
AceGUI:ClearFocus() |
end |
local function OnEnter(this) |
this.obj.highlight:Show() |
this.obj:Fire("OnEnter") |
end |
local function OnLeave(this) |
this.obj.highlight:Hide() |
this.obj:Fire("OnLeave") |
end |
local function Constructor() |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.SetLabel = SetLabel |
self.frame = frame |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
-- SetText should be deprecated along the way |
self.SetText = SetLabel |
self.SetDisabled = SetDisabled |
frame.obj = self |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnEnter", OnEnter) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight") |
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,10) |
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,10) |
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetJustifyV("TOP") |
label:SetHeight(18) |
self.image = image |
image:SetWidth(64) |
image:SetHeight(64) |
image:SetPoint("TOP",frame,"TOP",0,-10) |
image:SetPoint("TOP",frame,"TOP",0,-5) |
local highlight = frame:CreateTexture(nil,"OVERLAY") |
self.highlight = highlight |
]] |
do |
local Type = "Frame" |
local Version = 7 |
local Version = 8 |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
closebutton:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-27,17) |
closebutton:SetHeight(20) |
closebutton:SetWidth(100) |
closebutton:SetText("Close") |
closebutton:SetText(CLOSE) |
self.closebutton = closebutton |
closebutton.obj = self |
do |
local Type = "InlineGroup" |
local Version = 4 |
local Version = 5 |
local function OnAcquire(self) |
self:SetWidth(300) |
local function LayoutFinished(self, width, height) |
if self.noAutoHeight then return end |
self:SetHeight((height or 0) + 40) |
end |
--[[ $Id: AceGUIWidget-DropDown.lua 679 2008-09-06 12:51:18Z nargiddley $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 815 2009-07-08 20:58:17Z nevcairiel $ ]]-- |
local min, max, floor = math.min, math.max, math.floor |
local AceGUI = LibStub("AceGUI-3.0") |
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) |
end |
do |
do |
local widgetType = "Dropdown" |
local widgetVersion = 18 |
local widgetVersion = 20 |
--[[ Static data ]]-- |
pullout:SetCallback("OnOpen", OnPulloutOpen) |
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1) |
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren()) |
self:SetHeight(44) |
self:SetWidth(200) |
end |
-- exported, AceGUI callback |
self.pullout:Close() |
end |
AceGUI:Release(self.pullout) |
self.pullout = nil |
self:SetText("") |
self:SetLabel("") |
self:SetMultiselect(false) |
self.value = nil |
self.list = nil |
self.list = nil |
self.open = nil |
self.hasClose = nil |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.frame:Hide() |
end |
-- exported |
local close = AceGUI:Create("Dropdown-Item-Execute") |
close:SetText(CLOSE) |
self.pullout:AddItem(close) |
self.hasClose = true |
self.hasClose = true |
end |
end |
]] |
do |
local Type = "EditBox" |
local Version = 9 |
local Version = 11 |
local function OnAcquire(self) |
self:SetHeight(26) |
self:SetWidth(200) |
self:SetDisabled(false) |
self:SetLabel() |
self.showbutton = true |
end |
HideButton(self) |
end |
local function SetWidth(self, width) |
self.frame:SetWidth(width) |
end |
local function SetLabel(self, text) |
if text and text ~= "" then |
self.label:SetText(text) |
self.label:Show() |
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18) |
self.frame:SetHeight(44) |
self:SetHeight(44) |
self.alignoffset = 30 |
else |
self.label:SetText("") |
self.label:Hide() |
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0) |
self.frame:SetHeight(26) |
self:SetHeight(26) |
self.alignoffset = 12 |
end |
end |
self.SetDisabled = SetDisabled |
self.SetText = SetText |
self.SetWidth = SetWidth |
self.SetLabel = SetLabel |
self.frame = frame |
-------------------------- |
do |
local Type = "Heading" |
local Version = 3 |
local Version = 5 |
local function OnAcquire(self) |
self:SetText("") |
self:SetFullWidth() |
self:SetHeight(18) |
end |
local function OnRelease(self) |