1 -- Widget created by Yssaril
3 local DataVersion = 9001 -- dev version always overwrites everything else :)
8 local AGSMW = LibStub:NewLibrary("AceGUISharedMediaWidgets-1.0", DataVersion)
11 return -- already loaded and no upgrade necessary
14 LoadAddOn("LibSharedMedia-3.0")
15 local AceGUI = LibStub("AceGUI-3.0")
16 local Media = LibStub("LibSharedMedia-3.0")
20 AceGUIWidgetLSMlists = {
21 ['font'] = Media:HashTable("font"),
22 ['sound'] = Media:HashTable("sound"),
23 ['statusbar'] = Media:HashTable("statusbar"),
24 ['border'] = Media:HashTable("border"),
25 ['background'] = Media:HashTable("background"),
29 local function disable(frame)
30 frame.label:SetTextColor(.5,.5,.5)
31 frame.text:SetTextColor(.5,.5,.5)
32 frame.dropButton:Disable()
33 if frame.displayButtonFont then
34 frame.displayButtonFont:SetTextColor(.5,.5,.5)
35 frame.displayButton:Disable()
39 local function enable(frame)
40 frame.label:SetTextColor(1,.82,0)
41 frame.text:SetTextColor(1,1,1)
42 frame.dropButton:Enable()
43 if frame.displayButtonFont then
44 frame.displayButtonFont:SetTextColor(1,1,1)
45 frame.displayButton:Enable()
49 local displayButtonBackdrop = {
50 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
51 tile = true, tileSize = 16, edgeSize = 16,
52 insets = { left = 4, right = 4, top = 4, bottom = 4 },
55 -- create or retrieve BaseFrame
56 function AGSMW:GetBaseFrame()
57 local frame = CreateFrame("Frame", nil, UIParent)
60 frame:SetPoint("CENTER", UIParent, "CENTER")
62 local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
63 label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
64 label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
65 label:SetJustifyH("LEFT")
70 local DLeft = frame:CreateTexture(nil, "ARTWORK")
73 DLeft:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", -17, -21)
74 DLeft:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
75 DLeft:SetTexCoord(0, 0.1953125, 0, 1)
78 local DRight = frame:CreateTexture(nil, "ARTWORK")
81 DRight:SetPoint("TOP", DLeft, "TOP")
82 DRight:SetPoint("RIGHT", frame, "RIGHT", 17, 0)
83 DRight:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
84 DRight:SetTexCoord(0.8046875, 1, 0, 1)
87 local DMiddle = frame:CreateTexture(nil, "ARTWORK")
89 DMiddle:SetPoint("TOP", DLeft, "TOP")
90 DMiddle:SetPoint("LEFT", DLeft, "RIGHT")
91 DMiddle:SetPoint("RIGHT", DRight, "LEFT")
92 DMiddle:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
93 DMiddle:SetTexCoord(0.1953125, 0.8046875, 0, 1)
94 frame.DMiddle = DMiddle
96 local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlightSmall")
97 text:SetPoint("RIGHT",DRight,"RIGHT",-43,1)
98 text:SetPoint("LEFT",DLeft,"LEFT",26,1)
99 text:SetJustifyH("RIGHT")
104 local dropButton = CreateFrame("Button", nil, frame)
105 dropButton:SetWidth(24)
106 dropButton:SetHeight(24)
107 dropButton:SetPoint("TOPRIGHT", DRight, "TOPRIGHT", -16, -18)
108 dropButton:SetNormalTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up]])
109 dropButton:SetPushedTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down]])
110 dropButton:SetDisabledTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Disabled]])
111 dropButton:SetHighlightTexture([[Interface\Buttons\UI-Common-MouseHilight]], "ADD")
112 frame.dropButton = dropButton
114 frame.Disable = disable
115 frame.Enable = enable
119 function AGSMW:GetBaseFrameWithWindow()
120 local frame = self:GetBaseFrame()
122 local displayButton = CreateFrame("Button", nil, frame)
123 displayButton:SetHeight(42)
124 displayButton:SetWidth(42)
125 displayButton:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -2)
126 displayButton:SetBackdrop(displayButtonBackdrop)
127 displayButton:SetBackdropBorderColor(.5, .5, .5)
128 frame.displayButton = displayButton
130 frame.label:SetPoint("TOPLEFT",displayButton,"TOPRIGHT",1,2)
132 frame.DLeft:SetPoint("BOTTOMLEFT", displayButton, "BOTTOMRIGHT", -17, -20)
141 local sliderBackdrop = {
142 ["bgFile"] = [[Interface\Buttons\UI-SliderBar-Background]],
143 ["edgeFile"] = [[Interface\Buttons\UI-SliderBar-Border]],
154 local frameBackdrop = {
155 bgFile=[[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
156 edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
157 tile = true, tileSize = 32, edgeSize = 32,
158 insets = { left = 11, right = 12, top = 12, bottom = 9 },
161 local function OnMouseWheel(self, dir)
162 self.slider:SetValue(self.slider:GetValue()+(15*dir*-1))
165 local function AddFrame(self, frame)
166 frame:SetParent(self.contentframe)
167 frame:SetFrameStrata(self:GetFrameStrata())
168 frame:SetFrameLevel(self:GetFrameLevel() + 100)
170 if next(self.contentRepo) then
171 frame:SetPoint("TOPLEFT", self.contentRepo[#self.contentRepo], "BOTTOMLEFT", 0, 0)
172 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
173 self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight())
174 self.contentRepo[#self.contentRepo+1] = frame
176 self.contentframe:SetHeight(frame:GetHeight())
177 frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0)
178 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
179 self.contentRepo[1] = frame
182 if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then
183 self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -28, 12)
184 self:SetHeight(UIParent:GetHeight()*2/5)
186 self:SetScript("OnMouseWheel", OnMouseWheel)
187 self.scrollframe:UpdateScrollChildRect()
188 self.slider:SetMinMaxValues(0, self.contentframe:GetHeight()-self.scrollframe:GetHeight())
190 self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -14, 12)
191 self:SetHeight(self.contentframe:GetHeight()+25)
193 self:SetScript("OnMouseWheel", nil)
194 self.scrollframe:UpdateScrollChildRect()
195 self.slider:SetMinMaxValues(0, 0)
197 self.contentframe:SetWidth(self.scrollframe:GetWidth())
200 local function ClearFrames(self)
201 for i, frame in ipairs(self.contentRepo) do
203 self.contentRepo[i] = nil
207 local function slider_OnValueChanged(self, value)
208 self.frame.scrollframe:SetVerticalScroll(value)
211 local DropDownCache = {}
212 function AGSMW:GetDropDownFrame()
214 if next(DropDownCache) then
215 frame = table.remove(DropDownCache)
217 frame = CreateFrame("Frame", nil, UIParent)
218 frame:SetClampedToScreen(true)
220 frame:SetBackdrop(frameBackdrop)
221 frame:SetFrameStrata("TOOLTIP")
222 frame:EnableMouseWheel(true)
224 local contentframe = CreateFrame("Frame", nil, frame)
225 contentframe:SetWidth(160)
226 contentframe:SetHeight(0)
227 frame.contentframe = contentframe
229 local scrollframe = CreateFrame("ScrollFrame", nil, frame)
230 scrollframe:SetWidth(160)
231 scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 14, -13)
232 scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 12)
233 scrollframe:SetScrollChild(contentframe)
234 frame.scrollframe = scrollframe
236 contentframe:SetPoint("TOPLEFT", scrollframe)
237 contentframe:SetPoint("TOPRIGHT", scrollframe)
239 local bgTex = frame:CreateTexture(nil, "ARTWORK")
240 bgTex:SetAllPoints(scrollframe)
243 frame.AddFrame = AddFrame
244 frame.ClearFrames = ClearFrames
245 frame.contentRepo = {} -- store all our frames in here so we can get rid of them later
247 local slider = CreateFrame("Slider", nil, scrollframe)
248 slider:SetOrientation("VERTICAL")
249 slider:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -14, -10)
250 slider:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 10)
251 slider:SetBackdrop(sliderBackdrop)
252 slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]])
253 slider:SetMinMaxValues(0, 1)
254 --slider:SetValueStep(1)
257 slider:SetScript("OnValueChanged", slider_OnValueChanged)
258 frame.slider = slider
260 frame:SetHeight(UIParent:GetHeight()*2/5)
261 frame.slider:SetValue(0)
266 function AGSMW:ReturnDropDownFrame(frame)
268 frame:ClearAllPoints()
270 frame:SetBackdrop(frameBackdrop)
271 frame.bgTex:SetTexture(nil)
272 table.insert(DropDownCache, frame)