Asa@0: local AceGUI = LibStub("AceGUI-3.0") Asa@0: Asa@0: -- WoW APIs Asa@0: local CreateFrame, UIParent = CreateFrame, UIParent Asa@0: Asa@0: ------------- Asa@0: -- Widgets -- Asa@0: ------------- Asa@0: --[[ Asa@0: Widgets must provide the following functions Asa@0: Acquire() - Called when the object is aquired, should set everything to a default hidden state Asa@0: Release() - Called when the object is Released, should remove any anchors and hide the Widget Asa@0: Asa@0: And the following members Asa@0: frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes Asa@0: type - the type of the object, same as the name given to :RegisterWidget() Asa@0: Asa@0: Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet Asa@0: It will be cleared automatically when a widget is released Asa@0: Placing values directly into a widget object should be avoided Asa@0: Asa@0: If the Widget can act as a container for other Widgets the following Asa@0: content - frame or derivitive that children will be anchored to Asa@0: Asa@0: The Widget can supply the following Optional Members Asa@0: Asa@0: Asa@0: ]] Asa@0: Asa@0: -------------------------- Asa@0: -- Inline Group -- Asa@0: -------------------------- Asa@0: --[[ Asa@0: This is a simple grouping container, no selection Asa@0: It will resize automatically to the height of the controls added to it Asa@0: ]] Asa@0: Asa@0: do Asa@0: local Type = "InlineGroup" Asa@0: local Version = 6 Asa@0: Asa@0: local function OnAcquire(self) Asa@0: self:SetWidth(300) Asa@0: self:SetHeight(100) Asa@0: end Asa@0: Asa@0: local function OnRelease(self) Asa@0: self.frame:ClearAllPoints() Asa@0: self.frame:Hide() Asa@0: end Asa@0: Asa@0: local PaneBackdrop = { Asa@0: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Asa@0: edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", Asa@0: tile = true, tileSize = 16, edgeSize = 16, Asa@0: insets = { left = 3, right = 3, top = 5, bottom = 3 } Asa@0: } Asa@0: Asa@0: local function SetTitle(self,title) Asa@0: self.titletext:SetText(title) Asa@0: end Asa@0: Asa@0: Asa@0: local function LayoutFinished(self, width, height) Asa@0: if self.noAutoHeight then return end Asa@0: self:SetHeight((height or 0) + 40) Asa@0: end Asa@0: Asa@0: local function OnWidthSet(self, width) Asa@0: local content = self.content Asa@0: local contentwidth = width - 20 Asa@0: if contentwidth < 0 then Asa@0: contentwidth = 0 Asa@0: end Asa@0: content:SetWidth(contentwidth) Asa@0: content.width = contentwidth Asa@0: end Asa@0: Asa@0: Asa@0: local function OnHeightSet(self, height) Asa@0: local content = self.content Asa@0: local contentheight = height - 20 Asa@0: if contentheight < 0 then Asa@0: contentheight = 0 Asa@0: end Asa@0: content:SetHeight(contentheight) Asa@0: content.height = contentheight Asa@0: end Asa@0: Asa@0: local function Constructor() Asa@0: local frame = CreateFrame("Frame",nil,UIParent) Asa@0: local self = {} Asa@0: self.type = Type Asa@0: Asa@0: self.OnRelease = OnRelease Asa@0: self.OnAcquire = OnAcquire Asa@0: self.SetTitle = SetTitle Asa@0: self.frame = frame Asa@0: self.LayoutFinished = LayoutFinished Asa@0: self.OnWidthSet = OnWidthSet Asa@0: self.OnHeightSet = OnHeightSet Asa@0: Asa@0: frame.obj = self Asa@0: Asa@0: frame:SetHeight(100) Asa@0: frame:SetWidth(100) Asa@0: frame:SetFrameStrata("FULLSCREEN_DIALOG") Asa@0: Asa@0: local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") Asa@0: titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0) Asa@0: titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0) Asa@0: titletext:SetJustifyH("LEFT") Asa@0: titletext:SetHeight(18) Asa@0: Asa@0: self.titletext = titletext Asa@0: Asa@0: local border = CreateFrame("Frame",nil,frame) Asa@0: self.border = border Asa@0: border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-17) Asa@0: border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3) Asa@0: Asa@0: border:SetBackdrop(PaneBackdrop) Asa@0: border:SetBackdropColor(0.1,0.1,0.1,0.5) Asa@0: border:SetBackdropBorderColor(0.4,0.4,0.4) Asa@0: Asa@0: --Container Support Asa@0: local content = CreateFrame("Frame",nil,border) Asa@0: self.content = content Asa@0: content.obj = self Asa@0: content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) Asa@0: content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) Asa@0: Asa@0: AceGUI:RegisterAsContainer(self) Asa@0: return self Asa@0: end Asa@0: Asa@0: AceGUI:RegisterWidgetType(Type,Constructor,Version) Asa@0: end