Asa@0
|
1 local AceGUI = LibStub("AceGUI-3.0")
|
Asa@0
|
2
|
Asa@0
|
3 -- WoW APIs
|
Asa@0
|
4 local CreateFrame, UIParent = CreateFrame, UIParent
|
Asa@0
|
5
|
Asa@0
|
6 -------------
|
Asa@0
|
7 -- Widgets --
|
Asa@0
|
8 -------------
|
Asa@0
|
9 --[[
|
Asa@0
|
10 Widgets must provide the following functions
|
Asa@0
|
11 Acquire() - Called when the object is aquired, should set everything to a default hidden state
|
Asa@0
|
12 Release() - Called when the object is Released, should remove any anchors and hide the Widget
|
Asa@0
|
13
|
Asa@0
|
14 And the following members
|
Asa@0
|
15 frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
|
Asa@0
|
16 type - the type of the object, same as the name given to :RegisterWidget()
|
Asa@0
|
17
|
Asa@0
|
18 Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
|
Asa@0
|
19 It will be cleared automatically when a widget is released
|
Asa@0
|
20 Placing values directly into a widget object should be avoided
|
Asa@0
|
21
|
Asa@0
|
22 If the Widget can act as a container for other Widgets the following
|
Asa@0
|
23 content - frame or derivitive that children will be anchored to
|
Asa@0
|
24
|
Asa@0
|
25 The Widget can supply the following Optional Members
|
Asa@0
|
26
|
Asa@0
|
27
|
Asa@0
|
28 ]]
|
Asa@0
|
29
|
Asa@0
|
30 --------------------------
|
Asa@0
|
31 -- Inline Group --
|
Asa@0
|
32 --------------------------
|
Asa@0
|
33 --[[
|
Asa@0
|
34 This is a simple grouping container, no selection
|
Asa@0
|
35 It will resize automatically to the height of the controls added to it
|
Asa@0
|
36 ]]
|
Asa@0
|
37
|
Asa@0
|
38 do
|
Asa@0
|
39 local Type = "InlineGroup"
|
Asa@0
|
40 local Version = 6
|
Asa@0
|
41
|
Asa@0
|
42 local function OnAcquire(self)
|
Asa@0
|
43 self:SetWidth(300)
|
Asa@0
|
44 self:SetHeight(100)
|
Asa@0
|
45 end
|
Asa@0
|
46
|
Asa@0
|
47 local function OnRelease(self)
|
Asa@0
|
48 self.frame:ClearAllPoints()
|
Asa@0
|
49 self.frame:Hide()
|
Asa@0
|
50 end
|
Asa@0
|
51
|
Asa@0
|
52 local PaneBackdrop = {
|
Asa@0
|
53 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
Asa@0
|
54 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
Asa@0
|
55 tile = true, tileSize = 16, edgeSize = 16,
|
Asa@0
|
56 insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
Asa@0
|
57 }
|
Asa@0
|
58
|
Asa@0
|
59 local function SetTitle(self,title)
|
Asa@0
|
60 self.titletext:SetText(title)
|
Asa@0
|
61 end
|
Asa@0
|
62
|
Asa@0
|
63
|
Asa@0
|
64 local function LayoutFinished(self, width, height)
|
Asa@0
|
65 if self.noAutoHeight then return end
|
Asa@0
|
66 self:SetHeight((height or 0) + 40)
|
Asa@0
|
67 end
|
Asa@0
|
68
|
Asa@0
|
69 local function OnWidthSet(self, width)
|
Asa@0
|
70 local content = self.content
|
Asa@0
|
71 local contentwidth = width - 20
|
Asa@0
|
72 if contentwidth < 0 then
|
Asa@0
|
73 contentwidth = 0
|
Asa@0
|
74 end
|
Asa@0
|
75 content:SetWidth(contentwidth)
|
Asa@0
|
76 content.width = contentwidth
|
Asa@0
|
77 end
|
Asa@0
|
78
|
Asa@0
|
79
|
Asa@0
|
80 local function OnHeightSet(self, height)
|
Asa@0
|
81 local content = self.content
|
Asa@0
|
82 local contentheight = height - 20
|
Asa@0
|
83 if contentheight < 0 then
|
Asa@0
|
84 contentheight = 0
|
Asa@0
|
85 end
|
Asa@0
|
86 content:SetHeight(contentheight)
|
Asa@0
|
87 content.height = contentheight
|
Asa@0
|
88 end
|
Asa@0
|
89
|
Asa@0
|
90 local function Constructor()
|
Asa@0
|
91 local frame = CreateFrame("Frame",nil,UIParent)
|
Asa@0
|
92 local self = {}
|
Asa@0
|
93 self.type = Type
|
Asa@0
|
94
|
Asa@0
|
95 self.OnRelease = OnRelease
|
Asa@0
|
96 self.OnAcquire = OnAcquire
|
Asa@0
|
97 self.SetTitle = SetTitle
|
Asa@0
|
98 self.frame = frame
|
Asa@0
|
99 self.LayoutFinished = LayoutFinished
|
Asa@0
|
100 self.OnWidthSet = OnWidthSet
|
Asa@0
|
101 self.OnHeightSet = OnHeightSet
|
Asa@0
|
102
|
Asa@0
|
103 frame.obj = self
|
Asa@0
|
104
|
Asa@0
|
105 frame:SetHeight(100)
|
Asa@0
|
106 frame:SetWidth(100)
|
Asa@0
|
107 frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
Asa@0
|
108
|
Asa@0
|
109 local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
|
Asa@0
|
110 titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
|
Asa@0
|
111 titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
|
Asa@0
|
112 titletext:SetJustifyH("LEFT")
|
Asa@0
|
113 titletext:SetHeight(18)
|
Asa@0
|
114
|
Asa@0
|
115 self.titletext = titletext
|
Asa@0
|
116
|
Asa@0
|
117 local border = CreateFrame("Frame",nil,frame)
|
Asa@0
|
118 self.border = border
|
Asa@0
|
119 border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-17)
|
Asa@0
|
120 border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3)
|
Asa@0
|
121
|
Asa@0
|
122 border:SetBackdrop(PaneBackdrop)
|
Asa@0
|
123 border:SetBackdropColor(0.1,0.1,0.1,0.5)
|
Asa@0
|
124 border:SetBackdropBorderColor(0.4,0.4,0.4)
|
Asa@0
|
125
|
Asa@0
|
126 --Container Support
|
Asa@0
|
127 local content = CreateFrame("Frame",nil,border)
|
Asa@0
|
128 self.content = content
|
Asa@0
|
129 content.obj = self
|
Asa@0
|
130 content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
|
Asa@0
|
131 content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
|
Asa@0
|
132
|
Asa@0
|
133 AceGUI:RegisterAsContainer(self)
|
Asa@0
|
134 return self
|
Asa@0
|
135 end
|
Asa@0
|
136
|
Asa@0
|
137 AceGUI:RegisterWidgetType(Type,Constructor,Version)
|
Asa@0
|
138 end
|