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)
77 local DRight = frame:CreateTexture(nil, "ARTWORK")
80 DRight:SetPoint("TOP", DLeft, "TOP")
81 DRight:SetPoint("RIGHT", frame, "RIGHT", 17, 0)
82 DRight:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
83 DRight:SetTexCoord(0.8046875, 1, 0, 1)
85 local DMiddle = frame:CreateTexture(nil, "ARTWORK")
87 DMiddle:SetPoint("TOP", DLeft, "TOP")
88 DMiddle:SetPoint("LEFT", DLeft, "RIGHT")
89 DMiddle:SetPoint("RIGHT", DRight, "LEFT")
90 DMiddle:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
91 DMiddle:SetTexCoord(0.1953125, 0.8046875, 0, 1)
92 frame.DMiddle = DMiddle
94 local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlightSmall")
95 text:SetPoint("RIGHT",DRight,"RIGHT",-43,1)
96 text:SetPoint("LEFT",DLeft,"LEFT",26,1)
97 text:SetJustifyH("RIGHT")
102 local dropButton = CreateFrame("Button", nil, frame)
103 dropButton:SetWidth(24)
104 dropButton:SetHeight(24)
105 dropButton:SetPoint("TOPRIGHT", DRight, "TOPRIGHT", -16, -18)
106 dropButton:SetNormalTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up]])
107 dropButton:SetPushedTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down]])
108 dropButton:SetDisabledTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Disabled]])
109 dropButton:SetHighlightTexture([[Interface\Buttons\UI-Common-MouseHilight]], "ADD")
110 frame.dropButton = dropButton
112 frame.Disable = disable
113 frame.Enable = enable
117 function AGSMW:GetBaseFrameWithWindow()
118 local frame = self:GetBaseFrame()
120 local displayButton = CreateFrame("Button", nil, frame)
121 displayButton:SetHeight(42)
122 displayButton:SetWidth(42)
123 displayButton:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -2)
124 displayButton:SetBackdrop(displayButtonBackdrop)
125 displayButton:SetBackdropBorderColor(.5, .5, .5)
126 frame.displayButton = displayButton
128 frame.label:SetPoint("TOPLEFT",displayButton,"TOPRIGHT",1,2)
130 frame.DLeft:SetPoint("BOTTOMLEFT", displayButton, "BOTTOMRIGHT", -17, -20)
139 local sliderBackdrop = {
140 ["bgFile"] = [[Interface\Buttons\UI-SliderBar-Background]],
141 ["edgeFile"] = [[Interface\Buttons\UI-SliderBar-Border]],
152 local frameBackdrop = {
153 bgFile=[[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
154 edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
155 tile = true, tileSize = 32, edgeSize = 32,
156 insets = { left = 11, right = 12, top = 12, bottom = 9 },
159 local function OnMouseWheel(self, dir)
160 self.slider:SetValue(self.slider:GetValue()+(15*dir*-1))
163 local function AddFrame(self, frame)
164 frame:SetParent(self.contentframe)
165 local strata = self:GetFrameStrata()
166 frame:SetFrameStrata(strata)
167 local level = self:GetFrameLevel() + 100
168 frame:SetFrameLevel(level)
169 if next(self.contentRepo) then
170 frame:SetPoint("TOPLEFT", self.contentRepo[#self.contentRepo], "BOTTOMLEFT", 0, 0)
171 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
172 self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight())
173 self.contentRepo[#self.contentRepo+1] = frame
175 self.contentframe:SetHeight(frame:GetHeight())
176 frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0)
177 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
178 self.contentRepo[1] = frame
180 if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then
181 self.scrollframe:SetWidth(146)
182 self:SetHeight(UIParent:GetHeight()*2/5)
184 self:SetScript("OnMouseWheel", OnMouseWheel)
185 self.scrollframe:UpdateScrollChildRect()
186 self.slider:SetMinMaxValues(0, self.contentframe:GetHeight()-self.scrollframe:GetHeight())
188 self.scrollframe:SetWidth(160)
189 self:SetHeight(self.contentframe:GetHeight()+25)
191 self:SetScript("OnMouseWheel", nil)
192 self.scrollframe:UpdateScrollChildRect()
193 self.slider:SetMinMaxValues(0, 0)
195 self.contentframe:SetWidth(self.scrollframe:GetWidth())
198 local function ClearFrames(self)
199 for i, frame in ipairs(self.contentRepo) do
201 self.contentRepo[i] = nil
205 local function slider_OnValueChanged(self, value)
206 self.frame.scrollframe:SetVerticalScroll(value)
209 local DropDownCache = {}
210 function AGSMW:GetDropDownFrame()
212 if next(DropDownCache) then
213 frame = table.remove(DropDownCache)
215 frame = CreateFrame("Frame", nil, UIParent)
216 frame:SetClampedToScreen(true)
218 frame:SetBackdrop(frameBackdrop)
219 frame:SetFrameStrata("TOOLTIP")
220 frame:EnableMouseWheel(true)
222 local contentframe = CreateFrame("Frame", nil, frame)
223 contentframe:SetWidth(160)
224 contentframe:SetHeight(0)
225 frame.contentframe = contentframe
226 local scrollframe = CreateFrame("ScrollFrame", nil, frame)
227 scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 14, -13)
228 scrollframe:SetPoint("BOTTOM", frame, "BOTTOM", 0, 12)
229 scrollframe:SetWidth(160)
230 scrollframe:SetScrollChild(contentframe)
231 frame.scrollframe = scrollframe
232 local bgTex = frame:CreateTexture(nil, "ARTWORK")
233 bgTex:SetAllPoints(scrollframe)
236 frame.AddFrame = AddFrame
237 frame.ClearFrames = ClearFrames
238 frame.contentRepo = {} -- store all our frames in here so we can get rid of them later
239 local slider = CreateFrame("Slider", nil, scrollframe)
240 slider:SetOrientation("VERTICAL")
241 slider:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -14, -10)
242 slider:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 10)
243 slider:SetBackdrop(sliderBackdrop)
244 slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]])
245 slider:SetMinMaxValues(0, 1)
246 --slider:SetValueStep(1)
249 slider:SetScript("OnValueChanged", slider_OnValueChanged)
250 frame.slider = slider
252 frame:SetHeight(UIParent:GetHeight()*2/5)
253 frame.slider:SetValue(0)
258 function AGSMW:ReturnDropDownFrame(frame)
260 frame:ClearAllPoints()
262 frame:SetBackdrop(frameBackdrop)
263 frame.bgTex:SetTexture(nil)
264 table.insert(DropDownCache, frame)