/trunk/VendorMaster/libs/AceGUI-3.0/widgets
ScrollFrame Container |
Plain container that scrolls its content and doesn't grow in height. |
-------------------------------------------------------------------------------]] |
local Type, Version = "ScrollFrame", 23 |
local Type, Version = "ScrollFrame", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local IsLegion = select(4, GetBuildInfo()) >= 70000 |
-- Lua APIs |
local pairs, assert, type = pairs, assert, type |
local min, max, floor, abs = math.min, math.max, math.floor, math.abs |
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND") |
scrollbg:SetAllPoints(scrollbar) |
scrollbg:SetTexture(0, 0, 0, 0.4) |
if IsLegion then |
scrollbg:SetColorTexture(0, 0, 0, 0.4) |
else |
scrollbg:SetTexture(0, 0, 0, 0.4) |
end |
--Container Support |
local content = CreateFrame("Frame", nil, scrollframe) |
TreeGroup Container |
Container that uses a tree control to switch between groups. |
-------------------------------------------------------------------------------]] |
local Type, Version = "TreeGroup", 34 |
local Type, Version = "TreeGroup", 40 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local IsLegion = select(4, GetBuildInfo()) >= 70000 |
-- Lua APIs |
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type |
local math_min, math_max, floor = math.min, math.max, floor |
if self.enabletooltips then |
GameTooltip:SetOwner(frame, "ANCHOR_NONE") |
GameTooltip:SetPoint("LEFT",frame,"RIGHT") |
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, 1) |
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, true) |
GameTooltip:Show() |
end |
if frame.obj.noupdate then return end |
local self = frame.obj |
local status = self.status or self.localstatus |
status.scrollvalue = value |
status.scrollvalue = floor(value + 0.5) |
self:RefreshTree() |
AceGUI:ClearFocus() |
end |
["OnAcquire"] = function(self) |
self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE) |
self:EnableButtonTooltips(true) |
self.frame:SetScript("OnUpdate", FirstFrameUpdate) |
end, |
["OnRelease"] = function(self) |
button.toggle.button = button |
button.toggle:SetScript("OnClick",Expand_OnClick) |
button.text:SetHeight(14) -- Prevents text wrapping |
return button |
end, |
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND") |
scrollbg:SetAllPoints(scrollbar) |
scrollbg:SetTexture(0,0,0,0.4) |
if IsLegion then |
scrollbg:SetColorTexture(0,0,0,0.4) |
else |
scrollbg:SetTexture(0,0,0,0.4) |
end |
local border = CreateFrame("Frame",nil,frame) |
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT") |
border:SetPoint("BOTTOMRIGHT") |
Button Widget |
Graphical Button. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Button", 22 |
local Type, Version = "Button", 23 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local _G = _G |
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
self:SetHeight(24) |
self:SetWidth(200) |
self:SetDisabled(false) |
self:SetAutoWidth(false) |
self:SetText() |
end, |
["SetText"] = function(self, text) |
self.text:SetText(text) |
if self.autoWidth then |
self:SetWidth(self.text:GetStringWidth() + 30) |
end |
end, |
["SetAutoWidth"] = function(self, autoWidth) |
self.autoWidth = autoWidth |
if self.autoWidth then |
self:SetWidth(self.text:GetStringWidth() + 30) |
end |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Button", name, UIParent, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate") |
frame:Hide() |
frame:EnableMouse(true) |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 996 2010-12-01 18:34:17Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1137 2016-05-15 10:57:36Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
local IsLegion = select(4, GetBuildInfo()) >= 70000 |
-- Lua APIs |
local select, assert = select, assert |
-- A single line to separate items |
do |
local widgetType = "Dropdown-Item-Separator" |
local widgetVersion = 1 |
local widgetVersion = 2 |
-- exported, override |
local function SetDisabled(self, disabled) |
local line = self.frame:CreateTexture(nil, "OVERLAY") |
line:SetHeight(1) |
line:SetTexture(.5, .5, .5) |
if IsLegion then |
line:SetColorTexture(.5, .5, .5) |
else |
line:SetTexture(.5, .5, .5) |
end |
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0) |
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0) |
--[[----------------------------------------------------------------------------- |
ColorPicker Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "ColorPicker", 20 |
local Type, Version = "ColorPicker", 23 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local IsLegion = select(4, GetBuildInfo()) >= 70000 |
-- Lua APIs |
local pairs = pairs |
local self = frame.obj |
if not self.disabled then |
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG") |
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10) |
ColorPickerFrame:SetClampedToScreen(true) |
ColorPickerFrame.func = function() |
local r, g, b = ColorPickerFrame:GetColorRGB() |
local texture = frame:CreateTexture(nil, "BACKGROUND") |
texture:SetWidth(16) |
texture:SetHeight(16) |
texture:SetTexture(1, 1, 1) |
if IsLegion then |
texture:SetColorTexture(1, 1, 1) |
else |
texture:SetTexture(1, 1, 1) |
end |
texture:SetPoint("CENTER", colorSwatch) |
texture:Show() |
local Type, Version = "MultiLineEditBox", 27 |
local Type, Version = "MultiLineEditBox", 28 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: ACCEPT, ChatFontNormal |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
self.frame:SetScript("OnShow", OnShowFocus) |
end |
end, |
["HighlightText"] = function(self, from, to) |
self.editBox:HighlightText(from, to) |
end, |
["GetCursorPosition"] = function(self) |
return self.editBox:GetCursorPosition() |
end, |
label:SetText(ACCEPT) |
label:SetHeight(10) |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate") |
button:SetPoint("BOTTOMLEFT", 0, 4) |
button:SetHeight(22) |
button:SetWidth(label:GetStringWidth() + 24) |
Slider Widget |
Graphical Slider, like, for Range values. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Slider", 20 |
local Type, Version = "Slider", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local self = frame.obj |
if not frame.setup then |
local newvalue = frame:GetValue() |
if self.step and self.step > 0 then |
local min_value = self.min or 0 |
newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value |
end |
if newvalue ~= self.value and not self.disabled then |
self.value = newvalue |
self:Fire("OnValueChanged", newvalue) |
Keybinding Widget |
Set Keybindings in the Config UI. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Keybinding", 24 |
local Type, Version = "Keybinding", 25 |
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 self = frame.obj |
if self.waitingForKey then |
frame:EnableKeyboard(false) |
frame:EnableMouseWheel(false) |
self.msgframe:Hide() |
frame:UnlockHighlight() |
self.waitingForKey = nil |
else |
frame:EnableKeyboard(true) |
frame:EnableMouseWheel(true) |
self.msgframe:Show() |
frame:LockHighlight() |
self.waitingForKey = true |
end |
frame:EnableKeyboard(false) |
frame:EnableMouseWheel(false) |
self.msgframe:Hide() |
frame:UnlockHighlight() |
self.waitingForKey = nil |
Keybinding_OnKeyDown(frame, button) |
end |
local function Keybinding_OnMouseWheel(frame, direction) |
local button |
if direction >= 0 then |
button = "MOUSEWHEELUP" |
else |
button = "MOUSEWHEELDOWN" |
end |
Keybinding_OnKeyDown(frame, button) |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
self.msgframe:Hide() |
self:SetDisabled(false) |
self.button:EnableKeyboard(false) |
self.button:EnableMouseWheel(false) |
end, |
-- ["OnRelease"] = nil, |
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame", nil, UIParent) |
local button = CreateFrame("Button", name, frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate") |
button:EnableMouse(true) |
button:EnableMouseWheel(false) |
button:RegisterForClicks("AnyDown") |
button:SetScript("OnEnter", Control_OnEnter) |
button:SetScript("OnLeave", Control_OnLeave) |
button:SetScript("OnClick", Keybinding_OnClick) |
button:SetScript("OnKeyDown", Keybinding_OnKeyDown) |
button:SetScript("OnMouseDown", Keybinding_OnMouseDown) |
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel) |
button:SetPoint("BOTTOMLEFT") |
button:SetPoint("BOTTOMRIGHT") |
button:SetHeight(24) |
local select, pairs, print = select, pairs, print |
-- WoW APIs |
local CreateFrame, UIParent, GetBuildInfo = CreateFrame, UIParent, GetBuildInfo |
local CreateFrame, UIParent = CreateFrame, UIParent |
--[[----------------------------------------------------------------------------- |
Scripts |
for method, func in pairs(methods) do |
widget[method] = func |
end |
-- SetText is deprecated, but keep it around for a while. (say, to WoW 4.0) |
if (select(4, GetBuildInfo()) < 40000) then |
widget.SetText = widget.SetLabel |
else |
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end |
end |
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end |
return AceGUI:RegisterAsWidget(widget) |
end |
BlizOptionsGroup Container |
Simple container widget for the integration of AceGUI into the Blizzard Interface Options |
-------------------------------------------------------------------------------]] |
local Type, Version = "BlizOptionsGroup", 20 |
local Type, Version = "BlizOptionsGroup", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
frame.obj:Fire("cancel") |
end |
local function defaults(frame) |
frame.obj:Fire("defaults") |
local function default(frame) |
frame.obj:Fire("default") |
end |
local function refresh(frame) |
frame.obj:Fire("refresh") |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
-- support functions for the Blizzard Interface Options |
frame.okay = okay |
frame.cancel = cancel |
frame.defaults = defaults |
frame.default = default |
frame.refresh = refresh |
frame:SetScript("OnHide", OnHide) |
frame:SetScript("OnShow", OnShow) |
InlineGroup Container |
Simple container widget that creates a visible "box" with an optional title. |
-------------------------------------------------------------------------------]] |
local Type, Version = "InlineGroup", 20 |
local Type, Version = "InlineGroup", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
["OnAcquire"] = function(self) |
self:SetWidth(300) |
self:SetHeight(100) |
self:SetTitle("") |
end, |
-- ["OnRelease"] = nil, |
--[[ $Id: AceGUIWidget-DropDown.lua 1029 2011-06-10 23:10:58Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 1116 2014-10-12 08:15:46Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
do |
local widgetType = "Dropdown" |
local widgetVersion = 25 |
local widgetVersion = 30 |
--[[ Static data ]]-- |
--[[ UI event handler ]]-- |
local function Control_OnEnter(this) |
this.obj.button:LockHighlight() |
this.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(this) |
this.obj.button:UnlockHighlight() |
this.obj:Fire("OnLeave") |
end |
AceGUI:ClearFocus() |
else |
self.open = true |
self.pullout:SetWidth(self.frame:GetWidth()) |
self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth()) |
self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0) |
AceGUI:SetFocus(self) |
end |
end |
self.open = true |
self:Fire("OnOpened") |
end |
local function OnPulloutClose(this) |
self:SetHeight(44) |
self:SetWidth(200) |
self:SetLabel() |
self:SetPulloutWidth(nil) |
end |
-- exported, AceGUI callback |
if disabled then |
self.text:SetTextColor(0.5,0.5,0.5) |
self.button:Disable() |
self.button_cover:Disable() |
self.label:SetTextColor(0.5,0.5,0.5) |
else |
self.button:Enable() |
self.button_cover:Enable() |
self.label:SetTextColor(1,.82,0) |
self.text:SetTextColor(1,1,1) |
end |
if text and text ~= "" then |
self.label:SetText(text) |
self.label:Show() |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-18) |
self:SetHeight(44) |
self.alignoffset = 30 |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-14) |
self:SetHeight(40) |
self.alignoffset = 26 |
else |
self.label:SetText("") |
self.label:Hide() |
return self.multiselect |
end |
local function SetPulloutWidth(self, width) |
self.pulloutWidth = width |
end |
--[[ Constructor ]]-- |
local function Constructor() |
self.GetMultiselect = GetMultiselect |
self.SetItemValue = SetItemValue |
self.SetItemDisabled = SetItemDisabled |
self.SetPulloutWidth = SetPulloutWidth |
self.alignoffset = 30 |
self.alignoffset = 26 |
frame:SetScript("OnHide",Dropdown_OnHide) |
button:SetScript("OnLeave",Control_OnLeave) |
button:SetScript("OnClick",Dropdown_TogglePullout) |
local button_cover = CreateFrame("BUTTON",nil,self.frame) |
self.button_cover = button_cover |
button_cover.obj = self |
button_cover:SetPoint("TOPLEFT",self.frame,"BOTTOMLEFT",0,25) |
button_cover:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT") |
button_cover:SetScript("OnEnter",Control_OnEnter) |
button_cover:SetScript("OnLeave",Control_OnLeave) |
button_cover:SetScript("OnClick",Dropdown_TogglePullout) |
local text = _G[dropdown:GetName() .. "Text"] |
self.text = text |
text.obj = self |
--[[----------------------------------------------------------------------------- |
EditBox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "EditBox", 24 |
local Type, Version = "EditBox", 26 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
self:SetText(name) |
self:Fire("OnEnterPressed", name) |
ClearCursor() |
elseif type == "macro" then |
local name = GetMacroInfo(id) |
self:SetText(name) |
self:Fire("OnEnterPressed", name) |
ClearCursor() |
end |
HideButton(self) |
AceGUI:ClearFocus() |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", Frame_OnShowFocus) |
end |
end, |
["HighlightText"] = function(self, from, to) |
self.editbox:HighlightText(from, to) |
end |
} |