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: -- Simple Group -- Asa@0: -------------------------- Asa@0: --[[ Asa@0: This is a simple grouping container, no selection, no borders 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 = "SimpleGroup" Asa@0: local Version = 5 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 function LayoutFinished(self, width, height) Asa@0: if self.noAutoHeight then return end Asa@0: self:SetHeight(height or 0) Asa@0: end Asa@0: Asa@0: local function OnWidthSet(self, width) Asa@0: local content = self.content Asa@0: content:SetWidth(width) Asa@0: content.width = width Asa@0: end Asa@0: Asa@0: local function OnHeightSet(self, height) Asa@0: local content = self.content Asa@0: content:SetHeight(height) Asa@0: content.height = height 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.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: --Container Support Asa@0: local content = CreateFrame("Frame",nil,frame) Asa@0: self.content = content Asa@0: content.obj = self Asa@0: content:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) Asa@0: content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) 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