/trunk/TipTop/libs/AceGUI-3.0/widgets
--[[ $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) |
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 = "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 = "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("") |
local AceGUI = LibStub("AceGUI-3.0") |
-------------------------- |
-- Button -- |
-------------------------- |
do |
local Type = "Button" |
local Version = 11 |
local function OnAcquire(self) |
-- restore default values |
self:SetHeight(24) |
self:SetWidth(200) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
local function Button_OnClick(this) |
this.obj:Fire("OnClick") |
AceGUI:ClearFocus() |
end |
local function Button_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Button_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function SetText(self, text) |
self.text:SetText(text or "") |
end |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
else |
self.frame:Enable() |
end |
end |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
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: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) |
frame:SetScript("OnLeave",Button_OnLeave) |
self.SetText = SetText |
self.SetDisabled = SetDisabled |
frame:EnableMouse(true) |
frame:SetHeight(24) |
frame:SetWidth(200) |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
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 = "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 = "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 |
local AceGUI = LibStub("AceGUI-3.0") |
-------------------------- |
-- Label -- |
-------------------------- |
do |
local Type = "InteractiveLabel" |
local Version = 5 |
local function OnAcquire(self) |
self:SetHeight(18) |
self:SetWidth(200) |
self:SetText("") |
self:SetImage(nil) |
self:SetColor() |
self:SetFontObject() |
self:SetHighlight() |
self:SetHighlightTexCoord() |
end |
local function OnRelease(self) |
self:SetDisabled(false) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function UpdateImageAnchor(self) |
local width = self.frame.width or self.frame:GetWidth() or 0 |
local image = self.image |
local label = self.label |
local frame = self.frame |
local height |
label:ClearAllPoints() |
image:ClearAllPoints() |
if self.imageshown then |
local imagewidth = image:GetWidth() |
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then |
--image goes on top centered when less than 200 width for the text, or if there is no text |
image:SetPoint("TOP",frame,"TOP",0,0) |
label:SetPoint("TOP",image,"BOTTOM",0,0) |
label:SetPoint("LEFT",frame,"LEFT",0,0) |
label:SetWidth(width) |
height = image:GetHeight() + label:GetHeight() |
else |
--image on the left |
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPLEFT",image,"TOPRIGHT",0,0) |
label:SetWidth(width - imagewidth) |
height = math.max(image:GetHeight(), label:GetHeight()) |
end |
else |
--no image shown |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(width) |
height = self.label:GetHeight() |
end |
self.resizing = true |
self.frame:SetHeight(height) |
self.frame.height = height |
self.resizing = nil |
end |
local function SetText(self, text) |
self.label:SetText(text or "") |
UpdateImageAnchor(self) |
end |
local function SetColor(self, r, g, b) |
if not (r and g and b) then |
r, g, b = 1, 1, 1 |
end |
self.label:SetVertexColor(r, g, b) |
end |
local function OnWidthSet(self, width) |
if self.resizing then return end |
UpdateImageAnchor(self) |
end |
local function SetImage(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
self.imageshown = true |
local n = select('#', ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
end |
else |
self.imageshown = nil |
end |
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) |
UpdateImageAnchor(self) |
end |
local function SetHighlight(self, ...) |
self.highlight:SetTexture(...) |
end |
local function SetHighlightTexCoord(self, ...) |
if select('#', ...) >= 1 then |
self.highlight:SetTexCoord(...) |
else |
self.highlight:SetTexCoord(0, 1, 0, 1) |
end |
end |
local function SetDisabled(self,disabled) |
self.disabled = disabled |
if disabled then |
self.frame:EnableMouse(false) |
self.label:SetTextColor(0.5, 0.5, 0.5) |
else |
self.frame:EnableMouse(true) |
self.label:SetTextColor(1, 1, 1) |
end |
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 OnClick(this, ...) |
this.obj:Fire("OnClick", ...) |
AceGUI:ClearFocus() |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", OnEnter) |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnMouseDown", OnClick) |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.SetColor = SetColor |
self.frame = frame |
self.OnWidthSet = OnWidthSet |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
self.SetFont = SetFont |
self.SetFontObject = SetFontObject |
self.SetHighlight = SetHighlight |
self.SetHighlightTexCoord = SetHighlightTexCoord |
self.SetDisabled = SetDisabled |
frame.obj = self |
frame:SetHeight(18) |
frame:SetWidth(200) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(200) |
label:SetJustifyH("LEFT") |
label:SetJustifyV("TOP") |
self.label = label |
local highlight = frame:CreateTexture(nil, "OVERLAY") |
highlight:SetTexture(nil) |
highlight:SetAllPoints() |
highlight:SetBlendMode("ADD") |
highlight:Hide() |
self.highlight = highlight |
local image = frame:CreateTexture(nil,"BACKGROUND") |
self.image = image |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
-------------------------- |
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) |
--[[ |
--Multiline Editbox Widget, Originally by bam |
--]] |
local assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall = |
assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall |
local getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack = |
getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack |
local math, string, table = math, string, table |
local find, format, gmatch, gsub, tolower, match, toupper, join, split, trim = |
string.find, string.format, string.gmatch, string.gsub, string.lower, string.match, string.upper, string.join, string.split, string.trim |
local concat, insert, maxn, remove, sort = table.concat, table.insert, table.maxn, table.remove, table.sort |
local max, min, abs, ceil, floor = math.max, math.min, math.abs, math.ceil, math.floor |
local LibStub = assert(LibStub) |
local ChatFontNormal = ChatFontNormal |
local ClearCursor = ClearCursor |
local CreateFrame = CreateFrame |
local GetCursorInfo = GetCursorInfo |
local GetSpellName = GetSpellName |
local UIParent = UIParent |
local UISpecialFrames = UISpecialFrames |
-- No global variables after this! |
local _G = getfenv() |
local AceGUI = LibStub("AceGUI-3.0") |
local Version = 10 |
--------------------- |
-- Common Elements -- |
--------------------- |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", |
tile = true, tileSize = 32, edgeSize = 32, |
insets = { left = 8, right = 8, top = 8, bottom = 8 } |
} |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 5, bottom = 3 } |
} |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
-------------------------- |
-- Edit box -- |
-------------------------- |
--[[ |
Events : |
OnTextChanged |
OnEnterPressed |
]] |
do |
local Type = "MultiLineEditBox" |
local MultiLineEditBox = {} |
local function EditBox_OnEnterPressed(this) |
local self = this.obj |
local value = this:GetText() |
local cancel = self:Fire("OnEnterPressed",value) |
if not cancel then |
self.button:Disable() |
end |
end |
local function Button_OnClick(this) |
local editbox = this.obj.editbox |
editbox:ClearFocus() |
EditBox_OnEnterPressed(editbox) |
end |
local function EditBox_OnReceiveDrag(this) |
local self = this.obj |
local type, id, info = GetCursorInfo() |
if type == "item" then |
self:SetText(info) |
self:Fire("OnEnterPressed",info) |
ClearCursor() |
elseif type == "spell" then |
local name, rank = GetSpellName(id, info) |
if rank and rank:match("%d") then |
name = name.."("..rank..")" |
end |
self:SetText(name) |
self:Fire("OnEnterPressed",name) |
ClearCursor() |
end |
--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 |
function MultiLineEditBox:OnRelease() |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
function MultiLineEditBox:SetDisabled(disabled) |
self.disabled = disabled |
if disabled then |
self.editbox:EnableMouse(false) |
self.scrollframe:EnableMouse(false) |
self.editbox:ClearFocus() |
self.editbox:SetTextColor(0.5, 0.5, 0.5) |
self.label:SetTextColor(0.5,0.5,0.5) |
else |
self.editbox:EnableMouse(true) |
self.scrollframe:EnableMouse(true) |
self.editbox:SetTextColor(1, 1, 1) |
self.label:SetTextColor(1,.82,0) |
end |
end |
function MultiLineEditBox:SetText(text) |
text = text or "" |
local editbox = self.editbox |
local oldText = editbox:GetText() |
local dummy = format(" %s", text) |
self.lasttext = dummy -- prevents OnTextChanged from firing |
editbox:SetText(dummy) |
editbox:HighlightText(0, 1) |
self.lasttext = oldText |
editbox:Insert("") |
end |
function MultiLineEditBox:SetLabel(text) |
if (text or "") == "" then |
self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,0) |
self.label:Hide() |
self.label:SetText("") |
else |
self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-20) |
self.label:Show() |
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() |
end |
function MultiLineEditBox:ShowButton(show) |
if show then |
self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,22) |
self.button:Show() |
else |
self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) |
self.button:Hide() |
end |
end |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
local backdrop = CreateFrame("Frame", nil, frame) |
local self = {} |
for k, v in pairs(MultiLineEditBox) do self[k] = v end |
self.type = Type |
self.frame = frame |
self.backdrop = backdrop |
frame.obj = self |
backdrop:SetBackdrop(ControlBackdrop) |
backdrop:SetBackdropColor(0, 0, 0) |
backdrop:SetBackdropBorderColor(0.4, 0.4, 0.4) |
backdrop:SetPoint("TOPLEFT",frame,"TOPLEFT",0, -20) |
backdrop:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,22) |
local scrollframe = CreateFrame("ScrollFrame", format("%s@%s@%s", Type, "ScrollFrame", tostring(self)), backdrop, "UIPanelScrollFrameTemplate") |
scrollframe:SetPoint("TOPLEFT", 5, -6) |
scrollframe:SetPoint("BOTTOMRIGHT", -28, 6) |
scrollframe.obj = self |
self.scrollframe = scrollframe |
--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:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2) |
label:SetJustifyH("LEFT") |
label:SetHeight(18) |
self.label = label |
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:SetMaxLetters(7500) |
editbox:SetTextInsets(5, 5, 3, 3) |
editbox:EnableMouse(true) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(ChatFontNormal) |
scrollframe:SetScrollChild(editbox) |
local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate") |
button:SetWidth(80) |
button:SetHeight(20) |
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 |
button.obj = self |
scrollframe:EnableMouse(true) |
scrollframe:SetScript("OnMouseUp", function() editbox:SetFocus() end) |
scrollframe:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) |
scrollframe:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) |
editbox:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) |
editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) |
local function FixSize() |
--scrollchild:SetHeight(scrollframe:GetHeight()) |
--scrollchild:SetWidth(scrollframe:GetWidth()) |
editbox:SetWidth(scrollframe:GetWidth()) |
end |
scrollframe:SetScript("OnShow", FixSize) |
scrollframe:SetScript("OnSizeChanged", FixSize) |
editbox:SetScript("OnEscapePressed", editbox.ClearFocus) |
editbox:SetScript("OnTextChanged", function(_, ...) |
scrollframe:UpdateScrollChildRect() |
local value = editbox:GetText() |
if value ~= self.lasttext then |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
self.button:Enable() |
end |
end) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
do |
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) |
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 |
cursorOffset = nil |
end |
editbox:SetScript("OnCursorChanged", function(_, x, y, w, h) |
cursorOffset, cursorHeight = y, h |
if not idleTime then |
frame:SetScript("OnUpdate", FixScroll) |
end |
end) |
end |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
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) |
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 |
]] |
-------------------------- |
-- Tab Group -- |
-------------------------- |
do |
local Type = "TabGroup" |
local Version = 20 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 5, bottom = 3 } |
} |
local function OnAcquire(self) |
end |
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 |
for _, tab in pairs(self.tabs) do |
tab:Hide() |
end |
end |
local function Tab_SetText(self, text) |
self:_SetText(text) |
local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0 |
PanelTemplates_TabResize(self, 0, nil, width) |
end |
local function UpdateTabLook(self) |
if self.disabled then |
PanelTemplates_SetDisabledTabState(self) |
elseif self.selected then |
PanelTemplates_SelectTab(self) |
else |
PanelTemplates_DeselectTab(self) |
end |
end |
local function Tab_SetSelected(self, selected) |
self.selected = selected |
UpdateTabLook(self) |
end |
local function Tab_OnClick(self) |
if not (self.selected or self.disabled) then |
self.obj:SelectTab(self.value) |
end |
end |
local function Tab_SetDisabled(self, disabled) |
self.disabled = disabled |
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 Tab_OnShow(this) |
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30) |
end |
local function CreateTab(self, id) |
local tabname = "AceGUITabGroup"..self.num.."Tab"..id |
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate") |
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) |
tab:SetScript("OnShow", Tab_OnShow) |
tab._SetText = tab.SetText |
tab.SetText = Tab_SetText |
tab.SetSelected = Tab_SetSelected |
tab.SetDisabled = Tab_SetDisabled |
return tab |
end |
local function SetTitle(self, text) |
self.titletext:SetText(text or "") |
end |
-- called to set an external table to store status in |
local function SetStatusTable(self, status) |
assert(type(status) == "table") |
self.status = status |
end |
local function SelectTab(self, value) |
local status = self.status or self.localstatus |
local found |
for i, v in ipairs(self.tabs) do |
if v.value == value then |
v:SetSelected(true) |
found = true |
else |
v:SetSelected(false) |
end |
end |
status.selected = value |
if found then |
self:Fire("OnGroupSelected",value) |
end |
end |
local function SetTabs(self, tabs) |
self.tablist = tabs |
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 |
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 |
end |
tab:Show() |
tab:SetText(v.text) |
tab:SetDisabled(v.disabled) |
tab.value = v.value |
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 |
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, 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 |
--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, |
-- if the used space is above 75% already |
local padding = 0 |
if not (numrows == 1 and rowwidths[1] < width*0.75) then |
padding = (width - rowwidths[row]) / (endtab - starttab+1) |
end |
for i = starttab, endtab do |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) |
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 |
if contentwidth < 0 then |
contentwidth = 0 |
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 - (self.borderoffset + 23) |
if contentheight < 0 then |
contentheight = 0 |
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) |
local self = {} |
self.type = Type |
self.num = AceGUI:GetNextWidgetNum(Type) |
self.localstatus = {} |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetTitle = SetTitle |
self.CreateTab = CreateTab |
self.SelectTab = SelectTab |
self.BuildTabs = BuildTabs |
self.SetStatusTable = SetStatusTable |
self.SetTabs = SetTabs |
self.LayoutFinished = LayoutFinished |
self.frame = frame |
self.OnWidthSet = OnWidthSet |
self.OnHeightSet = OnHeightSet |
frame.obj = self |
frame:SetHeight(100) |
frame:SetWidth(100) |
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:SetJustifyH("LEFT") |
titletext:SetHeight(18) |
self.titletext = titletext |
local border = CreateFrame("Frame",nil,frame) |
self.border = border |
self.borderoffset = 27 |
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27) |
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3) |
border:SetBackdrop(PaneBackdrop) |
border:SetBackdropColor(0.1,0.1,0.1,0.5) |
border:SetBackdropBorderColor(0.4,0.4,0.4) |
self.tabs = {} |
--Container Support |
local content = CreateFrame("Frame",nil,border) |
self.content = content |
content.obj = self |
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) |
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) |
AceGUI:RegisterAsContainer(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
local AceGUI = LibStub("AceGUI-3.0") |
-------------------------- |
-- Keybinding -- |
-------------------------- |
do |
local Type = "Keybinding" |
local Version = 13 |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function keybindingMsgFixWidth(this) |
this:SetWidth(this.msg:GetWidth()+10) |
this:SetScript("OnUpdate",nil) |
end |
local function Keybinding_OnClick(this, button) |
if button == "LeftButton" or button == "RightButton" then |
local self = this.obj |
if self.waitingForKey then |
this:EnableKeyboard(false) |
self.msgframe:Hide() |
this:UnlockHighlight() |
self.waitingForKey = nil |
else |
this:EnableKeyboard(true) |
self.msgframe:Show() |
this:LockHighlight() |
self.waitingForKey = true |
end |
end |
AceGUI:ClearFocus() |
end |
local ignoreKeys = nil |
local function Keybinding_OnKeyDown(this, key) |
local self = this.obj |
if self.waitingForKey then |
local keyPressed = key |
if keyPressed == "ESCAPE" then |
keyPressed = "" |
else |
if not ignoreKeys then |
ignoreKeys = { |
["BUTTON1"] = true, ["BUTTON2"] = true, |
["UNKNOWN"] = true, |
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, |
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true, |
} |
end |
if ignoreKeys[keyPressed] then return end |
if IsShiftKeyDown() then |
keyPressed = "SHIFT-"..keyPressed |
end |
if IsControlKeyDown() then |
keyPressed = "CTRL-"..keyPressed |
end |
if IsAltKeyDown() then |
keyPressed = "ALT-"..keyPressed |
end |
end |
this:EnableKeyboard(false) |
self.msgframe:Hide() |
this:UnlockHighlight() |
self.waitingForKey = nil |
if not self.disabled then |
self:SetKey(keyPressed) |
self:Fire("OnKeyChanged",keyPressed) |
end |
end |
end |
local function Keybinding_OnMouseDown(this, button) |
if button == "LeftButton" or button == "RightButton" then |
return |
elseif button == "MiddleButton" then |
button = "BUTTON3" |
elseif button == "Button4" then |
button = "BUTTON4" |
elseif button == "Button5" then |
button = "BUTTON5" |
end |
Keybinding_OnKeyDown(this, button) |
end |
local function OnAcquire(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetLabel("") |
self:SetKey("") |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.waitingForKey = nil |
self.msgframe:Hide() |
self:SetDisabled(false) |
end |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if disabled then |
self.button:Disable() |
self.label:SetTextColor(0.5,0.5,0.5) |
else |
self.button:Enable() |
self.label:SetTextColor(1,1,1) |
end |
end |
local function SetKey(self, key) |
if (key or "") == "" then |
self.button:SetText(NOT_BOUND) |
self.button:SetNormalFontObject("GameFontNormal") |
else |
self.button:SetText(key) |
self.button:SetNormalFontObject("GameFontHighlight") |
end |
end |
local function SetLabel(self, label) |
self.label:SetText(label or "") |
if (label or "") == "" then |
self.alignoffset = nil |
self:SetHeight(24) |
else |
self.alignoffset = 30 |
self:SetHeight(44) |
end |
end |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame",nil,UIParent) |
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) |
text:SetPoint("RIGHT",button,"RIGHT",-7,0) |
button:SetScript("OnClick",Keybinding_OnClick) |
button:SetScript("OnKeyDown",Keybinding_OnKeyDown) |
button:SetScript("OnEnter",Control_OnEnter) |
button:SetScript("OnLeave",Control_OnLeave) |
button:SetScript("OnMouseDown",Keybinding_OnMouseDown) |
button:RegisterForClicks("AnyDown") |
button:EnableMouse() |
button:SetHeight(24) |
button:SetWidth(200) |
button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0) |
button:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
frame:SetWidth(200) |
frame:SetHeight(44) |
self.alignoffset = 30 |
self.button = button |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetHeight(18) |
self.label = label |
local msgframe = CreateFrame("Frame",nil,UIParent) |
msgframe:SetHeight(30) |
msgframe:SetBackdrop(ControlBackdrop) |
msgframe:SetBackdropColor(0,0,0) |
msgframe:SetFrameStrata("FULLSCREEN_DIALOG") |
msgframe:SetFrameLevel(1000) |
self.msgframe = msgframe |
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") |
msgframe.msg = msg |
msg:SetPoint("TOPLEFT",msgframe,"TOPLEFT",5,-5) |
msgframe:SetScript("OnUpdate", keybindingMsgFixWidth) |
msgframe:SetPoint("BOTTOM",button,"TOP",0,0) |
msgframe:Hide() |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.SetDisabled = SetDisabled |
self.SetKey = SetKey |
self.frame = frame |
frame.obj = self |
button.obj = self |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
]] |
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) |
local AceGUI = LibStub("AceGUI-3.0") |
-------------------------- |
-- Label -- |
-------------------------- |
do |
local Type = "Icon" |
local Version = 10 |
local function OnAcquire(self) |
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 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, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
self.imageshown = true |
local n = select('#', ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
end |
else |
self.imageshown = nil |
end |
end |
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() |
local frame = CreateFrame("Button",nil,UIParent) |
local self = {} |
self.type = Type |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
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:SetHeight(110) |
frame:SetWidth(110) |
frame:EnableMouse(true) |
frame:SetScript("OnClick", OnClick) |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnEnter", OnEnter) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight") |
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetJustifyV("TOP") |
label:SetHeight(18) |
self.label = label |
local image = frame:CreateTexture(nil,"BACKGROUND") |
self.image = image |
image:SetWidth(64) |
image:SetHeight(64) |
image:SetPoint("TOP",frame,"TOP",0,-5) |
local highlight = frame:CreateTexture(nil,"OVERLAY") |
self.highlight = highlight |
highlight:SetAllPoints(image) |
highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") |
highlight:SetTexCoord(0,1,0.23,0.77) |
highlight:SetBlendMode("ADD") |
highlight:Hide() |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
]] |
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 |