/trunk/Broadcaster/Libs/AceGUI-3.0
]] |
do |
local Type = "CheckBox" |
local Version = 3 |
local Version = 4 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetValue(false) |
self.tristate = nil |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.check:Hide() |
self.text:SetPoint("LEFT",self.check,"RIGHT",1,-1) |
self.down = true |
end |
AceGUI:ClearFocus() |
end |
local function SetDisabled(self,disabled) |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetValue = SetValue |
self.GetValue = GetValue |
-------------------------- |
do |
local Type = "Icon" |
local Version = 3 |
local Version = 4 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetText("") |
self:SetImage(nil) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function OnClick(this) |
this.obj:Fire("OnClick") |
AceGUI:ClearFocus() |
end |
local function OnEnter(this) |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.frame = frame |
self.SetImage = SetImage |
do |
local Type = "BlizOptionsGroup" |
local Version = 5 |
local Version = 6 |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetName() |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
self.SetName = SetName |
]] |
do |
local Type = "Frame" |
local Version = 3 |
local Version = 7 |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
this.obj:Fire("OnClose") |
end |
local function frameOnSizeChanged(this) |
local self = this.obj |
local status = self.status or self.localstatus |
status.width = this:GetWidth() |
status.height = this:GetHeight() |
status.top = this:GetTop() |
status.left = this:GetLeft() |
end |
local function closeOnClick(this) |
this.obj:Hide() |
end |
local function frameOnMouseDown(this) |
AceGUI:ClearFocus() |
end |
local function titleOnMouseDown(this) |
this:GetParent():StartMoving() |
AceGUI:ClearFocus() |
end |
local function frameOnMouseUp(this) |
local function sizerseOnMouseDown(this) |
this:GetParent():StartSizing("BOTTOMRIGHT") |
AceGUI:ClearFocus() |
end |
local function sizersOnMouseDown(this) |
this:GetParent():StartSizing("BOTTOM") |
AceGUI:ClearFocus() |
end |
local function sizereOnMouseDown(this) |
this:GetParent():StartSizing("RIGHT") |
AceGUI:ClearFocus() |
end |
local function sizerOnMouseUp(this) |
this:GetParent():StopMovingOrSizing() |
this:GetParent():StopMovingOrSizing() |
end |
local function SetTitle(self,title) |
self.frame:Show() |
end |
local function Acquire(self) |
local function OnAcquire(self) |
self.frame:SetParent(UIParent) |
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") |
self:ApplyStatus() |
end |
local function Release(self) |
local function OnRelease(self) |
self.status = nil |
for k in pairs(self.localstatus) do |
self.localstatus[k] = nil |
local function ApplyStatus(self) |
local status = self.status or self.localstatus |
local frame = self.frame |
frame:SetWidth(status.width or 700) |
frame:SetHeight(status.height or 500) |
self:SetWidth(status.width or 700) |
self:SetHeight(status.height or 500) |
if status.top and status.left then |
frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) |
frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) |
local function OnWidthSet(self, width) |
local content = self.content |
local contentwidth = width - 44 |
local contentwidth = width - 34 |
if contentwidth < 0 then |
contentwidth = 0 |
end |
content.height = contentheight |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.Hide = Hide |
self.Show = Show |
self.SetTitle = SetTitle |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetStatusText = SetStatusText |
self.SetStatusTable = SetStatusTable |
self.ApplyStatus = ApplyStatus |
frame:SetMovable(true) |
frame:SetResizable(true) |
frame:SetFrameStrata("FULLSCREEN_DIALOG") |
frame:SetScript("OnMouseDown", frameOnMouseDown) |
frame:SetBackdrop(FrameBackdrop) |
frame:SetBackdropColor(0,0,0,1) |
frame:SetScript("OnHide",frameOnClose) |
frame:SetMinResize(400,200) |
frame:SetScript("OnSizeChanged", frameOnSizeChanged) |
frame:SetToplevel(true) |
local closebutton = CreateFrame("Button",nil,frame,"UIPanelButtonTemplate") |
local title = CreateFrame("Frame",nil,frame) |
self.title = title |
title:EnableMouse() |
title:SetScript("OnMouseDown",frameOnMouseDown) |
title:SetScript("OnMouseDown",titleOnMouseDown) |
title:SetScript("OnMouseUp", frameOnMouseUp) |
do |
local Type = "InlineGroup" |
local Version = 3 |
local Version = 4 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetWidth(300) |
self:SetHeight(100) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetTitle = SetTitle |
self.frame = frame |
self.LayoutFinished = LayoutFinished |
--[[ $Id: AceGUIWidget-DropDown.lua 81438 2008-09-06 13:44:36Z nevcairiel $ ]]-- |
local min, max, floor = math.min, math.max, math.floor |
local AceGUI = LibStub("AceGUI-3.0") |
-------------------------- |
-- Dropdown -- |
-------------------------- |
--[[ |
Events : |
OnValueChanged |
local function fixlevels(parent,...) |
local i = 1 |
local child = select(i, ...) |
while child do |
child:SetFrameLevel(parent:GetFrameLevel()+1) |
fixlevels(child, child:GetChildren()) |
i = i + 1 |
child = select(i, ...) |
end |
end |
]] |
local function fixstrata(strata, parent, ...) |
local i = 1 |
local child = select(i, ...) |
parent:SetFrameStrata(strata) |
while child do |
fixstrata(strata, child, child:GetChildren()) |
i = i + 1 |
child = select(i, ...) |
end |
end |
do |
local Type = "Dropdown" |
local Version = 10 |
local ControlBackdrop = { |
local widgetType = "Dropdown-Pullout" |
local widgetVersion = 2 |
--[[ Static data ]]-- |
local backdrop = { |
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", |
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", |
edgeSize = 32, |
tile = true, |
insets = { left = 11, right = 12, top = 12, bottom = 11 }, |
} |
local sliderBackdrop = { |
bgFile = "Interface\\Buttons\\UI-SliderBar-Background", |
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", |
tile = true, tileSize = 8, edgeSize = 8, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
local function Acquire(self) |
self:SetLabel("") |
local defaultWidth = 200 |
local defaultMaxHeight = 600 |
--[[ UI Event Handlers ]]-- |
-- HACK: This should be no part of the pullout, but there |
-- is no other 'clean' way to response to any item-OnEnter |
-- Used to close Submenus when an other item is entered |
local function OnEnter(item) |
local self = item.pullout |
for k, v in ipairs(self.items) do |
if v.CloseMenu and v ~= item then |
v:CloseMenu() |
end |
end |
end |
local function Release(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetLabel(nil) |
self.list = nil |
self:SetDisabled(false) |
-- See the note in Constructor() for each scroll related function |
local function OnMouseWheel(this, value) |
this.obj:MoveScroll(value) |
end |
local function OnScrollValueChanged(this, value) |
this.obj:SetScroll(value) |
end |
local function OnSizeChanged(this) |
this.obj:FixScroll() |
end |
--[[ Exported methods ]]-- |
-- exported |
local function SetScroll(self, value) |
local status = self.scrollStatus |
local frame, child = self.scrollFrame, self.itemFrame |
local height, viewheight = frame:GetHeight(), child:GetHeight() |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
local offset |
if height > viewheight then |
offset = 0 |
else |
offset = floor((viewheight - height) / 1000 * value) |
end |
child:ClearAllPoints() |
child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset) |
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", self.slider:IsShown() and -12 or 0, offset) |
status.offset = offset |
status.scrollvalue = value |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
-- exported |
local function MoveScroll(self, value) |
local status = self.scrollStatus |
local frame, child = self.scrollFrame, self.itemFrame |
local height, viewheight = frame:GetHeight(), child:GetHeight() |
if height > viewheight then |
self.slider:Hide() |
else |
self.slider:Show() |
local diff = height - viewheight |
local delta = 1 |
if value < 0 then |
delta = -1 |
end |
self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000)) |
end |
end |
local function SetText(self, text) |
self.text:SetText(text or "") |
-- exported |
local function FixScroll(self) |
local status = self.scrollStatus |
local frame, child = self.scrollFrame, self.itemFrame |
local height, viewheight = frame:GetHeight(), child:GetHeight() |
local offset = status.offset or 0 |
if viewheight < height then |
self.slider:Hide() |
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset) |
self.slider:SetValue(0) |
else |
self.slider:Show() |
local value = (offset / (viewheight - height) * 1000) |
if value > 1000 then value = 1000 end |
self.slider:SetValue(value) |
self:SetScroll(value) |
if value < 1000 then |
child:ClearAllPoints() |
child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset) |
child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -12, offset) |
status.offset = offset |
end |
end |
end |
local function SetValue(self, value) |
if self.list then |
self.text:SetText(self.list[value] or "") |
-- exported, AceGUI callback |
local function OnAcquire(self) |
self.frame:SetParent(UIParent) |
--self.itemFrame:SetToplevel(true) |
end |
-- exported, AceGUI callback |
local function OnRelease(self) |
self:Clear() |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
-- exported |
local function AddItem(self, item) |
self.items[#self.items + 1] = item |
local h = #self.items * 16 |
self.itemFrame:SetHeight(h) |
self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement |
item.frame:SetPoint("LEFT", self.itemFrame, "LEFT") |
item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT") |
item:SetPullout(self) |
item:SetOnEnter(OnEnter) |
end |
-- exported |
local function Open(self, point, relFrame, relPoint, x, y) |
local items = self.items |
local frame = self.frame |
local itemFrame = self.itemFrame |
frame:SetPoint(point, relFrame, relPoint, x, y) |
local height = 8 |
for i, item in pairs(items) do |
if i == 1 then |
item:SetPoint("TOP", itemFrame, "TOP", 0, -2) |
else |
item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1) |
end |
item:Show() |
height = height + 16 |
end |
self.text.value = value |
itemFrame:SetHeight(height) |
fixstrata("TOOLTIP", frame, frame:GetChildren()) |
frame:Show() |
self:Fire("OnOpen") |
end |
-- exported |
local function Close(self) |
self.frame:Hide() |
self:Fire("OnClose") |
end |
-- exported |
local function Clear(self) |
local items = self.items |
for i, item in pairs(items) do |
AceGUI:Release(item) |
items[i] = nil |
end |
end |
-- exported |
local function IterateItems(self) |
return ipairs(self.items) |
end |
local function SetList(self, list) |
self.list = list |
-- exported |
local function SetHideOnLeave(self, val) |
self.hideOnLeave = val |
end |
local function AddItem(self, value, text) |
if self.list then |
self.list[value] = text |
-- exported |
local function SetMaxHeight(self, height) |
self.maxHeight = height or defaultMaxHeight |
if self.frame:GetHeight() > height then |
self.frame:SetHeight(height) |
elseif (self.itemFrame:GetHeight() + 34) < height then |
self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem |
end |
end |
-- exported |
local function GetRightBorderWidth(self) |
return 6 + (self.slider:IsShown() and 12 or 0) |
end |
local function Dropdown_OnEnterPressed(this) |
-- exported |
local function GetLeftBorderWidth(self) |
return 6 |
end |
--[[ Constructor ]]-- |
local function Constructor() |
local count = AceGUI:GetNextWidgetNum(widgetType) |
local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent) |
local self = {} |
self.count = count |
self.type = widgetType |
self.frame = frame |
frame.obj = self |
self.OnAcquire = OnAcquire |
self.OnRelease = OnRelease |
self.AddItem = AddItem |
self.Open = Open |
self.Close = Close |
self.Clear = Clear |
self.IterateItems = IterateItems |
self.SetHideOnLeave = SetHideOnLeave |
self.SetScroll = SetScroll |
self.MoveScroll = MoveScroll |
self.FixScroll = FixScroll |
self.SetMaxHeight = SetMaxHeight |
self.GetRightBorderWidth = GetRightBorderWidth |
self.GetLeftBorderWidth = GetLeftBorderWidth |
self.items = {} |
self.scrollStatus = { |
scrollvalue = 0, |
} |
self.maxHeight = defaultMaxHeight |
frame:SetBackdrop(backdrop) |
frame:SetBackdropColor(0, 0, 0) |
frame:SetFrameStrata("FULLSCREEN_DIALOG") |
frame:SetClampedToScreen(true) |
frame:SetWidth(defaultWidth) |
frame:SetHeight(self.maxHeight) |
--frame:SetToplevel(true) |
-- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame |
local scrollFrame = CreateFrame("ScrollFrame", nil, frame) |
local itemFrame = CreateFrame("Frame", nil, scrollFrame) |
self.scrollFrame = scrollFrame |
self.itemFrame = itemFrame |
scrollFrame.obj = self |
itemFrame.obj = self |
local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame) |
slider:SetOrientation("VERTICAL") |
slider:SetHitRectInsets(0, 0, -10, 0) |
slider:SetBackdrop(sliderBackdrop) |
slider:SetWidth(8) |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical") |
slider:SetFrameStrata("FULLSCREEN_DIALOG") |
self.slider = slider |
slider.obj = self |
scrollFrame:SetScrollChild(itemFrame) |
scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12) |
scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12) |
scrollFrame:EnableMouseWheel(true) |
scrollFrame:SetScript("OnMouseWheel", OnMouseWheel) |
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) |
scrollFrame:SetToplevel(true) |
scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG") |
itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0) |
itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0) |
itemFrame:SetHeight(400) |
itemFrame:SetToplevel(true) |
itemFrame:SetFrameStrata("FULLSCREEN_DIALOG") |
slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0) |
slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0) |
slider:SetScript("OnValueChanged", OnScrollValueChanged) |
slider:SetMinMaxValues(0, 1000) |
slider:SetValueStep(1) |
slider:SetValue(0) |
scrollFrame:Show() |
itemFrame:Show() |
slider:Hide() |
self:FixScroll() |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) |
end |
do |
local widgetType = "Dropdown" |
local widgetVersion = 18 |
--[[ Static data ]]-- |
--[[ UI event handler ]]-- |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function Dropdown_OnHide(this) |
local self = this.obj |
if not self.disabled then |
local ret = this.value or this:GetText() |
self:Fire("OnValueChanged",ret) |
if self.open then |
self.pullout:Close() |
end |
end |
local self = this.obj |
if self.open then |
self.open = nil |
self.pullout:Hide() |
self.pullout:Close() |
AceGUI:ClearFocus() |
else |
self.open = true |
self:BuildPullout() |
if self.lines[1] and self.lines[1]:IsShown() then |
self.pullout:Show() |
self.pullout:SetWidth(self.frame:GetWidth()) |
self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0) |
AceGUI:SetFocus(self) |
end |
end |
local function OnPulloutOpen(this) |
local self = this.userdata.obj |
local value = self.value |
if not self.multiselect then |
for i, item in this:IterateItems() do |
item:SetValue(item.userdata.value == value) |
end |
end |
self.open = true |
end |
local function OnPulloutClose(this) |
local self = this.userdata.obj |
self.open = nil |
self:Fire("OnClosed") |
end |
local function Dropdown_OnHide(this) |
this.obj.pullout:Hide() |
local function ShowMultiText(self) |
local text |
for i, widget in self.pullout:IterateItems() do |
if widget.type == "Dropdown-Item-Toggle" then |
if widget:GetValue() then |
if text then |
text = text..", "..widget:GetText() |
else |
text = widget:GetText() |
end |
end |
end |
end |
self:SetText(text) |
end |
local function Dropdown_LineClicked(this) |
local self = this.obj |
self.open = false |
self.pullout:Hide() |
self.text:SetText(this.text:GetText()) |
self.text.value = this.value |
Dropdown_OnEnterPressed(self.text) |
local function OnItemValueChanged(this, event, checked) |
local self = this.userdata.obj |
if self.multiselect then |
self:Fire("OnValueChanged", this.userdata.value, checked) |
ShowMultiText(self) |
else |
if checked then |
self:SetValue(this.userdata.value) |
self:Fire("OnValueChanged", this.userdata.value) |
else |
this:SetValue(true) |
end |
if self.open then |
self.pullout:Close() |
end |
end |
end |
local function Dropdown_LineEnter(this) |
this.highlight:Show() |
--[[ Exported methods ]]-- |
-- exported, AceGUI callback |
local function OnAcquire(self) |
local pullout = AceGUI:Create("Dropdown-Pullout") |
self.pullout = pullout |
pullout.userdata.obj = self |
pullout:SetCallback("OnClose", OnPulloutClose) |
pullout:SetCallback("OnOpen", OnPulloutOpen) |
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1) |
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren()) |
end |
local function Dropdown_LineLeave(this) |
this.highlight:Hide() |
end |
-- exported, AceGUI callback |
local function OnRelease(self) |
if self.open then |
self.pullout:Close() |
end |
AceGUI:Release(self.pullout) |
self:SetText("") |
self:SetLabel("") |
self:SetDisabled(false) |
self:SetMultiselect(false) |
self.value = nil |
self.list = nil |
self.open = nil |
self.hasClose = nil |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
-- exported |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if disabled then |
end |
end |
local function fixlevels(parent,...) |
local i = 1 |
local child = select(i, ...) |
while child do |
child:SetFrameLevel(parent:GetFrameLevel()+1) |
fixlevels(child, child:GetChildren()) |
i = i + 1 |
child = select(i, ...) |
-- exported |
local function ClearFocus(self) |
if self.open then |
self.pullout:Close() |
end |
end |
local ddsort = {} |
local function BuildPullout(self) |
local list = self.list |
local lines = self.lines |
local totalheight = 22 |
self:ClearPullout() |
self.pullout:SetFrameLevel(self.frame:GetFrameLevel()+1000) |
if type(list) == "table" then |
for k, v in pairs(list) do |
tinsert(ddsort,k) |
end |
table.sort(ddsort) |
for i, value in pairs(ddsort) do |
local text = list[value] |
if not lines[i] then |
lines[i] = self:CreateLine() |
if i == 1 then |
lines[i]:SetPoint("TOP",self.pullout,"TOP",0,-10) |
else |
lines[i]:SetPoint("TOP",lines[i-1],"BOTTOM",0,1) |
end |
end |
lines[i].text:SetText(text) |
lines[i]:SetFrameLevel(self.frame:GetFrameLevel()+1001) |
lines[i].value = value |
if lines[i].value == self.text.value then |
lines[i].check:Show() |
else |
lines[i].check:Hide() |
end |
lines[i]:Show() |
totalheight = totalheight + 16 |
i = i + 1 |
end |
for k in pairs(ddsort) do |
ddsort[k] = nil |
end |
end |
self.pullout:SetHeight(totalheight) |
fixlevels(self.pullout,self.pullout:GetChildren()) |
-- exported |
local function SetText(self, text) |
self.text:SetText(text or "") |
end |
local function ClearPullout(self) |
if self.lines then |
for i, line in ipairs(self.lines) do |
line.text:SetText("") |
line:Hide() |
end |
end |
self.pullout:SetHeight(10) |
self.pullout:SetWidth(200) |
end |
-- exported |
local function SetLabel(self, text) |
if text and text ~= "" then |
self.label:SetText(text) |
self.frame:SetHeight(26) |
end |
end |
local function CreateLine(self, row, column) |
local frame = CreateFrame("Button",nil,self.pullout) |
frame.text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") |
frame.text:SetTextColor(1,1,1) |
frame.text:SetJustifyH("LEFT") |
frame:SetHeight(17) |
frame:SetPoint("LEFT",self.pullout,"LEFT",6,0) |
frame:SetPoint("RIGHT",self.pullout,"RIGHT",-6,0) |
frame:SetFrameStrata("FULLSCREEN_DIALOG") |
frame.obj = self |
local highlight = frame:CreateTexture(nil, "OVERLAY") |
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") |
highlight:SetBlendMode("ADD") |
highlight:SetHeight(14) |
highlight:ClearAllPoints() |
highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0) |
highlight:SetPoint("LEFT",frame,"LEFT",5,0) |
highlight:Hide() |
frame.highlight = highlight |
-- exported |
local function SetValue(self, value) |
if self.list then |
self:SetText(self.list[value] or "") |
end |
self.value = value |
end |
local check = frame:CreateTexture("OVERLAY") |
frame.check = check |
check:SetWidth(16) |
check:SetHeight(16) |
check:SetPoint("LEFT",frame,"LEFT",3,-1) |
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") |
frame.text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0) |
frame.text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0) |
-- exported |
local function SetItemValue(self, item, value) |
if not self.multiselect then return end |
for i, widget in self.pullout:IterateItems() do |
if widget.userdata.value == item then |
if widget.SetValue then |
widget:SetValue(value) |
end |
end |
end |
ShowMultiText(self) |
end |
frame:SetScript("OnClick",Dropdown_LineClicked) |
frame:SetScript("OnEnter",Dropdown_LineEnter) |
frame:SetScript("OnLeave",Dropdown_LineLeave) |
return frame |
-- exported |
local function SetItemDisabled(self, item, disabled) |
for i, widget in self.pullout:IterateItems() do |
if widget.userdata.value == item then |
widget:SetDisabled(disabled) |
end |
end |
end |
local count = 0 |
local function AddListItem(self, value, text) |
local item = AceGUI:Create("Dropdown-Item-Toggle") |
item:SetText(text) |
item.userdata.obj = self |
item.userdata.value = value |
item:SetCallback("OnValueChanged", OnItemValueChanged) |
self.pullout:AddItem(item) |
end |
local function AddCloseButton(self) |
if not self.hasClose then |
local close = AceGUI:Create("Dropdown-Item-Execute") |
close:SetText(CLOSE) |
self.pullout:AddItem(close) |
self.hasClose = true |
end |
end |
-- exported |
local sortlist = {} |
local function SetList(self, list) |
self.list = list |
self.pullout:Clear() |
self.hasClose = nil |
if not list then return end |
for v in pairs(list) do |
sortlist[#sortlist + 1] = v |
end |
table.sort(sortlist) |
for i, value in pairs(sortlist) do |
AddListItem(self, value, list[value]) |
sortlist[i] = nil |
end |
if self.multiselect then |
ShowMultiText(self) |
AddCloseButton(self) |
end |
end |
-- exported |
local function AddItem(self, value, text) |
if self.list then |
self.list[value] = text |
AddListItem(self, value, text) |
end |
end |
-- exported |
local function SetMultiselect(self, multi) |
self.multiselect = multi |
if multi then |
ShowMultiText(self) |
AddCloseButton(self) |
end |
end |
-- exported |
local function GetMultiselect(self) |
return self.multiselect |
end |
--[[ Constructor ]]-- |
local function Constructor() |
count = count + 1 |
local count = AceGUI:GetNextWidgetNum(widgetType) |
local frame = CreateFrame("Frame", nil, UIParent) |
local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate") |
local self = {} |
local frame = CreateFrame("Frame",nil,UIParent) |
local dropdown = CreateFrame("Frame","AceGUI30DropDown" .. count,frame, "UIDropDownMenuTemplate") |
self.type = widgetType |
self.frame = frame |
self.dropdown = dropdown |
self.type = Type |
self.count = count |
frame.obj = self |
dropdown.obj = self |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.ClearFocus = ClearFocus |
self.Release = Release |
self.Acquire = Acquire |
self.CreateLine = CreateLine |
self.ClearPullout = ClearPullout |
self.BuildPullout = BuildPullout |
self.SetText = SetText |
self.SetValue = SetValue |
self.SetList = SetList |
self.AddItem = AddItem |
self.SetLabel = SetLabel |
self.SetText = SetText |
self.SetValue = SetValue |
self.SetList = SetList |
self.SetLabel = SetLabel |
self.SetDisabled = SetDisabled |
self.AddItem = AddItem |
self.SetMultiselect = SetMultiselect |
self.GetMultiselect = GetMultiselect |
self.SetItemValue = SetItemValue |
self.SetItemDisabled = SetItemDisabled |
self.frame = frame |
frame.obj = self |
self.alignoffset = 31 |
self.alignoffset = 30 |
frame:SetHeight(44) |
frame:SetWidth(200) |
frame:SetScript("OnHide",Dropdown_OnHide) |
dropdown:ClearAllPoints() |
dropdown:SetPoint("TOPLEFT",frame,"TOPLEFT",-15,0) |
dropdown:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",17,0) |
dropdown:SetScript("OnHide", nil) |
-- fix anchoring of the dropdown |
local left = _G[dropdown:GetName() .. "Left"] |
local middle = _G[dropdown:GetName() .. "Middle"] |
local right = _G[dropdown:GetName() .. "Right"] |
text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2) |
text:SetPoint("LEFT", left, "LEFT", 25, 2) |
local pullout = CreateFrame("Frame",nil,UIParent) |
self.pullout = pullout |
frame:EnableMouse() |
pullout:SetBackdrop(ControlBackdrop) |
pullout:SetBackdropColor(0,0,0) |
pullout:SetFrameStrata("FULLSCREEN_DIALOG") |
pullout:SetPoint("TOPLEFT",frame,"BOTTOMLEFT",0,0) |
pullout:SetPoint("TOPRIGHT",frame,"BOTTOMRIGHT",0,0) |
pullout:SetClampedToScreen(true) |
pullout:Hide() |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) |
label:SetHeight(18) |
label:Hide() |
self.label = label |
self.lines = {} |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) |
end |
]] |
do |
local Type = "EditBox" |
local Version = 5 |
local function Acquire(self) |
local Version = 8 |
local function OnAcquire(self) |
self:SetDisabled(false) |
self.showbutton = true |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
ClearCursor() |
end |
HideButton(self) |
AceGUI:ClearFocus() |
end |
local function EditBox_OnTextChanged(this) |
end |
end |
local count = 0 |
local function Constructor() |
count = count + 1 |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame",nil,UIParent) |
local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..count,frame,"InputBoxTemplate") |
local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..num,frame,"InputBoxTemplate") |
local self = {} |
self.type = Type |
self.num = num |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetDisabled = SetDisabled |
self.SetText = SetText |
editbox:SetScript("OnTextChanged",EditBox_OnTextChanged) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
editbox:SetTextInsets(0,0,3,3) |
editbox:SetMaxLetters(256) |
self.label = label |
local button = CreateFrame("Button",nil,editbox,"UIPanelButtonTemplate") |
button:SetWidth(20) |
button:SetWidth(40) |
button:SetHeight(20) |
button:SetPoint("RIGHT",editbox,"RIGHT",-2,0) |
button:SetText("OK") |
button:SetText(OKAY) |
button:SetScript("OnClick", Button_OnClick) |
button:Hide() |
-------------------------- |
do |
local Type = "Heading" |
local Version = 2 |
local Version = 3 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetText("") |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.frame = frame |
frame.obj = self |
do |
local Type = "SimpleGroup" |
local Version = 3 |
local Version = 4 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetWidth(300) |
self:SetHeight(100) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
self.LayoutFinished = LayoutFinished |
self.OnWidthSet = OnWidthSet |
local AceGUI = LibStub("AceGUI-3.0") |
------------- |
-- Widgets -- |
------------- |
--[[ |
Widgets must provide the following functions |
Acquire() - Called when the object is aquired, should set everything to a default hidden state |
Release() - Called when the object is Released, should remove any anchors and hide the Widget |
And the following members |
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes |
type - the type of the object, same as the name given to :RegisterWidget() |
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet |
It will be cleared automatically when a widget is released |
Placing values directly into a widget object should be avoided |
If the Widget can act as a container for other Widgets the following |
content - frame or derivitive that children will be anchored to |
The Widget can supply the following Optional Members |
]] |
--[[ |
Selection Group controls all have an interface to select a group for thier contents |
None of them will auto size to thier contents, and should usually be used with a scrollframe |
unless you know that the controls will fit inside |
]] |
do |
local Type = "DropdownGroup" |
local Version = 5 |
local Version = 9 |
local function Acquire(self) |
local function OnAcquire(self) |
self.dropdown:SetText("") |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.dropdown.list = nil |
local function SelectedGroup(self,event,value) |
local group = self.parentgroup |
local status = group.status or group.localstatus |
status.selectedgroup = value |
status.selected = value |
self.parentgroup:Fire("OnGroupSelected", value) |
end |
local function SetGroupList(self,list) |
self.dropdown.list = list |
self.dropdown:SetList(list) |
end |
-- called to set an external table to store status in |
local function SetGroup(self,group) |
self.dropdown:SetValue(group) |
local status = self.status or self.localstatus |
status.selectedgroup = group |
status.selected = group |
self:Fire("OnGroupSelected", group) |
end |
local function OnWidthSet(self, width) |
local content = self.content |
local contentwidth = width - 63 |
local contentwidth = width - 26 |
if contentwidth < 0 then |
contentwidth = 0 |
end |
local function OnHeightSet(self, height) |
local content = self.content |
local contentheight = height - 26 |
local contentheight = height - 63 |
if contentheight < 0 then |
contentheight = 0 |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.SetTitle = SetTitle |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetTitle = SetTitle |
self.SetGroupList = SetGroupList |
self.SetGroup = SetGroup |
self.SetStatusTable = SetStatusTable |
-------------------------- |
do |
local Type = "ScrollFrame" |
local Version = 2 |
local Version = 3 |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.status = nil |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.MoveScroll = MoveScroll |
self.FixScroll = FixScroll |
-------------------------- |
do |
local Type = "Button" |
local Version = 5 |
local Version = 7 |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
local function Button_OnClick(this) |
this.obj:Fire("OnClick") |
AceGUI:ClearFocus() |
end |
local function Button_OnEnter(this) |
end |
end |
local count = 0 |
local function Constructor() |
count = count + 1 |
local frame = CreateFrame("Button","AceGUI30Button"..count,UIParent,"UIPanelButtonTemplate2") |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Button","AceGUI30Button"..num,UIParent,"UIPanelButtonTemplate2") |
local self = {} |
self.num = num |
self.type = Type |
self.frame = frame |
frame:SetHeight(24) |
frame:SetWidth(200) |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
end |
end |
------------- |
-- Widgets -- |
------------- |
--[[ |
Widgets must provide the following functions |
Acquire() - Called when the object is aquired, should set everything to a default hidden state |
Release() - Called when the object is Released, should remove any anchors and hide the Widget |
And the following members |
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes |
type - the type of the object, same as the name given to :RegisterWidget() |
Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet |
It will be cleared automatically when a widget is released |
Placing values directly into a widget object should be avoided |
If the Widget can act as a container for other Widgets the following |
content - frame or derivitive that children will be anchored to |
The Widget can supply the following Optional Members |
local WotLK = select(4, GetBuildInfo()) >= 30000 |
]] |
-------------- |
-- TreeView -- |
-------------- |
do |
local Type = "TreeGroup" |
local Version = 6 |
local Version = 15 |
local DEFAULT_TREE_WIDTH = 175 |
local DEFAULT_TREE_SIZABLE = true |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
insets = { left = 3, right = 3, top = 5, bottom = 3 } |
} |
local function Acquire(self) |
local DraggerBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = nil, |
tile = true, tileSize = 16, edgeSize = 0, |
insets = { left = 3, right = 3, top = 7, bottom = 7 } |
} |
local function OnAcquire(self) |
self:SetTreeWidth(DEFAULT_TREE_WIDTH,DEFAULT_TREE_SIZABLE) |
self:EnableButtonTooltips(true) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.status = nil |
end |
end |
self.localstatus.scrollvalue = 0 |
self.localstatus.treewidth = DEFAULT_TREE_WIDTH |
self.localstatus.treesizable = DEFAULT_TREE_SIZABLE |
end |
local function GetButtonParents(line) |
this:LockHighlight() |
self:RefreshTree() |
end |
AceGUI:ClearFocus() |
end |
local function ExpandOnClick(this) |
status[button.uniquevalue] = not status[button.uniquevalue] |
self:RefreshTree() |
end |
local function EnableButtonTooltips(self, enable) |
self.enabletooltips = enable |
end |
local function Button_OnEnter(this) |
local self = this.obj |
self:Fire("OnButtonEnter", this.uniquevalue, this) |
if self.enabletooltips then |
GameTooltip:SetOwner(this, "ANCHOR_NONE") |
GameTooltip:SetPoint("LEFT",this,"RIGHT") |
GameTooltip:SetText(this.text:GetText(), 1, .82, 0, 1) |
GameTooltip:Show() |
end |
end |
local function Button_OnLeave(this) |
local self = this.obj |
self:Fire("OnButtonLeave", this.uniquevalue, this) |
if self.enabletooltips then |
GameTooltip:Hide() |
end |
end |
local buttoncount = 1 |
local function CreateButton(self) |
local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "InterfaceOptionsButtonTemplate") |
button:SetScript("OnClick",ButtonOnClick) |
button:SetScript("OnDoubleClick", ButtonOnDoubleClick) |
button:SetScript("OnEnter",Button_OnEnter) |
button:SetScript("OnLeave",Button_OnLeave) |
button.toggle.button = button |
button.toggle:SetScript("OnClick",ExpandOnClick) |
local line = button.line |
button.level = level |
if ( level == 1 ) then |
button:SetTextFontObject("GameFontNormal") |
if WotLK then |
button:SetNormalFontObject("GameFontNormal") |
else |
button:SetTextFontObject("GameFontNormal") |
end |
button:SetHighlightFontObject("GameFontHighlight") |
button.text:SetPoint("LEFT", 8, 2) |
else |
button:SetTextFontObject("GameFontHighlightSmall") |
if WotLK then |
button:SetNormalFontObject("GameFontHighlightSmall") |
else |
button:SetTextFontObject("GameFontHighlightSmall") |
end |
button:SetHighlightFontObject("GameFontHighlightSmall") |
button.text:SetPoint("LEFT", 8 * level, 2) |
end |
local status = self.status or self.localstatus |
status.scrollvalue = value |
self:RefreshTree() |
AceGUI:ClearFocus() |
end |
-- called to set an external table to store status in |
if not status.scrollvalue then |
status.scrollvalue = 0 |
end |
if not status.treewidth then |
status.treewidth = DEFAULT_TREE_WIDTH |
end |
if not status.treesizable then |
status.treesizable = DEFAULT_TREE_SIZABLE |
end |
self:SetTreeWidth(status.treewidth,status.treesizable) |
self:RefreshTree() |
end |
} |
]] |
local function SetTree(self, tree) |
assert(type(tree) == "table") |
if tree then |
assert(type(tree) == "table") |
end |
self.tree = tree |
self:RefreshTree() |
end |
end |
local function RefreshTree(self) |
if not self.tree then return end |
--Build the list of visible entries from the tree and status tables |
local status = self.status or self.localstatus |
local groupstatus = status.groups |
local tree = self.tree |
local buttons = self.buttons |
local lines = self.lines |
local buttons = self.buttons |
local treeframe = self.treeframe |
for i, v in ipairs(buttons) do |
v:Hide() |
end |
while lines[1] do |
local t = tremove(lines) |
for k in pairs(t) do |
t[k] = nil |
end |
del(t) |
end |
end |
if not self.tree then return end |
--Build the list of visible entries from the tree and status tables |
local status = self.status or self.localstatus |
local groupstatus = status.groups |
local tree = self.tree |
local treeframe = self.treeframe |
self:BuildLevel(tree, 1) |
for i, v in ipairs(buttons) do |
v:Hide() |
end |
local numlines = #lines |
local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 20)) |
local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) |
local first, last |
local function OnWidthSet(self, width) |
local content = self.content |
local contentwidth = width - 199 |
local treeframe = self.treeframe |
local status = self.status or self.localstatus |
local contentwidth = width - status.treewidth - 20 |
if contentwidth < 0 then |
contentwidth = 0 |
end |
content:SetWidth(contentwidth) |
content.width = contentwidth |
local maxtreewidth = math.min(400, width - 50) |
if maxtreewidth > 100 and status.treewidth > maxtreewidth then |
self:SetTreeWidth(maxtreewidth, status.treesizable) |
end |
treeframe:SetMaxResize(maxtreewidth,1600) |
end |
end |
end |
local function SetTreeWidth(self, treewidth, resizable) |
if not resizable then |
if type(treewidth) == 'number' then |
resizable = false |
elseif type(treewidth) == 'boolean' then |
resizable = treewidth |
treewidth = DEFAULT_TREE_WIDTH |
else |
resizable = false |
treewidth = DEFAULT_TREE_WIDTH |
end |
end |
self.treeframe:SetWidth(treewidth) |
self.dragger:EnableMouse(resizable) |
local status = self.status or self.localstatus |
status.treewidth = treewidth |
status.treesizable = resizable |
end |
local function draggerLeave(this) |
this:SetBackdropColor(1, 1, 1, 0) |
end |
local function draggerEnter(this) |
this:SetBackdropColor(1, 1, 1, 0.8) |
end |
local function draggerDown(this) |
local treeframe = this:GetParent() |
treeframe:StartSizing("RIGHT") |
end |
local function draggerUp(this) |
local treeframe = this:GetParent() |
local self = treeframe.obj |
local frame = treeframe:GetParent() |
treeframe:StopMovingOrSizing() |
--treeframe:SetScript("OnUpdate", nil) |
treeframe:SetUserPlaced(false) |
--Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize |
treeframe:SetHeight(0) |
treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth()) |
local status = self.status or self.localstatus |
status.treewidth = treeframe:GetWidth() |
end |
local createdcount = 0 |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
treeframe.obj = self |
treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
treeframe:SetWidth(183) |
treeframe:SetWidth(DEFAULT_TREE_WIDTH) |
treeframe:SetScript("OnUpdate",FirstFrameUpdate) |
treeframe:SetScript("OnSizeChanged",ResizeUpdate) |
treeframe:SetBackdropColor(0.1,0.1,0.1,0.5) |
treeframe:SetBackdropBorderColor(0.4,0.4,0.4) |
treeframe:SetResizable(true) |
treeframe:SetMinResize(100, 1) |
treeframe:SetMaxResize(400,1600) |
local dragger = CreateFrame("Frame", nil, treeframe) |
dragger:SetWidth(8) |
dragger:SetPoint("TOP", treeframe, "TOPRIGHT") |
dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT") |
dragger:SetBackdrop(DraggerBackdrop) |
dragger:SetBackdropColor(1, 1, 1, 0) |
dragger:SetScript("OnMouseDown", draggerDown) |
dragger:SetScript("OnMouseUp", draggerUp) |
dragger:SetScript("OnEnter", draggerEnter) |
dragger:SetScript("OnLeave", draggerLeave) |
self.dragger = dragger |
self.treeframe = treeframe |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetTree = SetTree |
self.SetTreeWidth = SetTreeWidth |
self.RefreshTree = RefreshTree |
self.SetStatusTable = SetStatusTable |
self.BuildLevel = BuildLevel |
self.SelectByPath = SelectByPath |
self.OnWidthSet = OnWidthSet |
self.OnHeightSet = OnHeightSet |
self.EnableButtonTooltips = EnableButtonTooltips |
self.frame = frame |
frame.obj = self |
createdcount = createdcount + 1 |
local scrollbar = CreateFrame("Slider",("AceConfigDialogTreeGroup%dScrollBar"):format(createdcount),treeframe,"UIPanelScrollBarTemplate") |
self.scrollbar = scrollbar |
local border = CreateFrame("Frame",nil,frame) |
self.border = border |
border:SetPoint("TOPLEFT",frame,"TOPLEFT",179,0) |
border:SetPoint("TOPLEFT",treeframe,"TOPRIGHT", 0,0) |
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
border:SetBackdrop(PaneBackdrop) |
-------------------------- |
do |
local Type = "ColorPicker" |
local Version = 8 |
local Version = 9 |
local function Acquire(self) |
local function OnAcquire(self) |
self.HasAlpha = false |
self:SetColor(0,0,0,1) |
end |
end |
ShowUIPanel(ColorPickerFrame) |
end |
AceGUI:ClearFocus() |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.SetColor = SetColor |
-------------------------- |
do |
local Type = "Label" |
local Version = 6 |
local Version = 8 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetText("") |
self:SetImage(nil) |
self:SetColor() |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
height = self.label:GetHeight() |
end |
frame.resizing = true |
self.resizing = true |
self.frame:SetHeight(height) |
self.frame.height = height |
frame.resizing = nil |
self.resizing = nil |
end |
local function SetText(self, text) |
end |
local function OnWidthSet(self, width) |
if self.resizing then return end |
UpdateImageAnchor(self) |
end |
local function OnFrameResize(this) |
if this.resizing then return end |
local self = this.obj |
OnWidthSet(self, this:GetWidth()) |
end |
local function SetImage(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.SetColor = SetColor |
self.frame = frame |
frame:SetHeight(18) |
frame:SetWidth(200) |
frame:SetScript("OnSizeChanged", OnFrameResize) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(200) |
local AceGUI = LibStub("AceGUI-3.0") |
local Version = 4 |
local Version = 6 |
--------------------- |
-- Common Elements -- |
--------------------- |
ClearCursor() |
end |
self.button:Disable() |
AceGUI:ClearFocus() |
end |
function MultiLineEditBox:Acquire() |
function MultiLineEditBox:OnAcquire() |
self:SetDisabled(false) |
self:ShowButton(true) |
end |
function MultiLineEditBox:Release() |
function MultiLineEditBox:OnRelease() |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
button:SetWidth(80) |
button:SetHeight(20) |
button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2) |
button:SetText("Apply") |
button:SetText(ACCEPT) |
button:SetScript("OnClick", Button_OnClick) |
button:Disable() |
button:Hide() |
-------------------------- |
do |
local Type = "Slider" |
local Version = 3 |
local Version = 5 |
local function Acquire(self) |
local function OnAcquire(self) |
self:SetDisabled(false) |
self:SetSliderValues(0,100,1) |
self:SetIsPercent(nil) |
self:SetValue(0) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.slider:EnableMouseWheel(false) |
local function FrameOnMouseDown(this) |
this.obj.slider:EnableMouseWheel(true) |
AceGUI:ClearFocus() |
end |
local SliderBackdrop = { |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
editbox:SetFontObject(GameFontHighlightSmall) |
editbox:SetPoint("TOP",slider,"BOTTOM",0,0) |
editbox:SetHeight(14) |
editbox:SetWidth(100) |
editbox:SetWidth(70) |
editbox:SetJustifyH("CENTER") |
editbox:EnableMouse(true) |
editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed) |
self.editbox = editbox |
editbox.obj = self |
local bg = editbox:CreateTexture(nil,"BACKGROUND") |
editbox.bg = bg |
bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
bg:SetVertexColor(0,0,0,0.25) |
bg:SetAllPoints(editbox) |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") |
frame:SetWidth(200) |
]] |
local WotLK = select(4, GetBuildInfo()) >= 30000 |
-------------------------- |
-- Tab Group -- |
-------------------------- |
do |
local Type = "TabGroup" |
local Version = 4 |
local Version = 15 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
insets = { left = 3, right = 3, top = 5, bottom = 3 } |
} |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.status = nil |
for k in pairs(self.localstatus) do |
self.localstatus[k] = nil |
end |
self.tablist = nil |
end |
local function Tab_FixWidth(self) |
self:SetScript("OnUpdate",nil) |
self:SetWidth(self.text:GetWidth()+20) |
end |
local function Tab_SetText(self, text) |
self.text:SetText(text) |
self:SetScript("OnUpdate",Tab_FixWidth) |
self:_SetText(text) |
-- TODO: Remove when 3.0 hits live |
if WotLK then |
PanelTemplates_TabResize(self, 0) |
else |
PanelTemplates_TabResize(0, self) |
end |
end |
local function UpdateTabLook(self) |
if self.selected then |
self.left:SetAlpha(1) |
self.right:SetAlpha(1) |
self.middle:SetAlpha(1) |
self.text:SetTextColor(1,1,1) |
self:GetHighlightTexture():Hide() |
if self.disabled then |
PanelTemplates_SetDisabledTabState(self) |
elseif self.selected then |
PanelTemplates_SelectTab(self) |
else |
self.left:SetAlpha(0.5) |
self.right:SetAlpha(0.5) |
self.middle:SetAlpha(0.5) |
self.text:SetTextColor(1,0.82,0) |
self:GetHighlightTexture():Show() |
PanelTemplates_DeselectTab(self) |
end |
if self.disabled then |
self.text:SetTextColor(0.5,0.5,0.5) |
self:GetHighlightTexture():Hide() |
end |
end |
local function Tab_SetSelected(self, selected) |
UpdateTabLook(self) |
end |
local function Tab_OnEnter(this) |
local self = this.obj |
self:Fire("OnTabEnter", self.tabs[this.id].value, this) |
end |
local function Tab_OnLeave(this) |
local self = this.obj |
self:Fire("OnTabLeave", self.tabs[this.id].value, this) |
end |
local function CreateTab(self, id) |
local tab = CreateFrame("Button",nil,self.border) |
local tabname = "AceGUITabGroup"..self.num.."Tab"..id |
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate") |
tab.obj = self |
tab.id = id |
tab:SetWidth(64) |
tab:SetHeight(32) |
tab:SetScript("OnClick",Tab_OnClick) |
tab:SetScript("OnEnter",Tab_OnEnter) |
tab:SetScript("OnLeave",Tab_OnLeave) |
tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") |
tab:GetHighlightTexture():SetBlendMode("ADD") |
tab:GetHighlightTexture():SetPoint("TOPLEFT",tab,"TOPLEFT",2,-7) |
tab:GetHighlightTexture():SetPoint("BOTTOMRIGHT",tab,"BOTTOMRIGHT",-2,-3) |
local left = tab:CreateTexture(nil,"BACKGROUND") |
local middle = tab:CreateTexture(nil,"BACKGROUND") |
local right = tab:CreateTexture(nil,"BACKGROUND") |
local text = tab:CreateFontString(nil,"BACKGROUND","GameFontNormalSmall") |
tab.text = text |
tab.left = left |
tab.right = right |
tab.middle = middle |
tab._SetText = tab.SetText |
tab.SetText = Tab_SetText |
tab.SetSelected = Tab_SetSelected |
tab.SetDisabled = Tab_SetDisabled |
text:SetPoint("LEFT",tab,"LEFT",5,-4) |
text:SetPoint("RIGHT",tab,"RIGHT",-5,-4) |
text:SetHeight(18) |
text:SetText("") |
left:SetTexture("Interface\\ChatFrame\\ChatFrameTab") |
middle:SetTexture("Interface\\ChatFrame\\ChatFrameTab") |
right:SetTexture("Interface\\ChatFrame\\ChatFrameTab") |
left:SetWidth(16) |
left:SetHeight(32) |
middle:SetWidth(44) |
middle:SetHeight(32) |
right:SetWidth(16) |
right:SetHeight(32) |
left:SetTexCoord(0,0.25,0,1) |
middle:SetTexCoord(0.25,0.75,0,1) |
right:SetTexCoord(0.75,1,0,1) |
left:SetPoint("TOPLEFT",tab,"TOPLEFT",0,0) |
right:SetPoint("TOPRIGHT",tab,"TOPRIGHT",0,0) |
middle:SetPoint("LEFT",left,"RIGHT",0,0) |
middle:SetPoint("RIGHT",right,"LEFT",0,0) |
return tab |
end |
self:BuildTabs() |
end |
local widths = {} |
local rowwidths = {} |
local rowends = {} |
local function BuildTabs(self) |
local status = self.status or self.localstatus |
local tablist = self.tablist |
local tabs = self.tabs |
for i, v in ipairs(tabs) do |
v:Hide() |
end |
if not tablist then return end |
local width = self.frame.width or self.frame:GetWidth() or 0 |
for i = #widths, 1, -1 do |
widths[i] = nil |
end |
for i = #rowwidths, 1, -1 do |
rowwidths[i] = nil |
end |
for i = #rowends, 1, -1 do |
rowends[i] = nil |
end |
--Place Text into tabs and get thier initial width |
for i, v in ipairs(tablist) do |
local tab = tabs[i] |
if not tab then |
tab = self:CreateTab(i) |
tabs[i] = tab |
if i == 1 then |
tab:SetPoint("BOTTOMLEFT",self.border,"TOPLEFT",0,-3) |
else |
tab:SetPoint("LEFT",tabs[i-1],"RIGHT",-3,0) |
end |
end |
tab:Show() |
tab:SetText(v.text) |
tab:SetDisabled(v.disabled) |
tab.value = v.value |
widths[i] = tab:GetWidth() - 10 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing |
end |
if #tablist > 1 then |
self:SelectTab(status.selected or tablist[1].value) |
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout |
local numtabs = #tablist |
local numrows = 1 |
local usedwidth = 0 |
for i = 1, #tablist do |
--If this is not the first tab of a row and there isn't room for it |
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then |
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px |
rowends[numrows] = i - 1 |
numrows = numrows + 1 |
usedwidth = 0 |
end |
usedwidth = usedwidth + widths[i] |
end |
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px |
rowends[numrows] = #tablist |
--Fix for single tabs being left on the last row, move a tab from the row above if applicable |
if numrows > 1 then |
--if the last row has only one tab |
if rowends[numrows-1] == numtabs-1 then |
--if there are more than 2 tabs in the 2nd last row |
if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then |
--move 1 tab from the second last row to the last |
rowends[numrows-1] = rowends[numrows-1] - 1 |
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1] |
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1] |
end |
end |
end |
--anchor the rows as defined and resize tabs to fill thier row |
local starttab = 1 |
for row, endtab in ipairs(rowends) do |
local first = true |
for tabno = starttab, endtab do |
local tab = tabs[tabno] |
tab:ClearAllPoints() |
if first then |
tab:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-7-(row-1)*20 ) |
first = false |
else |
tab:SetPoint("LEFT",tabs[tabno-1],"RIGHT",-10,0) |
end |
end |
--equal padding for each tab to fill the available width |
local padding = (width - rowwidths[row]) / (endtab - starttab+1) |
for i = starttab, endtab do |
-- TODO: Remove when 3.0 hits live |
if WotLK then |
PanelTemplates_TabResize(tabs[i], padding) |
else |
PanelTemplates_TabResize(padding, tabs[i]) |
end |
end |
starttab = endtab + 1 |
end |
self.borderoffset = 10+((numrows)*20) |
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",3,-self.borderoffset) |
end |
local function BuildTabsOnUpdate(this) |
BuildTabs(this.obj) |
this:SetScript("OnUpdate", nil) |
end |
local function OnWidthSet(self, width) |
local content = self.content |
local contentwidth = width - 60 |
end |
content:SetWidth(contentwidth) |
content.width = contentwidth |
BuildTabs(self) |
self.frame:SetScript("OnUpdate", BuildTabsOnUpdate) |
end |
local function OnHeightSet(self, height) |
local content = self.content |
local contentheight = height - 26 |
local contentheight = height - (self.borderoffset + 23) |
if contentheight < 0 then |
contentheight = 0 |
end |
content:SetHeight(contentheight) |
content.height = contentheight |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
self.num = AceGUI:GetNextWidgetNum(Type) |
self.localstatus = {} |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetTitle = SetTitle |
self.CreateTab = CreateTab |
self.SelectTab = SelectTab |
local border = CreateFrame("Frame",nil,frame) |
self.border = border |
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-37) |
self.borderoffset = 27 |
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27) |
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3) |
border:SetBackdrop(PaneBackdrop) |
-------------------------- |
do |
local Type = "Keybinding" |
local Version = 6 |
local Version = 8 |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
self.waitingForKey = true |
end |
end |
AceGUI:ClearFocus() |
end |
local ignoreKeys = nil |
Keybinding_OnKeyDown(this, button) |
end |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.waitingForKey = nil |
self.label:SetText(label or "") |
end |
local count = 0 |
local function Constructor() |
count = count + 1 |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame",nil,UIParent) |
local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..count,frame,"UIPanelButtonTemplate2") |
local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..num,frame,"UIPanelButtonTemplate2") |
local self = {} |
self.type = Type |
self.num = num |
local text = button:GetFontString() |
text:SetPoint("LEFT",button,"LEFT",7,0) |
msgframe:SetPoint("BOTTOM",button,"TOP",0,0) |
msgframe:Hide() |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.SetDisabled = SetDisabled |
self.SetKey = SetKey |
<Script file="widgets\AceGUIWidget-ColorPicker.lua"/> |
<Script file="widgets\AceGUIWidget-DropDownGroup.lua"/> |
<Script file="widgets\AceGUIWidget-DropDown.lua"/> |
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/> |
<Script file="widgets\AceGUIWidget-EditBox.lua"/> |
<Script file="widgets\AceGUIWidget-Frame.lua"/> |
<Script file="widgets\AceGUIWidget-Heading.lua"/> |
--[[ $Id: AceGUI-3.0.lua 65669 2008-03-25 08:59:22Z nevcairiel $ ]] |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 7 |
--[[ $Id: AceGUI-3.0.lua 81438 2008-09-06 13:44:36Z nevcairiel $ ]] |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 16 |
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR) |
if not AceGUI then return end -- No upgrade needed |
local con = LibStub("AceConsole-3.0",true) |
--local con = LibStub("AceConsole-3.0",true) |
AceGUI.WidgetRegistry = AceGUI.WidgetRegistry or {} |
AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {} |
if not objPools[type] then |
objPools[type] = {} |
end |
for i,v in ipairs(objPools[type]) do |
if v == obj then |
error("Attempt to Release Widget that is already released") |
return |
end |
end |
tinsert(objPools[type],obj) |
end |
end |
-- Gets a widget Object |
local warned = {} |
function AceGUI:Create(type) |
local reg = WidgetRegistry |
if reg[type] then |
local widget = new(type,reg[type]) |
if widget.Acquire then |
widget:Acquire() |
elseif widget.Aquire then |
if not warned[type] then |
DEFAULT_CHAT_FRAME:AddMessage(("AceGUI: Warning, Widget type %s uses the deprecated Aquire, this should be updated to Acquire"):format(type)) |
warned[type] = true |
end |
widget.Acquire = widget.Aquire |
widget:Acquire() |
if rawget(widget,'Acquire') then |
widget.OnAcquire = widget.Acquire |
widget.Acquire = nil |
elseif rawget(widget,'Aquire') then |
widget.OnAcquire = widget.Aquire |
widget.Aquire = nil |
end |
if rawget(widget,'Release') then |
widget.OnRelease = rawget(widget,'Release') |
widget.Release = nil |
end |
if widget.OnAcquire then |
widget:OnAcquire() |
else |
error(("Widget type %s doesn't supply an Acquire Function"):format(type)) |
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type)) |
end |
safecall(widget.ResumeLayout, widget) |
return widget |
safecall( widget.PauseLayout, widget ) |
widget:Fire("OnRelease") |
safecall( widget.ReleaseChildren, widget ) |
if widget.OnRelease then |
widget:OnRelease() |
else |
error(("Widget type %s doesn't supply an OnRelease Function"):format(type)) |
end |
for k in pairs(widget.userdata) do |
widget.userdata[k] = nil |
end |
for k in pairs(widget.events) do |
widget.events[k] = nil |
end |
widget.width = nil |
widget:Release() |
widget.width = nil |
--widget.frame:SetParent(nil) |
widget.frame:ClearAllPoints() |
widget.frame:Hide() |
del(widget,widget.type) |
end |
----------- |
-- Focus -- |
----------- |
----- |
-- Called when a widget has taken focus |
-- e.g. Dropdowns opening, Editboxes gaining kb focus |
----- |
function AceGUI:SetFocus(widget) |
if self.FocusedWidget and self.FocusedWidget ~= widget then |
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget) |
end |
self.FocusedWidget = widget |
end |
----- |
-- 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) |
self.FocusedWidget = nil |
end |
end |
------------- |
-- Widgets -- |
------------- |
--[[ |
Widgets must provide the following functions |
Acquire() - Called when the object is acquired, should set everything to a default hidden state |
Release() - Called when the object is Released, should remove any anchors and hide the Widget |
OnAcquire() - Called when the object is acquired, should set everything to a default hidden state |
OnRelease() - 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 |
content - frame or derivitive that children will be anchored to |
The Widget can supply the following Optional Members |
:OnWidthSet(width) - Called when the width of the widget is changed |
:OnHeightSet(height) - Called when the height of the widget is changed |
Widgets should not use the OnSizeChanged events of thier frame or content members, use these methods instead |
AceGUI already sets a handler to the event |
:OnLayoutFinished(width, height) - called after a layout has finished, the width and height will be the width and height of the |
area used for controls. These can be nil if the layout used the existing size to layout the controls. |
]] |
-------------------------- |
self:OnHeightSet(height) |
end |
end |
WidgetBase.IsVisible = function(self) |
return self.frame:IsVisible() |
end |
WidgetBase.IsShown= function(self) |
return self.frame:IsShown() |
end |
WidgetBase.Release = function(self) |
AceGUI:Release(self) |
end |
WidgetBase.SetPoint = function(self, ...) |
return self.frame:SetPoint(...) |
end |
WidgetBase.ClearAllPoints = function(self) |
return self.frame:ClearAllPoints() |
end |
WidgetBase.GetNumPoints = function(self) |
return self.frame:GetNumPoints() |
end |
WidgetBase.GetPoint = function(self, ...) |
return self.frame:GetPoint(...) |
end |
WidgetBase.GetUserDataTable = function(self) |
return self.userdata |
end |
WidgetBase.SetUserData = function(self, key, value) |
self.userdata[key] = value |
end |
WidgetBase.GetUserData = function(self, key) |
return self.userdata[key] |
end |
WidgetBase.IsFullHeight = function(self) |
return self.height == "fill" |
end |
WidgetBase.SetFullHeight = function(self, isFull) |
if isFull then |
self.height = "fill" |
else |
self.height = nil |
end |
end |
WidgetBase.IsFullWidth = function(self) |
return self.width == "fill" |
end |
WidgetBase.SetFullWidth = function(self, isFull) |
if isFull then |
self.width = "fill" |
else |
self.width = nil |
end |
end |
-- local function LayoutOnUpdate(this) |
-- this:SetScript("OnUpdate",nil) |
-- this.obj:PerformLayout() |
self.LayoutFunc = AceGUI:GetLayout(Layout) |
end |
local function FrameResize(this) |
local self = this.obj |
if this:GetWidth() and this:GetHeight() then |
if self.OnWidthSet then |
self:OnWidthSet(this:GetWidth()) |
end |
if self.OnHeightSet then |
self:OnHeightSet(this:GetHeight()) |
end |
end |
end |
local function ContentResize(this) |
if this.lastwidth ~= this:GetWidth() then |
if this:GetWidth() and this:GetHeight() then |
this.width = this:GetWidth() |
this.height = this:GetHeight() |
this.obj:DoLayout() |
end |
end |
setmetatable(WidgetContainerBase,{__index=WidgetBase}) |
--One of these function should be called on each Widget Instance as part of its creation process |
widget.userdata = {} |
widget.events = {} |
widget.base = WidgetContainerBase |
widget.content.obj = widget |
widget.frame.obj = widget |
widget.content:SetScript("OnSizeChanged",ContentResize) |
widget.frame:SetScript("OnSizeChanged",FrameResize) |
setmetatable(widget,{__index=WidgetContainerBase}) |
widget:SetLayout("List") |
end |
widget.userdata = {} |
widget.events = {} |
widget.base = WidgetBase |
widget.frame.obj = widget |
widget.frame:SetScript("OnSizeChanged",FrameResize) |
setmetatable(widget,{__index=WidgetBase}) |
end |
end |
return LayoutRegistry[Name] |
end |
AceGUI.counts = AceGUI.counts or {} |
function AceGUI:GetNextWidgetNum(type) |
if not self.counts[type] then |
self.counts[type] = 0 |
end |
self.counts[type] = self.counts[type] + 1 |
return self.counts[type] |
end |
--[[ Widget Template |
-------------------------- |
do |
local Type = "Type" |
local function Acquire(self) |
local function OnAcquire(self) |
end |
local function Release(self) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local self = {} |
self.type = Type |
self.Release = Release |
self.Acquire = Acquire |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
function(content, children) |
local height = 0 |
local width = content.width or content:GetWidth() or 0 |
for i, child in ipairs(children) do |
end |
if child.width == "fill" then |
child:SetWidth(width) |
frame:SetPoint("RIGHT",content,"RIGHT") |
if child.OnWidthSet then |
child:OnWidthSet(content.width or content:GetWidth()) |
AceGUI:RegisterLayout("Fill", |
function(content, children) |
if children[1] then |
children[1].frame:SetAllPoints(content) |
children[1]:SetWidth(content:GetWidth() or 0) |
children[1]:SetHeight(content:GetHeight() or 0) |
children[1].frame:SetAllPoints(content) |
children[1].frame:Show() |
safecall( content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight() ) |
end |
local frameoffset |
local lastframeoffset |
local oversize |
for i, child in ipairs(children) do |
oversize = nil |
local frame = child.frame |
local frameheight = frame.height or frame:GetHeight() or 0 |
local framewidth = frame.width or frame:GetWidth() or 0 |
rowstart = frame |
rowstartoffset = frameoffset |
usedwidth = framewidth |
if usedwidth > width then |
oversize = true |
end |
else |
-- if there isn't available width for the control start a new row |
-- if a control is "fill" it will be on a row of its own full width |
rowheight = frameheight |
rowoffset = frameoffset |
usedwidth = frame.width or frame:GetWidth() |
if usedwidth > width then |
oversize = true |
end |
-- put the control on the current row, adding it to the width and checking if the height needs to be increased |
else |
--handles cases where the new height is higher than either control because of the offsets |
rowheight = frame.height or frame:GetHeight() or 0 |
rowoffset = child.alignoffset or (rowheight / 2) |
rowstartoffset = rowoffset |
elseif oversize then |
if width > 1 then |
frame:SetPoint("RIGHT",content,"RIGHT",0,0) |
end |
end |
if child.height == "fill" then |