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 local AceGUI = LibStub("AceGUI-3.0")
15 local Media = LibStub("LibSharedMedia-3.0")
19 AceGUIWidgetLSMlists = {
20 ['font'] = Media:HashTable("font"),
21 ['sound'] = Media:HashTable("sound"),
22 ['statusbar'] = Media:HashTable("statusbar"),
23 ['border'] = Media:HashTable("border"),
24 ['background'] = Media:HashTable("background"),
28 local function disable(frame)
29 frame.label:SetTextColor(.5,.5,.5)
30 frame.text:SetTextColor(.5,.5,.5)
31 frame.dropButton:Disable()
32 if frame.displayButtonFont then
33 frame.displayButtonFont:SetTextColor(.5,.5,.5)
34 frame.displayButton:Disable()
38 local function enable(frame)
39 frame.label:SetTextColor(1,.82,0)
40 frame.text:SetTextColor(1,1,1)
41 frame.dropButton:Enable()
42 if frame.displayButtonFont then
43 frame.displayButtonFont:SetTextColor(1,1,1)
44 frame.displayButton:Enable()
48 local displayButtonBackdrop = {
49 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
50 tile = true, tileSize = 16, edgeSize = 16,
51 insets = { left = 4, right = 4, top = 4, bottom = 4 },
54 -- create or retrieve BaseFrame
55 function AGSMW:GetBaseFrame()
56 local frame = CreateFrame("Frame", nil, UIParent)
60 local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
61 label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
62 label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
63 label:SetJustifyH("LEFT")
68 local DLeft = frame:CreateTexture(nil, "ARTWORK")
71 DLeft:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", -17, -21)
72 DLeft:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
73 DLeft:SetTexCoord(0, 0.1953125, 0, 1)
76 local DRight = frame:CreateTexture(nil, "ARTWORK")
79 DRight:SetPoint("TOP", DLeft, "TOP")
80 DRight:SetPoint("RIGHT", frame, "RIGHT", 17, 0)
81 DRight:SetTexture([[Interface\Glues\CharacterCreate\CharacterCreate-LabelFrame]])
82 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 frame:SetFrameStrata(self:GetFrameStrata())
166 frame:SetFrameLevel(self:GetFrameLevel() + 100)
168 if next(self.contentRepo) then
169 frame:SetPoint("TOPLEFT", self.contentRepo[#self.contentRepo], "BOTTOMLEFT", 0, 0)
170 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
171 self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight())
172 self.contentRepo[#self.contentRepo+1] = frame
174 self.contentframe:SetHeight(frame:GetHeight())
175 frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0)
176 frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
177 self.contentRepo[1] = frame
180 if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then
181 self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -28, 12)
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:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -14, 12)
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
227 local scrollframe = CreateFrame("ScrollFrame", nil, frame)
228 scrollframe:SetWidth(160)
229 scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 14, -13)
230 scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 12)
231 scrollframe:SetScrollChild(contentframe)
232 frame.scrollframe = scrollframe
234 contentframe:SetPoint("TOPLEFT", scrollframe)
235 contentframe:SetPoint("TOPRIGHT", scrollframe)
237 local bgTex = frame:CreateTexture(nil, "ARTWORK")
238 bgTex:SetAllPoints(scrollframe)
241 frame.AddFrame = AddFrame
242 frame.ClearFrames = ClearFrames
243 frame.contentRepo = {} -- store all our frames in here so we can get rid of them later
245 local slider = CreateFrame("Slider", nil, scrollframe)
246 slider:SetOrientation("VERTICAL")
247 slider:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -14, -10)
248 slider:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 10)
249 slider:SetBackdrop(sliderBackdrop)
250 slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]])
251 slider:SetMinMaxValues(0, 1)
252 --slider:SetValueStep(1)
255 slider:SetScript("OnValueChanged", slider_OnValueChanged)
256 frame.slider = slider
258 frame:SetHeight(UIParent:GetHeight()*2/5)
259 frame.slider:SetValue(0)
264 function AGSMW:ReturnDropDownFrame(frame)
266 frame:ClearAllPoints()
268 frame:SetBackdrop(frameBackdrop)
269 frame.bgTex:SetTexture(nil)
270 table.insert(DropDownCache, frame)